blob: fe9868a043f7a2d8427d1ff4ba160bed2b13496d [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
Ray Milkey3bceb012018-09-07 13:42:46 -070018import java.util.Map;
19
Madan Jampani620f70d2016-01-30 22:22:47 -080020/**
21 * Interface for administratively manipulating leadership assignments.
22 */
23public interface LeadershipAdminService {
24
25 /**
26 * Attempts to assign leadership for a topic to a specified node.
27 * @param topic leadership topic
28 * @param nodeId identifier of the node to be made leader
29 * @return true is the transfer was successfully executed. This method returns {@code false}
30 * if {@code nodeId} is not one of the candidates for for the topic.
31 */
32 boolean transferLeadership(String topic, NodeId nodeId);
33
34 /**
35 * Make a node to be the next leader by promoting it to top of candidate list.
36 * @param topic leadership topic
37 * @param nodeId identifier of node to be next leader
38 * @return {@code true} if nodeId is now the top candidate. This method returns {@code false}
39 * if {@code nodeId} is not one of the candidates for for the topic.
40 */
41 boolean promoteToTopOfCandidateList(String topic, NodeId nodeId);
42
43 /**
44 * Removes all active leadership registrations for a given node.
45 * <p>
46 * This method will also evict the node from leaderships that it currently owns.
47 * @param nodeId node identifier
48 */
49 void unregister(NodeId nodeId);
Ray Milkey3bceb012018-09-07 13:42:46 -070050
51 /**
52 * Returns the current leader board.
53 *
54 * @return mapping from topic to leadership info.
55 */
56 Map<String, Leadership> getLeaderBoard();
Madan Jampani620f70d2016-01-30 22:22:47 -080057}