bool BaseResource::Invalidate () { ClassAd ad; /* Set the correct types */ SetMyTypeName ( ad, GRID_ADTYPE ); /* We only want to invalidate this resource. Using the tuple (HashName,SchedName,Owner) as unique id. */ std::string line; formatstr( line, "((TARGET.%s =?= \"%s\") && (TARGET.%s =?= \"%s\") && " "(TARGET.%s =?= \"%s\") && (TARGET.%s =?= \"%s\"))", ATTR_HASH_NAME, GetHashName (), ATTR_SCHEDD_NAME, ScheddObj->name (), ATTR_SCHEDD_IP_ADDR, ScheddObj->addr (), ATTR_OWNER, myUserName ); ad.AssignExpr ( ATTR_REQUIREMENTS, line.c_str() ); ad.Assign( ATTR_HASH_NAME, GetHashName() ); ad.Assign( ATTR_SCHEDD_NAME, ScheddObj->name() ); ad.Assign( ATTR_SCHEDD_IP_ADDR, ScheddObj->addr() ); ad.Assign( ATTR_OWNER, myUserName ); dprintf ( D_FULLDEBUG, "BaseResource::InvalidateResource: \n%s\n", line.c_str() ); return daemonCore->sendUpdates( INVALIDATE_GRID_ADS, &ad, NULL, true ) > 0; }
void ConsistentHashingLoadBalancer::Describe( std::ostream &os, const DescribeOptions& options) { if (!options.verbose) { os << "c_hash"; return; } os << "ConsistentHashingLoadBalancer {\n" << " hash function: " << GetHashName(_hash) << '\n' << " replica per host: " << _num_replicas << '\n'; std::map<butil::EndPoint, double> load_map; GetLoads(&load_map); os << " number of hosts: " << load_map.size() << '\n'; os << " load of hosts: {\n"; double expected_load_per_server = 1.0 / load_map.size(); double load_sum = 0; double load_sqr_sum = 0; for (std::map<butil::EndPoint, double>::iterator it = load_map.begin(); it!= load_map.end(); ++it) { os << " " << it->first << ": " << it->second << '\n'; double normalized_load = it->second / expected_load_per_server; load_sum += normalized_load; load_sqr_sum += normalized_load * normalized_load; } os << " }\n"; os << "deviation: " << sqrt(load_sqr_sum * load_map.size() - load_sum * load_sum) / load_map.size(); os << "}\n"; }
NzHashDigest NzHashSHA256::End() { nzUInt8 digest[SHA256_DIGEST_LENGTH]; SHA256_End(m_state, digest); return NzHashDigest(GetHashName(), digest, SHA256_DIGEST_LENGTH); }
void BaseResource::PublishResourceAd( ClassAd *resource_ad ) { std::string buff; formatstr( buff, "%s %s", ResourceType(), resourceName ); resource_ad->Assign( ATTR_NAME, buff.c_str() ); resource_ad->Assign( "HashName", GetHashName() ); resource_ad->Assign( ATTR_SCHEDD_NAME, ScheddName ); resource_ad->Assign( ATTR_SCHEDD_IP_ADDR, ScheddObj->addr() ); resource_ad->Assign( ATTR_OWNER, myUserName ); if ( SelectionValue ) { resource_ad->Assign( ATTR_GRIDMANAGER_SELECTION_VALUE, SelectionValue ); } resource_ad->Assign( "NumJobs", registeredJobs.Number() ); resource_ad->Assign( "JobLimit", jobLimit ); resource_ad->Assign( "SubmitsAllowed", submitsAllowed.Number() ); resource_ad->Assign( "SubmitsWanted", submitsWanted.Number() ); if ( resourceDown ) { resource_ad->Assign( ATTR_GRID_RESOURCE_UNAVAILABLE_TIME, (int)lastStatusChange ); } int num_idle = 0; int num_running = 0; BaseJob *job; registeredJobs.Rewind(); while ( registeredJobs.Next( job ) ) { switch ( job->condorState ) { case IDLE: num_idle++; break; case RUNNING: num_running++; break; default: break; } } resource_ad->Assign( ATTR_RUNNING_JOBS, num_running ); resource_ad->Assign( ATTR_IDLE_JOBS, num_idle ); }