Merge "Bug 3068 - checkRpcResponse - CancellationException" into stable/lithium
authorTony Tkacik <ttkacik@cisco.com>
Tue, 5 May 2015 13:49:48 +0000 (13:49 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Tue, 5 May 2015 13:49:48 +0000 (13:49 +0000)
28 files changed:
opendaylight/md-sal/messagebus-impl/src/main/java/org/opendaylight/controller/messagebus/app/impl/EventSourceTopology.java
opendaylight/md-sal/sal-binding-broker/pom.xml
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ConcurrentDOMDataBroker.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DistributedDataStore.java
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/ShardSnapshotCohort.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardTransaction.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardTransactionChain.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardTransactionFactory.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/TransactionChainProxy.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/TransactionContextImpl.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/TransactionFutureCallback.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/TransactionProxy.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/TransactionType.java [new file with mode: 0644]
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/compat/PreLithiumTransactionContextImpl.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/identifiers/ChainedTransactionIdentifier.java [new file with mode: 0644]
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/identifiers/TransactionIdentifier.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/AbstractTransactionProxyTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardTransactionFailureTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardTransactionTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/TransactionChainProxyTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/TransactionProxyTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/compat/PreLithiumTransactionProxyTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/compat/ShardTransactionHeliumBackwardsCompatibilityTest.java
opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/RestconfProviderImpl.java
opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/StatisticsRestconfServiceWrapper.java
opendaylight/md-sal/sal-rest-connector/src/main/yang/opendaylight-rest-connector.yang

index 10b9ec83cde9080a5eb652ea69b65936973b0f60..7771b82491f61f90207ac737742538bf370323d0 100644 (file)
@@ -78,10 +78,10 @@ public class EventSourceTopology implements EventAggregatorService, EventSourceR
                     .child(TopologyTypes.class)
                     .augmentation(TopologyTypes1.class);
 
-    private final Map<DataChangeListener, ListenerRegistration<DataChangeListener>> topicListenerRegistrations =
+    private final Map<EventSourceTopic, ListenerRegistration<DataChangeListener>> topicListenerRegistrations =
             new ConcurrentHashMap<>();
     private final Map<NodeKey, RoutedRpcRegistration<EventSourceService>> routedRpcRegistrations =
-            new ConcurrentHashMap<>();;
+            new ConcurrentHashMap<>();
 
     private final DataBroker dataBroker;
     private final RpcRegistration<EventAggregatorService> aggregatorRpcReg;
@@ -205,12 +205,16 @@ public class EventSourceTopology implements EventAggregatorService, EventSourceR
     }
 
     public void register(final EventSource eventSource){
-    NodeKey nodeKey = eventSource.getSourceNodeKey();
+        NodeKey nodeKey = eventSource.getSourceNodeKey();
         final KeyedInstanceIdentifier<Node, NodeKey> sourcePath = EVENT_SOURCE_TOPOLOGY_PATH.child(Node.class, nodeKey);
         RoutedRpcRegistration<EventSourceService> reg = rpcRegistry.addRoutedRpcImplementation(EventSourceService.class, eventSource);
         reg.registerPath(NodeContext.class, sourcePath);
         routedRpcRegistrations.put(nodeKey,reg);
         insert(sourcePath);
+
+        for(EventSourceTopic est : topicListenerRegistrations.keySet()){
+            est.notifyNode(EVENT_SOURCE_TOPOLOGY_PATH.child(Node.class, nodeKey));
+        }
     }
 
     public void unRegister(final EventSource eventSource){
index b392eb240292351280ef2de81781d815835dc53e..bd67973b8c958d9fc1c0ddde20930fcefc0db8d6 100644 (file)
         <configuration>
           <instructions>
             <Bundle-Name>${project.groupId}.${project.artifactId}</Bundle-Name>
-            <Export-package>org.opendaylight.controller.sal.binding.spi.*,</Export-package>
+            <Export-Package>
+                            org.opendaylight.controller.sal.binding.spi.*,
+                            org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.binding.impl.rev131028.*,
+                            org.opendaylight.controller.config.yang.md.sal.binding.impl
+            </Export-Package>
             <Private-Package>
-              org.opendaylight.controller.config.yang.md.sal.binding.impl,
                             org.opendaylight.controller.sal.binding.impl,
                             org.opendaylight.controller.sal.binding.impl.*,
                             org.opendaylight.controller.sal.binding.codegen,
                             org.opendaylight.controller.md.sal.binding.compat,
                             org.opendaylight.controller.md.sal.binding.spi,
               <!--org.opendaylight.controller.sal.binding.dom.*,-->
-              org.opendaylight.controller.sal.binding.osgi.*,
-                            org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.binding.impl.rev131028.*
+                            org.opendaylight.controller.sal.binding.osgi.*
             </Private-Package>
           </instructions>
         </configuration>
index b48e5946da46ecdc00b0a4c82dc5263ffcd13efc..aa5040fb11215711af2a511621d0831b8cd0c138 100644 (file)
@@ -9,18 +9,16 @@ package org.opendaylight.controller.cluster.datastore;
 
 import com.google.common.base.Preconditions;
 import com.google.common.util.concurrent.AbstractFuture;
-import com.google.common.util.concurrent.AbstractListeningExecutorService;
 import com.google.common.util.concurrent.CheckedFuture;
 import com.google.common.util.concurrent.FutureCallback;
 import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListenableFuture;
+import com.google.common.util.concurrent.MoreExecutors;
 import java.util.Collection;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.concurrent.Executor;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.TimeUnit;
 import org.opendaylight.controller.cluster.databroker.AbstractDOMBroker;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
@@ -51,15 +49,9 @@ public class ConcurrentDOMDataBroker extends AbstractDOMBroker {
     /**
      * This executor is used to execute Future listener callback Runnables async.
      */
-    private final ExecutorService clientFutureCallbackExecutor;
+    private final Executor clientFutureCallbackExecutor;
 
-    /**
-     * This executor is re-used internally in calls to Futures#addCallback to avoid the overhead
-     * of Futures#addCallback creating a MoreExecutors#sameThreadExecutor for each call.
-     */
-    private final ExecutorService internalFutureCallbackExecutor = new SimpleSameThreadExecutor();
-
-    public ConcurrentDOMDataBroker(final Map<LogicalDatastoreType, DOMStore> datastores, ExecutorService listenableFutureExecutor) {
+    public ConcurrentDOMDataBroker(final Map<LogicalDatastoreType, DOMStore> datastores, Executor listenableFutureExecutor) {
         super(datastores);
         this.clientFutureCallbackExecutor = Preconditions.checkNotNull(listenableFutureExecutor);
     }
@@ -69,7 +61,7 @@ public class ConcurrentDOMDataBroker extends AbstractDOMBroker {
     }
 
     @Override
-    public CheckedFuture<Void, TransactionCommitFailedException> submit(DOMDataWriteTransaction transaction,
+    protected CheckedFuture<Void, TransactionCommitFailedException> submit(DOMDataWriteTransaction transaction,
             Collection<DOMStoreThreePhaseCommitCohort> cohorts) {
 
         Preconditions.checkArgument(transaction != null, "Transaction must not be null.");
@@ -112,7 +104,7 @@ public class ConcurrentDOMDataBroker extends AbstractDOMBroker {
                         doPreCommit(startTime, clientSubmitFuture, transaction, cohorts);
                     } else {
                         ListenableFuture<Boolean> canCommitFuture = cohortIterator.next().canCommit();
-                        Futures.addCallback(canCommitFuture, this, internalFutureCallbackExecutor);
+                        Futures.addCallback(canCommitFuture, this, MoreExecutors.directExecutor());
                     }
                 }
             }
@@ -125,7 +117,7 @@ public class ConcurrentDOMDataBroker extends AbstractDOMBroker {
         };
 
         ListenableFuture<Boolean> canCommitFuture = cohortIterator.next().canCommit();
-        Futures.addCallback(canCommitFuture, futureCallback, internalFutureCallbackExecutor);
+        Futures.addCallback(canCommitFuture, futureCallback, MoreExecutors.directExecutor());
     }
 
     private void doPreCommit(final long startTime, final AsyncNotifyingSettableFuture clientSubmitFuture,
@@ -143,7 +135,7 @@ public class ConcurrentDOMDataBroker extends AbstractDOMBroker {
                     doCommit(startTime, clientSubmitFuture, transaction, cohorts);
                 } else {
                     ListenableFuture<Void> preCommitFuture = cohortIterator.next().preCommit();
-                    Futures.addCallback(preCommitFuture, this, internalFutureCallbackExecutor);
+                    Futures.addCallback(preCommitFuture, this, MoreExecutors.directExecutor());
                 }
             }
 
@@ -155,7 +147,7 @@ public class ConcurrentDOMDataBroker extends AbstractDOMBroker {
         };
 
         ListenableFuture<Void> preCommitFuture = cohortIterator.next().preCommit();
-        Futures.addCallback(preCommitFuture, futureCallback, internalFutureCallbackExecutor);
+        Futures.addCallback(preCommitFuture, futureCallback, MoreExecutors.directExecutor());
     }
 
     private void doCommit(final long startTime, final AsyncNotifyingSettableFuture clientSubmitFuture,
@@ -175,7 +167,7 @@ public class ConcurrentDOMDataBroker extends AbstractDOMBroker {
                     clientSubmitFuture.set();
                 } else {
                     ListenableFuture<Void> commitFuture = cohortIterator.next().commit();
-                    Futures.addCallback(commitFuture, this, internalFutureCallbackExecutor);
+                    Futures.addCallback(commitFuture, this, MoreExecutors.directExecutor());
                 }
             }
 
@@ -187,23 +179,23 @@ public class ConcurrentDOMDataBroker extends AbstractDOMBroker {
         };
 
         ListenableFuture<Void> commitFuture = cohortIterator.next().commit();
-        Futures.addCallback(commitFuture, futureCallback, internalFutureCallbackExecutor);
+        Futures.addCallback(commitFuture, futureCallback, MoreExecutors.directExecutor());
     }
 
