change log updated
[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/**
12f43871
VK
31 * Base value for custom notifications
32 */
33#define NXCC_CUSTOM_NOTIFICATION_BASE 1000
34
35/**
a7a4c1e9
VK
36 * Cluster node states
37 */
38enum ClusterNodeState
39{
40 CLUSTER_NODE_DOWN = 0,
41 CLUSTER_NODE_CONNECTED = 1,
de12aebc
VK
42 CLUSTER_NODE_SYNC = 2,
43 CLUSTER_NODE_UP = 3
a7a4c1e9
VK
44};
45
46/**
5e2690dd
VK
47 * Cluster message processing result
48 */
49enum ClusterMessageProcessingResult
50{
51 CLUSTER_MSG_IGNORED = 0,
52 CLUSTER_MSG_PROCESSED = 1,
53 CLUSTER_MSG_QUEUED = 2
54};
55
56/**
a7a4c1e9
VK
57 * Cluster node event handler
58 */
4f239fa3 59class LIBNXCC_EXPORTABLE ClusterEventHandler
a7a4c1e9
VK
60{
61public:
62 ClusterEventHandler();
63 virtual ~ClusterEventHandler();
64
65 virtual void onNodeJoin(UINT32 nodeId);
de12aebc 66 virtual void onNodeUp(UINT32 nodeId);
a7a4c1e9
VK
67 virtual void onNodeDisconnect(UINT32 nodeId);
68 virtual void onShutdown();
3a016deb 69 virtual void onSplitBrain();
a7a4c1e9 70
5e2690dd 71 virtual ClusterMessageProcessingResult onMessage(NXCPMessage *msg, UINT32 sourceNodeId);
12f43871 72 virtual void onNotification(int code, UINT32 sourceNodeId);
a7a4c1e9
VK
73};
74
75/**
76 * API functions
77 */
78bool LIBNXCC_EXPORTABLE ClusterInit(Config *config, const TCHAR *section, ClusterEventHandler *eventHandler);
79bool LIBNXCC_EXPORTABLE ClusterJoin();
596d8cf4 80void LIBNXCC_EXPORTABLE ClusterSetRunning();
a7a4c1e9
VK
81void LIBNXCC_EXPORTABLE ClusterShutdown();
82
596d8cf4 83UINT32 LIBNXCC_EXPORTABLE ClusterGetLocalNodeId();
b1543443 84UINT32 LIBNXCC_EXPORTABLE ClusterGetMasterNodeId();
a7a4c1e9 85bool LIBNXCC_EXPORTABLE ClusterIsMasterNode();
596d8cf4 86bool LIBNXCC_EXPORTABLE ClusterIsSyncNeeded();
de12aebc 87bool LIBNXCC_EXPORTABLE ClusterAllNodesConnected();
a7a4c1e9 88
5cf931e2 89void LIBNXCC_EXPORTABLE ClusterNotify(NXCPMessage *msg);
596d8cf4
VK
90void LIBNXCC_EXPORTABLE ClusterNotify(INT16 code);
91void LIBNXCC_EXPORTABLE ClusterDirectNotify(UINT32 nodeId, INT16 code);
b0e6d442 92void LIBNXCC_EXPORTABLE ClusterDirectNotify(UINT32 nodeId, NXCPMessage *msg);
5cf931e2
VK
93int LIBNXCC_EXPORTABLE ClusterSendCommand(NXCPMessage *msg);
94UINT32 LIBNXCC_EXPORTABLE ClusterSendDirectCommand(UINT32 nodeId, NXCPMessage *msg);
95NXCPMessage LIBNXCC_EXPORTABLE *ClusterSendDirectCommandEx(UINT32 nodeId, NXCPMessage *msg);
96void LIBNXCC_EXPORTABLE ClusterSendResponse(UINT32 nodeId, UINT32 requestId, UINT32 rcc);
a7404218 97void LIBNXCC_EXPORTABLE ClusterSendResponseEx(UINT32 nodeId, UINT32 requestId, NXCPMessage *msg);
5cf931e2 98
a7a4c1e9 99#endif