blob: bfdd1ca9a04a3dd9ea6979677a9630387881574b [file] [log] [blame]
Madan Jampaniec1df022015-10-13 21:23:03 -07001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2016-present Open Networking Laboratory
Madan Jampaniec1df022015-10-13 21:23:03 -07003 *
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
Madan Jampaniad3c5262016-01-20 00:50:17 -080018import java.util.Set;
Madan Jampaniec1df022015-10-13 21:23:03 -070019
Madan Jampaniad3c5262016-01-20 00:50:17 -080020import org.onosproject.net.provider.Provider;
Madan Jampaniec1df022015-10-13 21:23:03 -070021import org.onosproject.store.service.Versioned;
22
23/**
Madan Jampaniad3c5262016-01-20 00:50:17 -080024 * Abstraction of a {@link ClusterMetadata cluster metadata} provider.
Madan Jampaniec1df022015-10-13 21:23:03 -070025 */
Madan Jampaniad3c5262016-01-20 00:50:17 -080026public interface ClusterMetadataProvider extends Provider {
Madan Jampaniec1df022015-10-13 21:23:03 -070027
28 /**
Madan Jampaniad3c5262016-01-20 00:50:17 -080029 * 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 Jampaniec1df022015-10-13 21:23:03 -070036 * @return cluster metadata
37 */
38 Versioned<ClusterMetadata> getClusterMetadata();
39
40 /**
Madan Jampaniad3c5262016-01-20 00:50:17 -080041 * Updates cluster metadata.
42 * @param metadata new metadata
Madan Jampaniec1df022015-10-13 21:23:03 -070043 */
44 void setClusterMetadata(ClusterMetadata metadata);
45
Madan Jampaniab7e7cd2016-01-14 14:02:32 -080046 /**
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 Jampaniec1df022015-10-13 21:23:03 -070057
58 /**
Madan Jampaniab7e7cd2016-01-14 14:02:32 -080059 * Removes a controller node from the list of active members for a partition.
Madan Jampaniec1df022015-10-13 21:23:03 -070060 * @param partitionId partition identifier
Madan Jampaniad3c5262016-01-20 00:50:17 -080061 * @param nodeId identifier of controller node
Madan Jampaniec1df022015-10-13 21:23:03 -070062 */
Madan Jampaniab7e7cd2016-01-14 14:02:32 -080063 void removeActivePartitionMember(PartitionId partitionId, NodeId nodeId);
Madan Jampaniec1df022015-10-13 21:23:03 -070064
65 /**
Madan Jampaniad3c5262016-01-20 00:50:17 -080066 * Returns the set of controller nodes that are the active members for a partition.
Madan Jampaniec1df022015-10-13 21:23:03 -070067 * <p>
Madan Jampaniab7e7cd2016-01-14 14:02:32 -080068 * 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 Jampaniec1df022015-10-13 21:23:03 -070072 * <p>
Madan Jampaniab7e7cd2016-01-14 14:02:32 -080073 * <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 Jampaniec1df022015-10-13 21:23:03 -070076 * @param partitionId partition identifier
Madan Jampaniab7e7cd2016-01-14 14:02:32 -080077 * @return identifiers of controller nodes that are active members
Madan Jampaniec1df022015-10-13 21:23:03 -070078 */
Madan Jampaniad3c5262016-01-20 00:50:17 -080079 Set<NodeId> getActivePartitionMembers(PartitionId partitionId);
80}