blob: b3fc8a1b78ca5315eacd1768ae1f4c7b746123a3 [file] [log] [blame]
alshabibab984662014-12-04 18:56:18 -08001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2014-present Open Networking Laboratory
alshabibab984662014-12-04 18:56:18 -08003 *
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 */
Brian O'Connorabafb502014-12-02 22:26:20 -080016package org.onosproject.store.cluster;
Yuta HIGUCHI3e5d11a2014-11-04 14:16:44 -080017
18import java.util.HashMap;
19import java.util.Map;
20import java.util.Set;
21
Ray Milkeycc53abd2015-02-19 12:31:33 -080022import org.onosproject.cluster.ClusterServiceAdapter;
Brian O'Connorabafb502014-12-02 22:26:20 -080023import org.onosproject.cluster.ControllerNode;
Brian O'Connorabafb502014-12-02 22:26:20 -080024import org.onosproject.cluster.ControllerNode.State;
Ray Milkeycc53abd2015-02-19 12:31:33 -080025import org.onosproject.cluster.NodeId;
Yuta HIGUCHI3e5d11a2014-11-04 14:16:44 -080026
27import com.google.common.collect.Sets;
28
Ray Milkeycc53abd2015-02-19 12:31:33 -080029public abstract class StaticClusterService extends ClusterServiceAdapter {
Yuta HIGUCHI3e5d11a2014-11-04 14:16:44 -080030
31 protected final Map<NodeId, ControllerNode> nodes = new HashMap<>();
32 protected final Map<NodeId, ControllerNode.State> nodeStates = new HashMap<>();
33 protected ControllerNode localNode;
34
35 @Override
36 public ControllerNode getLocalNode() {
37 return localNode;
38 }
39
40 @Override
41 public Set<ControllerNode> getNodes() {
42 return Sets.newHashSet(nodes.values());
43 }
44
45 @Override
46 public ControllerNode getNode(NodeId nodeId) {
47 return nodes.get(nodeId);
48 }
49
50 @Override
51 public State getState(NodeId nodeId) {
52 return nodeStates.get(nodeId);
53 }
54
Brian O'Connorabafb502014-12-02 22:26:20 -080055}