Madan Jampani | 620f70d | 2016-01-30 22:22:47 -0800 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2016-present Open Networking Foundation |
Madan Jampani | 620f70d | 2016-01-30 22:22:47 -0800 | [diff] [blame] | 3 | * |
| 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 | */ |
| 16 | package org.onosproject.cluster; |
| 17 | |
Ray Milkey | 3bceb01 | 2018-09-07 13:42:46 -0700 | [diff] [blame] | 18 | import java.util.Map; |
| 19 | |
Madan Jampani | 620f70d | 2016-01-30 22:22:47 -0800 | [diff] [blame] | 20 | /** |
| 21 | * Interface for administratively manipulating leadership assignments. |
| 22 | */ |
| 23 | public 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 Milkey | 3bceb01 | 2018-09-07 13:42:46 -0700 | [diff] [blame] | 50 | |
| 51 | /** |
| 52 | * Returns the current leader board. |
| 53 | * |
| 54 | * @return mapping from topic to leadership info. |
| 55 | */ |
| 56 | Map<String, Leadership> getLeaderBoard(); |
pierventre | b59c51d | 2021-05-06 09:27:00 +0200 | [diff] [blame^] | 57 | |
| 58 | /** |
| 59 | * Attempts to demote a node to the bottom of the candidate list. It is not allowed |
| 60 | * to demote the current leader |
| 61 | * |
| 62 | * @param topic leadership topic |
| 63 | * @param nodeId identifier of node to be demoted |
| 64 | * @return {@code true} if nodeId is now the bottom candidate. This method returns {@code false} |
| 65 | * if {@code nodeId} is not one of the candidates for the topic or if it is the leader. |
| 66 | */ |
| 67 | boolean demote(String topic, NodeId nodeId); |
Madan Jampani | 620f70d | 2016-01-30 22:22:47 -0800 | [diff] [blame] | 68 | } |