From: Lukas Sedlak Date: Wed, 9 Jul 2014 07:21:35 +0000 (+0200) Subject: Bug 1339: Added doublecheck for RPC registration X-Git-Tag: release/helium~509 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=1b2f13eda5fcbe56b27d994169543353954e2448 Bug 1339: Added doublecheck for RPC registration Change-Id: I786934b6cc690817688e60fd3d422293f37056be Signed-off-by: Lukas Sedlak --- diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/connect/dom/BindingIndependentConnector.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/connect/dom/BindingIndependentConnector.java index fe8c4a151c..6e4b2d8d99 100644 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/connect/dom/BindingIndependentConnector.java +++ b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/connect/dom/BindingIndependentConnector.java @@ -602,7 +602,7 @@ public class BindingIndependentConnector implements // final Optional> rpcInterface = mappingService.getRpcServiceClassFor( name.getNamespace().toString(), name.getFormattedRevision()); if (rpcInterface.isPresent()) { - getRpcForwarder(rpcInterface.get(), null).registerToBidningBroker(); + getRpcForwarder(rpcInterface.get(), null).registerToBindingBroker(); } } @@ -621,6 +621,7 @@ public class BindingIndependentConnector implements // private final WeakHashMap strategiesByMethod = new WeakHashMap<>(); private final RpcService proxy; private ObjectRegistration forwarderRegistration; + private boolean registrationInProgress = false; public DomToBindingRpcForwarder(final Class service) { this.rpcServiceType = new WeakReference>(service); @@ -680,7 +681,8 @@ public class BindingIndependentConnector implements // * */ public void registerToDOMBroker() { - if(forwarderRegistration == null) { + if(!registrationInProgress && forwarderRegistration == null) { + registrationInProgress = true; CompositeObjectRegistrationBuilder builder = CompositeObjectRegistration.builderFor(this); try { for (QName rpc : supportedRpcs) { @@ -690,6 +692,7 @@ public class BindingIndependentConnector implements // LOG.error("Could not forward Rpcs of type {}", rpcServiceType.get(), e); } this.forwarderRegistration = builder.toInstance(); + registrationInProgress = false; } } @@ -801,12 +804,15 @@ public class BindingIndependentConnector implements // * creating forwarding loop. * */ - public void registerToBidningBroker() { - if(forwarderRegistration == null) { + public void registerToBindingBroker() { + if(!registrationInProgress && forwarderRegistration == null) { try { + registrationInProgress = true; this.forwarderRegistration = baRpcRegistry.addRpcImplementation((Class)rpcServiceType.get(), proxy); } catch (Exception e) { LOG.error("Unable to forward RPCs for {}",rpcServiceType.get(),e); + } finally { + registrationInProgress = false; } } }