ctdb-include: Group function prototypes from server/ctdb_traverse.c
[kai/samba-autobuild/.git] / ctdb / include / ctdb_protocol.h
index d96f565eb80cc1a6a8c131e44c60fa503d77d52d..750abc423d5d288440fadcb51c6e149816171860 100644 (file)
@@ -20,8 +20,7 @@
 #ifndef _CTDB_PROTOCOL_H
 #define _CTDB_PROTOCOL_H
 
-/* location of daemon socket */
-#define CTDB_PATH      "/tmp/ctdb.socket"
+#include <sys/socket.h>
 
 /* default ctdb port number */
 #define CTDB_PORT 4379
@@ -109,12 +108,24 @@ struct ctdb_call_info {
  */
 #define CTDB_SRVID_VACUUM_FETCH 0xF700000000000000LL
 
+/*
+ * a message to tell recovery daemon to detach a database
+ */
+#define CTDB_SRVID_DETACH_DATABASE 0xF701000000000000LL
 /*
   a message to tell the recovery daemon to write a talloc memdump
   to the log
  */
 #define CTDB_SRVID_MEM_DUMP 0xF800000000000000LL
 
+/* A message id used to ask the recover daemon to send logs
+*/
+#define CTDB_SRVID_GETLOG  0xF801000000000000LL
+
+/* A message id used to ask the recover daemon to send logs
+*/
+#define CTDB_SRVID_CLEARLOG  0xF802000000000000LL
+
 /*
    a message ID to get the recovery daemon to push the node flags out
  */
@@ -130,6 +141,17 @@ struct ctdb_call_info {
  */
 #define CTDB_SRVID_TAKEOVER_RUN 0xFB00000000000000LL
 
+/* request recovery daemon to rebalance ips for a node.
+   input is uint32_t for the node id.
+*/
+#define CTDB_SRVID_REBALANCE_NODE 0xFB01000000000000LL
+
+/* A message handler ID to stop takeover runs from occurring */
+#define CTDB_SRVID_DISABLE_TAKEOVER_RUNS 0xFB03000000000000LL
+
+/* A message handler ID to stop recoveries from occurring */
+#define CTDB_SRVID_DISABLE_RECOVERIES 0xFB04000000000000LL
+
 /* A message id to ask the recovery daemon to temporarily disable the
    public ip checks
 */
@@ -182,6 +204,8 @@ struct ctdb_call_info {
 #define CTDB_BROADCAST_VNNMAP 0xF0000003
 /* send a broadcast to all connected nodes */
 #define CTDB_BROADCAST_CONNECTED 0xF0000004
+/* send a broadcast to selected connected nodes */
+#define CTDB_MULTICAST 0xF0000005
 
 /* the key used for transaction locking on persistent databases */
 #define CTDB_TRANSACTION_LOCK_KEY "__transaction_lock__"
@@ -216,11 +240,11 @@ enum ctdb_eventscript_call {
        CTDB_EVENT_RECOVERED,           /* CTDB recovery finished: no args. */
        CTDB_EVENT_TAKE_IP,             /* IP taken: interface, IP address, netmask bits. */
        CTDB_EVENT_RELEASE_IP,          /* IP released: interface, IP address, netmask bits. */
-       CTDB_EVENT_STOPPED,             /* This node is stopped: no args. */
+       CTDB_EVENT_STOPPED,             /* Deprecated, do not use. */
        CTDB_EVENT_MONITOR,             /* Please check if service is healthy: no args. */
-       CTDB_EVENT_STATUS,              /* Report service status: no args. */
+       CTDB_EVENT_STATUS,              /* Deprecated, do not use. */
        CTDB_EVENT_SHUTDOWN,            /* CTDB shutting down: no args. */
-       CTDB_EVENT_RELOAD,              /* magic */
+       CTDB_EVENT_RELOAD,              /* Deprecated, do not use */
        CTDB_EVENT_UPDATE_IP,           /* IP updating: old interface, new interface, IP address, netmask bits. */
        CTDB_EVENT_IPREALLOCATED,       /* when a takeover_run() completes */
        CTDB_EVENT_MAX
@@ -246,7 +270,7 @@ enum ctdb_operation {
 };
 
 #define CTDB_MAGIC 0x43544442 /* CTDB */
-#define CTDB_VERSION 1
+#define CTDB_PROTOCOL 1
 
 enum ctdb_controls {CTDB_CONTROL_PROCESS_EXISTS          = 0,
                    CTDB_CONTROL_STATISTICS              = 1,
@@ -259,7 +283,7 @@ enum ctdb_controls {CTDB_CONTROL_PROCESS_EXISTS          = 0,
                    CTDB_CONTROL_SET_DEBUG               = 8,
                    CTDB_CONTROL_GET_DBMAP               = 9,
                    CTDB_CONTROL_GET_NODEMAPv4           = 10, /* obsolete */
-                   CTDB_CONTROL_SET_DMASTER             = 11,
+                   CTDB_CONTROL_SET_DMASTER             = 11, /* obsolete */
                    /* #12 removed */
                    CTDB_CONTROL_PULL_DB                 = 13,
                    CTDB_CONTROL_PUSH_DB                 = 14,
@@ -267,7 +291,7 @@ enum ctdb_controls {CTDB_CONTROL_PROCESS_EXISTS          = 0,
                    CTDB_CONTROL_SET_RECMODE             = 16,
                    CTDB_CONTROL_STATISTICS_RESET        = 17,
                    CTDB_CONTROL_DB_ATTACH               = 18,
-                   CTDB_CONTROL_SET_CALL                = 19,
+                   CTDB_CONTROL_SET_CALL                = 19, /* obsolete */
                    CTDB_CONTROL_TRAVERSE_START          = 20,
                    CTDB_CONTROL_TRAVERSE_ALL            = 21,
                    CTDB_CONTROL_TRAVERSE_DATA           = 22,
@@ -310,7 +334,7 @@ enum ctdb_controls {CTDB_CONTROL_PROCESS_EXISTS          = 0,
                    CTDB_CONTROL_CHECK_SERVER_ID         = 59,
                    CTDB_CONTROL_GET_SERVER_ID_LIST      = 60,
                    CTDB_CONTROL_DB_ATTACH_PERSISTENT    = 61,
-                   CTDB_CONTROL_PERSISTENT_STORE        = 62,
+                   CTDB_CONTROL_PERSISTENT_STORE        = 62, /* obsolete */
                    CTDB_CONTROL_UPDATE_RECORD           = 63,
                    CTDB_CONTROL_SEND_GRATIOUS_ARP       = 64,
                    CTDB_CONTROL_TRANSACTION_START       = 65,
@@ -331,10 +355,10 @@ enum ctdb_controls {CTDB_CONTROL_PROCESS_EXISTS          = 0,
                    CTDB_CONTROL_GET_CAPABILITIES        = 80,
                    CTDB_CONTROL_START_PERSISTENT_UPDATE = 81,
                    CTDB_CONTROL_CANCEL_PERSISTENT_UPDATE= 82,
-                   CTDB_CONTROL_TRANS2_COMMIT           = 83,
-                   CTDB_CONTROL_TRANS2_FINISHED         = 84,
-                   CTDB_CONTROL_TRANS2_ERROR            = 85,
-                   CTDB_CONTROL_TRANS2_COMMIT_RETRY     = 86,
+                   CTDB_CONTROL_TRANS2_COMMIT           = 83, /* obsolete */
+                   CTDB_CONTROL_TRANS2_FINISHED         = 84, /* obsolete */
+                   CTDB_CONTROL_TRANS2_ERROR            = 85, /* obsolete */
+                   CTDB_CONTROL_TRANS2_COMMIT_RETRY     = 86, /* obsolete */
                    CTDB_CONTROL_RECD_PING               = 87,
                    CTDB_CONTROL_RELEASE_IP              = 88,
                    CTDB_CONTROL_TAKEOVER_IP             = 89,
@@ -359,9 +383,9 @@ enum ctdb_controls {CTDB_CONTROL_PROCESS_EXISTS          = 0,
                    CTDB_CONTROL_TRANSACTION_CANCEL      = 113,
                    CTDB_CONTROL_REGISTER_NOTIFY         = 114,
                    CTDB_CONTROL_DEREGISTER_NOTIFY       = 115,
-                   CTDB_CONTROL_TRANS2_ACTIVE           = 116,
-                   CTDB_CONTROL_GET_LOG                 = 117,
-                   CTDB_CONTROL_CLEAR_LOG               = 118,
+                   CTDB_CONTROL_TRANS2_ACTIVE           = 116, /* obsolete */
+                   CTDB_CONTROL_GET_LOG                 = 117, /* obsolete */
+                   CTDB_CONTROL_CLEAR_LOG               = 118, /* obsolete */
                    CTDB_CONTROL_TRANS3_COMMIT           = 119,
                    CTDB_CONTROL_GET_DB_SEQNUM           = 120,
                    CTDB_CONTROL_DB_SET_HEALTHY          = 121,
@@ -375,6 +399,20 @@ enum ctdb_controls {CTDB_CONTROL_PROCESS_EXISTS          = 0,
                    CTDB_CONTROL_SET_DB_READONLY         = 129,
                    CTDB_CONTROL_CHECK_SRVIDS            = 130,
                    CTDB_CONTROL_TRAVERSE_START_EXT      = 131,
+                   CTDB_CONTROL_GET_DB_STATISTICS       = 132,
+                   CTDB_CONTROL_SET_DB_STICKY           = 133,
+                   CTDB_CONTROL_RELOAD_PUBLIC_IPS       = 134,
+                   CTDB_CONTROL_TRAVERSE_ALL_EXT        = 135,
+                   CTDB_CONTROL_RECEIVE_RECORDS         = 136,
+                   CTDB_CONTROL_IPREALLOCATED           = 137,
+                   CTDB_CONTROL_GET_RUNSTATE            = 138,
+                   CTDB_CONTROL_DB_DETACH               = 139,
+                   CTDB_CONTROL_GET_NODES_FILE          = 140,
+                   CTDB_CONTROL_DB_FREEZE               = 141,
+                   CTDB_CONTROL_DB_THAW                 = 142,
+                   CTDB_CONTROL_DB_TRANSACTION_START    = 143,
+                   CTDB_CONTROL_DB_TRANSACTION_COMMIT   = 144,
+                   CTDB_CONTROL_DB_TRANSACTION_CANCEL   = 145,
 };
 
 /*
@@ -442,17 +480,6 @@ struct ctdb_req_message {
        uint8_t data[1];
 };
 
-struct ctdb_req_getdbpath {
-       struct ctdb_req_header hdr;
-       uint32_t db_id;
-};
-
-struct ctdb_reply_getdbpath {
-       struct ctdb_req_header hdr;
-       uint32_t datalen;
-       uint8_t data[1];
-};
-
 struct ctdb_req_control {
        struct ctdb_req_header hdr;
        uint32_t opcode;
@@ -479,14 +506,6 @@ struct ctdb_req_keepalive {
 };
 
 
-/* types of failures possible from TRANS2_COMMIT */
-enum ctdb_trans2_commit_error {
-       CTDB_TRANS2_COMMIT_SUCCESS=0, /* all nodes committed successfully */
-       CTDB_TRANS2_COMMIT_TIMEOUT=1, /* at least one node timed out */
-       CTDB_TRANS2_COMMIT_ALLFAIL=2, /* all nodes failed the commit */
-       CTDB_TRANS2_COMMIT_SOMEFAIL=3 /* some nodes failed the commit, some allowed it */
-};
-
 /*
   the extended header for records in the ltdb
 */
@@ -502,6 +521,10 @@ struct ctdb_ltdb_header {
 #define CTDB_REC_RO_HAVE_READONLY              0x02000000
 #define CTDB_REC_RO_REVOKING_READONLY          0x04000000
 #define CTDB_REC_RO_REVOKE_COMPLETE            0x08000000
+#define CTDB_REC_RO_FLAGS                      (CTDB_REC_RO_HAVE_DELEGATIONS|\
+                                                CTDB_REC_RO_HAVE_READONLY|\
+                                                CTDB_REC_RO_REVOKING_READONLY|\
+                                                CTDB_REC_RO_REVOKE_COMPLETE)
        uint32_t flags;
 };
 
@@ -549,6 +572,26 @@ struct ctdb_node_map {
 #define NODE_FLAGS_DISABLED            (NODE_FLAGS_UNHEALTHY|NODE_FLAGS_PERMANENTLY_DISABLED)
 #define NODE_FLAGS_INACTIVE            (NODE_FLAGS_DELETED|NODE_FLAGS_DISCONNECTED|NODE_FLAGS_BANNED|NODE_FLAGS_STOPPED)
 
+/*
+ * Node capabilities
+ */
+#define CTDB_CAP_RECMASTER             0x00000001
+#define CTDB_CAP_LMASTER               0x00000002
+/* This capability is set if CTDB_LVS_PUBLIC_IP is set */
+#define CTDB_CAP_LVS                   0x00000004
+/* This capability is set if NATGW is enabled */
+#define CTDB_CAP_NATGW                 0x00000008
+
+/*
+ * Node features
+ */
+#define CTDB_CAP_PARALLEL_RECOVERY     0x00010000
+
+#define CTDB_CAP_FEATURES              (CTDB_CAP_PARALLEL_RECOVERY)
+
+#define CTDB_CAP_DEFAULT               (CTDB_CAP_RECMASTER | \
+                                        CTDB_CAP_LMASTER   | \
+                                        CTDB_CAP_FEATURES)
 
 struct ctdb_public_ip {
        uint32_t pnn;
@@ -595,6 +638,9 @@ struct ctdb_traverse_start_ext {
 /*
   ctdb statistics information
  */
+#define MAX_COUNT_BUCKETS 16
+#define MAX_HOT_KEYS      10
+
 struct ctdb_statistics {
        uint32_t num_clients;
        uint32_t frozen;
@@ -629,21 +675,29 @@ struct ctdb_statistics {
                struct latency_counter ctdbd;
                struct latency_counter recd;
        } reclock;
+       struct {
+               uint32_t num_calls;
+               uint32_t num_current;
+               uint32_t num_pending;
+               uint32_t num_failed;
+               struct latency_counter latency;
+               uint32_t buckets[MAX_COUNT_BUCKETS];
+       } locks;
        uint32_t total_calls;
        uint32_t pending_calls;
-       uint32_t lockwait_calls;
-       uint32_t pending_lockwait_calls;
        uint32_t childwrite_calls;
        uint32_t pending_childwrite_calls;
        uint32_t memory_used;
        uint32_t __last_counter; /* hack for control_statistics_all */
        uint32_t max_hop_count;
+       uint32_t hop_count_bucket[MAX_COUNT_BUCKETS];
        struct latency_counter call_latency;
-       struct latency_counter lockwait_latency;
        struct latency_counter childwrite_latency;
        uint32_t num_recoveries;
        struct timeval statistics_start_time;
        struct timeval statistics_current_time;
+       uint32_t total_ro_delegations;
+       uint32_t total_ro_revokes;
 };
 
 /*
@@ -654,6 +708,32 @@ struct ctdb_statistics_wire {
        struct ctdb_statistics stats[1];
 };
 
+/*
+ * db statistics
+ */
+struct ctdb_db_statistics {
+       struct {
+               uint32_t num_calls;
+               uint32_t num_current;
+               uint32_t num_pending;
+               uint32_t num_failed;
+               struct latency_counter latency;
+               uint32_t buckets[MAX_COUNT_BUCKETS];
+       } locks;
+       struct {
+               struct latency_counter latency;
+       } vacuum;
+       uint32_t db_ro_delegations;
+       uint32_t db_ro_revokes;
+       uint32_t hop_count_bucket[MAX_COUNT_BUCKETS];
+       uint32_t num_hot_keys;
+       struct {
+               uint32_t count;
+               TDB_DATA key;
+       } hot_keys[MAX_HOT_KEYS];
+       char hot_keys_wire[1];
+};
+
 /*
  * wire format for interface list
  */
@@ -674,4 +754,22 @@ struct ctdb_ifaces_list {
        struct ctdb_iface_info ifaces[1];
 };
 
+#define INVALID_GENERATION 1
+/* table that contains the mapping between a hash value and lmaster
+ */
+struct ctdb_vnn_map {
+       uint32_t generation;
+       uint32_t size;
+       uint32_t *map;
+};
+
+/* 
+   a wire representation of the vnn map
+ */
+struct ctdb_vnn_map_wire {
+       uint32_t generation;
+       uint32_t size;
+       uint32_t map[1];
+};
+
 #endif