Bug 2187: Implement add-replicas-for-all-shards RPC
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / yang / cluster-admin.yang
1 module cluster-admin {
2     yang-version 1;
3     namespace "urn:opendaylight:params:xml:ns:yang:controller:md:sal:cluster:admin";
4     prefix "cluster-admin";
5
6     description
7         "This module contains YANG RPC definitions for administering a cluster.";
8
9     revision "2015-10-13" {
10         description "Initial revision.";
11     }
12
13     typedef data-store-type {
14         type enumeration {
15             enum config {
16                 value 1;
17             }
18             enum operational {
19                 value 2;
20             }
21         }
22     }
23
24     grouping shard-operation-result {
25         leaf shard-name {
26             type string;
27         }
28
29         leaf data-store-type {
30             type data-store-type;
31         }
32
33         leaf succeeded {
34             type boolean;
35         }
36
37         leaf error-message {
38             type string;
39         }
40     }
41
42     rpc add-shard-replica {
43         input {
44             leaf shard-name {
45                 type string;
46                 description "The name of the shard for which to create a replica.";
47             }
48
49             leaf data-store-type {
50                 type data-store-type;
51                 description "The type of the data store to which the replica belongs";
52             }
53         }
54
55         description "Adds a replica of a shard to this node and joins it to an existing cluster. The shard must
56             already have a module configuration defined for it and there must already be a shard existing on
57             another node with a leader. This RPC first contacts peer member seed nodes searching for a shard.
58             When found, an AddServer message is sent to the shard leader and applied as described in the Raft
59             paper.";
60     }
61
62     rpc remove-shard-replica {
63         input {
64             leaf shard-name {
65                 type string;
66                 description "The name of the shard for which to remove the replica.";
67             }
68
69             leaf member-name {
70                 type string;
71                 description "The cluster member from which the shard replica should be removed";
72             }
73
74             leaf data-store-type {
75                 type data-store-type;
76                 description "The type of the data store to which the replica belongs";
77             }
78         }
79
80         description "Removes an existing replica of a shard from this node via the RemoveServer mechanism as
81             described in the Raft paper.";
82     }
83
84     rpc add-replicas-for-all-shards {
85         output {
86             list shard-result {
87                 key "shard-name";
88                 key "data-store-type";
89                 uses shard-operation-result;
90
91                 description "The list of results, one per shard";
92             }
93         }
94
95         description "Adds replicas on this node for all currently defined shards. This is equivalent to issuing
96             an add-shard-replica RPC for all shards.";
97     }
98
99     rpc remove-all-shard-replicas {
100         description "Removes replicas for all shards on this node. This is equivalent to issuing
101             a remove-shard-replica for all shards and essentially removes this node from a cluster.";
102     }
103
104     rpc convert-members-to-nonvoting-for-all-shards {
105         input {
106             leaf-list member-names {
107                 type string;
108                 description "The names of the cluster members to convert.";
109             }
110         }
111         
112         description "Converts the given cluster members to non-voting for all shards. The members will no 
113             longer participate in leader elections and consensus but will be replicated. This is useful for
114             having a set of members serve as a backup cluster in case the primary voting cluster suffers
115             catastrophic failure. This RPC can be issued to any cluster member and will be forwarded
116             to the leader.";
117     }
118
119     rpc convert-members-to-voting-for-all-shards {
120         input {
121             leaf-list member-names {
122                 type string;
123                 description "The names of the cluster members to convert.";
124             }
125         }
126
127         description "Converts the given cluster members to voting for all shards. The members will 
128             participate in leader elections and consensus.";
129     }
130
131     rpc backup-datastore {
132         input {
133             leaf file-path {
134               type string;
135               description "The path and name of the file in which to store the backup.";
136             }
137         }
138
139         description "Creates a backup file of the datastore state";
140     }
141 }