Merge "Bug 6110: Fixed bugs in statistics manager due to race condition." into stable...
[openflowplugin.git] / applications / forwardingrules-manager / src / main / java / org / opendaylight / openflowplugin / applications / frm / impl / DeviceMastership.java
index 54360a005dee373773f0d9fc2ff5f98da867413a..e6876ae401c461cc48502886f73bae9d052e4149 100644 (file)
@@ -25,25 +25,26 @@ public class DeviceMastership implements ClusterSingletonService, AutoCloseable
     private static final Logger LOG = LoggerFactory.getLogger(DeviceMastership.class);
     private final NodeId nodeId;
     private final ServiceGroupIdentifier identifier;
-    private final ClusterSingletonServiceRegistration clusterSingletonServiceRegistration;
+    private final ClusterSingletonServiceProvider clusterSingletonServiceProvider;
+    private ClusterSingletonServiceRegistration clusterSingletonServiceRegistration;
     private boolean deviceMastered;
 
     public DeviceMastership(final NodeId nodeId, final ClusterSingletonServiceProvider clusterSingletonService) {
         this.nodeId = nodeId;
         this.identifier = ServiceGroupIdentifier.create(nodeId.getValue());
         this.deviceMastered = false;
-        clusterSingletonServiceRegistration = clusterSingletonService.registerClusterSingletonService(this);
+        this.clusterSingletonServiceProvider = clusterSingletonService;
     }
 
     @Override
     public void instantiateServiceInstance() {
-        LOG.debug("FRM started for: {}", nodeId.getValue());
+        LOG.info("FRM started for: {}", nodeId.getValue());
         deviceMastered = true;
     }
 
     @Override
     public ListenableFuture<Void> closeServiceInstance() {
-        LOG.debug("FRM stopped for: {}", nodeId.getValue());
+        LOG.info("FRM stopped for: {}", nodeId.getValue());
         deviceMastered = false;
         return Futures.immediateFuture(null);
     }
@@ -68,4 +69,8 @@ public class DeviceMastership implements ClusterSingletonService, AutoCloseable
         return deviceMastered;
     }
 
+    public void registerClusterSingletonService() {
+        LOG.info("Registering FRM as a cluster singleton service listner for service id : {}",getIdentifier());
+        clusterSingletonServiceRegistration = clusterSingletonServiceProvider.registerClusterSingletonService(this);
+    }
 }