]> granicus.if.org Git - icinga2/commitdiff
Removed delegation::ServiceStatus message (obsoleted by the domain concept)
authorGunnar Beutner <gunnar@beutner.name>
Wed, 25 Jul 2012 07:03:02 +0000 (09:03 +0200)
committerGunnar Beutner <gunnar@beutner.name>
Wed, 25 Jul 2012 07:03:02 +0000 (09:03 +0200)
12 files changed:
cib/Makefile.am
cib/checkresultmessage.cpp [moved from cib/servicestatusmessage.cpp with 66% similarity]
cib/checkresultmessage.h [moved from cib/servicestatusmessage.h with 84% similarity]
cib/cib.cpp
cib/cib.h
cib/cib.vcxproj
cib/cib.vcxproj.filters
cib/i2-cib.h
components/checker/checkercomponent.cpp
components/cibsync/cibsynccomponent.cpp
components/cibsync/cibsynccomponent.h
components/delegation/delegationcomponent.cpp

index 2be3dae88a9d5cae8d4f516cbcc922ce00dae885..3990fea461502cdc1a25d8e71d7f12b296cf98c4 100644 (file)
@@ -6,6 +6,8 @@ pkglib_LTLIBRARIES = \
 libcib_la_SOURCES = \
        checkresult.cpp \
        checkresult.h \
+       checkresultmessage.cpp \
+       checkresultmessage.h \
        cib.cpp \
        cib.h \
        configobjectadapter.cpp \
@@ -24,9 +26,7 @@ libcib_la_SOURCES = \
        service.cpp \
        service.h \
        servicegroup.cpp \
-       servicegroup.h \
-       servicestatusmessage.cpp \
-       servicestatusmessage.h
+       servicegroup.h
 
 libcib_la_CPPFLAGS = \
        -DI2_CIB_BUILD \
similarity index 66%
rename from cib/servicestatusmessage.cpp
rename to cib/checkresultmessage.cpp
index 3b0e95adb0f7f1d17e858c2d15d76f9a2e43d62f..d48b9dc6d2a6727cf74de3427b0c7244f271ddd3 100644 (file)
 
 using namespace icinga;
 
-bool ServiceStatusMessage::GetService(string *service) const
+bool CheckResultMessage::GetService(string *service) const
 {
        return Get("service", service);
 }
 
-void ServiceStatusMessage::SetService(const string& service)
+void CheckResultMessage::SetService(const string& service)
 {
        Set("service", service);
 }
 
