<model.bgp.version>2013.07.15.10-SNAPSHOT</model.bgp.version>
<openflowplugin.version>0.4.0-SNAPSHOT</openflowplugin.version>
<genius.ovsdb.version>1.4.0-SNAPSHOT</genius.ovsdb.version>
+ <genius.infrautils.version>1.1.0-SNAPSHOT</genius.infrautils.version>
<liblldp.version>0.12.0-SNAPSHOT</liblldp.version>
<karaf.shell.console.version>3.0.3</karaf.shell.console.version>
</properties>
<artifactId>mdsalutil-api</artifactId>
<version>0.2.0-SNAPSHOT</version>
<packaging>bundle</packaging>
+
<dependencies>
<dependency>
<groupId>org.opendaylight.openflowplugin.model</groupId>
<artifactId>utils.config</artifactId>
<version>${genius.ovsdb.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.infrautils</groupId>
+ <artifactId>inject</artifactId>
+ <version>${genius.infrautils.version}</version>
+ </dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava-testlib</artifactId>
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
+import javax.annotation.PreDestroy;
import org.opendaylight.controller.md.sal.binding.api.ClusteredDataChangeListener;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker;
}
@Override
+ @PreDestroy
public void close() throws Exception {
if (listenerRegistration != null) {
try {
import org.slf4j.LoggerFactory;
import java.util.Collection;
-import java.util.concurrent.Callable;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
+import javax.annotation.PreDestroy;
public abstract class AsyncClusteredDataTreeChangeListenerBase<T extends DataObject, K extends ClusteredDataTreeChangeListener> implements ClusteredDataTreeChangeListener<T>, AutoCloseable {
private static final Logger LOG = LoggerFactory.getLogger(AsyncClusteredDataTreeChangeListenerBase.class);
final DataTreeIdentifier<T> treeId = new DataTreeIdentifier<>(dsType, getWildCardPath());
try {
TaskRetryLooper looper = new TaskRetryLooper(STARTUP_LOOP_TICK, STARTUP_LOOP_MAX_RETRIES);
- listenerRegistration = looper.loopUntilNoException(new Callable<ListenerRegistration<K>>() {
- @Override
- public ListenerRegistration<K> call() throws Exception {
- return db.registerDataTreeChangeListener(treeId, getDataTreeChangeListener());
- }
- });
+ listenerRegistration = looper.loopUntilNoException(() -> db.registerDataTreeChangeListener(treeId, getDataTreeChangeListener()));
} catch (final Exception e) {
LOG.warn("{}: Data Tree Change listener registration failed.", eventClazz.getName());
LOG.debug("{}: Data Tree Change listener registration failed: {}", eventClazz.getName(), e);
}
@Override
+ @PreDestroy
public void close() throws Exception {
if (listenerRegistration != null) {
try {
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
+import javax.annotation.PreDestroy;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.DataChangeListener;
import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker;
}
@Override
+ @PreDestroy
public void close() throws Exception {
if (listenerRegistration != null) {
try {
import com.google.common.base.Preconditions;
import java.util.Collection;
-import java.util.concurrent.Callable;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.DataObjectModification;
import org.opendaylight.controller.md.sal.binding.api.DataTreeChangeListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public abstract class AsyncDataTreeChangeListenerBase<T extends DataObject, K extends DataTreeChangeListener> implements DataTreeChangeListener<T>, AutoCloseable {
+public abstract class AsyncDataTreeChangeListenerBase<T extends DataObject, K extends DataTreeChangeListener>
+ implements DataTreeChangeListener<T>, AutoCloseable {
+
private static final Logger LOG = LoggerFactory.getLogger(AsyncDataTreeChangeListenerBase.class);
private static final int DATATREE_CHANGE_HANDLER_THREAD_POOL_CORE_SIZE = 1;
final DataTreeIdentifier<T> treeId = new DataTreeIdentifier<>(dsType, getWildCardPath());
try {
TaskRetryLooper looper = new TaskRetryLooper(STARTUP_LOOP_TICK, STARTUP_LOOP_MAX_RETRIES);
- listenerRegistration = looper.loopUntilNoException(new Callable<ListenerRegistration<K>>() {
- @Override
- public ListenerRegistration<K> call() throws Exception {
- return db.registerDataTreeChangeListener(treeId, getDataTreeChangeListener());
- }
- });
+ listenerRegistration = looper.loopUntilNoException(() -> db.registerDataTreeChangeListener(treeId, getDataTreeChangeListener()));
} catch (final Exception e) {
LOG.warn("{}: Data Tree Change listener registration failed.", eventClazz.getName());
LOG.debug("{}: Data Tree Change listener registration failed: {}", eventClazz.getName(), e);
}
}
+ /**
+ * Subclasses should override this and place initialization logic, notably calls to registerListener(), here.
+ */
+ @PostConstruct
+ protected void init() {
+ }
+
@Override
+ @PreDestroy
public void close() throws Exception {
if (listenerRegistration != null) {
try {
this.changes = changes;
}
-
-
@Override
public void run() {
for (DataTreeModification<T> change : changes) {