Merge "Remove raw references to Map in XSQL"
[controller.git] / opendaylight / md-sal / sal-dom-broker / src / main / java / org / opendaylight / controller / sal / dom / broker / impl / DataStoreStatsWrapper.java
index 9116d50d9c4965fc81842a4a6e1f558f457c2ad3..bc86581a2023460ab7019212c49bb899663571a7 100644 (file)
@@ -1,3 +1,10 @@
+/*
+ * 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.sal.dom.broker.impl;
 
 import java.util.concurrent.atomic.AtomicLong;
@@ -6,8 +13,9 @@ import org.opendaylight.controller.md.sal.common.api.data.DataModification;
 import org.opendaylight.controller.sal.core.api.data.DataStore;
 import org.opendaylight.yangtools.concepts.Delegator;
 import org.opendaylight.yangtools.yang.data.api.CompositeNode;
-import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 
+@Deprecated
 public class DataStoreStatsWrapper implements Delegator<DataStore>, DataStore {
 
     private final DataStore delegate;
@@ -31,7 +39,7 @@ public class DataStoreStatsWrapper implements Delegator<DataStore>, DataStore {
     }
 
     @Override
-    public CompositeNode readConfigurationData(InstanceIdentifier path) {
+    public CompositeNode readConfigurationData(YangInstanceIdentifier path) {
         cfgReadCount.incrementAndGet();
         final long startTime = System.nanoTime();
         try {
@@ -44,7 +52,7 @@ public class DataStoreStatsWrapper implements Delegator<DataStore>, DataStore {
     }
 
     @Override
-    public CompositeNode readOperationalData(InstanceIdentifier path) {
+    public CompositeNode readOperationalData(YangInstanceIdentifier path) {
         operReadCount.incrementAndGet();
         final long startTime = System.nanoTime();
         try {
@@ -52,12 +60,12 @@ public class DataStoreStatsWrapper implements Delegator<DataStore>, DataStore {
         } finally {
             final long endTime = System.nanoTime();
             final long runTime = endTime - startTime;
-            cfgReadTimeTotal.addAndGet(runTime);
+            operReadTimeTotal.addAndGet(runTime);
         }
     }
 
-    public DataCommitTransaction<InstanceIdentifier, CompositeNode> requestCommit(
-            DataModification<InstanceIdentifier, CompositeNode> modification) {
+    public DataCommitTransaction<YangInstanceIdentifier, CompositeNode> requestCommit(
+            DataModification<YangInstanceIdentifier, CompositeNode> modification) {
         requestCommitCount.incrementAndGet();
         final long startTime = System.nanoTime();
         try {
@@ -70,19 +78,19 @@ public class DataStoreStatsWrapper implements Delegator<DataStore>, DataStore {
     };
 
     @Override
-    public boolean containsConfigurationPath(InstanceIdentifier path) {
+    public boolean containsConfigurationPath(YangInstanceIdentifier path) {
         return delegate.containsConfigurationPath(path);
     }
 
-    public Iterable<InstanceIdentifier> getStoredConfigurationPaths() {
+    public Iterable<YangInstanceIdentifier> getStoredConfigurationPaths() {
         return delegate.getStoredConfigurationPaths();
     }
 
-    public Iterable<InstanceIdentifier> getStoredOperationalPaths() {
+    public Iterable<YangInstanceIdentifier> getStoredOperationalPaths() {
         return delegate.getStoredOperationalPaths();
     }
 
-    public boolean containsOperationalPath(InstanceIdentifier path) {
+    public boolean containsOperationalPath(YangInstanceIdentifier path) {
         return delegate.containsOperationalPath(path);
     }
 
@@ -98,40 +106,40 @@ public class DataStoreStatsWrapper implements Delegator<DataStore>, DataStore {
         return requestCommitCount.get();
     }
 
-    public final long getConfigurationReadTotalTime() {
-        return cfgReadTimeTotal.get();
+    public final double getConfigurationReadTotalTime() {
+        return cfgReadTimeTotal.get() / 1000.0d;
     }
 
-    public final long getOperationalReadTotalTime() {
-        return operReadTimeTotal.get();
+    public final double getOperationalReadTotalTime() {
+        return operReadTimeTotal.get() / 1000.0d;
     }
 
-    public final long getRequestCommitTotalTime() {
-        return requestCommitTimeTotal.get();
+    public final double getRequestCommitTotalTime() {
+        return requestCommitTimeTotal.get() / 1000.0d;
     }
 
-    public final long getConfigurationReadAverageTime() {
+    public final double getConfigurationReadAverageTime() {
         long readCount = cfgReadCount.get();
         if(readCount == 0) {
             return 0;
         }
-        return cfgReadTimeTotal.get() / readCount;
+        return getConfigurationReadTotalTime() / readCount;
     }
 
-    public final long getOperationalReadAverageTime() {
+    public final double getOperationalReadAverageTime() {
         long readCount = operReadCount.get();
         if(readCount == 0) {
             return 0;
         }
-        return operReadTimeTotal.get() / readCount;
+        return getOperationalReadTotalTime() / readCount;
     }
 
-    public final long getRequestCommitAverageTime() {
+    public final double getRequestCommitAverageTime() {
         long count = requestCommitCount.get();
         if(count == 0) {
             return 0;
         }
-        return requestCommitTimeTotal.get() / count;
+        return getRequestCommitTotalTime() / count;
     }
 
 }