-    private void handleException(final AsyncNotifyingSettableFuture clientSubmitFuture,
+    private static void handleException(final AsyncNotifyingSettableFuture clientSubmitFuture,
             final DOMDataWriteTransaction transaction,
             final Collection<DOMStoreThreePhaseCommitCohort> cohorts,
             final String phase, final TransactionCommitFailedExceptionMapper exMapper,
             final Throwable t) {
 
-        if(clientSubmitFuture.isDone()) {
+        if (clientSubmitFuture.isDone()) {
             // We must have had failures from multiple cohorts.
             return;
         }
 
         LOG.warn("Tx: {} Error during phase {}, starting Abort", transaction.getIdentifier(), phase, t);
-        Exception e;
-        if(t instanceof Exception) {
+        final Exception e;
+        if (t instanceof Exception) {
             e = (Exception)t;
         } else {
             e = new RuntimeException("Unexpected error occurred", t);
@@ -216,7 +208,7 @@ public class ConcurrentDOMDataBroker extends AbstractDOMBroker {
         @SuppressWarnings("unchecked")
         ListenableFuture<Void>[] canCommitFutures = new ListenableFuture[cohorts.size()];
         int i = 0;
-        for(DOMStoreThreePhaseCommitCohort cohort: cohorts) {
+        for (DOMStoreThreePhaseCommitCohort cohort : cohorts) {
             canCommitFutures[i++] = cohort.abort();
         }
 
@@ -236,7 +228,7 @@ public class ConcurrentDOMDataBroker extends AbstractDOMBroker {
                 // what's interesting to the client.
                 clientSubmitFuture.setException(clientException);
             }
-        }, internalFutureCallbackExecutor);
+        }, MoreExecutors.directExecutor());
     }
 
     /**
@@ -257,10 +249,10 @@ public class ConcurrentDOMDataBroker extends AbstractDOMBroker {
          */
         private static final ThreadLocal<Boolean> ON_TASK_COMPLETION_THREAD_TL = new ThreadLocal<Boolean>();
 
-        private final ExecutorService listenerExecutor;
+        private final Executor listenerExecutor;
 
-        AsyncNotifyingSettableFuture(ExecutorService listenerExecutor) {
-            this.listenerExecutor = listenerExecutor;
+        AsyncNotifyingSettableFuture(Executor listenerExecutor) {
+            this.listenerExecutor = Preconditions.checkNotNull(listenerExecutor);
         }
 
         @Override
@@ -321,41 +313,4 @@ public class ConcurrentDOMDataBroker extends AbstractDOMBroker {
             }
         }
     }
-
-    /**
-     * A simple same-thread executor without the internal locking overhead that
-     * MoreExecutors#sameThreadExecutor has. The #execute method is the only one of concern - we
-     * don't shutdown the executor so the other methods irrelevant.
-     */
-    private static class SimpleSameThreadExecutor extends AbstractListeningExecutorService {
-
-        @Override
-        public void execute(Runnable command) {
-            command.run();
-        }
-
-        @Override
-        public boolean awaitTermination(long arg0, TimeUnit arg1) throws InterruptedException {
-            return true;
-        }
-
-        @Override
-        public boolean isShutdown() {
-            return false;
-        }
-
-        @Override
-        public boolean isTerminated() {
-            return false;
-        }
-
-        @Override
-        public void shutdown() {
-        }
-
-        @Override
-        public List<Runnable> shutdownNow() {
-            return null;
-        }
-    }
 }