-bool ServiceStatusMessage::GetState(ServiceState *state) const
-{
-       long value;
-       if (Get("state", &value)) {
-               *state = static_cast<ServiceState>(value);
-               return true;
-       }
-       return false;
-}
-
-void ServiceStatusMessage::SetState(ServiceState state)
-{
-       Set("state", static_cast<long>(state));
-}
-
-bool ServiceStatusMessage::GetStateType(ServiceStateType *type) const
-{
-       long value;
-       if (Get("state_type", &value)) {
-               *type = static_cast<ServiceStateType>(value);
-               return true;
-       }
-       return false;
-}
-
-void ServiceStatusMessage::SetStateType(ServiceStateType type)
-{
-       Set("state_type", static_cast<long>(type));
-}
-
-bool ServiceStatusMessage::GetCheckResult(CheckResult *cr) const
+bool CheckResultMessage::GetCheckResult(CheckResult *cr) const
 {
        Dictionary::Ptr obj;
        if (Get("result", &obj)) {
@@ -71,7 +41,7 @@ bool ServiceStatusMessage::GetCheckResult(CheckResult *cr) const
        return false;
 }
 
-void ServiceStatusMessage::SetCheckResult(CheckResult cr)
+void CheckResultMessage::SetCheckResult(CheckResult cr)
 {
        Set("result", cr.GetDictionary());
 }
similarity index 84%
rename from cib/servicestatusmessage.h
rename to cib/checkresultmessage.h
index 6d67d1d3b821fe946e8132f50114298ea558b462..9dfd7041ee0f7461657bc3e2fc7205ef96bf1c4f 100644 (file)
  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.             *
  ******************************************************************************/
 
-#ifndef SERVICESTATUSMESSAGE_H
-#define SERVICESTATUSMESSAGE_H
+#ifndef CHECKRESULTMESSAGE_H
+#define CHECKRESULTMESSAGE_H
 
 namespace icinga
 {
 
-class I2_CIB_API ServiceStatusMessage : public MessagePart
+class I2_CIB_API CheckResultMessage : public MessagePart
 {
 public:
        ServiceStatusMessage(void) : MessagePart() { }
@@ -32,16 +32,10 @@ public:
        bool GetService(string *service) const;
        void SetService(const string& service);
 
-       bool GetState(ServiceState *state) const;
-       void SetState(ServiceState state);
-
-       bool GetStateType(ServiceStateType *type) const;
-       void SetStateType(ServiceStateType type);
-
        bool GetCheckResult(CheckResult *cr) const;
        void SetCheckResult(CheckResult cr);
 };
 
 }
 
-#endif /* SERVICESTATUSMESSAGE_H */
+#endif /* CHECKRESULTMESSAGE_H */
index 7c668ce32cbf5af5f125af01b47244745b5beeed..c4ee26f2b797b9c2143c5420c05eb6aa32528086 100644 (file)
@@ -22,7 +22,7 @@
 using namespace icinga;
 
 RingBuffer CIB::m_TaskStatistics(15 * 60);
-boost::signal<void (const ServiceStatusMessage&)> CIB::OnServiceStatusUpdate;
+boost::signal<void (const CheckResultMessage&)> CIB::OnCheckResultReceived;
 
 void CIB::UpdateTaskStatistics(long tv, int num)
 {
index 98a5db52d0446a03a733d19f45201d63d0cc6f61..f371153d84031f8c5835b62137b43b419bea1fcb 100644 (file)
--- a/cib/cib.h
+++ b/cib/cib.h
@@ -29,7 +29,7 @@ public:
        static void UpdateTaskStatistics(long tv, int num);
        static int GetTaskStatistics(long timespan);
 
-       static boost::signal<void (const ServiceStatusMessage&)> OnServiceStatusUpdate;
+       static boost::signal<void (const CheckResultMessage&)> OnCheckResultReceived;
 
 private:
        static RingBuffer m_TaskStatistics;
index 3b5f858f8a20eacd4060104895ea673105707bea..962c26a6a8ca32c5c3f5e2be3029fb5382617ad0 100644 (file)
@@ -93,7 +93,7 @@
     <ClInclude Include="nullchecktask.h" />
     <ClInclude Include="service.h" />
     <ClInclude Include="servicegroup.h" />
-    <ClInclude Include="servicestatusmessage.h" />
+    <ClInclude Include="checkresultmessage.h" />
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="checkresult.cpp" />
     <ClCompile Include="nullchecktask.cpp" />
     <ClCompile Include="service.cpp" />
     <ClCompile Include="servicegroup.cpp" />
-    <ClCompile Include="servicestatusmessage.cpp" />
+    <ClCompile Include="checkresultmessage.cpp" />
   </ItemGroup>
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
   <ImportGroup Label="ExtensionTargets">
   </ImportGroup>
-</Project>
\ No newline at end of file
+</Project>
index 81e391f32b18df28e52b1eec99514f0088316396..bd81053977ae51796866b1a9284c1cca62eb979e 100644 (file)
@@ -41,7 +41,7 @@
     <ClInclude Include="servicegroup.h">
       <Filter>Headerdateien</Filter>
     </ClInclude>
-    <ClInclude Include="servicestatusmessage.h">
+    <ClInclude Include="checkresultmessage.h">
       <Filter>Headerdateien</Filter>
     </ClInclude>
     <ClInclude Include="nullchecktask.h">
@@ -76,7 +76,7 @@
     <ClCompile Include="servicegroup.cpp">
       <Filter>Quelldateien</Filter>
     </ClCompile>
-    <ClCompile Include="servicestatusmessage.cpp">
+    <ClCompile Include="checkresultmessage.cpp">
       <Filter>Quelldateien</Filter>
     </ClCompile>
     <ClCompile Include="i2-cib.cpp">
@@ -86,4 +86,4 @@
       <Filter>Quelldateien</Filter>
     </ClCompile>
   </ItemGroup>
-</Project>
\ No newline at end of file
+</Project>
index 60525b9fb85fc7c7292218eed69d04811c82cd4f..956694d98b343d219b490e9595dd012da81abcf0 100644 (file)
@@ -47,7 +47,7 @@
 #include "nagioschecktask.h"
 #include "nullchecktask.h"
 
-#include "servicestatusmessage.h"
+#include "checkresultmessage.h"
 
 #include "cib.h"
 
index 24a437231fb7faecd5fde5fcb1c84e8fc9b6423a..2e17707b7c13dbc67f09197078d80719d1f0e0d8 100644 (file)
@@ -110,7 +110,7 @@ void CheckerComponent::CheckCompletedHandler(Service service, const ScriptTask::
                        RequestMessage rm;
                        rm.SetMethod("checker::CheckResult");
 
-                       ServiceStatusMessage params;
+                       CheckResultMessage params;
                        params.SetService(service.GetName());
                        params.SetCheckResult(result);
 
index a3df2adea73208ffc19fb217652833326cd4081b..59b5509574e7e6488077c1d4733bc4fc1de06b3d 100644 (file)
@@ -60,8 +60,8 @@ void CIBSyncComponent::Start(void)
            boost::bind(&CIBSyncComponent::RemoteObjectRemovedHandler, this, _3));
 
        /* service status */
-       m_Endpoint->RegisterTopicHandler("delegation::ServiceStatus",
-           boost::bind(&CIBSyncComponent::ServiceStatusRequestHandler, _2, _3));
+       m_Endpoint->RegisterTopicHandler("checker::CheckResult",
+           boost::bind(&CIBSyncComponent::CheckResultRequestHandler, _2, _3));
 
        EndpointManager::GetInstance()->RegisterEndpoint(m_Endpoint);
 }
@@ -77,14 +77,12 @@ void CIBSyncComponent::Stop(void)
                endpointManager->UnregisterEndpoint(m_Endpoint);
 }
 
