blob: 75f05a315b71896c987810095ef297cbbaaf9ebb [file] [log] [blame]
Madan Jampani0cb00672015-02-27 00:27:22 -08001/*
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 Jampania14047d2015-02-25 12:23:02 -080016package org.onosproject.store.cluster.impl;
17
18import java.util.Set;
19
Madan Jampania14047d2015-02-25 12:23:02 -080020import com.google.common.collect.ImmutableSet;
21
22/**
23 * Cluster definition.
24 */
25public class ClusterDefinition {
26
Madan Jampani0cb00672015-02-27 00:27:22 -080027 private Set<NodeInfo> nodes;
Madan Jampania14047d2015-02-25 12:23:02 -080028 private String ipPrefix;
29
30 /**
31 * Creates a new cluster definition.
Madan Jampani0cb00672015-02-27 00:27:22 -080032 * @param nodes cluster nodes information
33 * @param ipPrefix ip prefix common to all cluster nodes
Madan Jampania14047d2015-02-25 12:23:02 -080034 * @return cluster definition
35 */
Madan Jampani0cb00672015-02-27 00:27:22 -080036 public static ClusterDefinition from(Set<NodeInfo> nodes, String ipPrefix) {
Madan Jampania14047d2015-02-25 12:23:02 -080037 ClusterDefinition definition = new ClusterDefinition();
38 definition.ipPrefix = ipPrefix;
39 definition.nodes = ImmutableSet.copyOf(nodes);
40 return definition;
41 }
42
43 /**
Madan Jampani0cb00672015-02-27 00:27:22 -080044 * Returns set of cluster nodes info.
45 * @return cluster nodes info
Madan Jampania14047d2015-02-25 12:23:02 -080046 */
Madan Jampani0cb00672015-02-27 00:27:22 -080047 public Set<NodeInfo> getNodes() {
Madan Jampania14047d2015-02-25 12:23:02 -080048 return ImmutableSet.copyOf(nodes);
49 }
50
51 /**
52 * Returns ipPrefix in dotted decimal notion.
Madan Jampani0cb00672015-02-27 00:27:22 -080053 * @return ip prefix
Madan Jampania14047d2015-02-25 12:23:02 -080054 */
Madan Jampani0cb00672015-02-27 00:27:22 -080055 public String getIpPrefix() {
Madan Jampania14047d2015-02-25 12:23:02 -080056 return ipPrefix;
57 }
58}