blob: 46754e5a1e76fdceedc96bcd8d517b93e766a585 [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 */
16package org.onosproject.store.consistent.impl;
17
18import java.util.Map;
19import java.util.Set;
20
21import org.onosproject.store.cluster.impl.NodeInfo;
22
23import static com.google.common.base.Preconditions.checkNotNull;
24
25import com.google.common.collect.ImmutableMap;
26import com.google.common.collect.ImmutableSet;
27
28/**
29 * Partitioned database configuration.
30 */
31public class DatabaseDefinition {
32 private Map<String, Set<NodeInfo>> partitions;
33 private Set<NodeInfo> nodes;
34
35 /**
36 * Creates a new DatabaseDefinition.
37 * @param partitions partition map
38 * @param nodes set of nodes
39 * @return database definition
40 */
41 public static DatabaseDefinition from(Map<String, Set<NodeInfo>> partitions, Set<NodeInfo> nodes) {
42 checkNotNull(partitions);
43 checkNotNull(nodes);
44 DatabaseDefinition definition = new DatabaseDefinition();
45 definition.partitions = ImmutableMap.copyOf(partitions);
46 definition.nodes = ImmutableSet.copyOf(nodes);
47 return definition;
48 }
49
50 /**
51 * Returns the map of database partitions.
52 * @return db partition map
53 */
54 public Map<String, Set<NodeInfo>> getPartitions() {
55 return partitions;
56 }
57
58 /**
59 * Returns the set of nodes.
60 * @return nodes
61 */
62 public Set<NodeInfo> getNodes() {
63 return nodes;
64 }
65}