index 69c127f2897017f218222b2a95b270b1bcc9f0de..a136cc6f75392e9d95426fe786d10e9381a1a6cd 100644 (file)
@@ -149,19 +149,19 @@ public class DistributedDataStore implements DOMStore, SchemaContextListener,
 
     @Override
     public DOMStoreReadTransaction newReadOnlyTransaction() {
-        return new TransactionProxy(actorContext, TransactionProxy.TransactionType.READ_ONLY);
+        return new TransactionProxy(actorContext, TransactionType.READ_ONLY);
     }
 
     @Override
     public DOMStoreWriteTransaction newWriteOnlyTransaction() {
         actorContext.acquireTxCreationPermit();
-        return new TransactionProxy(actorContext, TransactionProxy.TransactionType.WRITE_ONLY);
+        return new TransactionProxy(actorContext, TransactionType.WRITE_ONLY);
     }
 
     @Override
     public DOMStoreReadWriteTransaction newReadWriteTransaction() {
         actorContext.acquireTxCreationPermit();
-        return new TransactionProxy(actorContext, TransactionProxy.TransactionType.READ_WRITE);
+        return new TransactionProxy(actorContext, TransactionType.READ_WRITE);
     }
 
     @Override
index e62e918e5e7eff53b8f7e00dbe1e8300d270b59f..2fd51de8b674be89a065f28d5f2cacd16ec101fc 100644 (file)
@@ -493,7 +493,7 @@ public class Shard extends RaftActor {
             ShardTransactionIdentifier transactionId, String transactionChainId,
             short clientVersion ) {
 
-        return transactionActorFactory.newShardTransaction(TransactionProxy.TransactionType.fromInt(transactionType),
+        return transactionActorFactory.newShardTransaction(TransactionType.fromInt(transactionType),
                 transactionId, transactionChainId, clientVersion);
     }
 
index 600509a26b87b480156f4baf843f2b887ed4f655..c4ac727cb3b59fa3efa77b2ef3ccf7427c2a81a7 100644 (file)
@@ -51,7 +51,7 @@ class ShardSnapshotCohort implements RaftActorSnapshotCohort {
                 "createSnapshot" + ++createSnapshotTransactionCounter);
 
         ActorRef createSnapshotTransaction = transactionActorFactory.newShardTransaction(
-                TransactionProxy.TransactionType.READ_ONLY, transactionID, "", DataStoreVersions.CURRENT_VERSION);
+                TransactionType.READ_ONLY, transactionID, "", DataStoreVersions.CURRENT_VERSION);
 
         createSnapshotTransaction.tell(CreateSnapshot.INSTANCE, actorRef);
     }
index 600ec393971ffe72efd12dfaaaf472cc61edd204..4f59f9feb52a5da87310d8d5e442bd2ca4dcf6b8 100644 (file)
@@ -16,7 +16,6 @@ import akka.japi.Creator;
 import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
 import org.opendaylight.controller.cluster.common.actor.AbstractUntypedActorWithMetering;
-import org.opendaylight.controller.cluster.datastore.TransactionProxy.TransactionType;
 import org.opendaylight.controller.cluster.datastore.exceptions.UnknownMessageException;
 import org.opendaylight.controller.cluster.datastore.jmx.mbeans.shard.ShardStats;
 import org.opendaylight.controller.cluster.datastore.messages.CloseTransaction;
index 7a163088d4bec3938132285810ae35d70f2127fe..aedc6c42b862d0cc2ffd94fc9082b82d38f2aa2e 100644 (file)
@@ -13,7 +13,6 @@ 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.TransactionProxy.TransactionType;
 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;
index 3a92062e7f86972d55fe7f230c655898d0f0acfb..f8b8b9c95252834b2f0661a2658005124c53ef0f 100644 (file)
@@ -37,7 +37,7 @@ class ShardTransactionActorFactory {
         this.shardActor = shardActor;
     }
 
