Code Review
/
netvirt.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
NETVIRT-1630 migrate to md-sal APIs
[netvirt.git]
/
elanmanager
/
impl
/
src
/
main
/
java
/
org
/
opendaylight
/
netvirt
/
elan
/
internal
/
ElanDpnToTransportZoneListener.java
diff --git
a/elanmanager/impl/src/main/java/org/opendaylight/netvirt/elan/internal/ElanDpnToTransportZoneListener.java
b/elanmanager/impl/src/main/java/org/opendaylight/netvirt/elan/internal/ElanDpnToTransportZoneListener.java
index 12b456cec8dbae6611577c8e1752b09110068f6b..f6ce28621c0ac54171ef0841ea522c2ff1e714bd 100644
(file)
--- a/
elanmanager/impl/src/main/java/org/opendaylight/netvirt/elan/internal/ElanDpnToTransportZoneListener.java
+++ b/
elanmanager/impl/src/main/java/org/opendaylight/netvirt/elan/internal/ElanDpnToTransportZoneListener.java
@@
-7,15
+7,16
@@
*/
package org.opendaylight.netvirt.elan.internal;
*/
package org.opendaylight.netvirt.elan.internal;
-import javax.annotation.P
ostConstruct
;
+import javax.annotation.P
reDestroy
;
import javax.inject.Inject;
import javax.inject.Singleton;
import javax.inject.Inject;
import javax.inject.Singleton;
-import org.opendaylight.
controller.md.sal.binding.api.DataBroker
;
-import org.opendaylight.
controller.md.sal.common.api.data.LogicalDatastoreType
;
-import org.opendaylight.
genius.datastoreutils.AsyncDataTreeChangeListenerBas
e;
+import org.opendaylight.
infrautils.utils.concurrent.Executors
;
+import org.opendaylight.
mdsal.binding.api.DataBroker
;
+import org.opendaylight.
mdsal.common.api.LogicalDatastoreTyp
e;
import org.opendaylight.netvirt.elan.cache.ElanInstanceCache;
import org.opendaylight.netvirt.elan.utils.ElanUtils;
import org.opendaylight.netvirt.elan.utils.TransportZoneNotificationUtil;
import org.opendaylight.netvirt.elan.cache.ElanInstanceCache;
import org.opendaylight.netvirt.elan.utils.ElanUtils;
import org.opendaylight.netvirt.elan.utils.TransportZoneNotificationUtil;
+import org.opendaylight.serviceutils.tools.listener.AbstractAsyncDataTreeChangeListener;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.config.rev150710.ElanConfig;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.ElanDpnInterfaces;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.ElanDpnInterfacesList;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.config.rev150710.ElanConfig;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.ElanDpnInterfaces;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.ElanDpnInterfacesList;
@@
-27,7
+28,7
@@
import org.slf4j.LoggerFactory;
@Singleton
public class ElanDpnToTransportZoneListener
@Singleton
public class ElanDpnToTransportZoneListener
- extends A
syncDataTreeChangeListenerBase<DpnInterfaces, ElanDpnToTransportZoneListener
> {
+ extends A
bstractAsyncDataTreeChangeListener<DpnInterfaces
> {
private static final Logger LOG = LoggerFactory.getLogger(ElanDpnToTransportZoneListener.class);
private final TransportZoneNotificationUtil transportZoneNotificationUtil;
private static final Logger LOG = LoggerFactory.getLogger(ElanDpnToTransportZoneListener.class);
private final TransportZoneNotificationUtil transportZoneNotificationUtil;
@@
-39,34
+40,33
@@
public class ElanDpnToTransportZoneListener
public ElanDpnToTransportZoneListener(final DataBroker dbx,
final ElanConfig elanConfig, final TransportZoneNotificationUtil tznu,
final ElanInstanceCache elanInstanceCache) {
public ElanDpnToTransportZoneListener(final DataBroker dbx,
final ElanConfig elanConfig, final TransportZoneNotificationUtil tznu,
final ElanInstanceCache elanInstanceCache) {
+ super(dbx, LogicalDatastoreType.OPERATIONAL, InstanceIdentifier.create(ElanDpnInterfaces.class)
+ .child(ElanDpnInterfacesList.class).child(DpnInterfaces.class),
+ Executors.newListeningSingleThreadExecutor("ElanDpnToTransportZoneListener", LOG));
useTransportZone = elanConfig.isAutoConfigTransportZones();
transportZoneNotificationUtil = tznu;
this.dbx = dbx;
this.elanInstanceCache = elanInstanceCache;
useTransportZone = elanConfig.isAutoConfigTransportZones();
transportZoneNotificationUtil = tznu;
this.dbx = dbx;
this.elanInstanceCache = elanInstanceCache;
+ start();
}
}
- @PostConstruct
public void start() {
public void start() {
-
if (useTransportZone) {
if (useTransportZone) {
- registerListener(LogicalDatastoreType.OPERATIONAL, dbx);
LOG.info("{} registered", getClass().getSimpleName());
}
}
@Override
LOG.info("{} registered", getClass().getSimpleName());
}
}
@Override
- public InstanceIdentifier<DpnInterfaces> getWildCardPath() {
- return InstanceIdentifier.builder(ElanDpnInterfaces.class).child(ElanDpnInterfacesList.class)
- .child(DpnInterfaces.class).build();
- }
-
- @Override
- protected void remove(InstanceIdentifier<DpnInterfaces> key, DpnInterfaces dataObjectModification) {
+ public void remove(InstanceIdentifier<DpnInterfaces> key, DpnInterfaces dataObjectModification) {
+ //Proceed only if "auto-config-transport-zones = TRUE"
+ if (!useTransportZone) {
+ return;
+ }
LOG.debug("Elan dpn {} delete detected, deleting transport zones", dataObjectModification.getDpId());
Uint64 dpId = dataObjectModification.getDpId();
String elanInstanceName = key.firstKeyOf(ElanDpnInterfacesList.class).getElanInstanceName();
LOG.debug("Elan dpn {} delete detected, deleting transport zones", dataObjectModification.getDpId());
Uint64 dpId = dataObjectModification.getDpId();
String elanInstanceName = key.firstKeyOf(ElanDpnInterfacesList.class).getElanInstanceName();
- if (!ElanUtils.isVxlanNetworkOrVxlanSegment(elanInstanceCache.get(elanInstanceName).or
Null(
))) {
+ if (!ElanUtils.isVxlanNetworkOrVxlanSegment(elanInstanceCache.get(elanInstanceName).or
Else(null
))) {
LOG.debug("ElanInstance {} is not vxlan network, nothing to do", elanInstanceName);
return;
}
LOG.debug("ElanInstance {} is not vxlan network, nothing to do", elanInstanceName);
return;
}
@@
-76,18
+76,22
@@
public class ElanDpnToTransportZoneListener
}
@Override
}
@Override
- p
rotected
void update(InstanceIdentifier<DpnInterfaces> key, DpnInterfaces dataObjectModificationBefore,
+ p
ublic
void update(InstanceIdentifier<DpnInterfaces> key, DpnInterfaces dataObjectModificationBefore,
DpnInterfaces dataObjectModificationAfter) {
}
@Override
DpnInterfaces dataObjectModificationAfter) {
}
@Override
- protected void add(InstanceIdentifier<DpnInterfaces> key, DpnInterfaces dataObjectModification) {
+ public void add(InstanceIdentifier<DpnInterfaces> key, DpnInterfaces dataObjectModification) {
+ //Proceed only if "auto-config-transport-zones = TRUE"
+ if (!useTransportZone) {
+ return;
+ }
LOG.debug("Elan dpn {} add detected, updating transport zones", dataObjectModification.getDpId());
Uint64 dpId = dataObjectModification.getDpId();
String elanInstanceName = key.firstKeyOf(ElanDpnInterfacesList.class).getElanInstanceName();
LOG.debug("Elan dpn {} add detected, updating transport zones", dataObjectModification.getDpId());
Uint64 dpId = dataObjectModification.getDpId();
String elanInstanceName = key.firstKeyOf(ElanDpnInterfacesList.class).getElanInstanceName();
- if (!ElanUtils.isVxlanNetworkOrVxlanSegment(elanInstanceCache.get(elanInstanceName).or
Null(
))) {
+ if (!ElanUtils.isVxlanNetworkOrVxlanSegment(elanInstanceCache.get(elanInstanceName).or
Else(null
))) {
return;
}
return;
}
@@
-95,7
+99,9
@@
public class ElanDpnToTransportZoneListener
}
@Override
}
@Override
- protected ElanDpnToTransportZoneListener getDataTreeChangeListener() {
- return ElanDpnToTransportZoneListener.this;
+ @PreDestroy
+ public void close() {
+ super.close();
+ Executors.shutdownAndAwaitTermination(getExecutorService());
}
}
}
}