Acquire SchemaContext from ShardDataTree 84/42784/3
authorRobert Varga <rovarga@cisco.com>
Fri, 29 Jul 2016 14:02:10 +0000 (16:02 +0200)
committerTom Pantelis <tpanteli@brocade.com>
Sat, 30 Jul 2016 09:11:48 +0000 (09:11 +0000)
Instead of passing the SchemaContext explictly, make
ShardRecoveryCoordinator understand that it can obtain
the SchemaContext from ShardDataTree.

Change-Id: Id5ed521a96e8a741ad7da6199ba117b99a8f78e4
Signed-off-by: Robert Varga <rovarga@cisco.com>
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/Shard.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardRecoveryCoordinator.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardRecoveryCoordinatorTest.java

index f9f4350e9eec1b3f8d8071e35c246b55a03f1003..0c65bdab122fa1caab86b28aa90d6d16784b0e83 100644 (file)
@@ -657,8 +657,8 @@ public class Shard extends RaftActor {
     @Override
     @Nonnull
     protected RaftActorRecoveryCohort getRaftActorRecoveryCohort() {
     @Override
     @Nonnull
     protected RaftActorRecoveryCohort getRaftActorRecoveryCohort() {
-        return new ShardRecoveryCoordinator(store, store.getSchemaContext(),
-                restoreFromSnapshot != null ? restoreFromSnapshot.getSnapshot() : null, persistenceId(), LOG);
+        return new ShardRecoveryCoordinator(store,
+            restoreFromSnapshot != null ? restoreFromSnapshot.getSnapshot() : null, persistenceId(), LOG);
     }
 
     @Override
     }
 
     @Override
index 624e68dd8662b6a85fa09380352b46758c0f5732..8aacec82e15522c2014974480d85c8f7df0f110a 100644 (file)
@@ -25,7 +25,6 @@ import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidates;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataValidationFailedException;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidates;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataValidationFailedException;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.slf4j.Logger;
 
 /**
 import org.slf4j.Logger;
 
 /**
@@ -41,24 +40,22 @@ class ShardRecoveryCoordinator implements RaftActorRecoveryCohort {
     private final ShardDataTree store;
     private final String shardName;
     private final Logger log;
     private final ShardDataTree store;
     private final String shardName;
     private final Logger log;
-    private final SchemaContext schemaContext;
     private PruningDataTreeModification transaction;
     private int size;
     private final byte[] restoreFromSnapshot;
 
     private PruningDataTreeModification transaction;
     private int size;
     private final byte[] restoreFromSnapshot;
 
-    ShardRecoveryCoordinator(ShardDataTree store, SchemaContext schemaContext, byte[] restoreFromSnapshot,
-            String shardName, Logger log) {
+    ShardRecoveryCoordinator(ShardDataTree store,  byte[] restoreFromSnapshot, String shardName, Logger log) {
         this.store = Preconditions.checkNotNull(store);
         this.restoreFromSnapshot = restoreFromSnapshot;
         this.store = Preconditions.checkNotNull(store);
         this.restoreFromSnapshot = restoreFromSnapshot;
-        this.shardName = shardName;
-        this.log = log;
-        this.schemaContext = schemaContext;
+        this.shardName = Preconditions.checkNotNull(shardName);
+        this.log = Preconditions.checkNotNull(log);
     }
 
     @Override
     public void startLogRecoveryBatch(int maxBatchSize) {
         log.debug("{}: starting log recovery batch with max size {}", shardName, maxBatchSize);
     }
 
     @Override
     public void startLogRecoveryBatch(int maxBatchSize) {
         log.debug("{}: starting log recovery batch with max size {}", shardName, maxBatchSize);
-        transaction = new PruningDataTreeModification(store.newModification(), store.getDataTree(), schemaContext);
+        transaction = new PruningDataTreeModification(store.newModification(), store.getDataTree(),
+            store.getSchemaContext());
         size = 0;
     }
 
         size = 0;
     }
 
@@ -121,7 +118,7 @@ class ShardRecoveryCoordinator implements RaftActorRecoveryCohort {
 
         final NormalizedNode<?, ?> node = SerializationUtils.deserializeNormalizedNode(snapshotBytes);
         final PruningDataTreeModification tx = new PruningDataTreeModification(store.newModification(),
 
         final NormalizedNode<?, ?> node = SerializationUtils.deserializeNormalizedNode(snapshotBytes);
         final PruningDataTreeModification tx = new PruningDataTreeModification(store.newModification(),
-                store.getDataTree(), schemaContext);
+                store.getDataTree(), store.getSchemaContext());
         tx.write(YangInstanceIdentifier.EMPTY, node);
         try {
             commitTransaction(tx);
         tx.write(YangInstanceIdentifier.EMPTY, node);
         try {
             commitTransaction(tx);
index 4a8363c866d68977e0051c9bc9724a377fecce12..79ea5d4cd6e27cbb3338cd2ec797a043509a26e1 100644 (file)
@@ -49,7 +49,7 @@ public class ShardRecoveryCoordinatorTest extends AbstractTest {
     @Test
     public void testAppendRecoveredLogEntryDataTreeCandidatePayload(){
         final ShardRecoveryCoordinator coordinator = new ShardRecoveryCoordinator(peopleDataTree,
     @Test
     public void testAppendRecoveredLogEntryDataTreeCandidatePayload(){
         final ShardRecoveryCoordinator coordinator = new ShardRecoveryCoordinator(peopleDataTree,
-                peopleSchemaContext, null, "foobar", LoggerFactory.getLogger("foo"));
+                null, "foobar", LoggerFactory.getLogger("foo"));
         coordinator.startLogRecoveryBatch(10);
         try {
             coordinator.appendRecoveredLogEntry(DataTreeCandidatePayload.create(createCar()));
         coordinator.startLogRecoveryBatch(10);
         try {
             coordinator.appendRecoveredLogEntry(DataTreeCandidatePayload.create(createCar()));
@@ -63,7 +63,7 @@ public class ShardRecoveryCoordinatorTest extends AbstractTest {
     @Test
     public void testAppendRecoveredLogEntryCommitTransactionPayload() throws IOException {
         final ShardRecoveryCoordinator coordinator = new ShardRecoveryCoordinator(peopleDataTree,
     @Test
     public void testAppendRecoveredLogEntryCommitTransactionPayload() throws IOException {
         final ShardRecoveryCoordinator coordinator = new ShardRecoveryCoordinator(peopleDataTree,
-                peopleSchemaContext, null, "foobar", LoggerFactory.getLogger("foo"));
+                null, "foobar", LoggerFactory.getLogger("foo"));
         coordinator.startLogRecoveryBatch(10);
         try {
             coordinator.appendRecoveredLogEntry(CommitTransactionPayload.create(nextTransactionId(), createCar()));
         coordinator.startLogRecoveryBatch(10);
         try {
             coordinator.appendRecoveredLogEntry(CommitTransactionPayload.create(nextTransactionId(), createCar()));
@@ -77,7 +77,7 @@ public class ShardRecoveryCoordinatorTest extends AbstractTest {
     @Test
     public void testApplyRecoverySnapshot(){
         final ShardRecoveryCoordinator coordinator = new ShardRecoveryCoordinator(peopleDataTree,
     @Test
     public void testApplyRecoverySnapshot(){
         final ShardRecoveryCoordinator coordinator = new ShardRecoveryCoordinator(peopleDataTree,
-                peopleSchemaContext, null, "foobar", LoggerFactory.getLogger("foo"));
+                null, "foobar", LoggerFactory.getLogger("foo"));
         coordinator.startLogRecoveryBatch(10);
 
         coordinator.applyRecoverySnapshot(createSnapshot());
         coordinator.startLogRecoveryBatch(10);
 
         coordinator.applyRecoverySnapshot(createSnapshot());
@@ -90,7 +90,7 @@ public class ShardRecoveryCoordinatorTest extends AbstractTest {
     @Test
     public void testApplyCurrentLogRecoveryBatch(){
         final ShardRecoveryCoordinator coordinator = new ShardRecoveryCoordinator(peopleDataTree,
     @Test
     public void testApplyCurrentLogRecoveryBatch(){
         final ShardRecoveryCoordinator coordinator = new ShardRecoveryCoordinator(peopleDataTree,
-                peopleSchemaContext, null, "foobar", LoggerFactory.getLogger("foo"));
+                null, "foobar", LoggerFactory.getLogger("foo"));
         coordinator.startLogRecoveryBatch(10);
 
         try {
         coordinator.startLogRecoveryBatch(10);
 
         try {