6b4fd7c204a194d1c2edf7f80ede8557e16a6eb7
[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.Shard;
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 Shard.AbstractBuilder<?, ?> shardBuilder;
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 Shard.AbstractBuilder<?, ?> shardBuilder, @Nullable DatastoreContext datastoreContext) {
36         this.moduleShardConfig = Preconditions.checkNotNull(moduleShardConfig);
37         this.shardBuilder = Preconditions.checkNotNull(shardBuilder);
38         this.datastoreContext = datastoreContext;
39     }
40
41     @Nonnull
42     public ModuleShardConfiguration getModuleShardConfig() {
43         return moduleShardConfig;
44     }
45
46     @Nonnull
47     public Shard.AbstractBuilder<?, ?> getShardBuilder() {
48         return shardBuilder;
49     }
50
51     @Nullable
52     public DatastoreContext getDatastoreContext() {
53         return datastoreContext;
54     }
55
56     @Override
57     public String toString() {
58         return "CreateShard [moduleShardConfig=" + moduleShardConfig + ", shardPropsCreator=" + shardBuilder + "]";
59     }
60 }