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