alshabib | ab98466 | 2014-12-04 18:56:18 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2014 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 | */ |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 16 | package org.onosproject.store.cluster; |
Yuta HIGUCHI | 3e5d11a | 2014-11-04 14:16:44 -0800 | [diff] [blame] | 17 | |
| 18 | import java.util.HashMap; |
| 19 | import java.util.Map; |
| 20 | import java.util.Set; |
| 21 | |
Ray Milkey | cc53abd | 2015-02-19 12:31:33 -0800 | [diff] [blame] | 22 | import org.onosproject.cluster.ClusterServiceAdapter; |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 23 | import org.onosproject.cluster.ControllerNode; |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 24 | import org.onosproject.cluster.ControllerNode.State; |
Ray Milkey | cc53abd | 2015-02-19 12:31:33 -0800 | [diff] [blame] | 25 | import org.onosproject.cluster.NodeId; |
Yuta HIGUCHI | 3e5d11a | 2014-11-04 14:16:44 -0800 | [diff] [blame] | 26 | |
| 27 | import com.google.common.collect.Sets; |
| 28 | |
Ray Milkey | cc53abd | 2015-02-19 12:31:33 -0800 | [diff] [blame] | 29 | public abstract class StaticClusterService extends ClusterServiceAdapter { |
Yuta HIGUCHI | 3e5d11a | 2014-11-04 14:16:44 -0800 | [diff] [blame] | 30 | |
| 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'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 55 | } |