catch and log cluster singleton service registration exceptions
[groupbasedpolicy.git] / neutron-ovsdb / src / main / java / org / opendaylight / controller / config / yang / config / neutron_ovsdb / impl / NeutronOvsdbInstance.java
index 66e2991463179121ecf9d4bbb892c4b595119223..6e8d74a9146956fca40856ba8ddbf9dd907a6340 100644 (file)
@@ -13,6 +13,7 @@ import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListenableFuture;
 import org.opendaylight.controller.config.yang.config.groupbasedpolicy.GroupbasedpolicyInstance;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
 import org.opendaylight.groupbasedpolicy.neutron.ovsdb.NeutronOvsdb;
 import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonService;
 import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider;
@@ -30,30 +31,35 @@ public class NeutronOvsdbInstance implements ClusterSingletonService, AutoClosea
     private static final ServiceGroupIdentifier IDENTIFIER =
             ServiceGroupIdentifier.create(GroupbasedpolicyInstance.GBP_SERVICE_GROUP_IDENTIFIER);
     private final DataBroker dataBroker;
-    private final EndpointService epService;
     private final IntegrationBridgeSetting settings;
     private final ClusterSingletonServiceProvider clusterSingletonService;
+    private final RpcProviderRegistry rpcBroker;
     private ClusterSingletonServiceRegistration singletonServiceRegistration;
     private NeutronOvsdb neutronOvsdb;
 
     public NeutronOvsdbInstance(final DataBroker dataBroker,
-                                final EndpointService epService,
+                                final RpcProviderRegistry rpcBroker,
                                 final IntegrationBridgeSetting settings,
                                 final ClusterSingletonServiceProvider clusterSingletonService) {
         this.dataBroker = Preconditions.checkNotNull(dataBroker);
-        this.epService = Preconditions.checkNotNull(epService);
+        this.rpcBroker = Preconditions.checkNotNull(rpcBroker);
         this.settings = Preconditions.checkNotNull(settings);
         this.clusterSingletonService = Preconditions.checkNotNull(clusterSingletonService);
     }
 
     public void initialize() {
         LOG.info("Clustering session initiated for {}", this.getClass().getSimpleName());
-        singletonServiceRegistration = clusterSingletonService.registerClusterSingletonService(this);
+        try {
+            singletonServiceRegistration = clusterSingletonService.registerClusterSingletonService(this);
+        } catch (Exception e) {
+            LOG.warn("Exception thrown while registering cluster singleton service in {}", this.getClass(), e.getMessage());
+        }
     }
 
     @Override
     public void instantiateServiceInstance() {
         LOG.info("Instantiating {}", this.getClass().getSimpleName());
+        final EndpointService epService = rpcBroker.getRpcService(EndpointService.class);
         neutronOvsdb = new NeutronOvsdb(dataBroker, epService, settings);
     }