BUG-509: Rename MutableDataTree to DataTreeModification 21/7221/2
authorRobert Varga <rovarga@cisco.com>
Mon, 19 May 2014 09:30:53 +0000 (11:30 +0200)
committerRobert Varga <rovarga@cisco.com>
Tue, 20 May 2014 12:08:50 +0000 (14:08 +0200)
This name better reflects the semantics of the class. Also add some
javadoc documentation.

Change-Id: I7292c134bf87af8c0518e2905c7bd2b628c37a25
Signed-off-by: Robert Varga <rovarga@cisco.com>
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/DataTreeModification.java [moved from opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/MutableDataTree.java with 89% similarity]
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/InMemoryDOMDataStore.java
opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/ModificationMetadataTreeTest.java

@@ -26,18 +26,23 @@ import org.slf4j.LoggerFactory;
 import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
 
+/**
+ * Class encapsulation of set of modifications to a base tree. This tree is backed
+ * by a read-only snapshot and tracks modifications on top of that. The modification
+ * has the ability to rebase itself on a new snapshot.
+ */
 /*
  * FIXME: the thread safety of concurrent write/delete/read/seal operations
  *        needs to be evaluated.
  */
-class MutableDataTree {
-    private static final Logger LOG = LoggerFactory.getLogger(MutableDataTree.class);
+class DataTreeModification {
+    private static final Logger LOG = LoggerFactory.getLogger(DataTreeModification.class);
     private final AtomicBoolean sealed = new AtomicBoolean();
     private final ModificationApplyOperation strategyTree;
     private final NodeModification rootModification;
     private final DataTree.Snapshot snapshot;
 
-    private MutableDataTree(final DataTree.Snapshot snapshot, final ModificationApplyOperation strategyTree) {
+    private DataTreeModification(final DataTree.Snapshot snapshot, final ModificationApplyOperation strategyTree) {
         this.snapshot = Preconditions.checkNotNull(snapshot);
         this.strategyTree = Preconditions.checkNotNull(strategyTree);
         this.rootModification = NodeModification.createUnmodified(snapshot.getRootNode());
@@ -119,8 +124,8 @@ class MutableDataTree {
         return OperationWithModification.from(operation, modification);
     }
 
-    public static MutableDataTree from(final DataTree.Snapshot snapshot, final ModificationApplyOperation resolver) {
-        return new MutableDataTree(snapshot, resolver);
+    public static DataTreeModification from(final DataTree.Snapshot snapshot, final ModificationApplyOperation resolver) {
+        return new DataTreeModification(snapshot, resolver);
     }
 
     public void seal() {
index 7d2ff30b1fe64f96d89619894e83d26880f8bd73..427e7a00dbb443e1bc0f5de8553aa66ab5fc63c8 100644 (file)
@@ -222,14 +222,14 @@ public class InMemoryDOMDataStore implements DOMStore, Identifiable<String>, Sch
 
     private static class SnapshotBackedWriteTransaction extends AbstractDOMStoreTransaction implements
             DOMStoreWriteTransaction {
-        private MutableDataTree mutableTree;
+        private DataTreeModification mutableTree;
         private InMemoryDOMDataStore store;
         private boolean ready = false;
 
         public SnapshotBackedWriteTransaction(final Object identifier, final DataTree.Snapshot snapshot,
                 final InMemoryDOMDataStore store, final ModificationApplyOperation applyOper) {
             super(identifier);
-            mutableTree = MutableDataTree.from(snapshot, applyOper);
+            mutableTree = DataTreeModification.from(snapshot, applyOper);
             this.store = store;
             LOG.debug("Write Tx: {} allocated with snapshot {}", identifier, snapshot);
         }
@@ -295,7 +295,7 @@ public class InMemoryDOMDataStore implements DOMStore, Identifiable<String>, Sch
             return store.submit(this);
         }
 
-        protected MutableDataTree getMutatedView() {
+        protected DataTreeModification getMutatedView() {
             return mutableTree;
         }
 
index 0445c47c6bcb29fa3825f9971bd8e50a8b7f9d45..efa5068fb61a2ebbcfc7eb8e9e4ca35d7fd3ac40 100644 (file)
@@ -137,7 +137,7 @@ public class ModificationMetadataTreeTest {
 
     @Test
     public void basicReadWrites() {
-        MutableDataTree modificationTree = MutableDataTree.from(new DataTree.Snapshot(schemaContext,
+        DataTreeModification modificationTree = DataTreeModification.from(new DataTree.Snapshot(schemaContext,
                 StoreMetadataNode.createRecursively(createDocumentOne(), UnsignedLong.valueOf(5))),
                 new SchemaAwareApplyOperationRoot(schemaContext));
         Optional<NormalizedNode<?, ?>> originalBarNode = modificationTree.read(OUTER_LIST_2_PATH);
@@ -160,7 +160,7 @@ public class ModificationMetadataTreeTest {
     }
 
 
-    public MutableDataTree createEmptyModificationTree() {
+    public DataTreeModification createEmptyModificationTree() {
         /**
          * Creates empty Snapshot with associated schema context.
          */
@@ -172,7 +172,7 @@ public class ModificationMetadataTreeTest {
          * context.
          *
          */
-        MutableDataTree modificationTree = MutableDataTree.from(t.takeSnapshot(), new SchemaAwareApplyOperationRoot(
+        DataTreeModification modificationTree = DataTreeModification.from(t.takeSnapshot(), new SchemaAwareApplyOperationRoot(
                 schemaContext));
         return modificationTree;
     }
@@ -180,7 +180,7 @@ public class ModificationMetadataTreeTest {
     @Test
     public void createFromEmptyState() {
 
-        MutableDataTree modificationTree = createEmptyModificationTree();
+        DataTreeModification modificationTree = createEmptyModificationTree();
         /**
          * Writes empty container node to /test
          *
@@ -217,7 +217,7 @@ public class ModificationMetadataTreeTest {
 
     @Test
     public void writeSubtreeReadChildren() {
-        MutableDataTree modificationTree = createEmptyModificationTree();
+        DataTreeModification modificationTree = createEmptyModificationTree();
         modificationTree.write(TEST_PATH, createTestContainer());
         Optional<NormalizedNode<?, ?>> potential = modificationTree.read(TWO_TWO_PATH);
         MapEntryNode node = assertPresentAndType(potential, MapEntryNode.class);
@@ -225,7 +225,7 @@ public class ModificationMetadataTreeTest {
 
     @Test
     public void writeSubtreeDeleteChildren() {
-        MutableDataTree modificationTree = createEmptyModificationTree();
+        DataTreeModification modificationTree = createEmptyModificationTree();
         modificationTree.write(TEST_PATH, createTestContainer());
 
         // We verify data are present