*/
package org.opendaylight.netvirt.natservice.ha;
-import java.math.BigInteger;
import java.util.concurrent.Executors;
-
+import javax.annotation.PreDestroy;
import javax.inject.Inject;
-
import javax.inject.Singleton;
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.genius.mdsalutil.MDSALUtil;
-import org.opendaylight.netvirt.natservice.api.CentralizedSwitchScheduler;
-import org.opendaylight.serviceutils.tools.mdsal.listener.AbstractClusteredAsyncDataTreeChangeListener;
+import org.opendaylight.mdsal.binding.api.DataBroker;
+import org.opendaylight.mdsal.binding.api.DataTreeIdentifier;
+import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
+import org.opendaylight.netvirt.natservice.api.NatSwitchCache;
+import org.opendaylight.serviceutils.tools.listener.AbstractClusteredAsyncDataTreeChangeListener;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.common.Uint64;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Singleton
public class SnatNodeEventListener extends AbstractClusteredAsyncDataTreeChangeListener<Node> {
private static final Logger LOG = LoggerFactory.getLogger(SnatNodeEventListener.class);
- private final CentralizedSwitchScheduler centralizedSwitchScheduler;
+ private final NatSwitchCache centralizedSwitchCache;
@Inject
public SnatNodeEventListener(final DataBroker dataBroker,
- final CentralizedSwitchScheduler centralizedSwitchScheduler) {
+ final NatSwitchCache centralizedSwitchCache) {
- super(dataBroker,new DataTreeIdentifier<>(LogicalDatastoreType.OPERATIONAL, InstanceIdentifier
+ super(dataBroker, DataTreeIdentifier.create(LogicalDatastoreType.OPERATIONAL, InstanceIdentifier
.create(Nodes.class).child(Node.class)),
Executors.newSingleThreadExecutor());
- this.centralizedSwitchScheduler = centralizedSwitchScheduler;
+ this.centralizedSwitchCache = centralizedSwitchCache;
+ }
+
+ @Override
+ @PreDestroy
+ public void close() {
+ super.close();
+ org.opendaylight.infrautils.utils.concurrent.Executors.shutdownAndAwaitTermination(getExecutorService());
}
@Override
public void remove(Node dataObjectModification) {
NodeKey nodeKey = dataObjectModification.key();
- BigInteger dpnId = MDSALUtil.getDpnIdFromNodeName(nodeKey.getId());
+ Uint64 dpnId = MDSALUtil.getDpnIdFromNodeName(nodeKey.getId());
LOG.info("Dpn removed {}", dpnId);
- centralizedSwitchScheduler.removeSwitch(dpnId);
+ centralizedSwitchCache.removeSwitch(dpnId);
}
@Override
@Override
public void add(Node dataObjectModification) {
NodeKey nodeKey = dataObjectModification.key();
- BigInteger dpnId = MDSALUtil.getDpnIdFromNodeName(nodeKey.getId());
+ Uint64 dpnId = MDSALUtil.getDpnIdFromNodeName(nodeKey.getId());
LOG.info("Dpn added {}", dpnId);
- centralizedSwitchScheduler.addSwitch(dpnId);
-
+ centralizedSwitchCache.addSwitch(dpnId);
}
}