Ask is moving to Stack Overflow and! Please use the "opendaylight" tag on either of these sites. This site is now in Read-Only mode


How do you change the leadership of a shard through CLI or REST?

asked 2016-03-30 09:14:15 -0800

DeJuan gravatar image

Let us assume that I'm running a 3-Node cluster in either Lithium or Beryllium, with all shards on member-1. How can I move the topology shard to member-2 through a command? I could try to relocate it by bringing down member-1, but I want to know if I can re-assign mastery for a given shard through a command, preferably through the REST API.

edit retag flag offensive close merge delete

1 answer

Sort by » oldest newest most voted

answered 2016-03-30 15:10:58 -0800

moraja gravatar image

DeJuan it's possible to do this but I'm afraid to suggest how because a formal API and documentation for this does not exist.

The long answer

By default you cannot control which cluster node becomes the leader of the Shard as we simply use Raft algorithm to determine the leader. Raft uses an election mechanism to determine the leader.

The only way to workaround Raft is to disable the election mechanism. To do that we came up with something called a RaftPolicy, this policy determines if elections should happen or not. Which policy is used is determined by configuration which is done in org.opendaylight.controller.cluster.datastore.cfg. You would need to set the RaftPolicy to DisableElectionsRaftPolicy.

Once the policy is set and you restart the nodes in the cluster you will notice that all the shard replica's will remain in the Follower state. You can now use JMX to switch the Shard states to Leader from the ShardManager MBean. If you use Jolokia you could then do the switching of behaviors using REST.

Again I would not recommend doing any of these things in production unless you have a very good way to externalize the election mechanism because if you get it wrong you will lose data.

There are a lot of specifics I am leaving out in this answer because I am not sure I want people using this. If you really must and are willing to experiment with an unpublished API/mechanism let me know and I will provide further details.

edit flag offensive delete publish link more


Let me ask my team. We need to be able to reassign leadership without restarting shards, but the proposed way of doing that means we have to be careful with the election mechanism, and I don't know if we can deal with that properly. I'll get back to you as soon as I can. Thank you for your reply!

DeJuan ( 2016-04-01 05:58:20 -0800 )edit
Login/Signup to Answer

Question Tools

1 follower


Asked: 2016-03-30 09:14:15 -0800

Seen: 255 times

Last updated: Mar 30 '16