Fixed save of syslog parser
[public/netxms.git] / include / nxcc.h
CommitLineData
a7a4c1e9
VK
1#ifndef _nxcc_h_
2#define _nxcc_h_
3
4#ifdef _WIN32
5#ifdef LIBNXCC_EXPORTS
6#define LIBNXCC_EXPORTABLE __declspec(dllexport)
7#else
8#define LIBNXCC_EXPORTABLE __declspec(dllimport)
9#endif
10#else /* _WIN32 */
11#define LIBNXCC_EXPORTABLE
12#endif
13
14#include <nms_common.h>
15#include <nms_util.h>
16#include <nms_threads.h>
17#include <nxcpapi.h>
18#include <nxconfig.h>
19
20/**
5cf931e2
VK
21 * Cluster error codes
22 */
23#define NXCC_RCC_SUCCESS 0
24#define NXCC_RCC_INVALID_NODE 1
25#define NXCC_RCC_TIMEOUT 2
26#define NXCC_RCC_COMM_FAILURE 3
6943e3ce
VK
27#define NXCC_RCC_NOT_MASTER 4
28#define NXCC_RCC_INVALID_REQUEST 5
5cf931e2
VK
29
30/**
a7a4c1e9
VK
31 * Cluster node states
32 */
33enum ClusterNodeState
34{
35 CLUSTER_NODE_DOWN = 0,
36 CLUSTER_NODE_CONNECTED = 1,
de12aebc
VK
37 CLUSTER_NODE_SYNC = 2,
38 CLUSTER_NODE_UP = 3
a7a4c1e9
VK
39};
40
41/**
5e2690dd
VK
42 * Cluster message processing result
43 */
44enum ClusterMessageProcessingResult
45{
46 CLUSTER_MSG_IGNORED = 0,
47 CLUSTER_MSG_PROCESSED = 1,
48 CLUSTER_MSG_QUEUED = 2
49};
50
51/**
a7a4c1e9
VK
52 * Cluster node event handler
53 */
4f239fa3 54class LIBNXCC_EXPORTABLE ClusterEventHandler
a7a4c1e9
VK
55{
56public:
57 ClusterEventHandler();
58 virtual ~ClusterEventHandler();
59
60 virtual void onNodeJoin(UINT32 nodeId);
de12aebc 61 virtual void onNodeUp(UINT32 nodeId);
a7a4c1e9
VK
62 virtual void onNodeDisconnect(UINT32 nodeId);
63 virtual void onShutdown();
3a016deb 64 virtual void onSplitBrain();
a7a4c1e9 65
5e2690dd 66 virtual ClusterMessageProcessingResult onMessage(NXCPMessage *msg, UINT32 sourceNodeId);
a7a4c1e9
VK
67};
68
69/**
70 * API functions
71 */
72bool LIBNXCC_EXPORTABLE ClusterInit(Config *config, const TCHAR *section, ClusterEventHandler *eventHandler);
73bool LIBNXCC_EXPORTABLE ClusterJoin();
596d8cf4 74void LIBNXCC_EXPORTABLE ClusterSetRunning();
a7a4c1e9
VK
75void LIBNXCC_EXPORTABLE ClusterShutdown();
76
596d8cf4 77UINT32 LIBNXCC_EXPORTABLE ClusterGetLocalNodeId();
b1543443 78UINT32 LIBNXCC_EXPORTABLE ClusterGetMasterNodeId();
a7a4c1e9 79bool LIBNXCC_EXPORTABLE ClusterIsMasterNode();
596d8cf4 80bool LIBNXCC_EXPORTABLE ClusterIsSyncNeeded();
de12aebc 81bool LIBNXCC_EXPORTABLE ClusterAllNodesConnected();
a7a4c1e9 82
5cf931e2 83void LIBNXCC_EXPORTABLE ClusterNotify(NXCPMessage *msg);
596d8cf4
VK
84void LIBNXCC_EXPORTABLE ClusterNotify(INT16 code);
85void LIBNXCC_EXPORTABLE ClusterDirectNotify(UINT32 nodeId, INT16 code);
b0e6d442 86void LIBNXCC_EXPORTABLE ClusterDirectNotify(UINT32 nodeId, NXCPMessage *msg);
5cf931e2
VK
87int LIBNXCC_EXPORTABLE ClusterSendCommand(NXCPMessage *msg);
88UINT32 LIBNXCC_EXPORTABLE ClusterSendDirectCommand(UINT32 nodeId, NXCPMessage *msg);
89NXCPMessage LIBNXCC_EXPORTABLE *ClusterSendDirectCommandEx(UINT32 nodeId, NXCPMessage *msg);
90void LIBNXCC_EXPORTABLE ClusterSendResponse(UINT32 nodeId, UINT32 requestId, UINT32 rcc);
a7404218 91void LIBNXCC_EXPORTABLE ClusterSendResponseEx(UINT32 nodeId, UINT32 requestId, NXCPMessage *msg);
5cf931e2 92
a7a4c1e9 93#endif