Bug 4105: Pass ModuleShardConfiguration with CreateShard
[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 com.google.common.base.Preconditions;
11 import javax.annotation.Nonnull;
12 import javax.annotation.Nullable;
13 import org.opendaylight.controller.cluster.datastore.DatastoreContext;
14 import org.opendaylight.controller.cluster.datastore.ShardPropsCreator;
15 import org.opendaylight.controller.cluster.datastore.config.ModuleShardConfiguration;
16
17 /**
18  * A message sent to the ShardManager to dynamically create a new shard.
19  *
20  * @author Thomas Pantelis
21  */
22 public class CreateShard {
23     private final ModuleShardConfiguration moduleShardConfig;
24     private final ShardPropsCreator shardPropsCreator;
25     private final DatastoreContext datastoreContext;
26
27     /**
28      * Constructor.
29      *
30      * @param moduleShardConfig the configuration of the new shard.
31      * @param shardPropsCreator used to obtain the Props for creating the shard actor instance.
32      * @param datastoreContext the DatastoreContext for the new shard. If null, the default is used.
33      */
34     public CreateShard(@Nonnull ModuleShardConfiguration moduleShardConfig,
35             @Nonnull ShardPropsCreator shardPropsCreator, @Nullable DatastoreContext datastoreContext) {
36         this.moduleShardConfig = Preconditions.checkNotNull(moduleShardConfig);
37         this.shardPropsCreator = Preconditions.checkNotNull(shardPropsCreator);
38         this.datastoreContext = datastoreContext;
39     }
40
41     @Nonnull public ModuleShardConfiguration getModuleShardConfig() {
42         return moduleShardConfig;
43     }
44
45     @Nonnull public ShardPropsCreator getShardPropsCreator() {
46         return shardPropsCreator;
47     }
48
49     @Nullable public DatastoreContext getDatastoreContext() {
50         return datastoreContext;
51     }
52
53     @Override
54     public String toString() {
55         return "CreateShard [moduleShardConfig=" + moduleShardConfig + ", shardPropsCreator=" + shardPropsCreator + "]";
56     }
57 }