Added transactions statistics for BI Broker. 33/3533/1
authorLukas Sedlak <lsedlak@cisco.com>
Fri, 6 Dec 2013 13:35:50 +0000 (14:35 +0100)
committerLukas Sedlak <lsedlak@cisco.com>
Fri, 6 Dec 2013 13:40:44 +0000 (14:40 +0100)
Added implementation of gathering transaction statistics when binding independent broker is used.

Signed-off-by: Lukas Sedlak <lsedlak@cisco.com>
Change-Id: Ia7fb9374575be62bb6bd6b2ace3112d28524bde5

opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/binding/statistics/DataBrokerRuntimeMXBeanImpl.java
opendaylight/md-sal/sal-binding-broker/src/main/yang/opendaylight-binding-broker-impl.yang
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/dom/impl/DomBrokerImplModule.java
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/dom/statistics/DomBrokerRuntimeMXBeanImpl.java [new file with mode: 0644]
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/BrokerConfigActivator.xtend
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/DataBrokerImpl.java
opendaylight/md-sal/sal-dom-broker/src/main/yang/opendaylight-dom-broker-impl.yang

index a1a24eb..5da084e 100644 (file)
@@ -1,14 +1,15 @@
 package org.opendaylight.controller.config.yang.md.sal.binding.statistics;\r
 \r
+import org.opendaylight.controller.config.yang.md.sal.binding.impl.Data;\r
 import org.opendaylight.controller.config.yang.md.sal.binding.impl.DataBrokerImplRuntimeMXBean;\r
 import org.opendaylight.controller.config.yang.md.sal.binding.impl.Transactions;\r
 import org.opendaylight.controller.sal.binding.impl.DataBrokerImpl;\r
 \r
 public class DataBrokerRuntimeMXBeanImpl extends DataBrokerImpl implements DataBrokerImplRuntimeMXBean {\r
     \r
-    private Transactions transactions = new Transactions();\r
+    private final Transactions transactions = new Transactions();\r
+    private final Data data = new Data();\r
     \r
-    @Override\r
     public Transactions getTransactions() {\r
         transactions.setCreated(getCreatedTransactionsCount().get());\r
         transactions.setSubmitted(getSubmittedTransactionsCount().get());\r
@@ -16,4 +17,14 @@ public class DataBrokerRuntimeMXBeanImpl extends DataBrokerImpl implements DataB
         transactions.setFailed(getFailedTransactionsCount().get());\r
         return transactions;\r
     }\r
+\r
+    @Override\r
+    public Data getData() {\r
+        transactions.setCreated(getCreatedTransactionsCount().get());\r
+        transactions.setSubmitted(getSubmittedTransactionsCount().get());\r
+        transactions.setSuccessful(getFinishedTransactionsCount().get());\r
+        transactions.setFailed(getFailedTransactionsCount().get());\r
+        data.setTransactions(transactions);\r
+        return data;\r
+    }\r
 }\r
