BUG 1815 - Do not allow Shards to be created till an appropriate schema context is...
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / ShardTransactionChain.java
index 42bd257ad1cdb97b3d28ab2588bbe6161894b8e9..8fe94cf468b6b63e78128a5f44ca2b1b7cebdd55 100644 (file)
@@ -11,7 +11,9 @@ package org.opendaylight.controller.cluster.datastore;
 import akka.actor.ActorRef;
 import akka.actor.Props;
 import akka.japi.Creator;
+import org.opendaylight.controller.cluster.common.actor.AbstractUntypedActor;
 
+import org.opendaylight.controller.cluster.datastore.jmx.mbeans.shard.ShardStats;
 import org.opendaylight.controller.cluster.datastore.messages.CloseTransactionChain;
 import org.opendaylight.controller.cluster.datastore.messages.CloseTransactionChainReply;
 import org.opendaylight.controller.cluster.datastore.messages.CreateTransaction;
@@ -25,14 +27,16 @@ import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 public class ShardTransactionChain extends AbstractUntypedActor {
 
     private final DOMStoreTransactionChain chain;
-    private final ShardContext shardContext;
+    private final DatastoreContext datastoreContext;
     private final SchemaContext schemaContext;
+    private final ShardStats shardStats;
 
     public ShardTransactionChain(DOMStoreTransactionChain chain, SchemaContext schemaContext,
-            ShardContext shardContext) {
+            DatastoreContext datastoreContext, ShardStats shardStats) {
         this.chain = chain;
-        this.shardContext = shardContext;
+        this.datastoreContext = datastoreContext;
         this.schemaContext = schemaContext;
+        this.shardStats = shardStats;
     }
 
     @Override
@@ -58,17 +62,17 @@ public class ShardTransactionChain extends AbstractUntypedActor {
                 TransactionProxy.TransactionType.READ_ONLY.ordinal()) {
             return getContext().actorOf(
                     ShardTransaction.props( chain.newReadOnlyTransaction(), getShardActor(),
-                            schemaContext, shardContext), transactionId);
+                            schemaContext, datastoreContext, shardStats), transactionId);
         } else if (createTransaction.getTransactionType() ==
                 TransactionProxy.TransactionType.READ_WRITE.ordinal()) {
             return getContext().actorOf(
                     ShardTransaction.props( chain.newReadWriteTransaction(), getShardActor(),
-                            schemaContext, shardContext), transactionId);
+                            schemaContext, datastoreContext, shardStats), transactionId);
         } else if (createTransaction.getTransactionType() ==
                 TransactionProxy.TransactionType.WRITE_ONLY.ordinal()) {
             return getContext().actorOf(
                     ShardTransaction.props( chain.newWriteOnlyTransaction(), getShardActor(),
-                            schemaContext, shardContext), transactionId);
+                            schemaContext, datastoreContext, shardStats), transactionId);
         } else {
             throw new IllegalArgumentException (
                     "CreateTransaction message has unidentified transaction type=" +
@@ -85,27 +89,31 @@ public class ShardTransactionChain extends AbstractUntypedActor {
     }
 
     public static Props props(DOMStoreTransactionChain chain, SchemaContext schemaContext,
-            ShardContext shardContext) {
-        return Props.create(new ShardTransactionChainCreator(chain, schemaContext, shardContext));
+        DatastoreContext datastoreContext, ShardStats shardStats) {
+        return Props.create(new ShardTransactionChainCreator(chain, schemaContext,
+                datastoreContext, shardStats));
     }
 
     private static class ShardTransactionChainCreator implements Creator<ShardTransactionChain> {
         private static final long serialVersionUID = 1L;
 
         final DOMStoreTransactionChain chain;
-        final ShardContext shardContext;
+        final DatastoreContext datastoreContext;
         final SchemaContext schemaContext;
+        final ShardStats shardStats;
+
 
         ShardTransactionChainCreator(DOMStoreTransactionChain chain, SchemaContext schemaContext,
-                ShardContext shardContext) {
+            DatastoreContext datastoreContext, ShardStats shardStats) {
             this.chain = chain;
-            this.shardContext = shardContext;
+            this.datastoreContext = datastoreContext;
             this.schemaContext = schemaContext;
+            this.shardStats = shardStats;
         }
 
         @Override
         public ShardTransactionChain create() throws Exception {
-            return new ShardTransactionChain(chain, schemaContext, shardContext);
+            return new ShardTransactionChain(chain, schemaContext, datastoreContext, shardStats);
         }
     }
 }