]> granicus.if.org Git - icinga2/commitdiff
Updated delegation/checker to use cibsync rather than sending service objects.
authorGunnar Beutner <gunnar.beutner@netways.de>
Tue, 17 Jul 2012 10:57:21 +0000 (12:57 +0200)
committerGunnar Beutner <gunnar.beutner@netways.de>
Tue, 17 Jul 2012 10:57:21 +0000 (12:57 +0200)
components/checker/checkercomponent.cpp
components/delegation/delegationcomponent.cpp

index e36c9710b23bcbea1941b420b9150485454cd2cb..5157ed5df5756223e8f727214c870506fb247c97 100644 (file)
@@ -48,6 +48,9 @@ void CheckerComponent::Start(void)
        m_ResultTimer->SetInterval(5);
        m_ResultTimer->OnTimerExpired.connect(boost::bind(&CheckerComponent::ResultTimerHandler, this));
        m_ResultTimer->Start();
+
+       CIB::RequireInformation(CIB_Configuration);
+       CIB::RequireInformation(CIB_ServiceStatus);
 }
 
 void CheckerComponent::Stop(void)
@@ -85,9 +88,6 @@ void CheckerComponent::CheckTimerHandler(void)
                task = service.InvokeMethod("check", arguments, boost::bind(&CheckerComponent::CheckCompletedHandler, this, service, _1));
                assert(task); /* TODO: gracefully handle missing hooks */
 
-               /*CheckTask::Ptr task = CheckTask::CreateTask(service, boost::bind(&CheckerComponent::CheckCompletedHandler, this, _1));
-               task->Start();*/
-
                service.SetTag("current_task", task);
 
                tasks++;
@@ -128,7 +128,6 @@ void CheckerComponent::CheckCompletedHandler(Service service, const ScriptTask::
 
                        EndpointManager::GetInstance()->SendMulticastMessage(m_Endpoint, rm);
                }
-
        } catch (const exception& ex) {
                stringstream msgbuf;
                msgbuf << "Exception occured during check for service '"
@@ -165,25 +164,20 @@ void CheckerComponent::AssignServiceRequestHandler(const Endpoint::Ptr& sender,
        if (!request.GetParams(&params))
                return;
 
-       MessagePart serviceMsg;
-       if (!params.Get("service", &serviceMsg))
+       string service;
+       if (!params.Get("service", &service))
                return;
 
-       ConfigObject::Ptr object = boost::make_shared<ConfigObject>(serviceMsg.GetDictionary());
-       Service service(object);
-       m_Services.push(service);
+       ConfigObject::Ptr object = ConfigObject::GetObject("service", service);
 
-       Logger::Write(LogDebug, "checker", "Accepted delegation for service '" + service.GetName() + "'");
+       if (!object) {
+               Logger::Write(LogWarning, "checker", "Ignoring delegation request for unknown service '" + service + "'.");
+               return;
+       }
 
-       string id;
-       if (request.GetID(&id)) {
-               ResponseMessage rm;
-               rm.SetID(id);
+       m_Services.push(object);
 
-               MessagePart result;
-               rm.SetResult(result);
-               EndpointManager::GetInstance()->SendUnicastMessage(m_Endpoint, sender, rm);
-       }
+       Logger::Write(LogDebug, "checker", "Accepted delegation for service '" + service + "'");
 }
 
 void CheckerComponent::ClearServicesRequestHandler(const Endpoint::Ptr& sender, const RequestMessage& request)
@@ -193,8 +187,6 @@ void CheckerComponent::ClearServicesRequestHandler(const Endpoint::Ptr& sender,
        /* clear the services lists */
        m_Services = ServiceQueue();
        m_PendingServices.clear();
-
-       /* TODO: clear checks we've already sent to the thread pool */
 }
 
 EXPORT_COMPONENT(checker, CheckerComponent);
index a8ea618e00f961bd00b7eabf25465aae8f4c48e9..591560b22adb18133f0e502494d601454040652a 100644 (file)
@@ -96,7 +96,7 @@ void DelegationComponent::AssignService(const Endpoint::Ptr& checker, const Serv
        request.SetMethod("checker::AssignService");
 
        MessagePart params;
-       params.Set("service", service.GetConfigObject()->GetProperties());
+       params.Set("service", service.GetName());
        request.SetParams(params);
 
        Logger::Write(LogDebug, "delegation", "Trying to delegate service '" + service.GetName() + "'");