本文整理汇总了C++中CondorError类的典型用法代码示例。如果您正苦于以下问题:C++ CondorError类的具体用法?C++ CondorError怎么用?C++ CondorError使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CondorError类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: handleConstraints
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: strerror
int
Job::declare_file(const MyString &name,
filesize_t size,
CondorError &errstack)
{
JobFile *ignored;
JobFile jobFile;
jobFile.size = size;
jobFile.currentOffset = 0;
jobFile.name = name;
jobFile.file =
safe_open_wrapper_follow((spoolDirectory + DIR_DELIM_STRING + jobFile.name).Value(),
O_WRONLY | O_CREAT | _O_BINARY,
0600);
if (-1 != jobFile.file) {
if (0 == declaredFiles.lookup(name, ignored)) {
close(jobFile.file);
errstack.pushf("SOAP",
ALREADYEXISTS,
"File '%s' already declared.",
name.Value());
return 4;
}
if (declaredFiles.insert(name, jobFile)) {
close(jobFile.file);
errstack.pushf("SOAP",
FAIL,
"Failed to record file '%s'.",
name.Value());
return 2;
}
} else {
// If there is a path delimiter in the name we assume that
// the client knows what she is doing and will set a
// proper Iwd later on. If there is no path delimiter we
// have a problem.
if (-1 != name.FindChar(DIR_DELIM_CHAR)) {
dprintf(D_FULLDEBUG,
"Failed to open '%s' for writing, reason: %s\n",
(spoolDirectory+DIR_DELIM_STRING+jobFile.name).Value(),
strerror(errno));
errstack.pushf("SOAP",
FAIL,
"Failed to open '%s' for writing, reason: %s",
name.Value(),
strerror(errno));
return 3;
}
}
return 0;
}
示例3: strerror
int
Job::get_file(const MyString &name,
int offset,
int length,
unsigned char *&data,
CondorError &errstack)
{
memset(data, 0, length);
int file = safe_open_wrapper_follow((spoolDirectory + DIR_DELIM_STRING + name).Value(),
O_RDONLY | _O_BINARY,
0);
if (-1 != file) {
if (-1 == lseek(file, offset, SEEK_SET)) {
close(file);
errstack.pushf("SOAP",
FAIL,
"Failed to lseek in file '%s', reason: %s",
name.Value(),
strerror(errno));
return 2;
}
int result;
if (-1 ==
(result = full_read(file, data, sizeof(unsigned char) * length))) {
close(file);
errstack.pushf("SOAP",
FAIL,
"Failed to read from file '%s', wanted to "
"read %d bytes but received %d",
name.Value(),
length,
result);
return 3;
}
if (-1 == close(file)) {
errstack.pushf("SOAP",
FAIL,
"Failed to close file '%s', reason: %s",
name.Value(),
strerror(errno));
return 4;
}
} else {
errstack.pushf("SOAP",
FAIL,
"Failed to open file '%s', reason: %s",
name.Value(),
strerror(errno));
return 1;
}
return 0;
}
示例4: 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;
}
示例5: dprintf
// 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;
}
示例6: GetFileID
///////////////////////////////////////////////////////////////////////////////
// Note: on Unix/Linux, the file ID is a string encoding the combination of
// device number and inode; on Windows the file ID is simply the value
// _fullpath() returns on the path we're given. The Unix/Linux version
// is preferable because it will work correctly even if there are hard
// links to log files; but there are no inodes on Windows, so we're
// doing what we can.
bool
GetFileID( const MyString &filename, MyString &fileID,
CondorError &errstack )
{
// Make sure the log file exists. Even though we may later call
// InitializeFile(), we have to make sure the file exists here
// first so we make sure that the file exists and we can therefore
// get an inode or real path for it.
// We *don't* want to truncate the file here, though, because
// we don't know for sure whether it's the first time we're seeing
// it.
if ( access( filename.Value(), F_OK ) != 0 ) {
if ( !MultiLogFiles::InitializeFile( filename.Value(),
false, errstack ) ) {
errstack.pushf( "ReadMultipleUserLogs", UTIL_ERR_LOG_FILE,
"Error initializing log file %s", filename.Value() );
return false;
}
}
#ifdef WIN32
char *tmpRealPath = realpath( filename.Value(), NULL );
if ( !tmpRealPath ) {
errstack.pushf( "ReadMultipleUserLogs", UTIL_ERR_LOG_FILE,
"Error (%d, %s) getting real path for specified path %s",
errno, strerror( errno ), filename.Value() );
return false;
}
fileID = tmpRealPath;
free( tmpRealPath );
#else
StatWrapper swrap;
if ( swrap.Stat( filename.Value() ) != 0 ) {
errstack.pushf( "ReadMultipleUserLogs", UTIL_ERR_LOG_FILE,
"Error getting inode for log file %s",
filename.Value() );
return false;
}
fileID.formatstr( "%llu:%llu", (unsigned long long)swrap.GetBuf()->st_dev,
(unsigned long long)swrap.GetBuf()->st_ino );
#endif
return true;
}
示例7: 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;
}
示例8: dprintf
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;
}
示例9: 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 );
}
}
}
示例10: handleAll
void
handleAll()
{
char constraint[128];
sprintf( constraint, "%s >= 0", ATTR_CLUSTER_ID );
CondorError errstack;
if( doWorkByConstraint(constraint, &errstack) ) {
fprintf( stdout, "All jobs %s.\n",
(mode == JA_REMOVE_JOBS) ?
"marked for removal" :
(mode == JA_REMOVE_X_JOBS) ?
"removed locally (remote state unknown)" :
actionWord(mode,true) );
} else {
fprintf( stderr, "%s\n", errstack.getFullText(true).c_str() );
if (had_error)
{
fprintf( stderr, "Could not %s all jobs.\n",
actionWord(mode,false) );
}
}
}
示例11: directoryInfo
int
Job::get_spool_list(List<FileInfo> &file_list,
CondorError &errstack)
{
StatInfo directoryInfo(spoolDirectory.Value());
if (directoryInfo.IsDirectory()) {
Directory directory(spoolDirectory.Value());
const char * name;
FileInfo *info;
while (NULL != (name = directory.Next())) {
info = new FileInfo();
info->initialize(name, directory.GetFileSize());
ASSERT(info);
if (!file_list.Append(info)) {
errstack.pushf("SOAP",
FAIL,
"Error adding %s to file list.",
name);
return 2;
}
}
return 0;
} else {
dprintf(D_ALWAYS, "spoolDirectory == '%s'\n",
spoolDirectory.Value());
errstack.pushf("SOAP",
FAIL,
"spool directory '%s' is not actually a directory.",
spoolDirectory.Value());
return 1;
}
}
示例12:
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);
}
示例13: strerror
bool
MultiLogFiles::InitializeFile(const char *filename, bool truncate,
CondorError &errstack)
{
dprintf( D_LOG_FILES, "MultiLogFiles::InitializeFile(%s, %d)\n",
filename, (int)truncate );
int flags = O_WRONLY;
if ( truncate ) {
flags |= O_TRUNC;
dprintf( D_ALWAYS, "MultiLogFiles: truncating log file %s\n",
filename );
}
// Two-phase attempt at open here is to make things work if
// a log file is a symlink to another file (see gittrac #2704).
int fd = safe_create_fail_if_exists( filename, flags );
if ( fd < 0 && errno == EEXIST ) {
fd = safe_open_no_create_follow( filename, flags );
}
if ( fd < 0 ) {
errstack.pushf("MultiLogFiles", UTIL_ERR_OPEN_FILE,
"Error (%d, %s) opening file %s for creation "
"or truncation", errno, strerror( errno ), filename );
return false;
}
if ( close( fd ) != 0 ) {
errstack.pushf("MultiLogFiles", UTIL_ERR_CLOSE_FILE,
"Error (%d, %s) closing file %s for creation "
"or truncation", errno, strerror( errno ), filename );
return false;
}
return true;
}
示例14: main
//.........这里部分代码省略.........
if( ! schedd->locate() ) {
fprintf( stderr, "%s: %s\n", MyName, schedd->error() );
exit( 1 );
}
// 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" );
示例15: procArg
void
procArg(const char* arg)
{
int c, p; // cluster/proc #
char* tmp;
MyString constraint;
if( str_isint(arg) || str_isreal(arg,true) )
// process by cluster/proc #
{
c = strtol(arg, &tmp, 10);
if(c <= 0)
{
fprintf(stderr, "Invalid cluster # from %s.\n", arg);
had_error = true;
return;
}
if(*tmp == '\0')
// delete the cluster
{
CondorError errstack;
constraint.formatstr( "%s == %d", ATTR_CLUSTER_ID, c );
if( doWorkByConstraint(constraint.Value(), &errstack) ) {
fprintf( stdout,
"Cluster %d %s.\n", c,
(mode == JA_REMOVE_JOBS) ?
"has been marked for removal" :
(mode == JA_REMOVE_X_JOBS) ?
"has 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 in cluster %d.\n",
actionWord(mode,false), c );
}
}
return;
}
if(*tmp == '.')
{
p = strtol(tmp + 1, &tmp, 10);
if(p < 0)
{
fprintf( stderr, "Invalid proc # from %s.\n", arg);
had_error = true;
return;
}
if(*tmp == '\0')
// process a proc
{
if( ! job_ids ) {
job_ids = new StringList();
}
job_ids->append( arg );
return;
}
}
fprintf( stderr, "Warning: unrecognized \"%s\" skipped.\n", arg );
return;
}
// process by user name
else {
CondorError errstack;
constraint.formatstr("%s == \"%s\"", ATTR_OWNER, arg );
if( doWorkByConstraint(constraint.Value(), &errstack) ) {
fprintf( stdout, "User %s's job(s) %s.\n", arg,
(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 of user %s's job(s).\n",
actionWord(mode,false), arg );
}
}
}
}