Fix followerDistributedDataStore tear down
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / messages / CreateShard.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.messages;
9
10 import static java.util.Objects.requireNonNull;
11
12 import org.eclipse.jdt.annotation.NonNull;
13 import org.eclipse.jdt.annotation.Nullable;
14 import org.opendaylight.controller.cluster.datastore.DatastoreContext;
15 import org.opendaylight.controller.cluster.datastore.Shard;
16 import org.opendaylight.controller.cluster.datastore.Shard.AbstractBuilder;
17 import org.opendaylight.controller.cluster.datastore.config.ModuleShardConfiguration;
18
19 /**
20  * A message sent to the ShardManager to dynamically create a new shard.
21  *
22  * @author Thomas Pantelis
23  */
24 public class CreateShard {
25     private final ModuleShardConfiguration moduleShardConfig;
26     private final Shard.AbstractBuilder<?, ?> shardBuilder;
27     private final DatastoreContext datastoreContext;
28
29     /**
30      * Constructor.
31      *
32      * @param moduleShardConfig the configuration of the new shard.
33      * @param shardBuilder used to obtain the Props for creating the shard actor instance.
34      * @param datastoreContext the DatastoreContext for the new shard. If null, the default is used.
35      */
36     public CreateShard(@NonNull ModuleShardConfiguration moduleShardConfig, @NonNull AbstractBuilder<?, ?> shardBuilder,
37             @Nullable DatastoreContext datastoreContext) {
38         this.moduleShardConfig = requireNonNull(moduleShardConfig);
39         this.shardBuilder = requireNonNull(shardBuilder);
40         this.datastoreContext = datastoreContext;
41     }
42
43     public @NonNull ModuleShardConfiguration getModuleShardConfig() {
44         return moduleShardConfig;
45     }
46
47     public @NonNull AbstractBuilder<?, ?> getShardBuilder() {
48         return shardBuilder;
49     }
50
51     public @Nullable DatastoreContext getDatastoreContext() {
52         return datastoreContext;
53     }
54
55     @Override
56     public String toString() {
57         return "CreateShard [moduleShardConfig=" + moduleShardConfig + ", shardPropsCreator=" + shardBuilder + "]";
58     }
59 }