本文整理汇总了C++中CondorError::getFullText方法的典型用法代码示例。如果您正苦于以下问题:C++ CondorError::getFullText方法的具体用法?C++ CondorError::getFullText怎么用?C++ CondorError::getFullText使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CondorError
的用法示例。
在下文中一共展示了CondorError::getFullText方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: locally
void
handleConstraints( void )
{
if( ! has_constraint ) {
return;
}
const char* tmp = global_constraint.Value();
CondorError errstack;
if( doWorkByConstraint(tmp, &errstack) ) {
fprintf( stdout, "Jobs matching constraint %s %s\n", tmp,
(mode == JA_REMOVE_JOBS) ?
"have been marked for removal" :
(mode == JA_REMOVE_X_JOBS) ?
"have been removed locally (remote state unknown)" :
actionWord(mode,true) );
} else {
fprintf( stderr, "%s\n", errstack.getFullText(true).c_str() );
if (had_error)
{
fprintf( stderr,
"Couldn't find/%s all jobs matching constraint %s\n",
actionWord(mode,false), tmp );
}
}
}
示例2: schedd
// This function calls up the schedd passed in on the command line and
// registers the transferd as being available for the schedd's use.
RegisterResult
TransferD::register_to_schedd(ReliSock **regsock_ptr)
{
CondorError errstack;
MyString sname;
MyString id;
MyString sinful;
bool rval;
if (*regsock_ptr != NULL) {
*regsock_ptr = NULL;
}
sname = m_features.get_schedd_sinful();
id = m_features.get_id();
if (sname == "N/A") {
// no schedd supplied with which to register
dprintf(D_ALWAYS, "No schedd specified to which to register.\n");
return REG_RESULT_NO_SCHEDD;
}
// what is my sinful string?
sinful = daemonCore->InfoCommandSinfulString(-1);
dprintf(D_FULLDEBUG, "Registering myself(%s) to schedd(%s)\n",
sinful.Value(), sname.Value());
// hook up to the schedd.
DCSchedd schedd(sname.Value(), NULL);
// register myself, give myself 1 minute to connect.
rval = schedd.register_transferd(sinful, id, 20*3, regsock_ptr, &errstack);
if (rval == false) {
// emit why
dprintf(D_ALWAYS, "TransferRequest::register_to_schedd(): Failed to "
"register. Schedd gave reason '%s'\n", errstack.getFullText().c_str());
return REG_RESULT_FAILED;
}
// WARNING WARNING WARNING WARNING //
// WARNING WARNING WARNING WARNING //
// WARNING WARNING WARNING WARNING //
// WARNING WARNING WARNING WARNING //
// WARNING WARNING WARNING WARNING //
// Here, I must infact go back to daemon core without closing or doing
// anything with the socket. This is because the schedd is going to
// reconnect back to me, and I can't deadlock.
dprintf(D_FULLDEBUG,
"Succesfully registered, awaiting treq channel message....\n");
return REG_RESULT_SUCCESS;
}
示例3: strdup
// Called when the schedd initially connects to the transferd to finish
// the registration process.
int
TransferD::setup_transfer_request_handler(int /*cmd*/, Stream *sock)
{
ReliSock *rsock = (ReliSock*)sock;
MyString sock_id;
dprintf(D_ALWAYS, "Got TRANSFER_CONTROL_CHANNEL!\n");
rsock->decode();
///////////////////////////////////////////////////////////////
// make sure we are authenticated
///////////////////////////////////////////////////////////////
if( ! rsock->triedAuthentication() ) {
CondorError errstack;
if( ! SecMan::authenticate_sock(rsock, WRITE, &errstack) ) {
// we failed to authenticate, we should bail out now
// since we don't know what user is trying to perform
// this action.
// TODO: it'd be nice to print out what failed, but we
// need better error propagation for that...
errstack.push( "TransferD::setup_transfer_request_handler()", 42,
"Failure to register transferd - Authentication failed" );
dprintf( D_ALWAYS, "setup_transfer_request_handler() "
"aborting: %s\n",
errstack.getFullText().c_str() );
refuse(rsock);
return CLOSE_STREAM;
}
}
rsock->decode();
///////////////////////////////////////////////////////////////
// Register this socket with a socket handler to handle incoming requests
///////////////////////////////////////////////////////////////
sock_id += "<TreqChannel-Socket>";
char* _sock_id = strdup( sock_id.Value() ); //de-const
// register the handler for any future transfer requests on this socket.
daemonCore->Register_Socket((Sock*)rsock, _sock_id,
(SocketHandlercpp)&TransferD::accept_transfer_request_handler,
"TransferD::accept_transfer_request_handler", this, ALLOW);
free( _sock_id );
dprintf(D_ALWAYS, "Treq channel established.\n");
dprintf(D_ALWAYS, "Accepting Transfer Requests.\n");
return KEEP_STREAM;
}
示例4: ConnectQ
//---------------------------------------------------------------------------
Qmgr_connection *
DagmanClassad::OpenConnection()
{
// Open job queue
CondorError errstack;
Qmgr_connection *queue = ConnectQ( _schedd->addr(), 0, false,
&errstack, NULL, _schedd->version() );
if ( !queue ) {
debug_printf( DEBUG_QUIET,
"WARNING: failed to connect to queue manager (%s)\n",
errstack.getFullText().c_str() );
check_warning_strictness( DAG_STRICT_3 );
return NULL;
}
return queue;
}
示例5:
DCStarter::X509UpdateStatus
DCStarter::delegateX509Proxy( const char * filename, time_t expiration_time, char const *sec_session_id, time_t *result_expiration_time)
{
ReliSock rsock;
rsock.timeout(60);
if( ! rsock.connect(_addr) ) {
dprintf(D_ALWAYS, "DCStarter::delegateX509Proxy: "
"Failed to connect to starter %s\n", _addr);
return XUS_Error;
}
CondorError errstack;
if( ! startCommand(DELEGATE_GSI_CRED_STARTER, &rsock, 0, &errstack, NULL, false, sec_session_id) ) {
dprintf( D_ALWAYS, "DCStarter::delegateX509Proxy: "
"Failed send command to the starter: %s\n",
errstack.getFullText().c_str());
return XUS_Error;
}
// Send the gsi proxy
filesize_t file_size = 0; // will receive the size of the file
if ( rsock.put_x509_delegation(&file_size,filename,expiration_time,result_expiration_time) < 0 ) {
dprintf(D_ALWAYS,
"DCStarter::delegateX509Proxy "
"failed to delegate proxy file %s (size=%ld)\n",
filename, (long int)file_size);
return XUS_Error;
}
// Fetch the result
rsock.decode();
int reply = 0;
rsock.code(reply);
rsock.end_of_message();
switch(reply) {
case 0: return XUS_Error;
case 1: return XUS_Okay;
case 2: return XUS_Declined;
}
dprintf(D_ALWAYS, "DCStarter::delegateX509Proxy: "
"remote side returned unknown code %d. Treating "
"as an error.\n", reply);
return XUS_Error;
}
示例6: dir
/**
* Process the history directory and maintain the history file map
*
* Only handle rotated history files, those history.* that are not an
* index. For each one that is not in the history file map, create a
* new HistoryFile, poll it for entries to process, and add it to the
* map.
*/
void
aviary::history::processHistoryDirectory()
{
const char *file = NULL;
// each time through we rebuild our set of inodes
if (force_reset) {
m_historyFiles.clear();
}
Directory dir ( m_path.Value() );
dir.Rewind();
while ( ( file = dir.Next() ) )
{
// Skip all non-history files, e.g. history and history.*.idx
if ( strncmp ( file, "history.", 8 ) ||
!strncmp ( file + ( strlen ( file ) - 4 ), HISTORY_INDEX_SUFFIX, 4 ) ) continue;
HistoryFile h_file ( ( m_path + DIR_DELIM_STRING + file ).Value() );
CondorError errstack;
if ( !h_file.init ( errstack ) )
{
dprintf ( D_ALWAYS, "%s\n", errstack.getFullText().c_str() );
return;
}
errstack.clear();
long unsigned int id;
ASSERT ( h_file.getId ( id ) );
HistoryFileListType::iterator entry = m_historyFiles.find ( id );
if ( m_historyFiles.end() == entry )
{
HistoryFile::HistoryEntriesTypeIterators ij = h_file.poll ( errstack );
for ( HistoryFile::HistoryEntriesTypeIterator i = ij.first;
i != ij.second;
i++ )
{
process ( ( *i ) );
}
m_historyFiles.insert ( id );
}
}
}
示例7:
bool
DCStartd::getAds( ClassAdList &adsList )
{
CondorError errstack;
// fetch the query
QueryResult q;
CondorQuery* query;
char* ad_addr;
// instantiate query object
if (!(query = new CondorQuery (STARTD_AD))) {
dprintf( D_ALWAYS, "Error: Out of memory\n");
return(false);
}
if( this->locate() ){
ad_addr = this->addr();
q = query->fetchAds(adsList, ad_addr, &errstack);
if (q != Q_OK) {
if (q == Q_COMMUNICATION_ERROR) {
dprintf( D_ALWAYS, "%s\n", errstack.getFullText(true).c_str() );
}
else {
dprintf (D_ALWAYS, "Error: Could not fetch ads --- %s\n",
getStrQueryResult(q));
}
delete query;
return (false);
}
} else {
delete query;
return(false);
}
delete query;
return(true);
}
示例8: doContactSchedd
void
doContactSchedd()
{
int rc;
Qmgr_connection *schedd;
BaseJob *curr_job;
ClassAd *next_ad;
char expr_buf[12000];
bool schedd_updates_complete = false;
bool schedd_deletes_complete = false;
bool add_remove_jobs_complete = false;
bool update_jobs_complete = false;
bool commit_transaction = true;
int failure_line_num = 0;
bool send_reschedule = false;
std::string error_str = "";
StringList dirty_job_ids;
char *job_id_str;
PROC_ID job_id;
CondorError errstack;
dprintf(D_FULLDEBUG,"in doContactSchedd()\n");
initJobExprs();
contactScheddTid = TIMER_UNSET;
// vacateJobs
/////////////////////////////////////////////////////
if ( pendingScheddVacates.getNumElements() != 0 ) {
std::string buff;
StringList job_ids;
VacateRequest curr_request;
int result;
ClassAd* rval;
pendingScheddVacates.startIterations();
while ( pendingScheddVacates.iterate( curr_request ) != 0 ) {
formatstr( buff, "%d.%d", curr_request.job->procID.cluster,
curr_request.job->procID.proc );
job_ids.append( buff.c_str() );
}
char *tmp = job_ids.print_to_string();
if ( tmp ) {
dprintf( D_FULLDEBUG, "Calling vacateJobs on %s\n", tmp );
free(tmp);
tmp = NULL;
}
rval = ScheddObj->vacateJobs( &job_ids, VACATE_FAST, &errstack );
if ( rval == NULL ) {
formatstr( error_str, "vacateJobs returned NULL, CondorError: %s!",
errstack.getFullText().c_str() );
goto contact_schedd_failure;
} else {
pendingScheddVacates.startIterations();
while ( pendingScheddVacates.iterate( curr_request ) != 0 ) {
formatstr( buff, "job_%d_%d", curr_request.job->procID.cluster,
curr_request.job->procID.proc );
if ( !rval->LookupInteger( buff.c_str(), result ) ) {
dprintf( D_FULLDEBUG, "vacateJobs returned malformed ad\n" );
EXCEPT( "vacateJobs returned malformed ad" );
} else {
dprintf( D_FULLDEBUG, " %d.%d vacate result: %d\n",
curr_request.job->procID.cluster,
curr_request.job->procID.proc,result);
pendingScheddVacates.remove( curr_request.job->procID );
curr_request.result = (action_result_t)result;
curr_request.job->SetEvaluateState();
completedScheddVacates.insert( curr_request.job->procID,
curr_request );
}
}
delete rval;
}
}
schedd = ConnectQ( ScheddAddr, QMGMT_TIMEOUT, false, NULL, myUserName, CondorVersion() );
if ( !schedd ) {
error_str = "Failed to connect to schedd!";
goto contact_schedd_failure;
}
// CheckLeases
/////////////////////////////////////////////////////
if ( checkLeasesSignaled ) {
dprintf( D_FULLDEBUG, "querying for renewed leases\n" );
// Grab the lease attributes of all the jobs in our global hashtable.
BaseJob::JobsByProcId.startIterations();
while ( BaseJob::JobsByProcId.iterate( curr_job ) != 0 ) {
int new_expiration;
//.........这里部分代码省略.........
示例9: list
int
do_Q_request(ReliSock *syscall_sock,bool &may_fork)
{
int request_num = -1;
int rval;
syscall_sock->decode();
assert( syscall_sock->code(request_num) );
dprintf(D_SYSCALLS, "Got request #%d\n", request_num);
switch( request_num ) {
case CONDOR_InitializeConnection:
{
// dprintf( D_ALWAYS, "InitializeConnection()\n" );
bool authenticated = true;
// Authenticate socket, if not already done by daemonCore
if( !syscall_sock->triedAuthentication() ) {
if( IsDebugLevel(D_SECURITY) ) {
MyString methods;
SecMan::getAuthenticationMethods( WRITE, &methods );
dprintf(D_SECURITY,"Calling authenticate(%s) in qmgmt_receivers\n", methods.Value());
}
CondorError errstack;
if( ! SecMan::authenticate_sock(syscall_sock, WRITE, &errstack) ) {
// Failed to authenticate
dprintf( D_ALWAYS, "SCHEDD: authentication failed: %s\n",
errstack.getFullText().c_str() );
authenticated = false;
}
}
if ( authenticated ) {
InitializeConnection( syscall_sock->getOwner(),
syscall_sock->getDomain() );
} else {
InitializeConnection( NULL, NULL );
}
return 0;
}
case CONDOR_InitializeReadOnlyConnection:
{
// dprintf( D_ALWAYS, "InitializeReadOnlyConnection()\n" );
// Since InitializeConnection() does nothing, and we need
// to record the fact that this is a read-only connection,
// but we have to do it in the socket (since we don't have
// any other persistent data structure, and it's probably
// the right place anyway), set the FQU.
//
// We need to record if this is a read-only connection so that
// we can avoid expanding $$ in GetJobAd; simply checking if the
// connection is authenticated isn't sufficient, because the
// security session cache means that read-only connection could
// be authenticated by a previous authenticated connection from
// the same address (when using host-based security) less than
// the expiration period ago.
syscall_sock->setFullyQualifiedUser( "read-only" );
// same as InitializeConnection but no authenticate()
InitializeConnection( NULL, NULL );
may_fork = true;
return 0;
}
case CONDOR_SetEffectiveOwner:
{
MyString owner;
int terrno;
assert( syscall_sock->get(owner) );
assert( syscall_sock->end_of_message() );
rval = QmgmtSetEffectiveOwner( owner.Value() );
terrno = errno;
syscall_sock->encode();
assert( syscall_sock->code(rval) );
if( rval < 0 ) {
assert( syscall_sock->code(terrno) );
}
assert( syscall_sock->end_of_message() );
char const *fqu = syscall_sock->getFullyQualifiedUser();
dprintf(D_SYSCALLS, "\tSetEffectiveOwner\n");
dprintf(D_SYSCALLS, "\tauthenticated user = '%s'\n", fqu ? fqu : "");
dprintf(D_SYSCALLS, "\trequested owner = '%s'\n", owner.Value());
dprintf(D_SYSCALLS, "\trval %d, errno %d\n", rval, terrno);
return 0;
}
case CONDOR_NewCluster:
{
int terrno;
//.........这里部分代码省略.........
示例10: main
int main(int argc, char **argv)
{
int result = 0;
if ( argc <= 1 || (argc >= 2 && !strcmp("-usage", argv[1])) ) {
printf("Usage: condor_check_userlogs <log file 1> "
"[log file 2] ... [log file n]\n");
exit(0);
}
// Set up dprintf.
dprintf_set_tool_debug("condor_check_userlogs", 0);
set_debug_flags(NULL, D_ALWAYS);
StringList logFiles;
for ( int argnum = 1; argnum < argc; ++argnum ) {
logFiles.append(argv[argnum]);
}
logFiles.rewind();
ReadMultipleUserLogs ru;
char *filename;
while ( (filename = logFiles.next()) ) {
MyString filestring( filename );
CondorError errstack;
if ( !ru.monitorLogFile( filestring, false, errstack ) ) {
fprintf( stderr, "Error monitoring log file %s: %s\n", filename,
errstack.getFullText().c_str() );
result = 1;
}
}
bool logsMissing = false;
CheckEvents ce;
int totalSubmitted = 0;
int netSubmitted = 0;
bool done = false;
while( !done ) {
ULogEvent* e = NULL;
MyString errorMsg;
ULogEventOutcome outcome = ru.readEvent( e );
switch (outcome) {
case ULOG_RD_ERROR:
case ULOG_UNK_ERROR:
logsMissing = true;
case ULOG_NO_EVENT:
printf( "Log outcome: %s\n", ULogEventOutcomeNames[outcome] );
done = true;
break;
case ULOG_OK:
printf( "Log event: %s (%d.%d.%d)",
ULogEventNumberNames[e->eventNumber],
e->cluster, e->proc, e->subproc );
if ( ce.CheckAnEvent(e, errorMsg) != CheckEvents::EVENT_OKAY ) {
fprintf(stderr, "%s\n", errorMsg.Value());
result = 1;
}
if( e->eventNumber == ULOG_SUBMIT ) {
SubmitEvent* ee = (SubmitEvent*) e;
printf( " (\"%s\")", ee->submitEventLogNotes );
++totalSubmitted;
++netSubmitted;
printf( "\n Total submitted: %d; net submitted: %d\n",
totalSubmitted, netSubmitted );
}
if( e->eventNumber == ULOG_JOB_HELD ) {
JobHeldEvent* ee = (JobHeldEvent*) e;
printf( " (code=%d subcode=%d)", ee->getReasonCode(),
ee->getReasonSubCode());
}
if( e->eventNumber == ULOG_JOB_TERMINATED ) {
--netSubmitted;
printf( "\n Total submitted: %d; net submitted: %d\n",
totalSubmitted, netSubmitted );
}
if( e->eventNumber == ULOG_JOB_ABORTED ) {
--netSubmitted;
printf( "\n Total submitted: %d; net submitted: %d\n",
totalSubmitted, netSubmitted );
}
if( e->eventNumber == ULOG_EXECUTABLE_ERROR ) {
--netSubmitted;
printf( "\n Total submitted: %d; net submitted: %d\n",
totalSubmitted, netSubmitted );
}
//.........这里部分代码省略.........
示例11: getParamFromSubmitLine
///////////////////////////////////////////////////////////////////////////////
// Note: this method should get speeded up (see Gnats PR 846).
MyString
MultiLogFiles::loadLogFileNameFromSubFile(const MyString &strSubFilename,
const MyString &directory, bool &isXml, bool usingDefaultNode)
{
dprintf( D_FULLDEBUG, "MultiLogFiles::loadLogFileNameFromSubFile(%s, %s)\n",
strSubFilename.Value(), directory.Value() );
TmpDir td;
if ( directory != "" ) {
MyString errMsg;
if ( !td.Cd2TmpDir(directory.Value(), errMsg) ) {
dprintf(D_ALWAYS, "Error from Cd2TmpDir: %s\n", errMsg.Value());
return "";
}
}
StringList logicalLines;
if ( fileNameToLogicalLines( strSubFilename, logicalLines ) != "" ) {
return "";
}
MyString logFileName("");
MyString initialDir("");
MyString isXmlLogStr("");
// Now look through the submit file logical lines to find the
// log file and initial directory (if specified) and combine
// them into a path to the log file that's either absolute or
// relative to the DAG submit directory. Also look for log_xml.
const char *logicalLine;
while( (logicalLine = logicalLines.next()) != NULL ) {
MyString submitLine(logicalLine);
MyString tmpLogName = getParamFromSubmitLine(submitLine, "log");
if ( tmpLogName != "" ) {
logFileName = tmpLogName;
}
// If we are using the default node log, we don't care
// about these
if( !usingDefaultNode ) {
MyString tmpInitialDir = getParamFromSubmitLine(submitLine,
"initialdir");
if ( tmpInitialDir != "" ) {
initialDir = tmpInitialDir;
}
MyString tmpLogXml = getParamFromSubmitLine(submitLine, "log_xml");
if ( tmpLogXml != "" ) {
isXmlLogStr = tmpLogXml;
}
}
}
if ( !usingDefaultNode ) {
//
// Check for macros in the log file name -- we currently don't
// handle those.
//
// If we are using the default node, we don't need to check this
if ( logFileName != "" ) {
if ( strstr(logFileName.Value(), "$(") ) {
dprintf(D_ALWAYS, "MultiLogFiles: macros ('$(...') not allowed "
"in log file name (%s) in DAG node submit files\n",
logFileName.Value());
logFileName = "";
}
}
// Do not need to prepend initialdir if we are using the
// default node log
if ( logFileName != "" ) {
// Prepend initialdir to log file name if log file name is not
// an absolute path.
if ( initialDir != "" && !fullpath(logFileName.Value()) ) {
logFileName = initialDir + DIR_DELIM_STRING + logFileName;
}
// We do this in case the same log file is specified with a
// relative and an absolute path.
// Note: we now do further checking that doesn't rely on
// comparing paths to the log files. wenger 2004-05-27.
CondorError errstack;
if ( !makePathAbsolute( logFileName, errstack ) ) {
dprintf(D_ALWAYS, "%s\n", errstack.getFullText().c_str());
return "";
}
}
isXmlLogStr.lower_case();
isXml = (isXmlLogStr == "true");
if ( directory != "" ) {
MyString errMsg;
if ( !td.Cd2MainDir(errMsg) ) {
dprintf(D_ALWAYS, "Error from Cd2MainDir: %s\n", errMsg.Value());
return "";
}
}
}
return logFileName;
//.........这里部分代码省略.........
示例12: recycleShadow
bool DCSchedd::recycleShadow( int previous_job_exit_reason, ClassAd **new_job_ad, MyString &error_msg )
{
int timeout = 300;
CondorError errstack;
ReliSock sock;
if( !connectSock(&sock,timeout,&errstack) ) {
error_msg.formatstr("Failed to connect to schedd: %s",
errstack.getFullText().c_str());
return false;
}
if( !startCommand(RECYCLE_SHADOW, &sock, timeout, &errstack) ) {
error_msg.formatstr("Failed to send RECYCLE_SHADOW to schedd: %s",
errstack.getFullText().c_str());
return false;
}
if( !forceAuthentication(&sock, &errstack) ) {
error_msg.formatstr("Failed to authenticate: %s",
errstack.getFullText().c_str());
return false;
}
sock.encode();
int mypid = getpid();
if( !sock.put( mypid ) ||
!sock.put( previous_job_exit_reason ) ||
!sock.end_of_message() )
{
error_msg = "Failed to send job exit reason";
return false;
}
sock.decode();
int found_new_job = 0;
sock.get( found_new_job );
if( found_new_job ) {
*new_job_ad = new ClassAd();
if( !getClassAd( &sock, *(*new_job_ad) ) ) {
error_msg = "Failed to receive new job ClassAd";
delete *new_job_ad;
*new_job_ad = NULL;
return false;
}
}
if( !sock.end_of_message() ) {
error_msg = "Failed to receive end of message";
delete *new_job_ad;
*new_job_ad = NULL;
return false;
}
if( *new_job_ad ) {
sock.encode();
int ok=1;
if( !sock.put(ok) ||
!sock.end_of_message() )
{
error_msg = "Failed to send ok";
delete *new_job_ad;
*new_job_ad = NULL;
return false;
}
}
return true;
}
示例13: my_schedd
//.........这里部分代码省略.........
}
if ( ConstraintArg && UserJobIdArg ) {
fprintf( stderr, "You can't use both -constraint and usernames or job ids\n" );
usage();
}
// Pick the default reason if the user didn't specify one
if( actionReason == NULL ) {
switch( mode ) {
case JA_RELEASE_JOBS:
actionReason = strdup("via condor_release");
break;
case JA_REMOVE_X_JOBS:
actionReason = strdup("via condor_rm -forcex");
break;
case JA_REMOVE_JOBS:
actionReason = strdup("via condor_rm");
break;
case JA_HOLD_JOBS:
actionReason = strdup("via condor_hold");
break;
case JA_SUSPEND_JOBS:
actionReason = strdup("via condor_suspend");
break;
case JA_CONTINUE_JOBS:
actionReason = strdup("via condor_continue");
break;
default:
actionReason = NULL;
}
}
// We're done parsing args, now make sure we know how to
// contact the schedd.
if( ! scheddAddr ) {
// This will always do the right thing, even if either or
// both of scheddName or pool are NULL.
schedd = new DCSchedd( scheddName, pool ? pool->addr() : NULL );
} else {
schedd = new DCSchedd( scheddAddr );
}
if( ! schedd->locate() ) {
fprintf( stderr, "%s: %s\n", MyName, schedd->error() );
exit( 1 );
}
// Special case for condor_rm -forcex: a configuration
// setting can disable this functionality. The real
// validation is done in the schedd, but we can catch
// the most common cases here and give a useful error
// message.
if(mode == JA_REMOVE_X_JOBS) {
if( mayUserForceRm() == false) {
fprintf( stderr, "Remove aborted. condor_rm -forcex has been disabled by the administrator.\n" );
exit( 1 );
}
}
// Process the args so we do the work.
if( All ) {
handleAll();
} else {
for(i = 0; i < nArgs; i++) {
if( match_prefix( args[i], "-constraint" ) ) {
i++;
addConstraint( args[i] );
} else {
procArg(args[i]);
}
}
}
// Deal with all the -constraint constraints
handleConstraints();
// Finally, do the actual work for all our args which weren't
// constraints...
if( job_ids ) {
CondorError errstack;
ClassAd* result_ad = doWorkByList( job_ids, &errstack );
if (had_error) {
fprintf( stderr, "%s\n", errstack.getFullText(true).c_str() );
}
printNewMessages( result_ad, job_ids );
delete( result_ad );
}
// If releasing jobs, and no errors happened, do a
// reschedule command now.
if ( mode == JA_RELEASE_JOBS && had_error == false ) {
Daemon my_schedd(DT_SCHEDD, NULL, NULL);
CondorError errstack;
if (!my_schedd.sendCommand(RESCHEDULE, Stream::safe_sock, 0, &errstack)) {
fprintf( stderr, "%s\n", errstack.getFullText(true).c_str() );
}
}
return had_error;
}
示例14: setPPstyle
//.........这里部分代码省略.........
fprintf(stderr, "Error: Failed to locate %s\n", id);
fprintf(stderr, "%s\n", d->error());
exit( 1 );
}
}
}
ClassAdList result;
CondorError errstack;
if (NULL != ads_file) {
MyString req; // query requirements
q = query->getRequirements(req);
const char * constraint = req.empty() ? NULL : req.c_str();
if (read_classad_file(ads_file, result, constraint)) {
q = Q_OK;
}
} else if (NULL != addr) {
// this case executes if pool was provided, or if in "direct" mode with
// subsystem that corresponds to a daemon (above).
// Here 'addr' represents either the host:port of requested pool, or
// alternatively the host:port of daemon associated with requested subsystem (direct mode)
q = query->fetchAds (result, addr, &errstack);
} else {
// otherwise obtain list of collectors and submit query that way
CollectorList * collectors = CollectorList::create();
q = collectors->query (*query, result, &errstack);
delete collectors;
}
// if any error was encountered during the query, report it and exit
if (Q_OK != q) {
dprintf_WriteOnErrorBuffer(stderr, true);
// we can always provide these messages:
fprintf( stderr, "Error: %s\n", getStrQueryResult(q) );
fprintf( stderr, "%s\n", errstack.getFullText(true).c_str() );
if ((NULL != requested_daemon) && ((Q_NO_COLLECTOR_HOST == q) ||
(requested_daemon->type() == DT_COLLECTOR)))
{
// Specific long message if connection to collector failed.
const char* fullhost = requested_daemon->fullHostname();
if (NULL == fullhost) fullhost = "<unknown_host>";
const char* daddr = requested_daemon->addr();
if (NULL == daddr) daddr = "<unknown>";
char info[1000];
sprintf(info, "%s (%s)", fullhost, daddr);
printNoCollectorContact( stderr, info, !expert );
} else if ((NULL != requested_daemon) && (Q_COMMUNICATION_ERROR == q)) {
// more helpful message for failure to connect to some daemon/subsys
const char* id = requested_daemon->idStr();
if (NULL == id) id = requested_daemon->name();
if (NULL == id) id = "daemon";
const char* daddr = requested_daemon->addr();
if (NULL == daddr) daddr = "<unknown>";
fprintf(stderr, "Error: Failed to contact %s at %s\n", id, daddr);
}
// fail
exit (1);
}
if (noSort) {
// do nothing
} else if (sortSpecs.empty()) {
// default classad sorting
result.Sort((SortFunctionType)lessThanFunc);
} else {
// User requested custom sorting expressions:
// insert attributes related to custom sorting
result.Open();
while (ClassAd* ad = result.Next()) {
for (vector<SortSpec>::iterator ss(sortSpecs.begin()); ss != sortSpecs.end(); ++ss) {
ss->expr->SetParentScope(ad);
classad::Value v;
ss->expr->Evaluate(v);
stringstream vs;
// This will properly render all supported value types,
// including undefined and error, although current semantic
// pre-filters classads where sort expressions are undef/err:
vs << ((v.IsStringValue())?"\"":"") << v << ((v.IsStringValue())?"\"":"");
ad->AssignExpr(ss->keyAttr.c_str(), vs.str().c_str());
// Save the full expr in case user wants to examine on output:
ad->AssignExpr(ss->keyExprAttr.c_str(), ss->arg.c_str());
}
}
result.Open();
result.Sort((SortFunctionType)customLessThanFunc);
}
// output result
prettyPrint (result, &totals);
delete query;
return 0;
}
示例15: dctd
//.........这里部分代码省略.........
}
// Process the args.
if( All ) {
handleAll();
} else {
for(i = 0; i < nArgs; i++) {
if( match_prefix( args[i], "-constraint" ) ) {
i++;
addConstraint( args[i] );
} else {
procArg(args[i]);
}
}
}
// Sanity check: make certain we now have a constraint
if ( global_constraint.Length() <= 0 ) {
fprintf( stderr, "Unable to create a job constraint!\n");
exit(1);
}
fprintf(stdout,"Fetching data files...\n");
switch(st_method) {
case STM_USE_SCHEDD_ONLY:
{ // start block
// Get the sandbox directly from the schedd.
// And now, do the work.
CondorError errstack;
result = schedd->receiveJobSandbox(global_constraint.Value(),
&errstack);
if ( !result ) {
fprintf( stderr, "\n%s\n", errstack.getFullText(true).c_str() );
fprintf( stderr, "ERROR: Failed to spool job files.\n" );
exit(1);
}
// All done
return 0;
} //end block
break;
case STM_USE_TRANSFERD:
{ // start block
// NEW METHOD where we ask the schedd for a transferd, then get the
// files from the transferd
CondorError errstack;
ClassAd respad;
int invalid;
MyString reason;
MyString td_sinful;
MyString td_cap;
result = schedd->requestSandboxLocation(FTPD_DOWNLOAD,
global_constraint, FTP_CFTP, &respad, &errstack);
if ( !result ) {
fprintf( stderr, "\n%s\n", errstack.getFullText(true).c_str() );
fprintf( stderr, "ERROR: Failed to spool job files.\n" );
exit(1);
}
respad.LookupInteger(ATTR_TREQ_INVALID_REQUEST, invalid);
if (invalid == TRUE) {
fprintf( stderr, "ERROR: Failed to spool job files.\n" );
respad.LookupString(ATTR_TREQ_INVALID_REASON, reason);
fprintf( stderr, "%s\n", reason.Value());
exit(EXIT_FAILURE);
}
respad.LookupString(ATTR_TREQ_TD_SINFUL, td_sinful);
respad.LookupString(ATTR_TREQ_CAPABILITY, td_cap);
dprintf(D_ALWAYS,
"td: %s, cap: %s\n", td_sinful.Value(), td_cap.Value());
DCTransferD dctd(td_sinful.Value());
result = dctd.download_job_files(&respad, &errstack);
if ( !result ) {
fprintf( stderr, "\n%s\n", errstack.getFullText(true).c_str() );
fprintf( stderr, "ERROR: Failed to spool job files.\n" );
exit(1);
}
} // end block
break;
default:
EXCEPT("PROGRAMMER ERROR: st_method must be known.");
break;
}
// All done
return 0;
}