예제 #1
0
파일: Starter.cpp 프로젝트: emaste/htcondor
int 
Starter::spawn( time_t now, Stream* s )
{
		// if execute dir has not been set, choose one now
	finalizeExecuteDir();

	if (claimType() == CLAIM_COD) {
		s_pid = execJobPipeStarter();
	}
#if HAVE_JOB_HOOKS
	else if (claimType() == CLAIM_FETCH) {
		s_pid = execJobPipeStarter();
	}
#endif /* HAVE_JOB_HOOKS */
#if HAVE_BOINC
	else if( isBOINC() ) {
		s_pid = execBOINCStarter(); 
	}
#endif /* HAVE_BOINC */
	else if( is_dc() ) {
		s_pid = execDCStarter( s ); 
	}
	else {
			// Use old icky non-daemoncore starter.
		s_pid = execOldStarter();
	}

	if( s_pid == 0 ) {
		dprintf( D_ALWAYS, "ERROR: exec_starter returned %d\n", s_pid );
	} else {
		s_birthdate = now;
	}

	return s_pid;
}
예제 #2
0
파일: Starter.cpp 프로젝트: emaste/htcondor
int
Starter::execBOINCStarter( void )
{
	ArgList args;

	args.AppendArg("condor_starter");
	args.AppendArg("-f");
	args.AppendArg("-append");
	args.AppendArg("boinc");
	args.AppendArg("-job-keyword");
	args.AppendArg("boinc");
	return execDCStarter( args, NULL, NULL, NULL );
}
예제 #3
0
파일: Starter.cpp 프로젝트: emaste/htcondor
int
Starter::execDCStarter( Stream* s )
{
	ArgList args;

	char* hostname = s_claim->client()->host();
	if ( resmgr->is_smp() ) {
		// Note: the "-a" option is a daemon core option, so it
		// must come first on the command line.
		args.AppendArg("condor_starter");
		args.AppendArg("-f");
		args.AppendArg("-a");
		args.AppendArg(s_claim->rip()->r_id_str);
		args.AppendArg(hostname);
	} else {
		args.AppendArg("condor_starter");
		args.AppendArg("-f");
		args.AppendArg(hostname);
	}
	execDCStarter( args, NULL, NULL, s );

	return s_pid;
}
예제 #4
0
파일: Starter.cpp 프로젝트: emaste/htcondor
int
Starter::execJobPipeStarter( void )
{
	int rval;
	MyString lock_env;
	ArgList args;
	Env env;
	char* tmp;

	if (s_claim->type() == CLAIM_COD) {
		tmp = param( "LOCK" );
		if( ! tmp ) { 
			tmp = param( "LOG" );
		}
		if( ! tmp ) { 
			EXCEPT( "LOG not defined!" );
		}
		lock_env = "_condor_STARTER_LOCK=";
		lock_env += tmp;
		free( tmp );
		lock_env += DIR_DELIM_CHAR;
		lock_env += "StarterLock.cod";

		env.SetEnv(lock_env.Value());
	}

		// Create an argument list for this starter, based on the claim.
	s_claim->makeStarterArgs(args);

	int* std_fds_p = NULL;
	int std_fds[3];
	int pipe_fds[2];
	if( s_claim->hasJobAd() ) {
		if( ! daemonCore->Create_Pipe(pipe_fds) ) {
			dprintf( D_ALWAYS, "ERROR: Can't create pipe to pass job ClassAd "
					 "to starter, aborting\n" );
			return 0;
		}
			// pipe_fds[0] is the read-end of the pipe.  we want that
			// setup as STDIN for the starter.  we'll hold onto the
			// write end of it so 
		std_fds[0] = pipe_fds[0];
		std_fds[1] = -1;
		std_fds[2] = -1;
		std_fds_p = std_fds;
	}

	rval = execDCStarter( args, &env, std_fds_p, NULL );

	if( s_claim->hasJobAd() ) {
			// now that the starter has been spawned, we need to do
			// some things with the pipe:

			// 1) close our copy of the read end of the pipe, so we
			// don't leak it.  we have to use DC::Close_Pipe() for
			// this, not just close(), so things work on windoze.
		daemonCore->Close_Pipe( pipe_fds[0] );

			// 2) dump out the job ad to the write end, since the
			// starter is now alive and can read from the pipe.

		s_claim->writeJobAd( pipe_fds[1] );

			// Now that all the data is written to the pipe, we can
			// safely close the other end, too.  
		daemonCore->Close_Pipe( pipe_fds[1] );
	}

	return rval;
}
예제 #5
0
int
Starter::execDCStarter( Stream* s )
{
	ArgList args;

	// decide whether we are going to pass a -slot-name argument to the starter
	// by default we do things the pre 8.1.4 way
	// we default to -slot-name, but that can be disabled by setting STARTER_LOG_NAME_APPEND = true
	// otherwise the value of this param determines what we append.
	bool slot_arg = false;
	enum { APPEND_NOTHING, APPEND_SLOT, APPEND_CLUSTER, APPEND_JOBID } append = APPEND_SLOT;

	// by default, single slots machines get no log append and no slot argument.
	if ( ! resmgr->is_smp()) {
		slot_arg = false;
		append = APPEND_NOTHING;
	}

	MyString ext;
	if (param(ext, "STARTER_LOG_NAME_APPEND")) {
		slot_arg = true;
		if (MATCH == strcasecmp(ext.c_str(), "Slot")) {
			append = APPEND_SLOT;
		} else if (MATCH == strcasecmp(ext.c_str(), "ClusterId") || MATCH == strcasecmp(ext.c_str(), "Cluster")) {
			append = APPEND_CLUSTER;
		} else if (MATCH == strcasecmp(ext.c_str(), "JobId")) {
			append = APPEND_JOBID;
		} else if (MATCH == strcasecmp(ext.c_str(), "false") || MATCH == strcasecmp(ext.c_str(), "0")) {
			append = APPEND_NOTHING;
		} else if (MATCH == strcasecmp(ext.c_str(), "true") || MATCH == strcasecmp(ext.c_str(), "1")) {
			append = APPEND_SLOT;
			slot_arg = false;
		}
	}


	char* hostname = s_claim->client()->host();

	args.AppendArg("condor_starter");
	args.AppendArg("-f");

	// Note: the "-a" option is a daemon core option, so it
	// must come first on the command line.
	if (append != APPEND_NOTHING) {
		args.AppendArg("-a");
		switch (append) {
		case APPEND_CLUSTER: args.AppendArg(s_claim->cluster()); break;

		case APPEND_JOBID: {
			MyString jobid;
			jobid.formatstr("%d.%d", s_claim->cluster(), s_claim->proc());
			args.AppendArg(jobid.c_str());
		} break;

		default:
		case APPEND_SLOT: args.AppendArg(s_claim->rip()->r_id_str); break;
		}
	}

	if (slot_arg) {
		args.AppendArg("-slot-name");
		args.AppendArg(s_claim->rip()->r_id_str);
	}

	args.AppendArg(hostname);
	execDCStarter( args, NULL, NULL, s );

	return s_pid;
}