Implement toString in DataBroker impls 73/44573/2
authorTom Pantelis <tpanteli@brocade.com>
Tue, 23 Aug 2016 21:45:57 +0000 (17:45 -0400)
committerTom Pantelis <tpanteli@brocade.com>
Wed, 24 Aug 2016 17:33:13 +0000 (17:33 +0000)
PingPongDataBroker extends from ForwardingObject which forwards toString to the
delegate which is the ConcurrentDOMDataBroker. Unfortunately this hides the fact
that it's actually the PingPongDataBroker and has lead to confusion. Similar with the
BindingDOMDataBrokerAdapter. So I implemented toString to appropriately to refect the
true identity and forwarding nature of the classes.

Change-Id: I58b931590ca41bdb90bad31f6fedfe71466787ea
Signed-off-by: Tom Pantelis <tpanteli@brocade.com>
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMDataBrokerAdapter.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/ConcurrentDOMDataBroker.java
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/PingPongDataBroker.java

index 1c43f12..6845dd4 100644 (file)
@@ -40,14 +40,7 @@ import org.opendaylight.yangtools.yang.binding.DataObject;
 public class BindingDOMDataBrokerAdapter extends AbstractForwardedDataBroker implements DataBroker, DataTreeChangeService {
 
 
-    static final Factory<DataBroker> BUILDER_FACTORY = new BindingDOMAdapterBuilder.Factory<DataBroker>() {
-
-        @Override
-        public BindingDOMAdapterBuilder<DataBroker> newBuilder() {
-            return new Builder();
-        }
-
-    };
+    static final Factory<DataBroker> BUILDER_FACTORY = () -> new Builder();
     private final DataTreeChangeService treeChangeService;
 
     public BindingDOMDataBrokerAdapter(final DOMDataBroker domDataBroker, final BindingToNormalizedNodeCodec codec) {
@@ -81,6 +74,11 @@ public class BindingDOMDataBrokerAdapter extends AbstractForwardedDataBroker imp
         return new BindingDOMTransactionChainAdapter(getDelegate(), getCodec(), listener);
     }
 
+    @Override
+    public String toString() {
+        return "BindingDOMDataBrokerAdapter for " + getDelegate();
+    }
+
     private static class Builder extends BindingDOMAdapterBuilder<DataBroker> {
 
         @Override
index 4794e2a..bdaa6db 100644 (file)
@@ -263,7 +263,7 @@ public class ConcurrentDOMDataBroker extends AbstractDOMBroker implements DOMDat
         /**
          * ThreadLocal used to detect if the task completion thread is running the future listener Runnables.
          */
-        private static final ThreadLocal<Boolean> ON_TASK_COMPLETION_THREAD_TL = new ThreadLocal<Boolean>();
+        private static final ThreadLocal<Boolean> ON_TASK_COMPLETION_THREAD_TL = new ThreadLocal<>();
 
         private final Executor listenerExecutor;
 
@@ -350,4 +350,9 @@ public class ConcurrentDOMDataBroker extends AbstractDOMBroker implements DOMDat
                 throw new IllegalArgumentException("Unsupported data store type: " + datastoreType);
         }
     }
+
+    @Override
+    public String toString() {
+        return "Clustered ConcurrentDOMDataBroker";
+    }
 }
index 53de1a2..2ba5912 100644 (file)
@@ -62,4 +62,9 @@ public final class PingPongDataBroker extends ForwardingDOMDataBroker implements
 
         throw new UnsupportedOperationException("Delegate " + delegate + " does not support required functionality");
     }
+
+    @Override
+    public String toString() {
+        return "PingPongDataBroker backed by " + delegate;
+    }
 }

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