Madan Jampani | 620f70d | 2016-01-30 22:22:47 -0800 | [diff] [blame] | 1 | /* |
Brian O'Connor | 5ab426f | 2016-04-09 01:19:45 -0700 | [diff] [blame] | 2 | * Copyright 2016-present Open Networking Laboratory |
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 | |
| 18 | /** |
| 19 | * Interface for administratively manipulating leadership assignments. |
| 20 | */ |
| 21 | public 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 | } |