index 9da073f..b040aa0 100644 (file)
@@ -121,7 +121,9 @@ module opendaylight-sal-binding-broker-impl {
     augment "/config:modules/config:module/config:state" {
         case binding-data-broker {
             when "/config:modules/config:module/config:type = 'binding-data-broker'";
-            uses common:data-state;
+            container data {
+                uses common:data-state;
+            }
         }
     }
     augment "/config:modules/config:module/config:state" {
index 050966f..9a2a904 100644 (file)
@@ -9,10 +9,12 @@
 */
 package org.opendaylight.controller.config.yang.md.sal.dom.impl;
 
+import org.opendaylight.controller.config.yang.md.sal.dom.statistics.DomBrokerRuntimeMXBeanImpl;
 import org.opendaylight.controller.sal.core.api.data.DataStore;
 import org.opendaylight.controller.sal.dom.broker.BrokerConfigActivator;
 import org.opendaylight.controller.sal.dom.broker.BrokerImpl;
 import org.osgi.framework.BundleContext;
+
 import static com.google.common.base.Preconditions.*;
 
 /**
@@ -37,14 +39,15 @@ public final class DomBrokerImplModule extends org.opendaylight.controller.confi
         checkArgument(getDataStore() != null, "Data Store needs to be provided for DomBroker");
     }
     
-    
-
     @Override
     public java.lang.AutoCloseable createInstance() {
-        BrokerImpl broker = new BrokerImpl();
-        BrokerConfigActivator activator = new BrokerConfigActivator();
-        DataStore store = getDataStoreDependency();
-        activator.start(broker, store,getBundleContext());
+        final BrokerImpl broker = new BrokerImpl();
+        final BrokerConfigActivator activator = new BrokerConfigActivator();
+        final DataStore store = getDataStoreDependency();
+        activator.start(broker, store, getBundleContext());
+        
+        final DomBrokerImplRuntimeMXBean domBrokerRuntimeMXBean = new DomBrokerRuntimeMXBeanImpl(activator.getDataService());
+        getRootRuntimeBeanRegistratorWrapper().register(domBrokerRuntimeMXBean);
         return broker;
     }
 
diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/dom/statistics/DomBrokerRuntimeMXBeanImpl.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/dom/statistics/DomBrokerRuntimeMXBeanImpl.java
new file mode 100644 (file)
index 0000000..bc13979
--- /dev/null
@@ -0,0 +1,36 @@
+package org.opendaylight.controller.config.yang.md.sal.dom.statistics;
+
+import org.opendaylight.controller.config.yang.md.sal.dom.impl.Data;
+import org.opendaylight.controller.config.yang.md.sal.dom.impl.DomBrokerImplRuntimeMXBean;
+import org.opendaylight.controller.config.yang.md.sal.dom.impl.Transactions;
+import org.opendaylight.controller.sal.dom.broker.DataBrokerImpl;
+
+public class DomBrokerRuntimeMXBeanImpl implements
+        DomBrokerImplRuntimeMXBean {
+    
+    private final DataBrokerImpl dataService;
+    private final Transactions transactions = new Transactions();
+    private final Data data = new Data();
+    
+    public DomBrokerRuntimeMXBeanImpl(DataBrokerImpl dataService) {
+        this.dataService = dataService; 
+    }
+
+    public Transactions getTransactions() {
+        transactions.setCreated(dataService.getCreatedTransactionsCount().get());
+        transactions.setSubmitted(dataService.getSubmittedTransactionsCount().get());
+        transactions.setSuccessful(dataService.getFinishedTransactionsCount().get());
+        transactions.setFailed(dataService.getFailedTransactionsCount().get());
+        return transactions;
+    }
+
+    @Override
+    public Data getData() {
+        transactions.setCreated(dataService.getCreatedTransactionsCount().get());
+        transactions.setSubmitted(dataService.getSubmittedTransactionsCount().get());
+        transactions.setSuccessful(dataService.getFinishedTransactionsCount().get());
+        transactions.setFailed(dataService.getFailedTransactionsCount().get());
+        data.setTransactions(transactions);
+        return data;
+    }
+}
index da7cccb..482cfa9 100644 (file)
@@ -19,15 +19,16 @@ class BrokerConfigActivator implements AutoCloseable {
     
     
     private static val ROOT = InstanceIdentifier.builder().toInstance();
+
+    @Property
+    private var DataBrokerImpl dataService;
     
     private var ServiceRegistration<SchemaService> schemaReg;
     private var ServiceRegistration<DataBrokerService> dataReg;
     private var ServiceRegistration<DataProviderService> dataProviderReg;
     private var ServiceRegistration<MountService> mountReg;
     private var ServiceRegistration<MountProvisionService> mountProviderReg;
-    
     private var SchemaServiceImpl schemaService;
-    private var DataBrokerImpl dataService;
     private var MountPointManagerImpl mountService;
     
     SchemaAwareDataStoreAdapter wrappedStore
index ac5313a..56eae97 100644 (file)
@@ -2,7 +2,6 @@ package org.opendaylight.controller.sal.dom.broker;
 
 import java.util.concurrent.atomic.AtomicLong;
 
-import org.opendaylight.controller.md.sal.common.api.data.DataChangeEvent;
 import org.opendaylight.controller.md.sal.common.api.data.DataReader;
 import org.opendaylight.controller.md.sal.common.impl.service.AbstractDataBroker;
 import org.opendaylight.controller.sal.common.DataStoreIdentifier;
@@ -15,17 +14,23 @@ import org.opendaylight.yangtools.yang.data.api.CompositeNode;
 import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
 
 public class DataBrokerImpl extends AbstractDataBroker<InstanceIdentifier, CompositeNode, DataChangeListener> implements
-        DataProviderService {
+        DataProviderService, AutoCloseable {
 
+    private AtomicLong nextTransaction = new AtomicLong();
+    private final AtomicLong createdTransactionsCount = new AtomicLong();
+    
     public DataBrokerImpl() {
         setDataReadRouter(new DataReaderRouter());
     }
-
-    private AtomicLong nextTransaction = new AtomicLong();
+    
+    public AtomicLong getCreatedTransactionsCount() {
+        return createdTransactionsCount;
+    }
     
     @Override
     public DataTransactionImpl beginTransaction() {
         String transactionId = "DOM-" + nextTransaction.getAndIncrement();
+        createdTransactionsCount.getAndIncrement();
         return new DataTransactionImpl(transactionId,this);
     }
 
@@ -66,4 +71,9 @@ public class DataBrokerImpl extends AbstractDataBroker<InstanceIdentifier, Compo
         throw new UnsupportedOperationException("Deprecated");
     }
 
+    @Override
+    public void close() throws Exception {
+        
+    }
+
 }
\ No newline at end of file
index bf12ac4..9ae9c9c 100644 (file)
@@ -5,6 +5,7 @@ module opendaylight-sal-dom-broker-impl {
 
        import config { prefix config; revision-date 2013-04-05; }
        import opendaylight-md-sal-dom {prefix sal;}
+       import opendaylight-md-sal-common {prefix common;}
 
     description
         "Service definition for Binding Aware MD-SAL.";
@@ -18,7 +19,7 @@ module opendaylight-sal-dom-broker-impl {
         base config:module-type;
         config:provided-service sal:dom-broker-osgi-registry;
         config:java-name-prefix DomBrokerImpl;
-    }
+    }    
     
     identity hash-map-data-store {
         base config:module-type;
@@ -58,4 +59,12 @@ module opendaylight-sal-dom-broker-impl {
         }
     }
     
+    augment "/config:modules/config:module/config:state" {
+        case dom-broker-impl {
+            when "/config:modules/config:module/config:type = 'dom-broker-impl'";
+            container data {
+                uses common:data-state;
+            } 
+        }
+    }
 }
\ No newline at end of file

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.