Madan Jampani | ec1df02 | 2015-10-13 21:23:03 -0700 | [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 | ec1df02 | 2015-10-13 21:23:03 -0700 | [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 | |
Madan Jampani | ad3c526 | 2016-01-20 00:50:17 -0800 | [diff] [blame] | 18 | import java.util.Set; |
Madan Jampani | ec1df02 | 2015-10-13 21:23:03 -0700 | [diff] [blame] | 19 | |
Madan Jampani | ad3c526 | 2016-01-20 00:50:17 -0800 | [diff] [blame] | 20 | import org.onosproject.net.provider.Provider; |
Madan Jampani | ec1df02 | 2015-10-13 21:23:03 -0700 | [diff] [blame] | 21 | import org.onosproject.store.service.Versioned; |
| 22 | |
| 23 | /** |
Madan Jampani | ad3c526 | 2016-01-20 00:50:17 -0800 | [diff] [blame] | 24 | * Abstraction of a {@link ClusterMetadata cluster metadata} provider. |
Madan Jampani | ec1df02 | 2015-10-13 21:23:03 -0700 | [diff] [blame] | 25 | */ |
Madan Jampani | ad3c526 | 2016-01-20 00:50:17 -0800 | [diff] [blame] | 26 | public interface ClusterMetadataProvider extends Provider { |
Madan Jampani | ec1df02 | 2015-10-13 21:23:03 -0700 | [diff] [blame] | 27 | |
| 28 | /** |
Madan Jampani | ad3c526 | 2016-01-20 00:50:17 -0800 | [diff] [blame] | 29 | * Tells if this provider is currently available and therefore can provide ClusterMetadata. |
| 30 | * @return {@code true} if this provider is available and can provide cluster metadata. |
| 31 | */ |
| 32 | boolean isAvailable(); |
| 33 | |
| 34 | /** |
| 35 | * Returns the current cluster metadata. |
Madan Jampani | ec1df02 | 2015-10-13 21:23:03 -0700 | [diff] [blame] | 36 | * @return cluster metadata |
| 37 | */ |
| 38 | Versioned<ClusterMetadata> getClusterMetadata(); |
| 39 | |
| 40 | /** |
Madan Jampani | ad3c526 | 2016-01-20 00:50:17 -0800 | [diff] [blame] | 41 | * Updates cluster metadata. |
| 42 | * @param metadata new metadata |
Madan Jampani | ec1df02 | 2015-10-13 21:23:03 -0700 | [diff] [blame] | 43 | */ |
| 44 | void setClusterMetadata(ClusterMetadata metadata); |
| 45 | |
Madan Jampani | ab7e7cd | 2016-01-14 14:02:32 -0800 | [diff] [blame] | 46 | /** |
| 47 | * Adds a controller node to the list of active members for a partition. |
| 48 | * <p> |
| 49 | * Active members of a partition are those that are actively participating |
| 50 | * in the data replication protocol being employed. When a node first added |
| 51 | * to a partition, it is in a passive or catch up mode where it attempts to |
| 52 | * bring it self up to speed with other active members in the partition. |
| 53 | * @param partitionId partition identifier |
| 54 | * @param nodeId identifier of controller node |
| 55 | */ |
| 56 | void addActivePartitionMember(PartitionId partitionId, NodeId nodeId); |
Madan Jampani | ec1df02 | 2015-10-13 21:23:03 -0700 | [diff] [blame] | 57 | |
| 58 | /** |
Madan Jampani | ab7e7cd | 2016-01-14 14:02:32 -0800 | [diff] [blame] | 59 | * Removes a controller node from the list of active members for a partition. |
Madan Jampani | ec1df02 | 2015-10-13 21:23:03 -0700 | [diff] [blame] | 60 | * @param partitionId partition identifier |
Madan Jampani | ad3c526 | 2016-01-20 00:50:17 -0800 | [diff] [blame] | 61 | * @param nodeId identifier of controller node |
Madan Jampani | ec1df02 | 2015-10-13 21:23:03 -0700 | [diff] [blame] | 62 | */ |
Madan Jampani | ab7e7cd | 2016-01-14 14:02:32 -0800 | [diff] [blame] | 63 | void removeActivePartitionMember(PartitionId partitionId, NodeId nodeId); |
Madan Jampani | ec1df02 | 2015-10-13 21:23:03 -0700 | [diff] [blame] | 64 | |
| 65 | /** |
Madan Jampani | ad3c526 | 2016-01-20 00:50:17 -0800 | [diff] [blame] | 66 | * Returns the set of controller nodes that are the active members for a partition. |
Madan Jampani | ec1df02 | 2015-10-13 21:23:03 -0700 | [diff] [blame] | 67 | * <p> |
Madan Jampani | ab7e7cd | 2016-01-14 14:02:32 -0800 | [diff] [blame] | 68 | * Active members of a partition are typically those that are actively |
| 69 | * participating in the data replication protocol being employed. When |
| 70 | * a node first added to a partition, it is in a passive or catch up mode where |
| 71 | * it attempts to bring it self up to speed with other active members in the partition. |
Madan Jampani | ec1df02 | 2015-10-13 21:23:03 -0700 | [diff] [blame] | 72 | * <p> |
Madan Jampani | ab7e7cd | 2016-01-14 14:02:32 -0800 | [diff] [blame] | 73 | * <b>Note:</b>If is possible for this list to different from the list of partition members |
| 74 | * specified by cluster meta data. The discrepancy can arise due to the fact that |
| 75 | * adding/removing members from a partition requires a data hand-off mechanism to complete. |
Madan Jampani | ec1df02 | 2015-10-13 21:23:03 -0700 | [diff] [blame] | 76 | * @param partitionId partition identifier |
Madan Jampani | ab7e7cd | 2016-01-14 14:02:32 -0800 | [diff] [blame] | 77 | * @return identifiers of controller nodes that are active members |
Madan Jampani | ec1df02 | 2015-10-13 21:23:03 -0700 | [diff] [blame] | 78 | */ |
Madan Jampani | ad3c526 | 2016-01-20 00:50:17 -0800 | [diff] [blame] | 79 | Set<NodeId> getActivePartitionMembers(PartitionId partitionId); |
| 80 | } |