import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
-
-import java.util.Collection;
-import java.util.Map;
-import java.util.concurrent.Callable;
-import java.util.concurrent.ConcurrentHashMap;
-
-import org.opendaylight.controller.md.sal.binding.api.*;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier;
+import org.opendaylight.controller.md.sal.binding.api.DataTreeModification;
+import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
import org.opendaylight.openflowplugin.applications.statistics.manager.StatNodeRegistration;
import org.opendaylight.openflowplugin.applications.statistics.manager.StatisticsManager;
import org.opendaylight.openflowplugin.common.wait.SimpleTaskRetryLooper;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
import org.opendaylight.yangtools.concepts.ListenerRegistration;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.binding.NotificationListener;
-
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Map;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ConcurrentHashMap;
+
/**
* statistics-manager
* org.opendaylight.openflowplugin.applications.statistics.manager.impl
*
* StatAbstractListeneningCommiter
- * Class is abstract implementation for all Configuration/DataStore DataChange
+ * Class is abstract implementation for all Configuration/DataStore DataTreeModification
* listenable DataObjects like flows, groups, meters. It is a holder for common
- * functionality needed by construction/destruction class and for DataChange
+ * functionality needed by construction/destruction class and for DataTreeModification
* event processing.
- *
*/
public abstract class StatAbstractListenCommit<T extends DataObject, N extends NotificationListener>
extends StatAbstractNotifyCommit<N> implements StatListeningCommiter<T,N> {
protected final Map<InstanceIdentifier<Node>, Map<InstanceIdentifier<T>, Integer>> mapNodesForDelete = new ConcurrentHashMap<>();
protected final Map<InstanceIdentifier<Node>, Integer> mapNodeFeautureRepeater = new ConcurrentHashMap<>();
+ protected final Map<InstanceIdentifier<Node>, ArrayList<T>> removedDataBetweenStatsCycle = new
+ ConcurrentHashMap<>();
private final Class<T> clazz;
- private final DataBroker dataBroker;
+ protected final DataBroker dataBroker;
protected final StatNodeRegistration nodeRegistrationManager;
this.nodeRegistrationManager = nodeRegistrationManager;
SimpleTaskRetryLooper looper = new SimpleTaskRetryLooper(STARTUP_LOOP_TICK, STARTUP_LOOP_MAX_RETRIES);
- try{
+ try {
listenerRegistration = looper.loopUntilNoException(new Callable<ListenerRegistration<StatAbstractListenCommit<T, N>>>() {
@Override
public ListenerRegistration<StatAbstractListenCommit<T, N>> call() throws Exception {
return db.registerDataTreeChangeListener(treeId,StatAbstractListenCommit.this);
}
});
- }catch(final Exception ex){
- LOG.debug(" StatAbstractListenCommit DataChange listener registration failed {}", ex.getMessage());
+ } catch (final Exception ex) {
+ LOG.debug(" StatAbstractListenCommit DataTreeChangeListener registration failed {}", ex.getMessage());
throw new IllegalStateException("Notification supplier startup fail! System needs restart.", ex);
}
}
*/
protected abstract InstanceIdentifier<T> getWildCardedRegistrationPath();
+ protected abstract void processDataChange(Collection<DataTreeModification<T>> changes);
+
@Override
public void onDataTreeChanged(Collection<DataTreeModification<T>> changes) {
Preconditions.checkNotNull(changes, "Changes must not be null!");
* Latest read transaction will be allocated on another read using readLatestConfiguration
*/
currentReadTxStale = true;
+ processDataChange(changes);
}
@SuppressWarnings("unchecked")
@Override
public void cleanForDisconnect(final InstanceIdentifier<Node> nodeIdent) {
mapNodesForDelete.remove(nodeIdent);
+ removedDataBetweenStatsCycle.remove(nodeIdent);
}
@Override
try {
listenerRegistration.close();
} catch (final Exception e) {
- LOG.error("Error by stop {} DataChange StatListeningCommiter.", clazz.getSimpleName(), e);
+ LOG.error("Error by stop {} DataTreeChangeListener StatListeningCommiter.", clazz.getSimpleName(), e);
}
listenerRegistration = null;
}