* 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.openflowplugin.applications.frsync.impl.clustering;
import com.google.common.annotations.VisibleForTesting;
import java.util.concurrent.ConcurrentHashMap;
import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider;
-import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceRegistration;
import org.opendaylight.openflowplugin.applications.frsync.util.ReconciliationRegistry;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
import org.slf4j.Logger;
}
public void onDeviceConnected(final NodeId nodeId) {
- final DeviceMastership mastership = new DeviceMastership(nodeId, reconciliationRegistry);
- final ClusterSingletonServiceRegistration registration = clusterSingletonService.registerClusterSingletonService(mastership);
- mastership.setClusterSingletonServiceRegistration(registration);
- deviceMasterships.put(nodeId, mastership);
LOG.debug("FRS service registered for: {}", nodeId.getValue());
+ final DeviceMastership mastership = new DeviceMastership(nodeId, reconciliationRegistry,
+ clusterSingletonService);
+ deviceMasterships.put(nodeId, mastership);
}
-
public void onDeviceDisconnected(final NodeId nodeId) {
final DeviceMastership mastership = deviceMasterships.remove(nodeId);
- final ClusterSingletonServiceRegistration registration = mastership.getClusterSingletonServiceRegistration();
- if (registration != null) {
- try {
- registration.close();
- } catch (Exception e) {
- LOG.error("FRS cluster service close fail: {} {}", nodeId.getValue(), e);
- }
+ if (mastership != null) {
+ mastership.close();
}
LOG.debug("FRS service unregistered for: {}", nodeId.getValue());
}