Merge "Bug 509: Improve logging in InMemoryDataStore."
authorEd Warnicke <eaw@cisco.com>
Mon, 21 Apr 2014 21:35:07 +0000 (21:35 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Mon, 21 Apr 2014 21:35:07 +0000 (21:35 +0000)
opendaylight/md-sal/sal-common-impl/src/main/java/org/opendaylight/controller/md/sal/common/impl/util/compat/DataNormalizationOperation.java
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/ChangeListenerNotifyTask.java
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/main/java/org/opendaylight/controller/md/sal/dom/store/impl/MutableDataTree.java
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/SchemaAwareApplyOperation.java

index 1055fa81fde264b1949217b0ca860dac945918d8..ae9b17bde4c413c0fee567193c84ff72dca06913 100644 (file)
@@ -508,7 +508,7 @@ public abstract class DataNormalizationOperation<T extends PathArgument> impleme
         }
 
         if (potential == null) {
-            throw new DataNormalizationException(String.format("Supplied QName %s is not valid according to schema %s", child, schema));
+            throw new DataNormalizationException(String.format("Supplied QName %s is not valid according to schema %s, potential children nodes: %s", child, schema,schema.getChildNodes()));
         }
 
         if ((schema instanceof DataSchemaNode) && !((DataSchemaNode) schema).isAugmenting() && potential.isAugmenting()) {
index 306dc2390b9a4381067baa62506112ad42d071c7..a7952ac824d3f595fa08ead9f307ccd31fff2736 100644 (file)
@@ -31,4 +31,9 @@ class ChangeListenerNotifyTask implements Runnable {
 
     }
 
+    @Override
+    public String toString() {
+        return "ChangeListenerNotifyTask [listeners=" + listeners + ", event=" + event + "]";
+    }
+
 }
index a66fa7f1ff47075643965ad055acc7101c2b560b..6c0e5823a49f885520f902cea0647499e715482b 100644 (file)
@@ -169,6 +169,7 @@ public class InMemoryDOMDataStore implements DOMStore, Identifiable<String>, Sch
             checkState(success, "Store snapshot and transaction snapshot differ. This should never happen.");
 
             for (ChangeListenerNotifyTask task : listenerResolver.call()) {
+                LOG.trace("Scheduling invocation of listeners: {}",task);
                 executor.submit(task);
             }
         }
@@ -248,13 +249,25 @@ public class InMemoryDOMDataStore implements DOMStore, Identifiable<String>, Sch
         @Override
         public void write(final InstanceIdentifier path, final NormalizedNode<?, ?> data) {
             checkNotReady();
-            mutableTree.write(path, data);
+            try {
+                LOG.trace("Tx: {} Write: {}:{}",getIdentifier(),path,data);
+                mutableTree.write(path, data);
+              // FIXME: Add checked exception
+            } catch (Exception e) {
+                LOG.error("Tx: {}, failed to write {}:{} in {}",getIdentifier(),path,data,mutableTree,e);
+            }
         }
 
         @Override
         public void delete(final InstanceIdentifier path) {
             checkNotReady();
-            mutableTree.delete(path);
+            try {
+                LOG.trace("Tx: {} Delete: {}",getIdentifier(),path);
+                mutableTree.delete(path);
+             // FIXME: Add checked exception
+            } catch (Exception e) {
+                LOG.error("Tx: {}, failed to delete {} in {}",getIdentifier(),path,mutableTree,e);
+            }
         }
 
         protected final boolean isReady() {
@@ -295,7 +308,13 @@ public class InMemoryDOMDataStore implements DOMStore, Identifiable<String>, Sch
 
         @Override
         public ListenableFuture<Optional<NormalizedNode<?, ?>>> read(final InstanceIdentifier path) {
-            return Futures.immediateFuture(getMutatedView().read(path));
+            LOG.trace("Tx: {} Read: {}",getIdentifier(),path);
+            try {
+                return Futures.immediateFuture(getMutatedView().read(path));
+            } catch (Exception e) {
+                LOG.error("Tx: {} Failed Read of {}",getIdentifier(),path,e);
+                throw e;
+            }
         }
     }
 
index 14d82799d76ec3d0a58b7797ab9d718163072c6c..bc7fe7a2c7aa69dc6bf6979497abd480d147863c 100644 (file)
@@ -80,7 +80,7 @@ class MutableDataTree {
             return resolveModificationStrategy(path).apply(modification, modification.getOriginal(),
                     StoreUtils.increase(snapshot.getMetadataTree().getSubtreeVersion()));
         } catch (Exception e) {
-            LOG.error("Could not create snapshot for {}", path,e);
+            LOG.error("Could not create snapshot for {}:{}", path,modification,e);
             throw e;
         }
     }
index 00727347eea95f7378ebc53fc9cf97d3cc7fc7f5..dd7eb3f71b68012b497bee6b5fb2119bcf9455c9 100644 (file)
@@ -45,6 +45,7 @@ import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
 
 import com.google.common.base.Function;
 import com.google.common.base.Optional;
+import com.google.common.base.Preconditions;
 import com.google.common.cache.CacheBuilder;
 import com.google.common.cache.CacheLoader;
 import com.google.common.cache.LoadingCache;
@@ -153,6 +154,7 @@ public abstract class SchemaAwareApplyOperation implements ModificationApplyOper
         case DELETE:
             return modification.storeSnapshot(Optional.<StoreMetadataNode>absent());
         case SUBTREE_MODIFIED:
+            Preconditions.checkArgument(currentMeta.isPresent(),"Metadata not available for modification",modification);
             return modification.storeSnapshot(Optional.of(applySubtreeChange(modification, currentMeta.get(), subtreeVersion)));
         case WRITE:
             return modification.storeSnapshot(Optional.of(applyWrite(modification, currentMeta, subtreeVersion)));