-void CIBSyncComponent::ServiceStatusRequestHandler(const Endpoint::Ptr& sender, const RequestMessage& request)
+void CIBSyncComponent::CheckResultRequestHandler(const Endpoint::Ptr& sender, const RequestMessage& request)
 {
-       ServiceStatusMessage params;
+       CheckResultMessage params;
        if (!request.GetParams(&params))
                return;
 
-       CIB::OnServiceStatusUpdate(params);
-
        string svcname;
        if (!params.GetService(&svcname))
                return;
@@ -92,8 +90,11 @@ void CIBSyncComponent::ServiceStatusRequestHandler(const Endpoint::Ptr& sender,
        Service service = Service::GetByName(svcname);
 
        CheckResult cr;
-       if (params.GetCheckResult(&cr))
-               service.ApplyCheckResult(cr);
+       if (!params.GetCheckResult(&cr))
+               return;
+
+       CIB::OnCheckResultReceived(params);
+       service.ApplyCheckResult(cr);
 
        time_t now;
        time(&now);
index 93a95a657a06a3ba33cd2579ed63aba5d3024838..9590b2ac4221213c92474d38d92a6dfc30f49eb3 100644 (file)
@@ -37,7 +37,7 @@ private:
        VirtualEndpoint::Ptr m_Endpoint;
        bool m_SyncingConfig;
 
-       static void ServiceStatusRequestHandler(const Endpoint::Ptr& sender, const RequestMessage& request);
+       static void CheckResultRequestHandler(const Endpoint::Ptr& sender, const RequestMessage& request);
 
        void NewEndpointHandler(const Endpoint::Ptr& endpoint);
        void SessionEstablishedHandler(const Endpoint::Ptr& endpoint);
index bb34a24af0910536e730d50defad664d0b76e0e8..f227b0d8d09e4e1f74957481d1900cf5ab6a4f8b 100644 (file)
@@ -43,8 +43,6 @@ void DelegationComponent::Start(void)
        m_Endpoint = boost::make_shared<VirtualEndpoint>();
        m_Endpoint->RegisterPublication("checker::AssignService");
        m_Endpoint->RegisterPublication("checker::ClearServices");
-       m_Endpoint->RegisterTopicHandler("checker::CheckResult",
-           boost::bind(&DelegationComponent::CheckResultRequestHandler, this, _2, _3));
        m_Endpoint->RegisterPublication("delegation::ServiceStatus");
        EndpointManager::GetInstance()->RegisterEndpoint(m_Endpoint);
 
@@ -295,27 +293,4 @@ void DelegationComponent::DelegationTimerHandler(void)
        Logger::Write(LogInformation, "delegation", msgbuf.str());
 }
 
-void DelegationComponent::CheckResultRequestHandler(const Endpoint::Ptr& sender, const RequestMessage& request)
-{
-       ServiceStatusMessage params;
-       if (!request.GetParams(&params))
-               return;
-
-       string svcname;
-       if (!params.GetService(&svcname))
-               return;
-
-       Service service = Service::GetByName(svcname);
-
-       /* validate that this is an authentic check result */
-       if (!service.IsAllowedChecker(sender->GetIdentity()))
-               return;
-
-       /* send state update */
-       RequestMessage rm;
-       rm.SetMethod("delegation::ServiceStatus");
-       rm.SetParams(params);
-       EndpointManager::GetInstance()->SendMulticastMessage(m_Endpoint, rm);
-}
-
 EXPORT_COMPONENT(delegation, DelegationComponent);