e4b88fb07d95084851e46efe6ff6203708dad0ee
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / config / ModuleShardConfiguration.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 com.google.common.base.Preconditions;
11 import java.net.URI;
12 import java.util.Collection;
13 import javax.annotation.Nonnull;
14 import javax.annotation.Nullable;
15
16 /**
17  * Encapsulates information for adding a new module shard configuration.
18  *
19  * @author Thomas Pantelis
20  */
21 public class ModuleShardConfiguration {
22     private final URI namespace;
23     private final String moduleName;
24     private final String shardName;
25     private final String shardStrategyName;
26     private final Collection<String> shardMemberNames;
27
28     /**
29      * Constructs a new instance.
30      *
31      * @param namespace the name space of the module.
32      * @param moduleName the name of the module.
33      * @param shardName the name of the shard.
34      * @param shardStrategyName the name of the sharding strategy (eg "module"). If null the default strategy
35      *                          is used.
36      * @param shardMemberNames the names of the shard's member replicas.
37      */
38     public ModuleShardConfiguration(@Nonnull URI namespace, @Nonnull String moduleName, @Nonnull String shardName,
39             @Nullable String shardStrategyName, @Nonnull Collection<String> shardMemberNames) {
40         this.namespace = Preconditions.checkNotNull(namespace, "nameSpace should not be null");
41         this.moduleName = Preconditions.checkNotNull(moduleName, "moduleName should not be null");
42         this.shardName = Preconditions.checkNotNull(shardName, "shardName should not be null");
43         this.shardStrategyName = shardStrategyName;
44         this.shardMemberNames = Preconditions.checkNotNull(shardMemberNames, "shardMemberNames");
45     }
46
47     public URI getNamespace() {
48         return namespace;
49     }
50
51     public String getModuleName() {
52         return moduleName;
53     }
54
55     public String getShardName() {
56         return shardName;
57     }
58
59     public String getShardStrategyName() {
60         return shardStrategyName;
61     }
62
63     public Collection<String> getShardMemberNames() {
64         return shardMemberNames;
65     }
66 }