21 #ifndef EVENTSWATCHER_H
22 #define EVENTSWATCHER_H
29 #include "AbstractWatcher.h"
30 #include "MQ/MqWatcher.h"
31 #include "TransportHelper.h"
32 #include "AppExceptions.h"
33 #include "InstrumentedObject.h"
47 static string ToString(
const SERVICE_STATE value );
49 string Report()
const;
52 Service() : m_State(
Service::STOPPED ), m_LastHeartbeat( 0 ), m_ServiceName(
"qPIUnk00" ), m_SessionId(
"" ),
53 m_ServiceId( -1 ), m_HeartbeatInterval( 30 ) {};
55 Service(
const long serviceId,
const long state,
const time_t lastHeartbeat,
56 const string& serviceName=
"qPIUnk00",
const string& sessionId=
"",
const long heartbeatInterval = 30 ) :
57 m_State( (
SERVICE_STATE )state ), m_LastHeartbeat( lastHeartbeat ), m_ServiceName( serviceName ),
58 m_SessionId( sessionId ), m_ServiceId( serviceId ), m_HeartbeatInterval( heartbeatInterval ) {}
62 void setSessionId(
const string& sessionId ) { m_SessionId = sessionId; }
68 string getName()
const {
return m_ServiceName; }
76 double getTimeSinceLastHeartbeat()
const;
91 #if defined( TESTDLL_EXPORT ) || defined ( TESTDLL_IMPORT )
92 friend class EventsTest;
105 static EventsWatcher* getInstance(
const string& configFile =
"" );
107 void Process(
const string& messageId,
const unsigned long messageLength );
109 static void UpdateServiceState(
const string& sessionId,
const Service::SERVICE_STATE newState,
const string& serviceName =
"" );
110 static void* HeartbeatMonitor(
void* data );
125 static void* StartInNewThread(
void* pThis );
126 void internalStart(
void );
128 void UploadMessage( AppException &ex );
130 long getServiceId(
const string& sessionId )
const;
155 #if defined( WIN32 ) && defined( _DEBUG )
156 _CrtMemState m_NextMemoryState, m_OldMemoryState;
157 bool m_OldStateAvailable;
161 #endif //EVENTSWATCHER_H