cluster join works in different combinations
[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
27
28/**
a7a4c1e9
VK
29 * Cluster node states
30 */
31enum ClusterNodeState
32{
33 CLUSTER_NODE_DOWN = 0,
34 CLUSTER_NODE_CONNECTED = 1,
de12aebc
VK
35 CLUSTER_NODE_SYNC = 2,
36 CLUSTER_NODE_UP = 3
a7a4c1e9
VK
37};
38
39/**
40 * Cluster node event handler
41 */
4f239fa3 42class LIBNXCC_EXPORTABLE ClusterEventHandler
a7a4c1e9
VK
43{
44public:
45 ClusterEventHandler();
46 virtual ~ClusterEventHandler();
47
48 virtual void onNodeJoin(UINT32 nodeId);
de12aebc 49 virtual void onNodeUp(UINT32 nodeId);
a7a4c1e9
VK
50 virtual void onNodeDisconnect(UINT32 nodeId);
51 virtual void onShutdown();
52
5cf931e2 53 virtual bool onMessage(NXCPMessage *msg, UINT32 sourceNodeId);
a7a4c1e9
VK
54};
55
56/**
57 * API functions
58 */
59bool LIBNXCC_EXPORTABLE ClusterInit(Config *config, const TCHAR *section, ClusterEventHandler *eventHandler);
60bool LIBNXCC_EXPORTABLE ClusterJoin();
61void LIBNXCC_EXPORTABLE ClusterShutdown();
62
63void LIBNXCC_EXPORTABLE ClusterSetDebugCallback(void (*cb)(int, const TCHAR *, va_list));
64
65bool LIBNXCC_EXPORTABLE ClusterIsMasterNode();
de12aebc 66bool LIBNXCC_EXPORTABLE ClusterAllNodesConnected();
a7a4c1e9 67
5cf931e2
VK
68void LIBNXCC_EXPORTABLE ClusterNotify(NXCPMessage *msg);
69int LIBNXCC_EXPORTABLE ClusterSendCommand(NXCPMessage *msg);
70UINT32 LIBNXCC_EXPORTABLE ClusterSendDirectCommand(UINT32 nodeId, NXCPMessage *msg);
71NXCPMessage LIBNXCC_EXPORTABLE *ClusterSendDirectCommandEx(UINT32 nodeId, NXCPMessage *msg);
72void LIBNXCC_EXPORTABLE ClusterSendResponse(UINT32 nodeId, UINT32 requestId, UINT32 rcc);
73
a7a4c1e9 74#endif