import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
+import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipService;
import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RpcRegistration;
-import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
+import org.opendaylight.lispflowmapping.clustering.ClusterNodeModulSwitcherImpl;
+import org.opendaylight.lispflowmapping.clustering.api.ClusterNodeModuleSwitcher;
import org.opendaylight.lispflowmapping.lisp.type.LispMessage;
import org.opendaylight.lispflowmapping.southbound.lisp.LispSouthboundHandler;
import org.opendaylight.lispflowmapping.southbound.lisp.LispXtrSouthboundHandler;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MessageType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.transport.address.TransportAddress;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.sb.rev150904.OdlLispSbService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.lisp.sb.config.rev150517.LispSbConfig;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class LispSouthboundPlugin implements IConfigLispSouthboundPlugin, AutoCloseable {
+public class LispSouthboundPlugin implements IConfigLispSouthboundPlugin, AutoCloseable, ClusterNodeModuleSwitcher {
protected static final Logger LOG = LoggerFactory.getLogger(LispSouthboundPlugin.class);
private static Object startLock = new Object();
+ private final ClusterNodeModulSwitcherImpl clusterNodeModulSwitcher;
private LispSouthboundHandler lispSouthboundHandler;
private LispXtrSouthboundHandler lispXtrSouthboundHandler;
private NotificationPublishService notificationPublishService;
- private RpcProviderRegistry rpcRegistry;
private NioDatagramChannel channel;
private volatile String bindingAddress = "0.0.0.0";
private volatile int xtrPort = LispMessage.XTR_PORT_NUM;
private EventLoopGroup eventLoopGroup = new NioEventLoopGroup(0, threadFactory);
private DataBroker dataBroker;
+ public LispSouthboundPlugin(final DataBroker dataBroker,
+ final NotificationPublishService notificationPublishService,
+ final LispSbConfig lispSbConfig, final EntityOwnershipService entityOwnershipService) {
+ this.dataBroker = dataBroker;
+ this.notificationPublishService = notificationPublishService;
+ this.bindingAddress = lispSbConfig.getBindAddress();
+ this.mapRegisterCacheEnabled = lispSbConfig.isMapRegisterCache();
+ clusterNodeModulSwitcher = new ClusterNodeModulSwitcherImpl(entityOwnershipService);
+ clusterNodeModulSwitcher.setModule(this);
+ }
public void init() {
LOG.info("LISP (RFC6830) Southbound Plugin is initializing...");
- final LispSouthboundRPC sbRpcHandler = new LispSouthboundRPC(this);
-
- sbRpcRegistration = rpcRegistry.addRpcImplementation(OdlLispSbService.class, sbRpcHandler);
-
synchronized (startLock) {
lispSouthboundHandler = new LispSouthboundHandler(this);
lispSouthboundHandler.setDataBroker(dataBroker);
lispSouthboundHandler.setNotificationProvider(this.notificationPublishService);
lispSouthboundHandler.setMapRegisterCacheEnabled(mapRegisterCacheEnabled);
lispSouthboundHandler.init();
+ lispSouthboundHandler.restoreDaoFromDatastore();
lispXtrSouthboundHandler = new LispXtrSouthboundHandler();
lispXtrSouthboundHandler.setNotificationProvider(this.notificationPublishService);
LOG.info("LISP (RFC6830) Southbound Plugin is up!");
}
+ clusterNodeModulSwitcher.switchModuleByEntityOwnership();
}
private void start() {
startXtr();
}
- public void setNotificationPublishService(NotificationPublishService notificationService) {
- this.notificationPublishService = notificationService;
- }
-
- public void setRpcRegistryDependency(RpcProviderRegistry rpcRegistry) {
- this.rpcRegistry = rpcRegistry;
- }
-
private void unloadActions() {
lispSouthboundHandler = null;
lispXtrSouthboundHandler = null;
}
}
- public void setDataBroker(final DataBroker dataBroker) {
- this.dataBroker = dataBroker;
- }
-
public void setMapRegisterCacheEnabled(final boolean mapRegisterCacheEnabled) {
this.mapRegisterCacheEnabled = mapRegisterCacheEnabled;
if (mapRegisterCacheEnabled) {
@Override
public void close() throws Exception {
- unloadActions();
eventLoopGroup.shutdownGracefully();
sbRpcRegistration.close();
lispSouthboundHandler.close();
+ unloadActions();
+ }
+
+ @Override
+ public void stopModule() {
+ if (lispSouthboundHandler != null) {
+ lispSouthboundHandler.setNotificationProvider(null);
+ lispSouthboundHandler.setIsReadFromChannelEnabled(false);
+ }
+ if (lispXtrSouthboundHandler != null) {
+ lispXtrSouthboundHandler.setNotificationProvider(null);
+ }
+ }
+
+ @Override
+ public void startModule() {
+ if (lispSouthboundHandler != null) {
+ lispSouthboundHandler.setNotificationProvider(notificationPublishService);
+ lispSouthboundHandler.restoreDaoFromDatastore();
+ lispSouthboundHandler.setIsReadFromChannelEnabled(true);
+ }
+ if (lispXtrSouthboundHandler != null) {
+ lispXtrSouthboundHandler.setNotificationProvider(notificationPublishService);
+ }
}
}