Merge "Bug 1352: Fixed issue when ModificationSnapshot was not updated during schema...
authorTony Tkacik <ttkacik@cisco.com>
Thu, 10 Jul 2014 18:18:35 +0000 (18:18 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Thu, 10 Jul 2014 18:18:35 +0000 (18:18 +0000)
1  2 
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/InMemoryDataTree.java

index 42ef2023f2ff0a6594a79367883d739e38d85e5d,6102018d48fdc918781d8acfb6c0ea774a320c8e..7013e55ad1fccdafcb4eb0c9e1550bfa9a4352df
@@@ -7,8 -7,9 +7,9 @@@
   */
  package org.opendaylight.yangtools.yang.data.impl.schema.tree;
  
- import com.google.common.base.Optional;
- import com.google.common.base.Preconditions;
+ import java.util.concurrent.locks.ReadWriteLock;
+ import java.util.concurrent.locks.ReentrantReadWriteLock;
  import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
  import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree;
  import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate;
@@@ -16,12 -17,13 +17,13 @@@ import org.opendaylight.yangtools.yang.
  import org.opendaylight.yangtools.yang.data.api.schema.tree.DataValidationFailedException;
  import org.opendaylight.yangtools.yang.data.api.schema.tree.ModificationType;
  import org.opendaylight.yangtools.yang.data.api.schema.tree.spi.TreeNode;
+ import org.opendaylight.yangtools.yang.data.impl.schema.tree.RootModificationApplyOperation.LatestOperationHolder;
  import org.opendaylight.yangtools.yang.model.api.SchemaContext;
  import org.slf4j.Logger;
  import org.slf4j.LoggerFactory;
  
- import java.util.concurrent.locks.ReadWriteLock;
- import java.util.concurrent.locks.ReentrantReadWriteLock;
+ import com.google.common.base.Optional;
+ import com.google.common.base.Preconditions;
  
  /**
   * Read-only snapshot of the data tree.
@@@ -31,7 -33,7 +33,7 @@@ final class InMemoryDataTree implement
      private static final InstanceIdentifier PUBLIC_ROOT_PATH = InstanceIdentifier.builder().build();
  
      private final ReadWriteLock rwLock = new ReentrantReadWriteLock(true);
-     private ModificationApplyOperation applyOper = new AlwaysFailOperation();
+     private final LatestOperationHolder operationHolder = new LatestOperationHolder();
      private SchemaContext currentSchemaContext;
      private TreeNode rootNode;
  
@@@ -48,7 -50,7 +50,7 @@@
      public synchronized void setSchemaContext(final SchemaContext newSchemaContext) {
          Preconditions.checkNotNull(newSchemaContext);
  
 -        LOG.info("Attepting to install schema context {}", newSchemaContext);
 +        LOG.info("Attempting to install schema context {}", newSchemaContext);
  
          /*
           * FIXME: we should walk the schema contexts, both current and new and see
@@@ -61,7 -63,7 +63,7 @@@
          // Ready to change the context now, make sure no operations are running
          rwLock.writeLock().lock();
          try {
-             this.applyOper = newApplyOper;
+             this.operationHolder.setCurrent(newApplyOper);
              this.currentSchemaContext = newSchemaContext;
          } finally {
              rwLock.writeLock().unlock();
@@@ -72,7 -74,7 +74,7 @@@
      public InMemoryDataTreeSnapshot takeSnapshot() {
          rwLock.readLock().lock();
          try {
-             return new InMemoryDataTreeSnapshot(currentSchemaContext, rootNode, applyOper);
+             return new InMemoryDataTreeSnapshot(currentSchemaContext, rootNode, operationHolder.newSnapshot());
          } finally {
              rwLock.readLock().unlock();
          }