int LogNewClassAd::Play(void *data_structure) { int result; ClassAdHashTable *table = (ClassAdHashTable *)data_structure; ClassAd *ad = new ClassAd(); ad->SetMyTypeName(mytype); ad->SetTargetTypeName(targettype); result = table->insert(HashKey(key), ad); #if defined(HAVE_DLOPEN) ClassAdLogPluginManager::NewClassAd(key); #endif return result; }
void XferSummary::time_out(time_t now, char *hostaddr) { ClassAd info; char line[128], *tmp; char *str = NULL; info.SetMyTypeName("CkptServer"); info.SetTargetTypeName("CkptFile"); sprintf(line, "%s = \"%s\"", ATTR_NAME, my_full_hostname() ); info.Insert(line); sprintf(line, "%s = \"%s\"", ATTR_MACHINE, hostaddr ); info.Insert(line); sprintf(line, "%s = \"%s\"", ATTR_VERSION, CondorVersion() ); info.Insert(line); sprintf(line, "%s = \"%s\"", ATTR_PLATFORM, CondorPlatform() ); info.Insert(line); sprintf(line, "NumSends = %d", num_sends); info.Insert(line); sprintf(line, "BytesSent = %d", (int) bytes_sent); info.Insert(line); sprintf(line, "TimeSending = %d", time_sending); info.Insert(line); sprintf(line, "AvgSendBandwidth = %f", num_sends ? tot_send_bandwidth / num_sends : 0.0); info.Insert(line); sprintf(line, "NumRecvs = %d", num_recvs); info.Insert(line); sprintf(line, "BytesReceived = %d", (int) bytes_recv); info.Insert(line); sprintf(line, "TimeReceiving = %d", time_recving); info.Insert(line); sprintf(line, "AvgReceiveBandwidth = %f", num_recvs ? tot_recv_bandwidth / num_recvs : 0.0); info.Insert(line); /* ctime adds a newline at the end of the ascii conversion.... */ str = ctime(&start_time); sprintf(line, "CkptServerIntervalStart = \"%s\"", str ? str : "Unknown\n"); tmp = strchr( line, '\n' ); if (tmp != NULL) { /* delete the newline */ *tmp = '\"'; tmp++; *tmp = '\0'; } info.Insert(line); /* ctime adds a newline at the end of the ascii conversion.... */ str = ctime(&now); sprintf(line, "CkptServerIntervalEnd = \"%s\"", str ? str : "Unknown\n"); tmp = strchr( line, '\n' ); if (tmp != NULL) { /* delete the newline */ *tmp = '\"'; tmp++; *tmp = '\0'; } info.Insert(line); sprintf(line, "Disk = %d", sysapi_disk_space(pwd.Value()) ); info.Insert(line); // Send to collector if ( Collectors ) { dprintf(D_NETWORK, "Sending CkptServer ClassAd:\n"); info.dPrint(D_NETWORK); Collectors->sendUpdates (UPDATE_CKPT_SRVR_AD, &info, NULL, true); } init(); }
QueryResult CondorQuery:: getQueryAd (ClassAd &queryAd) { QueryResult result; ExprTree *tree; queryAd = extraAttrs; result = (QueryResult) query.makeQuery (tree); if (result != Q_OK) return result; queryAd.Insert(ATTR_REQUIREMENTS, tree); // fix types queryAd.SetMyTypeName (QUERY_ADTYPE); switch (queryType) { #ifdef HAVE_EXT_POSTGRESQL case QUILL_AD: queryAd.SetTargetTypeName (QUILL_ADTYPE); break; #endif /* HAVE_EXT_POSTGRESQL */ case STARTD_AD: case STARTD_PVT_AD: queryAd.SetTargetTypeName (STARTD_ADTYPE); break; case SCHEDD_AD: queryAd.SetTargetTypeName (SCHEDD_ADTYPE); break; case SUBMITTOR_AD: queryAd.SetTargetTypeName (SUBMITTER_ADTYPE); break; case LICENSE_AD: queryAd.SetTargetTypeName (LICENSE_ADTYPE); break; case MASTER_AD: queryAd.SetTargetTypeName (MASTER_ADTYPE); break; case CKPT_SRVR_AD: queryAd.SetTargetTypeName (CKPT_SRVR_ADTYPE); break; case COLLECTOR_AD: queryAd.SetTargetTypeName (COLLECTOR_ADTYPE); break; case NEGOTIATOR_AD: queryAd.SetTargetTypeName (NEGOTIATOR_ADTYPE); break; case STORAGE_AD: queryAd.SetTargetTypeName (STORAGE_ADTYPE); break; case CREDD_AD: queryAd.SetTargetTypeName (CREDD_ADTYPE); break; case GENERIC_AD: if ( genericQueryType ) { queryAd.SetTargetTypeName (genericQueryType); } else { queryAd.SetTargetTypeName (GENERIC_ADTYPE); } break; case XFER_SERVICE_AD: queryAd.SetTargetTypeName (XFER_SERVICE_ADTYPE); break; case LEASE_MANAGER_AD: queryAd.SetTargetTypeName (LEASE_MANAGER_ADTYPE); break; case ANY_AD: queryAd.SetTargetTypeName (ANY_ADTYPE); break; case DATABASE_AD: queryAd.SetTargetTypeName (DATABASE_ADTYPE); break; case DBMSD_AD: queryAd.SetTargetTypeName (DBMSD_ADTYPE); break; case TT_AD: queryAd.SetTargetTypeName (TT_ADTYPE); break; case GRID_AD: queryAd.SetTargetTypeName (GRID_ADTYPE); break; case HAD_AD: queryAd.SetTargetTypeName (HAD_ADTYPE); break; default: return Q_INVALID_QUERY; } return Q_OK; }
void Starter::exited(int status) { ClassAd *jobAd = NULL; bool jobAdNeedsFree = true; if (s_claim && s_claim->ad()) { // real jobs in the startd have claims and job ads, boinc and perhaps others won't jobAd = s_claim->ad(); jobAdNeedsFree = false; } else { // Dummy up an ad int now = (int) time(0); jobAd = new ClassAd(); jobAd->SetMyTypeName("Job"); jobAd->SetTargetTypeName("Machine"); jobAd->Assign(ATTR_CLUSTER_ID, now); jobAd->Assign(ATTR_PROC_ID, 1); jobAd->Assign(ATTR_OWNER, "boinc"); jobAd->Assign(ATTR_Q_DATE, (int)s_birthdate); jobAd->Assign(ATTR_JOB_PRIO, 0); jobAd->Assign(ATTR_IMAGE_SIZE, 0); jobAd->Assign(ATTR_JOB_CMD, "boinc"); MyString gjid; gjid.formatstr("%s#%d#%d#%d", get_local_hostname().Value(), now, 1, now); jobAd->Assign(ATTR_GLOBAL_JOB_ID, gjid); } // First, patch up the ad a little bit jobAd->Assign(ATTR_COMPLETION_DATE, (int)time(0)); int runtime = time(0) - s_birthdate; jobAd->Assign(ATTR_JOB_REMOTE_WALL_CLOCK, runtime); int jobStatus = COMPLETED; if (WIFSIGNALED(status)) { jobStatus = REMOVED; } jobAd->Assign(ATTR_JOB_STATUS, jobStatus); AppendHistory(jobAd); WritePerJobHistoryFile(jobAd, true /* use gjid for filename*/); if (jobAdNeedsFree) { delete jobAd; } // Make sure our time isn't going to go off. cancelKillTimer(); // Just for good measure, try to kill what's left of our whole // pid family. if (daemonCore->Kill_Family(s_pid) == FALSE) { dprintf(D_ALWAYS, "error killing process family of starter with pid %u\n", s_pid); } // Now, delete any files lying around. ASSERT( executeDir() ); cleanup_execute_dir( s_pid, executeDir() ); #if defined(LINUX) if( param_boolean( "GLEXEC_STARTER", false ) ) { cleanupAfterGlexec(); } #endif }
ClassAd *CollectorEngine:: collect (int command,ClassAd *clientAd,const condor_sockaddr& from,int &insert,Sock *sock) { ClassAd *retVal; ClassAd *pvtAd; int insPvt; AdNameHashKey hk; HashString hashString; static int repeatStartdAds = -1; // for debugging ClassAd *clientAdToRepeat = NULL; if (repeatStartdAds == -1) { repeatStartdAds = param_integer("COLLECTOR_REPEAT_STARTD_ADS",0); } if( !ValidateClassAd(command,clientAd,sock) ) { return NULL; } // mux on command switch (command) { case UPDATE_STARTD_AD: case UPDATE_STARTD_AD_WITH_ACK: #if !defined(WANT_OLD_CLASSADS) clientAd->AddTargetRefs( TargetJobAttrs ); #endif if ( repeatStartdAds > 0 ) { clientAdToRepeat = new ClassAd(*clientAd); } if (!makeStartdAdHashKey (hk, clientAd)) { dprintf (D_ALWAYS, "Could not make hashkey --- ignoring ad\n"); insert = -3; retVal = 0; break; } hashString.Build( hk ); retVal=updateClassAd (StartdAds, "StartdAd ", "Start", clientAd, hk, hashString, insert, from ); // if we want to store private ads if (!sock) { dprintf (D_ALWAYS, "Want private ads, but no socket given!\n"); break; } else { if (!(pvtAd = new ClassAd)) { EXCEPT ("Memory error!"); } if( !pvtAd->initFromStream(*sock) ) { dprintf(D_FULLDEBUG,"\t(Could not get startd's private ad)\n"); delete pvtAd; break; } // Fix up some stuff in the private ad that we depend on. // We started doing this in 7.2.0, so once we no longer // care about compatibility with stuff from before then, // the startd could stop bothering to send these attributes. // Queries of private ads depend on the following: pvtAd->SetMyTypeName( STARTD_ADTYPE ); // Negotiator matches up private ad with public ad by // using the following. if( retVal ) { pvtAd->CopyAttribute( ATTR_MY_ADDRESS, retVal ); pvtAd->CopyAttribute( ATTR_NAME, retVal ); } // insert the private ad into its hashtable --- use the same // hash key as the public ad (void) updateClassAd (StartdPrivateAds, "StartdPvtAd ", "StartdPvt", pvtAd, hk, hashString, insPvt, from ); } // create fake duplicates of this ad, each with a different name, if // we are told to do so. this feature exists for developer // scalability testing. if ( repeatStartdAds > 0 && clientAdToRepeat ) { ClassAd *fakeAd; int n; char newname[150],oldname[130]; oldname[0] = '\0'; clientAdToRepeat->LookupString("Name",oldname,sizeof(oldname)); for (n=0;n<repeatStartdAds;n++) { fakeAd = new ClassAd(*clientAdToRepeat); snprintf(newname,sizeof(newname), "Name=\"fake%d-%s\"",n,oldname); fakeAd->InsertOrUpdate(newname); makeStartdAdHashKey (hk, fakeAd); hashString.Build( hk ); if (! updateClassAd (StartdAds, "StartdAd ", "Start", fakeAd, hk, hashString, insert, from ) ) { // don't leak memory if there is some failure delete fakeAd; } } delete clientAdToRepeat; clientAdToRepeat = NULL; } break; case MERGE_STARTD_AD: #if !defined(WANT_OLD_CLASSADS) clientAd->AddTargetRefs( TargetJobAttrs ); #endif if (!makeStartdAdHashKey (hk, clientAd)) { dprintf (D_ALWAYS, "Could not make hashkey --- ignoring ad\n"); insert = -3; retVal = 0; break; } hashString.Build( hk ); retVal=mergeClassAd (StartdAds, "StartdAd ", "Start", clientAd, hk, hashString, insert, from ); break; #ifdef HAVE_EXT_POSTGRESQL case UPDATE_QUILL_AD: if (!makeQuillAdHashKey (hk, clientAd)) { dprintf (D_ALWAYS, "Could not make hashkey --- ignoring ad\n"); insert = -3; retVal = 0; break; } hashString.Build( hk ); retVal=updateClassAd (QuillAds, "QuillAd ", "Quill", clientAd, hk, hashString, insert, from ); break; #endif /* HAVE_EXT_POSTGRESQL */ case UPDATE_SCHEDD_AD: if (!makeScheddAdHashKey (hk, clientAd)) { dprintf (D_ALWAYS, "Could not make hashkey --- ignoring ad\n"); insert = -3; retVal = 0; break; } hashString.Build( hk ); retVal=updateClassAd (ScheddAds, "ScheddAd ", "Schedd", clientAd, hk, hashString, insert, from ); break; case UPDATE_SUBMITTOR_AD: // use the same hashkey function as a schedd ad if (!makeScheddAdHashKey (hk, clientAd)) { dprintf (D_ALWAYS, "Could not make hashkey --- ignoring ad\n"); insert = -3; retVal = 0; break; } // CRUFT: Before 7.3.2, submitter ads had a MyType of // "Scheduler". The only way to tell the difference // was that submitter ads didn't have ATTR_NUM_USERS. // Coerce MyStype to "Submitter" for ads coming from // these older schedds. // Before 7.7.3, submitter ads for parallel universe // jobs had a MyType of "Scheduler". clientAd->SetMyTypeName( SUBMITTER_ADTYPE ); // since submittor ads always follow a schedd ad, and a master check is // performed for schedd ads, we don't need a master check in here hashString.Build( hk ); retVal=updateClassAd (SubmittorAds, "SubmittorAd ", "Submittor", clientAd, hk, hashString, insert, from ); break; case UPDATE_LICENSE_AD: // use the same hashkey function as a schedd ad if (!makeLicenseAdHashKey (hk, clientAd)) { dprintf (D_ALWAYS, "Could not make hashkey --- ignoring ad\n"); insert = -3; retVal = 0; break; } // since submittor ads always follow a schedd ad, and a master check is // performed for schedd ads, we don't need a master check in here hashString.Build( hk ); retVal=updateClassAd (LicenseAds, "LicenseAd ", "License", clientAd, hk, hashString, insert, from ); break; case UPDATE_MASTER_AD: if (!makeMasterAdHashKey (hk, clientAd)) { dprintf (D_ALWAYS, "Could not make hashkey --- ignoring ad\n"); insert = -3; retVal = 0; break; } hashString.Build( hk ); retVal=updateClassAd (MasterAds, "MasterAd ", "Master", clientAd, hk, hashString, insert, from ); break; case UPDATE_CKPT_SRVR_AD: if (!makeCkptSrvrAdHashKey (hk, clientAd)) { dprintf (D_ALWAYS, "Could not make hashkey --- ignoring ad\n"); insert = -3; retVal = 0; break; } hashString.Build( hk ); retVal=updateClassAd (CkptServerAds, "CkptSrvrAd ", "CkptSrvr", clientAd, hk, hashString, insert, from ); break; case UPDATE_COLLECTOR_AD: if (!makeCollectorAdHashKey (hk, clientAd)) { dprintf (D_ALWAYS, "Could not make hashkey --- ignoring ad\n"); insert = -3; retVal = 0; break; } hashString.Build( hk ); retVal=updateClassAd (CollectorAds, "CollectorAd ", "Collector", clientAd, hk, hashString, insert, from ); break; case UPDATE_STORAGE_AD: if (!makeStorageAdHashKey (hk, clientAd)) { dprintf (D_ALWAYS, "Could not make hashkey --- ignoring ad\n"); insert = -3; retVal = 0; break; } hashString.Build( hk ); retVal=updateClassAd (StorageAds, "StorageAd ", "Storage", clientAd, hk, hashString, insert, from ); break; case UPDATE_NEGOTIATOR_AD: if (!makeNegotiatorAdHashKey (hk, clientAd)) { dprintf (D_ALWAYS, "Could not make hashkey --- ignoring ad\n"); insert = -3; retVal = 0; break; } hashString.Build( hk ); // first, purge all the existing negotiator ads, since we // want to enforce that *ONLY* 1 negotiator is in the // collector any given time. purgeHashTable( NegotiatorAds ); retVal=updateClassAd (NegotiatorAds, "NegotiatorAd ", "Negotiator", clientAd, hk, hashString, insert, from ); break; case UPDATE_HAD_AD: if (!makeHadAdHashKey (hk, clientAd)) { dprintf (D_ALWAYS, "Could not make hashkey --- ignoring ad\n"); insert = -3; retVal = 0; break; } hashString.Build( hk ); retVal=updateClassAd (HadAds, "HadAd ", "HAD", clientAd, hk, hashString, insert, from ); break; case UPDATE_GRID_AD: if (!makeGridAdHashKey(hk, clientAd)) { dprintf (D_ALWAYS, "Could not make hashkey --- ignoring ad\n"); insert = -3; retVal = 0; break; } hashString.Build( hk ); retVal=updateClassAd (GridAds, "GridAd ", "Grid", clientAd, hk, hashString, insert, from ); break; case UPDATE_AD_GENERIC: { const char *type_str = clientAd->GetMyTypeName(); if (type_str == NULL) { dprintf(D_ALWAYS, "collect: UPDATE_AD_GENERIC: ad has no type\n"); insert = -3; retVal = 0; break; } MyString type(type_str); CollectorHashTable *cht = findOrCreateTable(type); if (cht == NULL) { dprintf(D_ALWAYS, "collect: findOrCreateTable failed\n"); insert = -3; retVal = 0; break; } if (!makeGenericAdHashKey (hk, clientAd)) { dprintf(D_ALWAYS, "Could not make haskey --- ignoring ad\n"); insert = -3; retVal = 0; break; } hashString.Build(hk); retVal = updateClassAd(*cht, type_str, type_str, clientAd, hk, hashString, insert, from); break; } case UPDATE_XFER_SERVICE_AD: if (!makeXferServiceAdHashKey (hk, clientAd)) { dprintf (D_ALWAYS, "Could not make hashkey --- ignoring ad\n"); insert = -3; retVal = 0; break; } hashString.Build( hk ); retVal=updateClassAd (XferServiceAds, "XferServiceAd ", "XferService", clientAd, hk, hashString, insert, from ); break; case UPDATE_LEASE_MANAGER_AD: if (!makeLeaseManagerAdHashKey (hk, clientAd)) { dprintf (D_ALWAYS, "Could not make hashkey --- ignoring ad\n"); insert = -3; retVal = 0; break; } hashString.Build( hk ); // first, purge all the existing LeaseManager ads, since we // want to enforce that *ONLY* 1 manager is in the // collector any given time. purgeHashTable( LeaseManagerAds ); retVal=updateClassAd (LeaseManagerAds, "LeaseManagerAd ", "LeaseManager", clientAd, hk, hashString, insert, from ); break; case QUERY_STARTD_ADS: case QUERY_SCHEDD_ADS: case QUERY_MASTER_ADS: case QUERY_GATEWAY_ADS: case QUERY_SUBMITTOR_ADS: case QUERY_CKPT_SRVR_ADS: case QUERY_STARTD_PVT_ADS: case QUERY_COLLECTOR_ADS: case QUERY_NEGOTIATOR_ADS: case QUERY_HAD_ADS: case QUERY_XFER_SERVICE_ADS: case QUERY_LEASE_MANAGER_ADS: case QUERY_GENERIC_ADS: case INVALIDATE_STARTD_ADS: case INVALIDATE_SCHEDD_ADS: case INVALIDATE_MASTER_ADS: case INVALIDATE_GATEWAY_ADS: case INVALIDATE_CKPT_SRVR_ADS: case INVALIDATE_SUBMITTOR_ADS: case INVALIDATE_COLLECTOR_ADS: case INVALIDATE_NEGOTIATOR_ADS: case INVALIDATE_HAD_ADS: case INVALIDATE_XFER_SERVICE_ADS: case INVALIDATE_LEASE_MANAGER_ADS: case INVALIDATE_ADS_GENERIC: // these are not implemented in the engine, but we allow another // daemon to detect that these commands have been given insert = -2; retVal = 0; break; default: dprintf (D_ALWAYS, "Received illegal command: %d\n", command); insert = -1; retVal = 0; } // return the updated ad return retVal; }