Vhost::Vhost (qpid::management::Manageable* parentBroker, Broker* broker) : mgmtObject(0) { if (parentBroker != 0 && broker != 0) { ManagementAgent* agent = broker->getManagementAgent(); if (agent != 0) { mgmtObject = new _qmf::Vhost(agent, this, parentBroker, "/"); agent->addObject (mgmtObject, 0x1000000000000003LL); } } }
void Triggerd::init() { std::string trigger_log; ClassAd* ad; HashKey key; uint32_t key_value; ReliSock* sock; int index; char* host; char* tmp; char* dataDir = NULL; char* username; char* password; char* mechanism; int port, interval; std::string storefile; std::string error_text; std::stringstream int_str; qpid::management::ConnectionSettings settings; bool enable_console = true; dprintf(D_FULLDEBUG, "Triggerd::init called\n"); char* name = param("TRIGGERD_NAME"); if (name) { char* valid_name = build_valid_daemon_name(name); daemonName = valid_name; delete[] name; delete[] valid_name; } else { char* default_name = build_valid_daemon_name("triggerd"); if(default_name) { daemonName = default_name; delete[] default_name; } } port = param_integer("QMF_BROKER_PORT", 5672); if (NULL == (host = param("QMF_BROKER_HOST"))) { host = strdup("localhost"); } if (NULL == (username = param("QMF_BROKER_USERNAME"))) { username = strdup(""); } if (NULL == (mechanism = param("QMF_BROKER_AUTH_MECH"))) { mechanism = strdup("ANONYMOUS"); } tmp = param("QMF_STOREFILE"); if (NULL == tmp) { storefile = ".triggerd_storefile"; } else { storefile = tmp; free(tmp); tmp = NULL; } interval = param_integer("QMF_UPDATE_INTERVAL", 10); password = getBrokerPassword(); dataDir = param("DATA"); ASSERT(dataDir); trigger_log = dataDir; trigger_log += "/triggers.log"; triggerCollection = new ClassAdCollection(NULL, trigger_log.c_str()); free(dataDir); settings.host = std::string(host); settings.port = port; settings.username = std::string(username); settings.password = std::string(password); settings.mechanism = std::string(mechanism); // Initialize the QMF agent singleton = new ManagementAgent::Singleton(); ManagementAgent* agent = singleton->getInstance(); CondorTriggerService::registerSelf(agent); CondorTrigger::registerSelf(agent); EventCondorTriggerNotify::registerSelf(agent); agent->setName("com.redhat.grid","condortriggerservice", daemonName.c_str()); agent->init(settings, interval, true, storefile); mgmtObject = new CondorTriggerService(agent, this); // Initialize the QMF console, if desired enable_console = param_boolean("ENABLE_ABSENT_NODES_DETECTION", false); if (true == enable_console) { console = new TriggerConsole(); console->config(host, port, username, password, mechanism); } free(host); free(username); free(password); free(mechanism); // Initialize the triggers if any already exist triggerCollection->StartIterateAllClassAds(); while(true == triggerCollection->IterateAllClassAds(ad, key)) { key_value = atoll(key.value()); if (triggers.end() == triggers.find(key_value)) { if (STATUS_OK != AddTriggerToCollection(key_value, ad, error_text)) { dprintf(D_ALWAYS, "Triggerd Error: '%s'. Removing trigger\n", error_text.c_str()); int_str << key_value; triggerCollection->DestroyClassAd(int_str.str().c_str()); } } } bool lifetime = param_boolean("QMF_IS_PERSISTENT", true); agent->addObject(mgmtObject, daemonName.c_str(), lifetime); // Create a socket to handle management method calls sock = new ReliSock; if (NULL == sock) { EXCEPT("Failed to create Managment socket"); } if (0 == sock->assign(agent->getSignalFd())) { EXCEPT("Failed to bind Management socket"); } if (-1 == (index = daemonCore->Register_Socket((Stream *) sock, "Management Method Socket", (SocketHandlercpp) &Triggerd::HandleMgmtSocket, "Handler for Management Methods", this))) { EXCEPT("Failed to register Management socket"); } config(); }