-    ActorRef newShardTransaction(TransactionProxy.TransactionType type, ShardTransactionIdentifier transactionID,
+    ActorRef newShardTransaction(TransactionType type, ShardTransactionIdentifier transactionID,
             String transactionChainID, short clientVersion) {
         final AbstractShardDataTreeTransaction<?> transaction;
         switch (type) {
index cf261cbd2af103b70f3dfce9885903a88ee293e6..97f3e7444d3ee564c88845256e7448209036fe09 100644 (file)
@@ -91,20 +91,20 @@ public class TransactionChainProxy implements DOMStoreTransactionChain {
         State localState = currentState;
         checkReadyState(localState);
 
-        return new ChainedTransactionProxy(actorContext, TransactionProxy.TransactionType.READ_ONLY,
+        return new ChainedTransactionProxy(actorContext, TransactionType.READ_ONLY,
                 transactionChainId, localState.getPreviousReadyFutures());
     }
 
     @Override
     public DOMStoreReadWriteTransaction newReadWriteTransaction() {
         actorContext.acquireTxCreationPermit();
-        return allocateWriteTransaction(TransactionProxy.TransactionType.READ_WRITE);
+        return allocateWriteTransaction(TransactionType.READ_WRITE);
     }
 
     @Override
     public DOMStoreWriteTransaction newWriteOnlyTransaction() {
         actorContext.acquireTxCreationPermit();
-        return allocateWriteTransaction(TransactionProxy.TransactionType.WRITE_ONLY);
+        return allocateWriteTransaction(TransactionType.WRITE_ONLY);
     }
 
     @Override
@@ -115,7 +115,7 @@ public class TransactionChainProxy implements DOMStoreTransactionChain {
         actorContext.broadcast(new CloseTransactionChain(transactionChainId).toSerializable());
     }
 
-    private ChainedTransactionProxy allocateWriteTransaction(TransactionProxy.TransactionType type) {
+    private ChainedTransactionProxy allocateWriteTransaction(TransactionType type) {
         State localState = currentState;
 
         checkReadyState(localState);
index a9deeaaeba0806a1ad355dfeb40216d4a624219f..b6fe2c29bda9872245c90fa93f7aea7c4eeb6d5c 100644 (file)
@@ -30,7 +30,6 @@ import org.opendaylight.controller.cluster.datastore.utils.ActorContext;
 import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import scala.concurrent.Future;
@@ -38,7 +37,6 @@ import scala.concurrent.Future;
 public class TransactionContextImpl extends AbstractTransactionContext {
     private static final Logger LOG = LoggerFactory.getLogger(TransactionContextImpl.class);
 
-    private final String transactionChainId;
     private final ActorContext actorContext;
     private final ActorSelection actor;
     private final boolean isTxActorLocal;
@@ -49,11 +47,10 @@ public class TransactionContextImpl extends AbstractTransactionContext {
     private int totalBatchedModificationsSent;
 
     protected TransactionContextImpl(ActorSelection actor, TransactionIdentifier identifier,
-            String transactionChainId, ActorContext actorContext, SchemaContext schemaContext, boolean isTxActorLocal,
+            ActorContext actorContext, boolean isTxActorLocal,
             short remoteTransactionVersion, OperationCompleter operationCompleter) {
         super(identifier);
         this.actor = actor;
-        this.transactionChainId = transactionChainId;
         this.actorContext = actorContext;
         this.isTxActorLocal = isTxActorLocal;
         this.remoteTransactionVersion = remoteTransactionVersion;
@@ -142,7 +139,7 @@ public class TransactionContextImpl extends AbstractTransactionContext {
     }
 
     private BatchedModifications newBatchedModifications() {
-        return new BatchedModifications(getIdentifier().toString(), remoteTransactionVersion, transactionChainId);
+        return new BatchedModifications(getIdentifier().toString(), remoteTransactionVersion, getIdentifier().getChainId());
     }
 
     private void batchModification(Modification modification) {
index a8a93c5e7ce196a2a5e7c0a0e60678b40bbb0854..0fddd66c54cbe77ece3f7d52a40f8a009c1e978c 100644 (file)
@@ -17,7 +17,6 @@ import java.util.List;
 import java.util.concurrent.Semaphore;
 import java.util.concurrent.TimeUnit;
 import javax.annotation.concurrent.GuardedBy;
-import org.opendaylight.controller.cluster.datastore.TransactionProxy.TransactionType;
 import org.opendaylight.controller.cluster.datastore.exceptions.NoShardLeaderException;
 import org.opendaylight.controller.cluster.datastore.identifiers.TransactionIdentifier;
 import org.opendaylight.controller.cluster.datastore.messages.CreateTransaction;
index e397ab501c064adf98c5ee6c2f6708f05eb6f2fe..5081c9b4f8f652e55e5241733051bc8064aa96e2 100644 (file)
@@ -62,23 +62,6 @@ import scala.concurrent.Promise;
  */
 public class TransactionProxy extends AbstractDOMStoreTransaction<TransactionIdentifier> implements DOMStoreReadWriteTransaction {
 
-    public static enum TransactionType {
-        READ_ONLY,
-        WRITE_ONLY,
-        READ_WRITE;
-
-        // Cache all values
-        private static final TransactionType[] VALUES = values();
-
-        public static TransactionType fromInt(final int type) {
-            try {
-                return VALUES[type];
-            } catch (IndexOutOfBoundsException e) {
-                throw new IllegalArgumentException("In TransactionType enum value " + type, e);
-            }
-        }
-    }
-
     private static enum TransactionState {
         OPEN,
         READY,
@@ -114,7 +97,6 @@ public class TransactionProxy extends AbstractDOMStoreTransaction<TransactionIde
 
     private final TransactionType transactionType;
     final ActorContext actorContext;
-    private final String transactionChainId;
     private final SchemaContext schemaContext;
     private TransactionState state = TransactionState.OPEN;
 
@@ -127,25 +109,24 @@ public class TransactionProxy extends AbstractDOMStoreTransaction<TransactionIde
     }
 
     public TransactionProxy(ActorContext actorContext, TransactionType transactionType, String transactionChainId) {
-        super(createIdentifier(actorContext));
+        super(createIdentifier(actorContext, transactionChainId));
         this.actorContext = Preconditions.checkNotNull(actorContext,
             "actorContext should not be null");
         this.transactionType = Preconditions.checkNotNull(transactionType,
             "transactionType should not be null");
         this.schemaContext = Preconditions.checkNotNull(actorContext.getSchemaContext(),
             "schemaContext should not be null");
-        this.transactionChainId = transactionChainId;
 
         LOG.debug("Created txn {} of type {} on chain {}", getIdentifier(), transactionType, transactionChainId);
     }
 
-    private static TransactionIdentifier createIdentifier(ActorContext actorContext) {
+    private static TransactionIdentifier createIdentifier(ActorContext actorContext, String transactionChainId) {
         String memberName = actorContext.getCurrentMemberName();
         if (memberName == null) {
             memberName = "UNKNOWN-MEMBER";
         }
 
-        return new TransactionIdentifier(memberName, counter.getAndIncrement());
+        return TransactionIdentifier.create(memberName, counter.getAndIncrement(), transactionChainId);
     }
 
     @VisibleForTesting
@@ -381,7 +362,7 @@ public class TransactionProxy extends AbstractDOMStoreTransaction<TransactionIde
         TransactionFutureCallback txFutureCallback = txFutureCallbackMap.values().iterator().next();
 
         LOG.debug("Tx {} Readying transaction for shard {} on chain {}", getIdentifier(),
-                txFutureCallback.getShardName(), transactionChainId);
+                txFutureCallback.getShardName(), getTransactionChainId());
 
         final OperationCallback.Reference operationCallbackRef =
                 new OperationCallback.Reference(OperationCallback.NO_OP_CALLBACK);
@@ -421,7 +402,7 @@ public class TransactionProxy extends AbstractDOMStoreTransaction<TransactionIde
         for(TransactionFutureCallback txFutureCallback : txFutureCallbackMap.values()) {
 
             LOG.debug("Tx {} Readying transaction for shard {} on chain {}", getIdentifier(),
-                        txFutureCallback.getShardName(), transactionChainId);
+                        txFutureCallback.getShardName(), getTransactionChainId());
 
             final TransactionContext transactionContext = txFutureCallback.getTransactionContext();
             final Future<ActorSelection> future;
@@ -521,7 +502,7 @@ public class TransactionProxy extends AbstractDOMStoreTransaction<TransactionIde
     }
 
     String getTransactionChainId() {
-        return transactionChainId;
+        return getIdentifier().getChainId();
     }
 
     protected ActorContext getActorContext() {
@@ -558,11 +539,11 @@ public class TransactionProxy extends AbstractDOMStoreTransaction<TransactionIde
 
         if(remoteTransactionVersion < DataStoreVersions.LITHIUM_VERSION) {
             return new PreLithiumTransactionContextImpl(transactionPath, transactionActor, getIdentifier(),
-                    transactionChainId, actorContext, schemaContext, isTxActorLocal, remoteTransactionVersion,
+                    actorContext, isTxActorLocal, remoteTransactionVersion,
                     operationCompleter);
         } else {
-            return new TransactionContextImpl(transactionActor, getIdentifier(), transactionChainId,
-                    actorContext, schemaContext, isTxActorLocal, remoteTransactionVersion, operationCompleter);
+            return new TransactionContextImpl(transactionActor, getIdentifier(),
+                    actorContext, isTxActorLocal, remoteTransactionVersion, operationCompleter);
         }
     }
 }
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/TransactionType.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/TransactionType.java
new file mode 100644 (file)
index 0000000..649dae5
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.cluster.datastore;
+
+public enum TransactionType {
+    READ_ONLY,
+    WRITE_ONLY,
+    READ_WRITE;
+
+    // Cache all values
+    private static final TransactionType[] VALUES = values();
+
+    public static TransactionType fromInt(final int type) {
+        try {
+            return VALUES[type];
+        } catch (IndexOutOfBoundsException e) {
+            throw new IllegalArgumentException("In TransactionType enum value " + type, e);
+        }
+    }
+}
\ No newline at end of file
index 8b6cce6c5bd392101a6e91040a08596ac743dfe5..249a115588b7b1f78dbd7e720c777a958f9b23b6 100644 (file)
@@ -20,7 +20,6 @@ import org.opendaylight.controller.cluster.datastore.messages.WriteData;
 import org.opendaylight.controller.cluster.datastore.utils.ActorContext;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import scala.concurrent.Future;
@@ -37,10 +36,9 @@ public class PreLithiumTransactionContextImpl extends TransactionContextImpl {
     private final String transactionPath;
 
     public PreLithiumTransactionContextImpl(String transactionPath, ActorSelection actor, TransactionIdentifier identifier,
-            String transactionChainId, ActorContext actorContext, SchemaContext schemaContext, boolean isTxActorLocal,
+            ActorContext actorContext, boolean isTxActorLocal,
             short remoteTransactionVersion, OperationCompleter operationCompleter) {
-        super(actor, identifier, transactionChainId, actorContext, schemaContext, isTxActorLocal,
-                remoteTransactionVersion, operationCompleter);
+        super(actor, identifier, actorContext, isTxActorLocal, remoteTransactionVersion, operationCompleter);
         this.transactionPath = transactionPath;
     }
 
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/identifiers/ChainedTransactionIdentifier.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/identifiers/ChainedTransactionIdentifier.java
new file mode 100644 (file)
index 0000000..1aec854
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.cluster.datastore.identifiers;
+
+import com.google.common.base.Preconditions;
+
+/**
+ * A TransactionIdentifier which is tied to a backend transaction chain.
+ */
+public class ChainedTransactionIdentifier extends TransactionIdentifier {
+    private final String chainId;
+
+    public ChainedTransactionIdentifier(final String memberName, final long counter, final String chainId) {
+        super(memberName, counter);
+        this.chainId = Preconditions.checkNotNull(chainId);
+    }
+
+    @Override
+    public String getChainId() {
+        return chainId;
+    }
+}
index 32637a578e2d2af08c79f160bade7a9e2faf62aa..6742b5c7db259998da37767facea6482c06725dd 100644 (file)
@@ -9,6 +9,7 @@
 package org.opendaylight.controller.cluster.datastore.identifiers;
 
 import com.google.common.base.Preconditions;
+import com.google.common.base.Strings;
 
 public class TransactionIdentifier {
     private static final String TX_SEPARATOR = "-txn-";
@@ -22,6 +23,18 @@ public class TransactionIdentifier {
         this.counter = counter;
     }
 
+    public String getChainId() {
+        return "";
+    }
+
+    public static TransactionIdentifier create(String memberName, long counter, String chainId) {
+        if (Strings.isNullOrEmpty(chainId)) {
+            return new TransactionIdentifier(memberName, counter);
+        } else {
+            return new ChainedTransactionIdentifier(memberName, counter, chainId);
+        }
+    }
+
     @Override
     public boolean equals(Object o) {
         if (this == o) {
index a64a5802b8387102bdfac19e4535a440088ccf55..c22b7acd386cf3c5ecc66ab8dbbf2cc1d75f7e8f 100644 (file)
@@ -46,7 +46,6 @@ import org.mockito.Mock;
 import org.mockito.Mockito;
 import org.mockito.MockitoAnnotations;
 import org.opendaylight.controller.cluster.datastore.DatastoreContext.Builder;
-import org.opendaylight.controller.cluster.datastore.TransactionProxy.TransactionType;
 import org.opendaylight.controller.cluster.datastore.TransactionProxyTest.TestException;
 import org.opendaylight.controller.cluster.datastore.messages.BatchedModifications;
 import org.opendaylight.controller.cluster.datastore.messages.BatchedModificationsReply;
index 1ecf0971c10d3f0a429f3c56ea36d84eaa44befc..06d9f360aae23ab8edb0d99e5529ae6457e1d3b7 100644 (file)
@@ -365,7 +365,7 @@ public class ShardTest extends AbstractShardTest {
             shard.tell(new UpdateSchemaContext(TestModel.createTestContext()), getRef());
 
             shard.tell(new CreateTransaction("txn-1",
-                    TransactionProxy.TransactionType.READ_ONLY.ordinal() ).toSerializable(), getRef());
+                    TransactionType.READ_ONLY.ordinal() ).toSerializable(), getRef());
 
             CreateTransactionReply reply = expectMsgClass(duration("3 seconds"),
                     CreateTransactionReply.class);
@@ -386,7 +386,7 @@ public class ShardTest extends AbstractShardTest {
             waitUntilLeader(shard);
 
             shard.tell(new CreateTransaction("txn-1",
-                    TransactionProxy.TransactionType.READ_ONLY.ordinal() , "foobar").toSerializable(),
+                    TransactionType.READ_ONLY.ordinal() , "foobar").toSerializable(),
                     getRef());
 
             CreateTransactionReply reply = expectMsgClass(duration("3 seconds"),
@@ -961,7 +961,7 @@ public class ShardTest extends AbstractShardTest {
 
             // Create a read Tx on the same chain.
 
-            shard.tell(new CreateTransaction(transactionID2, TransactionProxy.TransactionType.READ_ONLY.ordinal() ,
+            shard.tell(new CreateTransaction(transactionID2, TransactionType.READ_ONLY.ordinal() ,
                     transactionChainID).toSerializable(), getRef());
 
             CreateTransactionReply createReply = expectMsgClass(duration("3 seconds"), CreateTransactionReply.class);
index e45389f5f36fbd151a24ae9e4d5a02a4995a2772..15f61660643ea1f02e84055d42aad749d305983e 100644 (file)
@@ -17,7 +17,6 @@ import akka.testkit.TestActorRef;
 import java.util.Collections;
 import java.util.concurrent.TimeUnit;
 import org.junit.Test;
-import org.opendaylight.controller.cluster.datastore.TransactionProxy.TransactionType;
 import org.opendaylight.controller.cluster.datastore.identifiers.ShardIdentifier;
 import org.opendaylight.controller.cluster.datastore.jmx.mbeans.shard.ShardStats;
 import org.opendaylight.controller.cluster.datastore.node.utils.serialization.NormalizedNodeSerializer;
index 23984ad973933666d41fb60c762e18517181ef1a..f20db19bd7ea137cd786c9fc30cdb23c7828d53a 100644 (file)
@@ -17,7 +17,6 @@ import org.junit.Test;
 import org.mockito.InOrder;
 import org.mockito.Mockito;
 import org.opendaylight.controller.cluster.datastore.ShardWriteTransaction.GetCompositeModificationReply;
-import org.opendaylight.controller.cluster.datastore.TransactionProxy.TransactionType;
 import org.opendaylight.controller.cluster.datastore.exceptions.UnknownMessageException;
 import org.opendaylight.controller.cluster.datastore.identifiers.ShardIdentifier;
 import org.opendaylight.controller.cluster.datastore.jmx.mbeans.shard.ShardStats;
index 026b5490288c1bbdeb1ec44d37e998abddad813e..76f299b548596a05b11280c8c0402ea6c0faae7b 100644 (file)
@@ -21,8 +21,8 @@ import static org.mockito.Mockito.never;
 import static org.mockito.Mockito.timeout;
 import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
-import static org.opendaylight.controller.cluster.datastore.TransactionProxy.TransactionType.READ_WRITE;
-import static org.opendaylight.controller.cluster.datastore.TransactionProxy.TransactionType.WRITE_ONLY;
+import static org.opendaylight.controller.cluster.datastore.TransactionType.READ_WRITE;
+import static org.opendaylight.controller.cluster.datastore.TransactionType.WRITE_ONLY;
 import akka.actor.ActorRef;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.TimeUnit;
index 844feb2f47e988b89498a80946d97aecbff8c049..dd55441c2a22a014d725674379c071c990c051cf 100644 (file)
@@ -11,9 +11,9 @@ import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.never;
 import static org.mockito.Mockito.verify;
-import static org.opendaylight.controller.cluster.datastore.TransactionProxy.TransactionType.READ_ONLY;
-import static org.opendaylight.controller.cluster.datastore.TransactionProxy.TransactionType.READ_WRITE;
-import static org.opendaylight.controller.cluster.datastore.TransactionProxy.TransactionType.WRITE_ONLY;
+import static org.opendaylight.controller.cluster.datastore.TransactionType.READ_ONLY;
+import static org.opendaylight.controller.cluster.datastore.TransactionType.READ_WRITE;
+import static org.opendaylight.controller.cluster.datastore.TransactionType.WRITE_ONLY;
 import akka.actor.ActorRef;
 import akka.actor.ActorSelection;
 import akka.actor.ActorSystem;
@@ -34,7 +34,6 @@ import org.junit.Assert;
 import org.junit.Test;
 import org.mockito.InOrder;
 import org.mockito.Mockito;
-import org.opendaylight.controller.cluster.datastore.TransactionProxy.TransactionType;
 import org.opendaylight.controller.cluster.datastore.exceptions.NoShardLeaderException;
 import org.opendaylight.controller.cluster.datastore.exceptions.NotInitializedException;
 import org.opendaylight.controller.cluster.datastore.exceptions.PrimaryNotFoundException;
@@ -677,7 +676,7 @@ public class TransactionProxyTest extends AbstractTransactionProxyTest {
     public void testGetIdentifier() {
         setupActorContextWithInitialCreateTransaction(getSystem(), READ_ONLY);
         TransactionProxy transactionProxy = new TransactionProxy(mockActorContext,
-                TransactionProxy.TransactionType.READ_ONLY);
+                TransactionType.READ_ONLY);
 
         Object id = transactionProxy.getIdentifier();
         assertNotNull("getIdentifier returned null", id);
index ca342b960a8749d78ae5aa0b1879b06ecc61110b..5681b760920a8615910bb1661ed16702b42df519 100644 (file)
@@ -15,8 +15,8 @@ import static org.mockito.Matchers.eq;
 import static org.mockito.Matchers.isA;
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.verify;
-import static org.opendaylight.controller.cluster.datastore.TransactionProxy.TransactionType.READ_WRITE;
-import static org.opendaylight.controller.cluster.datastore.TransactionProxy.TransactionType.WRITE_ONLY;
+import static org.opendaylight.controller.cluster.datastore.TransactionType.READ_WRITE;
+import static org.opendaylight.controller.cluster.datastore.TransactionType.WRITE_ONLY;
 import akka.actor.ActorRef;
 import akka.dispatch.Futures;
 import akka.util.Timeout;
index e206e69cdaaa88d04ca38ab530865ba9e7e37320..cdbab1c6d1c7b9cdd70bddf92efc733ee64d7f93 100644 (file)
@@ -22,7 +22,7 @@ import org.opendaylight.controller.cluster.datastore.DatastoreContext;
 import org.opendaylight.controller.cluster.datastore.Shard;
 import org.opendaylight.controller.cluster.datastore.ShardTest;
 import org.opendaylight.controller.cluster.datastore.ShardTestKit;
-import org.opendaylight.controller.cluster.datastore.TransactionProxy;
+import org.opendaylight.controller.cluster.datastore.TransactionType;
 import org.opendaylight.controller.cluster.datastore.identifiers.ShardIdentifier;
 import org.opendaylight.controller.cluster.datastore.messages.AbortTransactionReply;
 import org.opendaylight.controller.cluster.datastore.messages.CanCommitTransactionReply;
@@ -73,7 +73,7 @@ public class ShardTransactionHeliumBackwardsCompatibilityTest extends AbstractAc
             String transactionID = "txn-1";
             shard.tell(ShardTransactionMessages.CreateTransaction.newBuilder()
                     .setTransactionId(transactionID)
-                    .setTransactionType(TransactionProxy.TransactionType.WRITE_ONLY.ordinal())
+                    .setTransactionType(TransactionType.WRITE_ONLY.ordinal())
                     .setTransactionChainId("").build(), getRef());
 
             final FiniteDuration duration = duration("5 seconds");
@@ -147,7 +147,7 @@ public class ShardTransactionHeliumBackwardsCompatibilityTest extends AbstractAc
             String transactionID = "txn-1";
             shard.tell(ShardTransactionMessages.CreateTransaction.newBuilder()
                     .setTransactionId(transactionID)
-                    .setTransactionType(TransactionProxy.TransactionType.WRITE_ONLY.ordinal())
+                    .setTransactionType(TransactionType.WRITE_ONLY.ordinal())
                     .setTransactionChainId("").build(), getRef());
 
             final FiniteDuration duration = duration("5 seconds");
index 84b092e10eae92f9fc7715162c6bbdc48a975ad1..624d709c60a7abd761c7c40011ffb0619cd66e4c 100644 (file)
@@ -11,6 +11,7 @@ import java.math.BigInteger;
 import java.util.Collection;
 import java.util.Collections;
 import org.opendaylight.controller.config.yang.md.sal.rest.connector.Config;
+import org.opendaylight.controller.config.yang.md.sal.rest.connector.Delete;
 import org.opendaylight.controller.config.yang.md.sal.rest.connector.Get;
 import org.opendaylight.controller.config.yang.md.sal.rest.connector.Operational;
 import org.opendaylight.controller.config.yang.md.sal.rest.connector.Post;
@@ -78,15 +79,31 @@ public class RestconfProviderImpl implements Provider, AutoCloseable, RestConnec
     @Override
     public Config getConfig() {
         final Config config = new Config();
+
         final Get get = new Get();
         get.setReceivedRequests(stats.getConfigGet());
+        get.setSuccessfulResponses(stats.getSuccessGetConfig());
+        get.setFailedResponses(stats.getFailureGetConfig());
         config.setGet(get);
+
         final Post post = new Post();
         post.setReceivedRequests(stats.getConfigPost());
+        post.setSuccessfulResponses(stats.getSuccessPost());
+        post.setFailedResponses(stats.getFailurePost());
         config.setPost(post);
+
         final Put put = new Put();
         put.setReceivedRequests(stats.getConfigPut());
+        put.setSuccessfulResponses(stats.getSuccessPut());
+        put.setFailedResponses(stats.getFailurePut());
         config.setPut(put);
+
+        final Delete delete = new Delete();
+        delete.setReceivedRequests(stats.getConfigDelete());
+        delete.setSuccessfulResponses(stats.getSuccessDelete());
+        delete.setFailedResponses(stats.getFailureDelete());
+        config.setDelete(delete);
+
         return config;
     }
 
@@ -96,6 +113,8 @@ public class RestconfProviderImpl implements Provider, AutoCloseable, RestConnec
         final Operational operational = new Operational();
         final Get get = new Get();
         get.setReceivedRequests(opGet);
+        get.setSuccessfulResponses(stats.getSuccessGetOperational());
+        get.setFailedResponses(stats.getFailureGetOperational());
         operational.setGet(get);
         return operational;
     }
@@ -105,6 +124,6 @@ public class RestconfProviderImpl implements Provider, AutoCloseable, RestConnec
         final BigInteger rpcInvoke = stats.getRpc();
         final Rpcs rpcs = new Rpcs();
         rpcs.setReceivedRequests(rpcInvoke);
-        return rpcs ;
+        return rpcs;
     }
-}
+}
\ No newline at end of file
index 07178f537999ce0a04c285431c1398f684453e67..f4a5fbc926479c94ed3eaa762722483424036133 100644 (file)
@@ -10,6 +10,7 @@ package org.opendaylight.controller.sal.restconf.impl;
 import java.math.BigInteger;
 import java.util.concurrent.atomic.AtomicLong;
 import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.Status;
 import javax.ws.rs.core.UriInfo;
 import org.opendaylight.controller.sal.rest.api.RestconfService;
 
@@ -21,6 +22,16 @@ public class StatisticsRestconfServiceWrapper implements RestconfService {
     AtomicLong configPost = new AtomicLong();
     AtomicLong configPut = new AtomicLong();
     AtomicLong configDelete = new AtomicLong();
+    AtomicLong successGetConfig = new AtomicLong();
+    AtomicLong successGetOperational = new AtomicLong();
+    AtomicLong successPost = new AtomicLong();
+    AtomicLong successPut = new AtomicLong();
+    AtomicLong successDelete = new AtomicLong();
+    AtomicLong failureGetConfig = new AtomicLong();
+    AtomicLong failureGetOperational = new AtomicLong();
+    AtomicLong failurePost = new AtomicLong();
+    AtomicLong failurePut = new AtomicLong();
+    AtomicLong failureDelete = new AtomicLong();
 
     private static final StatisticsRestconfServiceWrapper INSTANCE = new StatisticsRestconfServiceWrapper(RestconfImpl.getInstance());
 
@@ -79,36 +90,115 @@ public class StatisticsRestconfServiceWrapper implements RestconfService {
     @Override
     public NormalizedNodeContext readConfigurationData(final String identifier, final UriInfo uriInfo) {
         configGet.incrementAndGet();
-        return delegate.readConfigurationData(identifier, uriInfo);
+        NormalizedNodeContext normalizedNodeContext = null;
+        try {
+            normalizedNodeContext = delegate.readConfigurationData(identifier, uriInfo);
+            if (normalizedNodeContext.getData() != null) {
+                successGetConfig.incrementAndGet();
+            }
+            else {
+                failureGetConfig.incrementAndGet();
+            }
+        } catch (Exception e) {
+            failureGetConfig.incrementAndGet();
+            throw e;
+        }
+        return normalizedNodeContext;
     }
 
     @Override
     public NormalizedNodeContext readOperationalData(final String identifier, final UriInfo uriInfo) {
         operationalGet.incrementAndGet();
-        return delegate.readOperationalData(identifier, uriInfo);
+        NormalizedNodeContext normalizedNodeContext = null;
+        try {
+            normalizedNodeContext = delegate.readOperationalData(identifier, uriInfo);
+            if (normalizedNodeContext.getData() != null) {
+                successGetOperational.incrementAndGet();
+            }
+            else {
+                failureGetOperational.incrementAndGet();
+            }
+        } catch (Exception e) {
+            failureGetOperational.incrementAndGet();
+            throw e;
+        }
+        return normalizedNodeContext;
     }
 
     @Override
     public Response updateConfigurationData(final String identifier, final NormalizedNodeContext payload) {
         configPut.incrementAndGet();
-        return delegate.updateConfigurationData(identifier, payload);
+        Response response = null;
+        try {
+            response = delegate.updateConfigurationData(identifier, payload);
+            if (response.getStatus() == Status.OK.getStatusCode()) {
+                successPut.incrementAndGet();
+            }
+            else {
+                failurePut.incrementAndGet();
+            }
+        } catch (Exception e) {
+            failurePut.incrementAndGet();
+            throw e;
+        }
+        return response;
     }
 
     @Override
     public Response createConfigurationData(final String identifier, final NormalizedNodeContext payload, final UriInfo uriInfo) {
         configPost.incrementAndGet();
-        return delegate.createConfigurationData(identifier, payload, uriInfo);
+        Response response = null;
+        try {
+            response = delegate.createConfigurationData(identifier, payload, uriInfo);
+            if (response.getStatus() == Status.OK.getStatusCode()) {
+                successPost.incrementAndGet();
+            }
+            else {
+                failurePost.incrementAndGet();
+            }
+        } catch (Exception e) {
+            failurePost.incrementAndGet();
+            throw e;
+        }
+        return response;
     }
 
     @Override
     public Response createConfigurationData(final NormalizedNodeContext payload, final UriInfo uriInfo) {
         configPost.incrementAndGet();
-        return delegate.createConfigurationData(payload, uriInfo);
+        Response response = null;
+        try {
+            response = delegate.createConfigurationData(payload, uriInfo);
+            if (response.getStatus() == Status.OK.getStatusCode()) {
+                successPost.incrementAndGet();
+            }
+            else {
+                failurePost.incrementAndGet();
+            }
+        }catch (Exception e) {
+            failurePost.incrementAndGet();
+            throw e;
+        }
+        return response;
     }
 
     @Override
     public Response deleteConfigurationData(final String identifier) {
-        return delegate.deleteConfigurationData(identifier);
+        configDelete.incrementAndGet();
+        Response response = null;
+        try {
+            response = delegate.deleteConfigurationData(identifier);
+            if (response.getStatus() == Status.OK.getStatusCode()) {
+                successDelete.incrementAndGet();
+            }
+            else {
+                failureDelete.incrementAndGet();
+            }
+        } catch (Exception e) {
+            failureDelete.incrementAndGet();
+            throw e;
+        }
+        return response;
     }
 
     @Override
@@ -144,4 +234,44 @@ public class StatisticsRestconfServiceWrapper implements RestconfService {
     public BigInteger getRpc() {
         return BigInteger.valueOf(rpc.get());
     }
-}
+
+    public BigInteger getSuccessGetConfig() {
+        return BigInteger.valueOf(successGetConfig.get());
+    }
+
+    public BigInteger getSuccessGetOperational() {
+        return BigInteger.valueOf(successGetOperational.get());
+    }
+
+    public BigInteger getSuccessPost() {
+        return BigInteger.valueOf(successPost.get());
+    }
+
+    public BigInteger getSuccessPut() {
+        return BigInteger.valueOf(successPut.get());
+    }
+
+    public BigInteger getSuccessDelete() {
+        return BigInteger.valueOf(successDelete.get());
+    }
+
+    public BigInteger getFailureGetConfig() {
+        return BigInteger.valueOf(failureGetConfig.get());
+    }
+
+    public BigInteger getFailureGetOperational() {
+        return BigInteger.valueOf(failureGetOperational.get());
+    }
+
+    public BigInteger getFailurePost() {
+        return BigInteger.valueOf(failurePost.get());
+    }
+
+    public BigInteger getFailurePut() {
+        return BigInteger.valueOf(failurePut.get());
+    }
+
+    public BigInteger getFailureDelete() {
+        return BigInteger.valueOf(failureDelete.get());
+    }
+}
\ No newline at end of file
index 6d2add6ff14313b8824a5ade4d8cba187260bc24..6fa9c86ec1879985afa664783f65e483ffad60da 100644 (file)
@@ -31,6 +31,14 @@ module opendaylight-rest-connector {
         leaf received-requests {
            type uint64;
         }
+
+        leaf successful-responses {
+            type uint64;
+        }
+
+        leaf failed-responses {
+            type uint64;
+        }
     }
 
     augment "/config:modules/config:module/config:configuration" {
@@ -70,6 +78,10 @@ module opendaylight-rest-connector {
                 container put {
                     uses statistics;
                 }
+                
+                container delete {
+                    uses statistics;
+                }
             }
 
             container operational {