Пример #1
0
extern "C" void 
initializeUserLog ()
{
	MyString logfilename;
	MyString gjid;
	int use_xml;
	bool have_a_log = false;
	if ( getPathToUserLog(JobAd, logfilename) ) {
		have_a_log = true;	
		if(JobAd->LookupString(ATTR_GLOBAL_JOB_ID, gjid) != 1) {
			gjid = "Unknown";
		}
		std::string logfile(logfilename.Value());
		WriteUserLog* ulogi = new WriteUserLog;
		if( !ulogi ) {
			EXCEPT("Out of memory!\n");
		}
		if (!ulogi->initialize (Proc->owner, NULL, logfilename.Value(),
					Proc->id.cluster, Proc->id.proc, 0, gjid.Value())) {
			EXCEPT("Failed to initialize user log!\n");
		}
		ulogi->setUseXML(JobAd->LookupBool(ATTR_ULOG_USE_XML, use_xml)
				&& use_xml);
		dprintf(D_FULLDEBUG, "%s = %s\n", ATTR_ULOG_FILE, logfilename.Value());
		ULog.push_back(ulogi);
	}
	if ( getPathToUserLog(JobAd, logfilename, ATTR_DAGMAN_WORKFLOW_LOG) ) {
		have_a_log = true;	
		if(JobAd->LookupString(ATTR_GLOBAL_JOB_ID, gjid) != 1) {
			gjid = "Unknown";
		}
		std::string logfile(logfilename.Value());
		WriteUserLog* ulogi = new WriteUserLog;
		if( !ulogi ) {
			EXCEPT("Out of memory!\n");
		}
		ulogi->setUseXML(false);
		if (!ulogi->initialize (Proc->owner, NULL, logfilename.Value(),
					Proc->id.cluster, Proc->id.proc, 0, gjid.Value())) {
			EXCEPT("Failed to initialize user log!\n");
		}
		dprintf(D_FULLDEBUG, "%s = %s\n", ATTR_ULOG_FILE, logfilename.Value());
		if(!ULog.empty()){ // Only write to global event log once
			ulogi->setEnableGlobalLog( false );	
		}
		ULog.push_back(ulogi);
	}
	if( !have_a_log ) {
		dprintf(D_FULLDEBUG, "no %s found\n", ATTR_ULOG_FILE);
		dprintf(D_FULLDEBUG, "Also, no %s found\n", ATTR_DAGMAN_WORKFLOW_LOG);
	}
}
Пример #2
0
extern "C" void 
initializeUserLog ()
{
	std::string logfilename,dagmanLogName;
	int use_xml;
	std::vector<const char*> logfiles;
	if ( getPathToUserLog(JobAd, logfilename) ) {
		logfiles.push_back(logfilename.c_str());
		dprintf(D_FULLDEBUG, "%s = %s\n", ATTR_ULOG_FILE, logfilename.c_str());
	}
	if ( getPathToUserLog(JobAd, dagmanLogName, ATTR_DAGMAN_WORKFLOW_LOG) ) {
		logfiles.push_back(dagmanLogName.c_str());
		dprintf(D_FULLDEBUG, "%s = %s\n", ATTR_DAGMAN_WORKFLOW_LOG,
			dagmanLogName.c_str());
	}
	if(!logfiles.empty()) {
		if ( !ULog.initialize (Proc->owner, NULL, logfiles,
				Proc->id.cluster, Proc->id.proc, 0)) {
			EXCEPT("Failed to initialize user log!");
		} else {
			ULog.setUseXML(JobAd->LookupBool(ATTR_ULOG_USE_XML, use_xml) && use_xml);
		}
	} else {
		dprintf(D_FULLDEBUG, "no %s found and no %s found\n", ATTR_ULOG_FILE,
			ATTR_DAGMAN_WORKFLOW_LOG);
	}
}
Пример #3
0
// Initialize a UserLog object for a given job and return a pointer to
// the UserLog object created.  This object can then be used to write
// events and must be deleted when you're done.  This returns NULL if
// the user didn't want a UserLog, so you must check for NULL before
// using the pointer you get back.
WriteUserLog*
InitializeUserLog( ClassAd *job_ad )
{
    int cluster, proc;
    MyString userLogFile, dagmanNodeLog;
    std::string gjid;
    bool use_xml = false;
    std::vector<const char*> logfiles;

    if( getPathToUserLog(job_ad, userLogFile) ) {
        logfiles.push_back(userLogFile.Value());
    }
    if( getPathToUserLog(job_ad, dagmanNodeLog, ATTR_DAGMAN_WORKFLOW_LOG) ) {
        logfiles.push_back(dagmanNodeLog.Value());
    }
    if(logfiles.empty()) {
        return NULL;
    }

    job_ad->LookupInteger( ATTR_CLUSTER_ID, cluster );
    job_ad->LookupInteger( ATTR_PROC_ID, proc );
    job_ad->LookupString( ATTR_GLOBAL_JOB_ID, gjid );
    job_ad->LookupBool( ATTR_ULOG_USE_XML, use_xml );

    WriteUserLog *ULog = new WriteUserLog();
    ULog->initialize(logfiles, cluster, proc, 0, gjid.c_str());
    ULog->setUseXML( use_xml );
    return ULog;
}
Пример #4
0
bool writePreSkipEvent( CondorID& condorID, Job* job, const char* DAGNodeName, 
			   const char* directory, const char *logFile )
{
	TmpDir tmpDir;
	MyString	errMsg;
	if ( !tmpDir.Cd2TmpDir( directory, errMsg ) ) {
		debug_printf( DEBUG_QUIET,
				"Could not change to node directory %s: %s\n",
				directory, errMsg.Value() );
		return false;
	}

		// Special HTCondorID for NOOP jobs -- actually indexed by
		// otherwise-unused subprocID.
	condorID._cluster = 0;
	condorID._proc = Job::NOOP_NODE_PROCID;

	condorID._subproc = 1+get_fake_condorID();
		// Increment this value
	set_fake_condorID(condorID._subproc);

	if( job ) {
		job->SetCondorID( condorID );
	}

	WriteUserLog ulog;
	ulog.setEnableGlobalLog( false );
	ulog.setUseXML( false );
	ulog.initialize( std::vector<const char*>(1,logFile), condorID._cluster,
		condorID._proc, condorID._subproc, NULL );

	PreSkipEvent pEvent;
	pEvent.cluster = condorID._cluster;
	pEvent.proc = condorID._proc;
	pEvent.subproc = condorID._subproc;

	MyString pEventNotes("DAG Node: " );
	pEventNotes += DAGNodeName;
		// skipEventLogNotes gets deleted in PreSkipEvent destructor.
	pEvent.skipEventLogNotes = strnewp( pEventNotes.Value() );

	if ( !ulog.writeEvent( &pEvent ) ) {
		EXCEPT( "Error: writing PRESKIP event failed!" );
		return false;
	}
	return true;
}
Пример #5
0
//-------------------------------------------------------------------------
bool
fake_condor_submit( CondorID& condorID, Job* job, const char* DAGNodeName, 
			   const char* directory, const char *logFile )
{
	TmpDir		tmpDir;
	MyString	errMsg;
	if ( !tmpDir.Cd2TmpDir( directory, errMsg ) ) {
		debug_printf( DEBUG_QUIET,
				"Could not change to node directory %s: %s\n",
				directory, errMsg.Value() );
		return false;
	}

	_subprocID++;
		// Special HTCondorID for NOOP jobs -- actually indexed by
		// otherwise-unused subprocID.
	condorID._cluster = 0;
	condorID._proc = Job::NOOP_NODE_PROCID;
	condorID._subproc = _subprocID;

		// Make sure that this job gets marked as a NOOP 
	if( job ) {
		job->SetCondorID( condorID );
	}

	WriteUserLog ulog;
	ulog.setEnableGlobalLog( false );
	ulog.setUseXML( false );
	ulog.initialize( logFile, condorID._cluster,
		condorID._proc, condorID._subproc, NULL );

	SubmitEvent subEvent;
	subEvent.cluster = condorID._cluster;
	subEvent.proc = condorID._proc;
	subEvent.subproc = condorID._subproc;

		// We need some value for submitHost for the event to be read
		// correctly.
	subEvent.setSubmitHost( "<dummy-submit-for-noop-job>" );

	MyString subEventNotes("DAG Node: " );
	subEventNotes += DAGNodeName;
		// submitEventLogNotes get deleted in SubmitEvent destructor.
	subEvent.submitEventLogNotes = strnewp( subEventNotes.Value() );

	if ( !ulog.writeEvent( &subEvent ) ) {
		EXCEPT( "Error: writing dummy submit event for NOOP node failed!" );
		return false;
	}


	JobTerminatedEvent termEvent;
	termEvent.cluster = condorID._cluster;
	termEvent.proc = condorID._proc;
	termEvent.subproc = condorID._subproc;
	termEvent.normal = true;
	termEvent.returnValue = 0;
	termEvent.signalNumber = 0;

	if ( !ulog.writeEvent( &termEvent ) ) {
		EXCEPT( "Error: writing dummy terminated event for NOOP node failed!" );
		return false;
	}

	return true;
}