Bug 4105: Add EntityOwnershipShard
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / Shard.java
index dd1c0ad6ff464959bb6fdf97220a8862d52edf8d..7b34f5df6097ce4ea00c49233f3f4a4a8e5c7728 100644 (file)
@@ -162,14 +162,8 @@ public class Shard extends RaftActor {
                 datastoreContext.getShardTransactionCommitTimeoutInSeconds(), TimeUnit.SECONDS) / 2;
     }
 
-    public static Props props(final ShardIdentifier name,
-        final Map<String, String> peerAddresses,
-        final DatastoreContext datastoreContext, final SchemaContext schemaContext) {
-        Preconditions.checkNotNull(name, "name should not be null");
-        Preconditions.checkNotNull(peerAddresses, "peerAddresses should not be null");
-        Preconditions.checkNotNull(datastoreContext, "dataStoreContext should not be null");
-        Preconditions.checkNotNull(schemaContext, "schemaContext should not be null");
-
+    public static Props props(final ShardIdentifier name, final Map<String, String> peerAddresses,
+            final DatastoreContext datastoreContext, final SchemaContext schemaContext) {
         return Props.create(new ShardCreator(name, peerAddresses, datastoreContext, schemaContext));
     }
 
@@ -291,7 +285,7 @@ public class Shard extends RaftActor {
                 leaderPayloadVersion);
     }
 
-    private void onDatastoreContext(DatastoreContext context) {
+    protected void onDatastoreContext(DatastoreContext context) {
         datastoreContext = context;
 
         commitCoordinator.setQueueCapacity(datastoreContext.getShardTransactionCommitQueueCapacity());
@@ -690,22 +684,29 @@ public class Shard extends RaftActor {
         return commitCoordinator;
     }
 
+    protected abstract static class AbstractShardCreator implements Creator<Shard> {
+        private static final long serialVersionUID = 1L;
 
-    private static class ShardCreator implements Creator<Shard> {
+        protected final ShardIdentifier name;
+        protected final Map<String, String> peerAddresses;
+        protected final DatastoreContext datastoreContext;
+        protected final SchemaContext schemaContext;
 
-        private static final long serialVersionUID = 1L;
+        protected AbstractShardCreator(final ShardIdentifier name, final Map<String, String> peerAddresses,
+                final DatastoreContext datastoreContext, final SchemaContext schemaContext) {
+            this.name = Preconditions.checkNotNull(name, "name should not be null");
+            this.peerAddresses = Preconditions.checkNotNull(peerAddresses, "peerAddresses should not be null");
+            this.datastoreContext = Preconditions.checkNotNull(datastoreContext, "dataStoreContext should not be null");
+            this.schemaContext = Preconditions.checkNotNull(schemaContext, "schemaContext should not be null");
+        }
+    }
 
-        final ShardIdentifier name;
-        final Map<String, String> peerAddresses;
-        final DatastoreContext datastoreContext;
-        final SchemaContext schemaContext;
+    private static class ShardCreator extends AbstractShardCreator {
+        private static final long serialVersionUID = 1L;
 
         ShardCreator(final ShardIdentifier name, final Map<String, String> peerAddresses,
                 final DatastoreContext datastoreContext, final SchemaContext schemaContext) {
-            this.name = name;
-            this.peerAddresses = peerAddresses;
-            this.datastoreContext = datastoreContext;
-            this.schemaContext = schemaContext;
+            super(name, peerAddresses, datastoreContext, schemaContext);
         }
 
         @Override