Madan Jampani | ec1df02 | 2015-10-13 21:23:03 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2015 Open Networking Laboratory |
| 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 | import java.util.Collection; |
| 19 | |
| 20 | import org.onosproject.store.Store; |
| 21 | import org.onosproject.store.service.Versioned; |
| 22 | |
| 23 | /** |
Madan Jampani | ab7e7cd | 2016-01-14 14:02:32 -0800 | [diff] [blame] | 24 | * Manages persistence of {@link ClusterMetadata cluster metadata}; not intended for direct use. |
Madan Jampani | ec1df02 | 2015-10-13 21:23:03 -0700 | [diff] [blame] | 25 | */ |
| 26 | public interface ClusterMetadataStore extends Store<ClusterMetadataEvent, ClusterMetadataStoreDelegate> { |
| 27 | |
| 28 | /** |
| 29 | * Returns the cluster metadata. |
| 30 | * <p> |
Madan Jampani | ab7e7cd | 2016-01-14 14:02:32 -0800 | [diff] [blame] | 31 | * The retuned metadata is encapsulated as a {@link Versioned versioned} and therefore has a specific version. |
Madan Jampani | ec1df02 | 2015-10-13 21:23:03 -0700 | [diff] [blame] | 32 | * @return cluster metadata |
| 33 | */ |
| 34 | Versioned<ClusterMetadata> getClusterMetadata(); |
| 35 | |
| 36 | /** |
| 37 | * Updates the cluster metadata. |
| 38 | * @param metadata new metadata value |
| 39 | */ |
| 40 | void setClusterMetadata(ClusterMetadata metadata); |
| 41 | |
Madan Jampani | ab7e7cd | 2016-01-14 14:02:32 -0800 | [diff] [blame] | 42 | /** |
| 43 | * Adds a controller node to the list of active members for a partition. |
| 44 | * <p> |
| 45 | * Active members of a partition are those that are actively participating |
| 46 | * in the data replication protocol being employed. When a node first added |
| 47 | * to a partition, it is in a passive or catch up mode where it attempts to |
| 48 | * bring it self up to speed with other active members in the partition. |
| 49 | * @param partitionId partition identifier |
| 50 | * @param nodeId identifier of controller node |
| 51 | */ |
| 52 | void addActivePartitionMember(PartitionId partitionId, NodeId nodeId); |
Madan Jampani | ec1df02 | 2015-10-13 21:23:03 -0700 | [diff] [blame] | 53 | |
| 54 | /** |
Madan Jampani | ab7e7cd | 2016-01-14 14:02:32 -0800 | [diff] [blame] | 55 | * 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] | 56 | * @param partitionId partition identifier |
| 57 | * @param nodeId id of controller node |
| 58 | */ |
Madan Jampani | ab7e7cd | 2016-01-14 14:02:32 -0800 | [diff] [blame] | 59 | void removeActivePartitionMember(PartitionId partitionId, NodeId nodeId); |
Madan Jampani | ec1df02 | 2015-10-13 21:23:03 -0700 | [diff] [blame] | 60 | |
| 61 | /** |
Madan Jampani | ab7e7cd | 2016-01-14 14:02:32 -0800 | [diff] [blame] | 62 | * Returns the collection of controller nodes that are the active members for a partition. |
Madan Jampani | ec1df02 | 2015-10-13 21:23:03 -0700 | [diff] [blame] | 63 | * <p> |
Madan Jampani | ab7e7cd | 2016-01-14 14:02:32 -0800 | [diff] [blame] | 64 | * Active members of a partition are typically those that are actively |
| 65 | * participating in the data replication protocol being employed. When |
| 66 | * a node first added to a partition, it is in a passive or catch up mode where |
| 67 | * 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] | 68 | * <p> |
Madan Jampani | ab7e7cd | 2016-01-14 14:02:32 -0800 | [diff] [blame] | 69 | * <b>Note:</b>If is possible for this list to different from the list of partition members |
| 70 | * specified by cluster meta data. The discrepancy can arise due to the fact that |
| 71 | * 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] | 72 | * @param partitionId partition identifier |
Madan Jampani | ab7e7cd | 2016-01-14 14:02:32 -0800 | [diff] [blame] | 73 | * @return identifiers of controller nodes that are active members |
Madan Jampani | ec1df02 | 2015-10-13 21:23:03 -0700 | [diff] [blame] | 74 | */ |
Madan Jampani | ab7e7cd | 2016-01-14 14:02:32 -0800 | [diff] [blame] | 75 | Collection<NodeId> getActivePartitionMembers(PartitionId partitionId); |
Madan Jampani | ec1df02 | 2015-10-13 21:23:03 -0700 | [diff] [blame] | 76 | } |