guint worker_getRawCPUFrequency() { Worker* worker = _worker_getPrivate(); return slave_getRawCPUFrequency(worker->slave); }
static void _master_registerHostCallback(ConfigurationHostElement* he, Master* master) { MAGIC_ASSERT(master); utility_assert(he); utility_assert(he->id.isSet && he->id.string); guint64 quantity = he->quantity.isSet ? he->quantity.integer : 1; for(guint64 i = 0; i < quantity; i++) { HostParameters* params = g_new0(HostParameters, 1); /* hostname and id params */ const gchar* hostNameBase = he->id.string->str; GString* hostnameBuffer = g_string_new(hostNameBase); if(quantity > 1) { g_string_append_printf(hostnameBuffer, "%"G_GUINT64_FORMAT, i+1); } params->hostname = hostnameBuffer->str; /* cpu params - if they didnt specify a CPU frequency, use the slave machine frequency */ gint slaveCPUFreq = slave_getRawCPUFrequency(master->slave); params->cpuFrequency = he->cpufrequency.isSet ? he->cpufrequency.integer : (slaveCPUFreq > 0) ? (guint64)slaveCPUFreq : 0; if(params->cpuFrequency == 0) { params->cpuFrequency = 2500000; // 2.5 GHz debug("both configured and raw slave cpu frequencies unavailable, using 2500000 KHz"); } gint defaultCPUThreshold = options_getCPUThreshold(master->options); params->cpuThreshold = defaultCPUThreshold > 0 ? defaultCPUThreshold : 0; gint defaultCPUPrecision = options_getCPUPrecision(master->options); params->cpuPrecision = defaultCPUPrecision > 0 ? defaultCPUPrecision : 0; params->logLevel = he->loglevel.isSet ? loglevel_fromStr(he->loglevel.string->str) : options_getLogLevel(master->options); params->heartbeatLogLevel = he->heartbeatloglevel.isSet ? loglevel_fromStr(he->heartbeatloglevel.string->str) : options_getHeartbeatLogLevel(master->options); params->heartbeatInterval = he->heartbeatfrequency.isSet ? (SimulationTime)(he->heartbeatfrequency.integer * SIMTIME_ONE_SECOND) : options_getHeartbeatInterval(master->options); params->heartbeatLogInfo = he->heartbeatloginfo.isSet ? options_toHeartbeatLogInfo(master->options, he->heartbeatloginfo.string->str) : options_getHeartbeatLogInfo(master->options); params->logPcap = (he->logpcap.isSet && !g_ascii_strcasecmp(he->logpcap.string->str, "true")) ? TRUE : FALSE; params->pcapDir = he->pcapdir.isSet ? he->pcapdir.string->str : NULL; /* socket buffer settings - if size is set manually, turn off autotuning */ params->recvBufSize = he->socketrecvbuffer.isSet ? he->socketrecvbuffer.integer : options_getSocketReceiveBufferSize(master->options); params->autotuneRecvBuf = he->socketrecvbuffer.isSet ? FALSE : options_doAutotuneReceiveBuffer(master->options); params->sendBufSize = he->socketsendbuffer.isSet ? he->socketsendbuffer.integer : options_getSocketSendBufferSize(master->options); params->autotuneSendBuf = he->socketsendbuffer.isSet ? FALSE : options_doAutotuneSendBuffer(master->options); params->interfaceBufSize = he->interfacebuffer.isSet ? he->interfacebuffer.integer : options_getInterfaceBufferSize(master->options); params->qdisc = options_getQueuingDiscipline(master->options); /* requested attributes from shadow config */ params->ipHint = he->ipHint.isSet ? he->ipHint.string->str : NULL; params->countrycodeHint = he->countrycodeHint.isSet ? he->countrycodeHint.string->str : NULL; params->citycodeHint = he->citycodeHint.isSet ? he->citycodeHint.string->str : NULL; params->geocodeHint = he->geocodeHint.isSet ? he->geocodeHint.string->str : NULL; params->typeHint = he->typeHint.isSet ? he->typeHint.string->str : NULL; params->requestedBWDownKiBps = he->bandwidthdown.isSet ? he->bandwidthdown.integer : 0; params->requestedBWUpKiBps = he->bandwidthup.isSet ? he->bandwidthup.integer : 0; slave_addNewVirtualHost(master->slave, params); ProcessCallbackArgs processArgs; processArgs.master = master; processArgs.hostParams = params; /* now handle each virtual process the host will run */ g_queue_foreach(he->processes, (GFunc)_master_registerProcessCallback, &processArgs); /* cleanup for next pass through the loop */ g_string_free(hostnameBuffer, TRUE); g_free(params); } }