Madan Jampani | 0cb0067 | 2015-02-27 00:27:22 -0800 | [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 | */ |
Madan Jampani | a14047d | 2015-02-25 12:23:02 -0800 | [diff] [blame] | 16 | package org.onosproject.store.cluster.impl; |
| 17 | |
| 18 | import java.util.Set; |
| 19 | |
Madan Jampani | a14047d | 2015-02-25 12:23:02 -0800 | [diff] [blame] | 20 | import com.google.common.collect.ImmutableSet; |
| 21 | |
| 22 | /** |
| 23 | * Cluster definition. |
| 24 | */ |
| 25 | public class ClusterDefinition { |
| 26 | |
Madan Jampani | 0cb0067 | 2015-02-27 00:27:22 -0800 | [diff] [blame] | 27 | private Set<NodeInfo> nodes; |
Madan Jampani | a14047d | 2015-02-25 12:23:02 -0800 | [diff] [blame] | 28 | private String ipPrefix; |
| 29 | |
| 30 | /** |
| 31 | * Creates a new cluster definition. |
Madan Jampani | 0cb0067 | 2015-02-27 00:27:22 -0800 | [diff] [blame] | 32 | * @param nodes cluster nodes information |
| 33 | * @param ipPrefix ip prefix common to all cluster nodes |
Madan Jampani | a14047d | 2015-02-25 12:23:02 -0800 | [diff] [blame] | 34 | * @return cluster definition |
| 35 | */ |
Madan Jampani | 0cb0067 | 2015-02-27 00:27:22 -0800 | [diff] [blame] | 36 | public static ClusterDefinition from(Set<NodeInfo> nodes, String ipPrefix) { |
Madan Jampani | a14047d | 2015-02-25 12:23:02 -0800 | [diff] [blame] | 37 | ClusterDefinition definition = new ClusterDefinition(); |
| 38 | definition.ipPrefix = ipPrefix; |
| 39 | definition.nodes = ImmutableSet.copyOf(nodes); |
| 40 | return definition; |
| 41 | } |
| 42 | |
| 43 | /** |
Madan Jampani | 0cb0067 | 2015-02-27 00:27:22 -0800 | [diff] [blame] | 44 | * Returns set of cluster nodes info. |
| 45 | * @return cluster nodes info |
Madan Jampani | a14047d | 2015-02-25 12:23:02 -0800 | [diff] [blame] | 46 | */ |
Madan Jampani | 0cb0067 | 2015-02-27 00:27:22 -0800 | [diff] [blame] | 47 | public Set<NodeInfo> getNodes() { |
Madan Jampani | a14047d | 2015-02-25 12:23:02 -0800 | [diff] [blame] | 48 | return ImmutableSet.copyOf(nodes); |
| 49 | } |
| 50 | |
| 51 | /** |
| 52 | * Returns ipPrefix in dotted decimal notion. |
Madan Jampani | 0cb0067 | 2015-02-27 00:27:22 -0800 | [diff] [blame] | 53 | * @return ip prefix |
Madan Jampani | a14047d | 2015-02-25 12:23:02 -0800 | [diff] [blame] | 54 | */ |
Madan Jampani | 0cb0067 | 2015-02-27 00:27:22 -0800 | [diff] [blame] | 55 | public String getIpPrefix() { |
Madan Jampani | a14047d | 2015-02-25 12:23:02 -0800 | [diff] [blame] | 56 | return ipPrefix; |
| 57 | } |
| 58 | } |