Bug 9034: TracingBroker with TracingTransactionChain 88/62288/2
authorMichael Vorburger <vorburger@redhat.com>
Thu, 24 Aug 2017 17:24:59 +0000 (19:24 +0200)
committerTom Pantelis <tompantelis@gmail.com>
Fri, 25 Aug 2017 02:05:26 +0000 (02:05 +0000)
This is one of a serious of (small, easy to review) commits which is
part of a solution I'm proposing in order to be able to detect OOM
issues such as Bug 9034, based on using the mdsal-trace DataBroker.

Change-Id: I098c48a1fce1da2fdd0aafdc82fd3bef5626988a
Signed-off-by: Michael Vorburger <vorburger@redhat.com>
opendaylight/md-sal/mdsal-trace/dom-impl/src/main/java/org/opendaylight/controller/md/sal/trace/dom/impl/TracingBroker.java
opendaylight/md-sal/mdsal-trace/dom-impl/src/main/java/org/opendaylight/controller/md/sal/trace/dom/impl/TracingTransactionChain.java [new file with mode: 0644]

index a30d3e0..aeba283 100644 (file)
@@ -96,8 +96,8 @@ public class TracingBroker implements TracingDOMDataBroker {
 
     private final BindingNormalizedNodeSerializer codec;
     private final DOMDataBroker delegate;
-    private List<Watch> registrationWatches = new ArrayList<>();
-    private List<Watch> writeWatches = new ArrayList<>();
+    private final List<Watch> registrationWatches = new ArrayList<>();
+    private final List<Watch> writeWatches = new ArrayList<>();
 
 
     private class Watch {
@@ -299,7 +299,7 @@ public class TracingBroker implements TracingDOMDataBroker {
 
     @Override
     public DOMTransactionChain createTransactionChain(TransactionChainListener transactionChainListener) {
-        return delegate.createTransactionChain(transactionChainListener);
+        return new TracingTransactionChain(delegate.createTransactionChain(transactionChainListener), this);
     }
 
     @Override
diff --git a/opendaylight/md-sal/mdsal-trace/dom-impl/src/main/java/org/opendaylight/controller/md/sal/trace/dom/impl/TracingTransactionChain.java b/opendaylight/md-sal/mdsal-trace/dom-impl/src/main/java/org/opendaylight/controller/md/sal/trace/dom/impl/TracingTransactionChain.java
new file mode 100644 (file)
index 0000000..13312ea
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2017 Red Hat, 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.md.sal.trace.dom.impl;
+
+import java.util.Objects;
+import org.opendaylight.controller.md.sal.dom.api.DOMDataReadOnlyTransaction;
+import org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction;
+import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction;
+import org.opendaylight.controller.md.sal.dom.api.DOMTransactionChain;
+
+class TracingTransactionChain implements DOMTransactionChain {
+
+    private final DOMTransactionChain delegate;
+    private final TracingBroker tracingBroker;
+
+    TracingTransactionChain(DOMTransactionChain delegate, TracingBroker tracingBroker) {
+        this.delegate = Objects.requireNonNull(delegate);
+        this.tracingBroker = Objects.requireNonNull(tracingBroker);
+    }
+
+    @Override
+    public DOMDataReadOnlyTransaction newReadOnlyTransaction() {
+        return delegate.newReadOnlyTransaction();
+    }
+
+    @Override
+    public DOMDataReadWriteTransaction newReadWriteTransaction() {
+        return new TracingReadWriteTransaction(delegate.newReadWriteTransaction(), tracingBroker);
+    }
+
+    @Override
+    public DOMDataWriteTransaction newWriteOnlyTransaction() {
+        return new TracingWriteTransaction(delegate.newWriteOnlyTransaction(), tracingBroker);
+    }
+
+    @Override
+    public void close() {
+        delegate.close();
+    }
+
+}

©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.