Bug 4105: Pass ModuleShardConfiguration with CreateShard
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / config / ModuleConfig.java
1 /*
2  * Copyright (c) 2015 Brocade Communications Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.controller.cluster.datastore.config;
9
10 import java.util.Collection;
11 import java.util.HashMap;
12 import java.util.Map;
13 import java.util.Set;
14 import org.opendaylight.controller.cluster.datastore.shardstrategy.ShardStrategy;
15
16 /**
17  * Encapsulates configuration for a module.
18  *
19  * @author Thomas Pantelis
20  */
21 public class ModuleConfig {
22     private final String name;
23     private String nameSpace;
24     private ShardStrategy shardStrategy;
25     private final Map<String, ShardConfig> shardConfigs = new HashMap<>();
26
27     public ModuleConfig(final String name) {
28         this.name = name;
29     }
30
31     public String getName() {
32         return name;
33     }
34
35     public String getNameSpace() {
36         return nameSpace;
37     }
38
39     public ShardStrategy getShardStrategy() {
40         return shardStrategy;
41     }
42
43     public ShardConfig getShardConfig(String name) {
44         return shardConfigs.get(name);
45     }
46
47     public Collection<ShardConfig> getShardConfigs() {
48         return shardConfigs.values();
49     }
50
51     public Collection<String> getShardNames() {
52         return shardConfigs.keySet();
53     }
54
55     public void addShardConfig(String name, Set<String> replicas) {
56         shardConfigs.put(name, new ShardConfig(name, replicas));
57     }
58
59     public void setNameSpace(String nameSpace) {
60         this.nameSpace = nameSpace;
61     }
62
63     public void setShardStrategy(ShardStrategy shardStrategy) {
64         this.shardStrategy = shardStrategy;
65     }
66 }