blob: 45a8fa49366bfc48b26d8a147775eb54c907f50d [file] [log] [blame]
Madan Jampani620f70d2016-01-30 22:22:47 -08001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2016-present Open Networking Foundation
Madan Jampani620f70d2016-01-30 22:22:47 -08003 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package org.onosproject.cluster;
17
18/**
19 * Interface for administratively manipulating leadership assignments.
20 */
21public interface LeadershipAdminService {
22
23 /**
24 * Attempts to assign leadership for a topic to a specified node.
25 * @param topic leadership topic
26 * @param nodeId identifier of the node to be made leader
27 * @return true is the transfer was successfully executed. This method returns {@code false}
28 * if {@code nodeId} is not one of the candidates for for the topic.
29 */
30 boolean transferLeadership(String topic, NodeId nodeId);
31
32 /**
33 * Make a node to be the next leader by promoting it to top of candidate list.
34 * @param topic leadership topic
35 * @param nodeId identifier of node to be next leader
36 * @return {@code true} if nodeId is now the top candidate. This method returns {@code false}
37 * if {@code nodeId} is not one of the candidates for for the topic.
38 */
39 boolean promoteToTopOfCandidateList(String topic, NodeId nodeId);
40
41 /**
42 * Removes all active leadership registrations for a given node.
43 * <p>
44 * This method will also evict the node from leaderships that it currently owns.
45 * @param nodeId node identifier
46 */
47 void unregister(NodeId nodeId);
48}