bool makeScheddAdHashKey (AdNameHashKey &hk, const ClassAd *ad ) { // get the name of the schedd if ( !adLookup( "Schedd", ad, ATTR_NAME, ATTR_MACHINE, hk.name ) ) { return false; } // this may be a submittor ad. if so, we also want to append the // schedd name to the hash. this will fix problems were submittor // ads will clobber one another if the more than one schedd runs // on the same IP address submitting into the same pool. // -Todd Tannenbaum <*****@*****.**> 2/2005 MyString tmp; if ( adLookup( "Schedd", ad, ATTR_SCHEDD_NAME, NULL, tmp, false ) ) { hk.name += tmp; } // get the IP and port of the schedd // As of 7.5.0, we look for MyAddress. Prior to that, we did not, // so new schedds must continue to send StartdIpAddr to remain // compatible with old collectors. if ( !getIpAddr( "Schedd", ad, ATTR_MY_ADDRESS, ATTR_SCHEDD_IP_ADDR, hk.ip_addr ) ) { return false; } return true; }
bool makeGridAdHashKey (AdNameHashKey &hk, const ClassAd *ad) { MyString tmp; // get the hash name of the the resource if ( !adLookup( "Grid", ad, ATTR_HASH_NAME, NULL, hk.name ) ) { return false; } // get the owner associated with the resource if ( !adLookup( "Grid", ad, ATTR_OWNER, NULL, tmp ) ) { return false; } hk.name += tmp; // get the schedd associated with the resource if we can // (this _may_ be undefined when running two instances or // Condor on one machine). if ( adLookup( "Grid", ad, ATTR_SCHEDD_NAME, NULL, tmp ) ) { hk.name += tmp; } else { if ( !adLookup ( "Grid", ad, ATTR_SCHEDD_IP_ADDR, NULL, hk.ip_addr ) ) { return false; } } if ( adLookup( "Grid", ad, ATTR_GRIDMANAGER_SELECTION_VALUE, NULL, tmp, false ) ) { hk.name += tmp; } return true; }
// Look up an IP attribute in an ad, optionally fall back to an alternate bool getIpAddr( const char *ad_type, const ClassAd *ad, const char *attrname, const char *attrold, MyString &ip ) { MyString tmp; // get the IP and port of the startd if ( !adLookup( ad_type, ad, attrname, attrold, tmp, true ) ) { return false; } // If no valid string, do our own thing.. char* host; if ( ( tmp.Length() == 0 ) || (host = getHostFromAddr(tmp.Value())) == NULL ) { dprintf (D_ALWAYS, "%sAd: Invalid IP address in classAd\n", ad_type ); return false; } ip = host; free(host); return true; }
bool makeAccountingAdHashKey (AdNameHashKey &hk, const ClassAd *ad) { hk.ip_addr = ""; if ( !adLookup( "Accounting", ad, ATTR_NAME, NULL, hk.name ) ) { return false; } // Get the name of the negotiator this accounting ad is from. // Older negotiators didn't set ATTR_NEGOTIATOR_NAME, so this is // optional. MyString tmp; if ( adLookup( "Accounting", ad, ATTR_NEGOTIATOR_NAME, NULL, tmp ) ) { hk.name += tmp; } return true; }
bool makeQuillAdHashKey (AdNameHashKey &hk, ClassAd *ad ) { // get the name of the quill daemon if ( !adLookup( "Quill", ad, ATTR_NAME, ATTR_MACHINE, hk.name ) ) { return false; } // as in the case of submittor ads (see makeScheddAdHashKey), we // also use the schedd name to construct the hash key for a quill // ad. this solves the problem of multiple quill daemons on the // same name on the same machine submitting to the same pool // -Ameet Kini <*****@*****.**> 8/2005 MyString tmp; if ( adLookup( "Quill", ad, ATTR_SCHEDD_NAME, NULL, tmp, false ) ) { hk.name += tmp; } return true; }
// functions to make the hashkeys ... // make hashkeys from the obtained ad bool makeStartdAdHashKey (AdNameHashKey &hk, const ClassAd *ad ) { // get the name of the startd; // this gets complicated with ID if ( !adLookup( "Start", ad, ATTR_NAME, NULL, hk.name, false ) ) { logWarning( "Start", ATTR_NAME, ATTR_MACHINE, ATTR_SLOT_ID ); // Get the machine name; if it's not there, give up if ( !adLookup( "Start", ad, ATTR_MACHINE, NULL, hk.name, false ) ) { logError( "Start", ATTR_NAME, ATTR_MACHINE ); return false; } // Finally, if there is a slot ID, append it. int slot; if (ad->LookupInteger( ATTR_SLOT_ID, slot)) { hk.name += ":"; hk.name += IntToStr( slot ); } else if (param_boolean("ALLOW_VM_CRUFT", false) && ad->LookupInteger(ATTR_VIRTUAL_MACHINE_ID, slot)) { hk.name += ":"; hk.name += IntToStr( slot ); } } hk.ip_addr = ""; // As of 7.5.0, we look for MyAddress. Prior to that, we did not, // so new startds must continue to send StartdIpAddr to remain // compatible with old collectors. if ( !getIpAddr( "Start", ad, ATTR_MY_ADDRESS, ATTR_STARTD_IP_ADDR, hk.ip_addr ) ) { dprintf (D_FULLDEBUG, "StartAd: No IP address in classAd from %s\n", hk.name.Value() ); } return true; }
bool makeLicenseAdHashKey (AdNameHashKey &hk, const ClassAd *ad ) { // get the name of the license if ( !adLookup( "License", ad, ATTR_NAME, ATTR_MACHINE, hk.name ) ) { return false; } // get the IP and port of the startd if ( !getIpAddr( "License", ad, ATTR_MY_ADDRESS, NULL, hk.ip_addr ) ) { return false; } return true; }
// for anything that sends its updates via UPDATE_AD_GENERIC, this // needs to provide a key that will uniquely identify each entity // with respect to all entities of that type // (e.g. this wouldn't work for submitter ads - see code for // makeScheddAdHashKey above) bool makeGenericAdHashKey (AdNameHashKey &hk, const ClassAd *ad ) { hk.ip_addr = ""; return adLookup( "Generic", ad, ATTR_NAME, NULL, hk.name ); }
bool makeNegotiatorAdHashKey (AdNameHashKey &hk, const ClassAd *ad) { hk.ip_addr = ""; return adLookup( "Negotiator", ad, ATTR_NAME, NULL, hk.name ); }
bool makeStorageAdHashKey (AdNameHashKey &hk, const ClassAd *ad) { hk.ip_addr = ""; return adLookup( "Storage", ad, ATTR_NAME, NULL, hk.name ); }
bool makeCollectorAdHashKey (AdNameHashKey &hk, const ClassAd *ad) { hk.ip_addr = ""; return adLookup( "Collector", ad, ATTR_NAME, ATTR_MACHINE, hk.name ); }
bool makeCkptSrvrAdHashKey (AdNameHashKey &hk, const ClassAd *ad) { hk.ip_addr = ""; return adLookup( "CheckpointServer", ad, ATTR_MACHINE, NULL, hk.name ); }
bool makeHadAdHashKey (AdNameHashKey &hk, ClassAd *ad) { hk.ip_addr = ""; return adLookup( "HAD", ad, ATTR_NAME, NULL, hk.name ); }
bool makeMasterAdHashKey (AdNameHashKey &hk, ClassAd *ad ) { hk.ip_addr = ""; return adLookup( "Master", ad, ATTR_NAME, ATTR_MACHINE, hk.name ); }