import java.util.Collections;
import java.util.List;
import java.util.SortedSet;
-import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
import javax.inject.Inject;
import javax.inject.Singleton;
-import org.opendaylight.controller.md.sal.binding.api.ClusteredDataTreeChangeListener;
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.genius.datastoreutils.AsyncDataTreeChangeListenerBase;
import org.opendaylight.genius.interfacemanager.interfaces.IInterfaceManager;
import org.opendaylight.infrautils.jobcoordinator.JobCoordinator;
+import org.opendaylight.infrautils.utils.concurrent.Executors;
+import org.opendaylight.mdsal.binding.api.ClusteredDataTreeChangeListener;
+import org.opendaylight.mdsal.binding.api.DataBroker;
+import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
import org.opendaylight.netvirt.aclservice.api.AclInterfaceCache;
import org.opendaylight.netvirt.aclservice.api.AclServiceManager;
import org.opendaylight.netvirt.aclservice.api.AclServiceManager.Action;
import org.opendaylight.netvirt.aclservice.utils.AclServiceUtils;
import org.opendaylight.serviceutils.srm.RecoverableListener;
import org.opendaylight.serviceutils.srm.ServiceRecoveryRegistry;
+import org.opendaylight.serviceutils.tools.listener.AbstractAsyncDataTreeChangeListener;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev170119.L2vlan;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.InterfacesState;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface;
import org.slf4j.LoggerFactory;
@Singleton
-public class AclInterfaceStateListener extends AsyncDataTreeChangeListenerBase<Interface,
- AclInterfaceStateListener> implements ClusteredDataTreeChangeListener<Interface>, RecoverableListener {
+public class AclInterfaceStateListener extends AbstractAsyncDataTreeChangeListener<Interface>
+ implements ClusteredDataTreeChangeListener<Interface>, RecoverableListener {
private static final Logger LOG = LoggerFactory.getLogger(AclInterfaceStateListener.class);
DataBroker dataBroker, AclDataUtil aclDataUtil, IInterfaceManager interfaceManager,
AclInterfaceCache aclInterfaceCache, AclServiceUtils aclServicUtils, JobCoordinator jobCoordinator,
ServiceRecoveryRegistry serviceRecoveryRegistry) {
- super(Interface.class, AclInterfaceStateListener.class);
+ super(dataBroker, LogicalDatastoreType.OPERATIONAL,
+ InstanceIdentifier.create(InterfacesState.class).child(Interface.class),
+ Executors.newListeningSingleThreadExecutor("AclInterfaceStateListener", LOG));
this.aclServiceManger = aclServiceManger;
this.aclClusterUtil = aclClusterUtil;
this.dataBroker = dataBroker;
serviceRecoveryRegistry.addRecoverableListener(AclServiceUtils.getRecoverServiceRegistryKey(), this);
}
- @Override
- @PostConstruct
public void init() {
LOG.info("{} start", getClass().getSimpleName());
- registerListener();
}
@Override
public void registerListener() {
- registerListener(LogicalDatastoreType.OPERATIONAL, dataBroker);
+ super.register();
}
@Override
- protected InstanceIdentifier<Interface> getWildCardPath() {
- return InstanceIdentifier.create(InterfacesState.class).child(Interface.class);
+ public void deregisterListener() {
+ super.close();
}
@Override
- protected void remove(InstanceIdentifier<Interface> key, Interface deleted) {
+ public void remove(InstanceIdentifier<Interface> key, Interface deleted) {
if (!L2vlan.class.equals(deleted.getType())) {
return;
}
}
@Override
- protected void update(InstanceIdentifier<Interface> key, Interface before, Interface after) {
+ public void update(InstanceIdentifier<Interface> key, Interface before, Interface after) {
/*
* The update is not of interest as the attributes populated from this listener will not change.
* The northbound updates are handled in AclInterfaceListener.
}
@Override
- protected void add(InstanceIdentifier<Interface> key, Interface added) {
+ public void add(InstanceIdentifier<Interface> key, Interface added) {
if (!L2vlan.class.equals(added.getType())) {
return;
}
}
aclInterfaceCache.addOrUpdate(added.getName(), (prevAclInterface, builder) -> {
builder.portSecurityEnabled(aclInPort.isPortSecurityEnabled())
- .securityGroups(aclInPort.getSecurityGroups())
+ .interfaceType(aclInPort.getInterfaceType()).securityGroups(aclInPort.getSecurityGroups())
.allowedAddressPairs(aclInPort.getAllowedAddressPairs()).subnetInfo(aclInPort.getSubnetInfo());
});
}
}
@Override
- protected AclInterfaceStateListener getDataTreeChangeListener() {
- return AclInterfaceStateListener.this;
+ @PreDestroy
+ public void close() {
+ super.close();
+ Executors.shutdownAndAwaitTermination(getExecutorService());
}
}