blob: 7e83b5b5cecf20ef41aeaa5aa7220ba360230868 [file] [log] [blame]
Madan Jampaniec1df022015-10-13 21:23:03 -07001/*
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 */
16package org.onosproject.cluster;
17
18import java.util.Collection;
19
20import org.onosproject.store.Store;
21import org.onosproject.store.service.Versioned;
22
23/**
24 * Manages persistence of cluster metadata; not intended for direct use.
25 */
26public interface ClusterMetadataStore extends Store<ClusterMetadataEvent, ClusterMetadataStoreDelegate> {
27
28 /**
29 * Returns the cluster metadata.
30 * <p>
31 * The returned metadata is versioned to aid determining if a metadata instance is more recent than another.
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
42 // TODO: The below methods should move to a separate store interface that is responsible for
43 // tracking cluster partition operational state.
44
45 /**
46 * Sets a controller node as an active member of a partition.
47 * <p>
48 * Active members are those replicas that are up to speed with the rest of the system and are
49 * usually capable of participating in the replica state management activities in accordance with
50 * the data consistency and replication protocol in use.
51 * @param partitionId partition identifier
52 * @param nodeId id of controller node
53 */
54 void setActiveReplica(String partitionId, NodeId nodeId);
55
56 /**
57 * Removes a controller node as an active member for a partition.
58 * <p>
59 * Active members are those replicas that are up to speed with the rest of the system and are
60 * usually capable of participating in the replica state management activities in accordance with
61 * the data consistency and replication protocol in use.
62 * @param partitionId partition identifier
63 * @param nodeId id of controller node
64 */
65 void unsetActiveReplica(String partitionId, NodeId nodeId);
66
67 /**
68 * Returns the collection of controller nodes that are the active replicas for a partition.
69 * <p>
70 * Active members are those replicas that are up to speed with the rest of the system and are
71 * usually capable of participating in the replica state management activities in accordance with
72 * the data consistency and replication protocol in use.
73 * @param partitionId partition identifier
74 * @return identifiers of controller nodes that are the active replicas
75 */
76 Collection<NodeId> getActiveReplicas(String partitionId);
77}