DTCL registration cannot really fail, do not loop on it needlessly.
Change-Id: Ifd0c1b820ada46cca921e09c3866e0bbc25fa9b4
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Signed-off-by: Sangwook Ha <sangwook.ha@verizon.com>
import org.opendaylight.openflowplugin.api.openflow.mastership.MastershipChangeService;
import org.opendaylight.openflowplugin.api.openflow.mastership.MastershipChangeServiceManager;
import org.opendaylight.openflowplugin.applications.frm.FlowNodeReconciliation;
-import org.opendaylight.openflowplugin.common.wait.SimpleTaskRetryLooper;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
private final ClusterSingletonServiceProvider clusterSingletonService;
private final FlowNodeReconciliation reconcliationAgent;
- private final DataBroker dataBroker;
private final ConcurrentHashMap<NodeId, DeviceMastership> deviceMasterships = new ConcurrentHashMap<>();
private final Object lockObj = new Object();
private final RpcProviderService rpcProviderService;
this.reconcliationAgent = reconcliationAgent;
this.rpcProviderService = rpcProviderService;
reconcliationService = reconciliationService;
- this.dataBroker = dataBroker;
- registerNodeListener();
+ listenerRegistration = dataBroker.registerDataTreeChangeListener(
+ DataTreeIdentifier.create(LogicalDatastoreType.OPERATIONAL,
+ InstanceIdentifier.create(Nodes.class).child(Node.class).augmentation(FlowCapableNode.class)), this);
mastershipChangeServiceRegistration = mastershipChangeServiceManager.register(this);
}
}
}
- @SuppressWarnings("IllegalCatch")
- private void registerNodeListener() {
-
- final InstanceIdentifier<FlowCapableNode> flowNodeWildCardIdentifier = InstanceIdentifier.create(Nodes.class)
- .child(Node.class).augmentation(FlowCapableNode.class);
-
- final DataTreeIdentifier<FlowCapableNode> treeId = DataTreeIdentifier.create(LogicalDatastoreType.OPERATIONAL,
- flowNodeWildCardIdentifier);
-
- try {
- SimpleTaskRetryLooper looper = new SimpleTaskRetryLooper(ForwardingRulesManagerImpl.STARTUP_LOOP_TICK,
- ForwardingRulesManagerImpl.STARTUP_LOOP_MAX_RETRIES);
-
- listenerRegistration = looper.loopUntilNoException(
- () -> dataBroker.registerDataTreeChangeListener(treeId, DeviceMastershipManager.this));
- } catch (Exception e) {
- LOG.warn("Data listener registration failed: {}", e.getMessage());
- LOG.debug("Data listener registration failed ", e);
- throw new IllegalStateException("Node listener registration failed!", e);
- }
- }
-
@Override
public void onBecomeOwner(@NonNull final DeviceInfo deviceInfo) {
LOG.debug("Mastership role notification received for device : {}", deviceInfo.getDatapathId());
import org.opendaylight.mdsal.binding.api.DataTreeIdentifier;
import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
import org.opendaylight.openflowplugin.applications.frm.FlowNodeConnectorInventoryTranslator;
-import org.opendaylight.openflowplugin.common.wait.SimpleTaskRetryLooper;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.concepts.Registration;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public final class FlowNodeConnectorInventoryTranslatorImpl
extends AbstractNodeConnectorCommitter<FlowCapableNodeConnector>
implements FlowNodeConnectorInventoryTranslator {
-
private static final Logger LOG = LoggerFactory.getLogger(FlowNodeConnectorInventoryTranslatorImpl.class);
-
- private ListenerRegistration<FlowNodeConnectorInventoryTranslatorImpl> dataTreeChangeListenerRegistration;
-
private static final String SEPARATOR = ":";
-
- private static final InstanceIdentifier<FlowCapableNodeConnector> II_TO_FLOW_CAPABLE_NODE_CONNECTOR
- = InstanceIdentifier.builder(Nodes.class)
+ private static final InstanceIdentifier<FlowCapableNodeConnector> II_TO_FLOW_CAPABLE_NODE_CONNECTOR =
+ InstanceIdentifier.builder(Nodes.class)
.child(Node.class)
.child(NodeConnector.class)
.augmentation(FlowCapableNodeConnector.class)
.build();
- private final Multimap<BigInteger, String> dpnToPortMultiMap = Multimaps
- .synchronizedListMultimap(ArrayListMultimap.create());
+ private Registration listenerRegistration;
+
+ private final Multimap<BigInteger, String> dpnToPortMultiMap = Multimaps.synchronizedListMultimap(
+ ArrayListMultimap.create());
- @SuppressWarnings("IllegalCatch")
public FlowNodeConnectorInventoryTranslatorImpl(final DataBroker dataBroker) {
requireNonNull(dataBroker, "DataBroker can not be null!");
-
- final DataTreeIdentifier<FlowCapableNodeConnector> treeId =
- DataTreeIdentifier.create(LogicalDatastoreType.OPERATIONAL, getWildCardPath());
- try {
- SimpleTaskRetryLooper looper = new SimpleTaskRetryLooper(ForwardingRulesManagerImpl.STARTUP_LOOP_TICK,
- ForwardingRulesManagerImpl.STARTUP_LOOP_MAX_RETRIES);
- dataTreeChangeListenerRegistration = looper.loopUntilNoException(() -> dataBroker
- .registerDataTreeChangeListener(treeId, FlowNodeConnectorInventoryTranslatorImpl.this));
- } catch (final Exception e) {
- LOG.warn(" FlowNodeConnectorInventoryTranslatorImpl listener registration fail!");
- LOG.debug("FlowNodeConnectorInventoryTranslatorImpl DataTreeChangeListener registration fail ..", e);
- throw new
- IllegalStateException("FlowNodeConnectorInventoryTranslatorImpl startup fail! System needs restart.", e);
- }
+ listenerRegistration = dataBroker.registerDataTreeChangeListener(
+ DataTreeIdentifier.create(LogicalDatastoreType.OPERATIONAL, getWildCardPath()), this);
}
@Override
@Override
public void close() {
- if (dataTreeChangeListenerRegistration != null) {
- dataTreeChangeListenerRegistration.close();
- dataTreeChangeListenerRegistration = null;
+ if (listenerRegistration != null) {
+ listenerRegistration.close();
+ listenerRegistration = null;
}
}
public final class ForwardingRulesManagerImpl implements ForwardingRulesManager {
private static final Logger LOG = LoggerFactory.getLogger(ForwardingRulesManagerImpl.class);
- static final int STARTUP_LOOP_TICK = 1000;
- static final int STARTUP_LOOP_MAX_RETRIES = 240;
private static final int FRM_RECONCILIATION_PRIORITY = Integer.getInteger("frm.reconciliation.priority", 1);
private static final String SERVICE_NAME = "FRM";
devicesGroupRegistry = new DevicesGroupRegistry();
nodeListener = new FlowNodeReconciliationImpl(this, dataService, SERVICE_NAME, FRM_RECONCILIATION_PRIORITY,
ResultState.DONOTHING, flowGroupCacheManager);
- if (this.isReconciliationDisabled()) {
+ if (isReconciliationDisabled()) {
LOG.debug("Reconciliation is disabled by user");
} else {
reconciliationNotificationRegistration = reconciliationManager.registerService(nodeListener);
import org.opendaylight.mdsal.binding.api.ClusteredDataTreeChangeListener;
import org.opendaylight.mdsal.binding.api.DataBroker;
import org.opendaylight.mdsal.binding.api.DataTreeIdentifier;
-import org.opendaylight.openflowplugin.common.wait.SimpleTaskRetryLooper;
import org.opendaylight.yangtools.concepts.ListenerRegistration;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-
@Singleton
public class ListenerRegistrationHelper {
private static final Logger LOG = LoggerFactory.getLogger(ListenerRegistrationHelper.class);
private static final long INVENTORY_CHECK_TIMER = 1;
+
private final String operational = "OPERATIONAL";
private final ListeningExecutorService listeningExecutorService;
private final DataBroker dataBroker;
public ListenerRegistrationHelper(final DataBroker dataBroker) {
this.dataBroker = dataBroker;
listeningExecutorService = MoreExecutors.listeningDecorator(Executors.newSingleThreadExecutor(
- new ThreadFactoryBuilder()
+ new ThreadFactoryBuilder()
.setNameFormat("frm-listener" + "%d")
.setDaemon(false)
.setUncaughtExceptionHandler((thread, ex) -> LOG.error("Uncaught exception {}", thread, ex))
}
public <T extends DataObject, L extends ClusteredDataTreeChangeListener<T>>
- ListenableFuture<ListenerRegistration<L>>
- checkedRegisterListener(DataTreeIdentifier<T> treeId, L listener) {
+ ListenableFuture<ListenerRegistration<L>> checkedRegisterListener(
+ DataTreeIdentifier<T> treeId, L listener) {
return listeningExecutorService.submit(() -> {
- while (! getInventoryConfigDataStoreStatus().equals(operational)) {
+ while (!getInventoryConfigDataStoreStatus().equals(operational)) {
try {
LOG.debug("Retrying for datastore to become operational for listener {}", listener);
Thread.sleep(INVENTORY_CHECK_TIMER * 1000);
Thread.currentThread().interrupt();
}
}
- SimpleTaskRetryLooper looper = new SimpleTaskRetryLooper(ForwardingRulesManagerImpl.STARTUP_LOOP_TICK,
- ForwardingRulesManagerImpl.STARTUP_LOOP_MAX_RETRIES);
- return looper.loopUntilNoException(() -> dataBroker.registerDataTreeChangeListener(treeId, listener));
+ return dataBroker.registerDataTreeChangeListener(treeId, listener);
});
}
public void close() throws Exception {
MoreExecutors.shutdownAndAwaitTermination(listeningExecutorService, 5, TimeUnit.SECONDS);
}
-}
\ No newline at end of file
+}
import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.mdsal.binding.api.ClusteredDataTreeChangeListener;
import org.opendaylight.mdsal.binding.api.DataBroker;
-import org.opendaylight.mdsal.binding.api.DataTreeChangeListener;
import org.opendaylight.mdsal.binding.api.DataTreeIdentifier;
import org.opendaylight.mdsal.binding.api.DataTreeModification;
import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
-import org.opendaylight.openflowplugin.common.wait.SimpleTaskRetryLooper;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnectorBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortConfig;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.concepts.Registration;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.slf4j.Logger;
* NodeConnectorInventoryEventTranslator is listening for changes in inventory operational DOM tree
* and update LLDPSpeaker and topology.
*/
-public class NodeConnectorInventoryEventTranslator<T extends DataObject>
+public final class NodeConnectorInventoryEventTranslator<T extends DataObject>
implements ClusteredDataTreeChangeListener<T>, AutoCloseable {
private static final Logger LOG = LoggerFactory.getLogger(NodeConnectorInventoryEventTranslator.class);
= InstanceIdentifier.builder(Nodes.class).child(Node.class).child(NodeConnector.class)
.augmentation(FlowCapableNodeConnector.class).build();
- private static final long STARTUP_LOOP_TICK = 500L;
- private static final int STARTUP_LOOP_MAX_RETRIES = 8;
-
- private final ListenerRegistration<DataTreeChangeListener> listenerOnPortRegistration;
- private final ListenerRegistration<DataTreeChangeListener> listenerOnPortStateRegistration;
+ private final Registration listenerOnPortRegistration;
+ private final Registration listenerOnPortStateRegistration;
private final Set<NodeConnectorEventsObserver> observers;
private final Map<InstanceIdentifier<?>, FlowCapableNodeConnector> iiToDownFlowCapableNodeConnectors
= new HashMap<>();
- @SuppressWarnings("IllegalCatch")
public NodeConnectorInventoryEventTranslator(final DataBroker dataBroker,
final NodeConnectorEventsObserver... observers) {
this.observers = ImmutableSet.copyOf(observers);
+
final DataTreeIdentifier dtiToNodeConnector = DataTreeIdentifier.create(LogicalDatastoreType.OPERATIONAL,
II_TO_FLOW_CAPABLE_NODE_CONNECTOR);
final DataTreeIdentifier dtiToNodeConnectorState = DataTreeIdentifier.create(LogicalDatastoreType.OPERATIONAL,
II_TO_STATE);
- final SimpleTaskRetryLooper looper = new SimpleTaskRetryLooper(STARTUP_LOOP_TICK, STARTUP_LOOP_MAX_RETRIES);
- try {
- listenerOnPortRegistration = looper.loopUntilNoException(() ->
- dataBroker.registerDataTreeChangeListener(dtiToNodeConnector,
- NodeConnectorInventoryEventTranslator.this));
- listenerOnPortStateRegistration = looper.loopUntilNoException(() ->
- dataBroker.registerDataTreeChangeListener(dtiToNodeConnectorState,
- NodeConnectorInventoryEventTranslator.this));
- } catch (Exception e) {
- LOG.error("DataTreeChangeListeners registration failed", e);
- throw new IllegalStateException("NodeConnectorInventoryEventTranslator startup failed!", e);
- }
+ listenerOnPortRegistration = dataBroker.registerDataTreeChangeListener(dtiToNodeConnector, this);
+ listenerOnPortStateRegistration = dataBroker.registerDataTreeChangeListener(dtiToNodeConnectorState, this);
LOG.info("NodeConnectorInventoryEventTranslator has started.");
}
import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
import org.opendaylight.openflowplugin.api.OFConstants;
import org.opendaylight.openflowplugin.applications.deviceownershipservice.DeviceOwnershipService;
-import org.opendaylight.openflowplugin.common.wait.SimpleTaskRetryLooper;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
import org.opendaylight.yang.gen.v1.urn.opendaylight.module.config.rev141015.NodeConfigService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.module.config.rev141015.SetConfigInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.SwitchConfigFlag;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.concepts.Registration;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Singleton
public class DefaultConfigPusher implements AutoCloseable, ClusteredDataTreeChangeListener<FlowCapableNode> {
private static final Logger LOG = LoggerFactory.getLogger(DefaultConfigPusher.class);
- private static final long STARTUP_LOOP_TICK = 500L;
- private static final int STARTUP_LOOP_MAX_RETRIES = 8;
+
private final NodeConfigService nodeConfigService;
private final DataBroker dataBroker;
private final DeviceOwnershipService deviceOwnershipService;
- private ListenerRegistration<?> listenerRegistration;
+
+ private Registration listenerRegistration;
@Inject
public DefaultConfigPusher(final NodeConfigService nodeConfigService, final DataBroker dataBroker,
this.deviceOwnershipService = requireNonNull(deviceOwnershipService, "DeviceOwnershipService can not be null");
}
- @SuppressWarnings("checkstyle:IllegalCatch")
@PostConstruct
public void start() {
- try {
- final InstanceIdentifier<FlowCapableNode> path = InstanceIdentifier.create(Nodes.class).child(Node.class)
- .augmentation(FlowCapableNode.class);
- final DataTreeIdentifier<FlowCapableNode> identifier = DataTreeIdentifier.create(
- LogicalDatastoreType.OPERATIONAL, path);
- final SimpleTaskRetryLooper looper = new SimpleTaskRetryLooper(STARTUP_LOOP_TICK, STARTUP_LOOP_MAX_RETRIES);
- listenerRegistration = looper.loopUntilNoException(
- () -> dataBroker.registerDataTreeChangeListener(identifier, DefaultConfigPusher.this));
- } catch (Exception e) {
- LOG.error("DataTreeChangeListener registration failed", e);
- throw new IllegalStateException("DefaultConfigPusher startup failed!", e);
- }
+ listenerRegistration = dataBroker.registerDataTreeChangeListener(
+ DataTreeIdentifier.create(LogicalDatastoreType.OPERATIONAL,
+ InstanceIdentifier.create(Nodes.class).child(Node.class).augmentation(FlowCapableNode.class)),
+ this);
LOG.info("DefaultConfigPusher has started.");
}
import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
import org.opendaylight.openflowplugin.api.OFConstants;
import org.opendaylight.openflowplugin.applications.deviceownershipservice.DeviceOwnershipService;
-import org.opendaylight.openflowplugin.common.wait.SimpleTaskRetryLooper;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri;
import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.OutputActionCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.output.action._case.OutputActionBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;
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.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.concepts.Registration;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.binding.util.BindingMap;
import org.opendaylight.yangtools.yang.common.Uint16;
public class LLDPPacketPuntEnforcer implements AutoCloseable, ClusteredDataTreeChangeListener<FlowCapableNode> {
private static final Logger LOG = LoggerFactory.getLogger(LLDPPacketPuntEnforcer.class);
- private static final long STARTUP_LOOP_TICK = 500L;
- private static final int STARTUP_LOOP_MAX_RETRIES = 8;
private static final Uint8 TABLE_ID = Uint8.ZERO;
private static final String LLDP_PUNT_WHOLE_PACKET_FLOW = "LLDP_PUNT_WHOLE_PACKET_FLOW";
private static final String DEFAULT_FLOW_ID = "42";
+
private final SalFlowService flowService;
private final DataBroker dataBroker;
private final DeviceOwnershipService deviceOwnershipService;
- private ListenerRegistration<?> listenerRegistration;
+ private Registration listenerRegistration;
public LLDPPacketPuntEnforcer(final SalFlowService flowService, final DataBroker dataBroker,
final DeviceOwnershipService deviceOwnershipService) {
this.deviceOwnershipService = requireNonNull(deviceOwnershipService, "DeviceOwnershipService can not be null");
}
- @SuppressWarnings("IllegalCatch")
public void start() {
- final InstanceIdentifier<FlowCapableNode> path = InstanceIdentifier.create(Nodes.class).child(Node.class)
- .augmentation(FlowCapableNode.class);
- final DataTreeIdentifier<FlowCapableNode> identifier = DataTreeIdentifier.create(
- LogicalDatastoreType.OPERATIONAL, path);
- SimpleTaskRetryLooper looper = new SimpleTaskRetryLooper(STARTUP_LOOP_TICK, STARTUP_LOOP_MAX_RETRIES);
- try {
- listenerRegistration = looper.loopUntilNoException(() ->
- dataBroker.registerDataTreeChangeListener(identifier, LLDPPacketPuntEnforcer.this));
- } catch (Exception e) {
- throw new IllegalStateException("registerDataTreeChangeListener failed", e);
- }
+ listenerRegistration = dataBroker.registerDataTreeChangeListener(
+ DataTreeIdentifier.create(LogicalDatastoreType.OPERATIONAL,
+ InstanceIdentifier.create(Nodes.class).child(Node.class).augmentation(FlowCapableNode.class)),
+ this);
}
@Override
AddFlowInputBuilder addFlowInput = new AddFlowInputBuilder(createFlow());
addFlowInput.setNode(new NodeRef(modification.getRootPath()
.getRootIdentifier().firstIdentifierOf(Node.class)));
- LoggingFutures.addErrorLogging(this.flowService.addFlow(addFlowInput.build()), LOG, "addFlow");
+ LoggingFutures.addErrorLogging(flowService.addFlow(addFlowInput.build()), LOG, "addFlow");
} else {
LOG.debug("Node {} is not owned by this controller, so skip adding LLDP table miss flow", nodeId);
}
*/
package org.opendaylight.openflowplugin.applications.topology.manager;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import org.opendaylight.mdsal.binding.api.DataBroker;
import org.opendaylight.mdsal.binding.api.DataTreeChangeListener;
import org.opendaylight.mdsal.binding.api.DataTreeIdentifier;
import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
-import org.opendaylight.openflowplugin.common.wait.SimpleTaskRetryLooper;
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.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology;
import org.opendaylight.yangtools.concepts.ListenerRegistration;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
public abstract class DataTreeChangeListenerImpl<T extends DataObject> implements DataTreeChangeListener<T>,
AutoCloseable {
+ static final InstanceIdentifier<Topology> II_TO_TOPOLOGY = InstanceIdentifier.create(NetworkTopology.class)
+ .child(Topology.class, new TopologyKey(new TopologyId(FlowCapableTopologyProvider.TOPOLOGY_ID)));
- private static final Logger LOG = LoggerFactory.getLogger(DataTreeChangeListenerImpl.class);
- private static final long STARTUP_LOOP_TICK = 500L;
- private static final int STARTUP_LOOP_MAX_RETRIES = 8;
protected final ListenerRegistration<?> listenerRegistration;
protected OperationProcessor operationProcessor;
- static final InstanceIdentifier<Topology> II_TO_TOPOLOGY = InstanceIdentifier.create(NetworkTopology.class)
- .child(Topology.class, new TopologyKey(new TopologyId(FlowCapableTopologyProvider.TOPOLOGY_ID)));
-
- @SuppressWarnings("checkstyle:IllegalCatch")
+ @SuppressFBWarnings(value = "MC_OVERRIDABLE_METHOD_CALL_IN_CONSTRUCTOR",
+ justification = "'this' passed to registerDataTreeChangeListener")
public DataTreeChangeListenerImpl(final OperationProcessor operationProcessor, final DataBroker dataBroker,
- final InstanceIdentifier<T> ii) {
- final DataTreeIdentifier<T> identifier = DataTreeIdentifier.create(LogicalDatastoreType.OPERATIONAL, ii);
- final SimpleTaskRetryLooper looper = new SimpleTaskRetryLooper(STARTUP_LOOP_TICK, STARTUP_LOOP_MAX_RETRIES);
- try {
- listenerRegistration = looper.loopUntilNoException(
- () -> dataBroker.registerDataTreeChangeListener(identifier, DataTreeChangeListenerImpl.this));
- } catch (Exception e) {
- LOG.error("Data listener registration failed!");
- throw new IllegalStateException("TopologyManager startup fail! TM bundle needs restart.", e);
- }
+ final InstanceIdentifier<T> ii) {
+ listenerRegistration = dataBroker.registerDataTreeChangeListener(
+ DataTreeIdentifier.create(LogicalDatastoreType.OPERATIONAL, ii), this);
this.operationProcessor = operationProcessor;
}
listenerRegistration.close();
}
- <T extends DataObject> void sendToTransactionChain(final T node, final InstanceIdentifier<T> iiToTopologyNode) {
+ <O extends DataObject> void sendToTransactionChain(final O node, final InstanceIdentifier<O> iiToTopologyNode) {
operationProcessor.enqueueOperation(
manager -> manager.mergeToTransaction(LogicalDatastoreType.OPERATIONAL, iiToTopologyNode, node, true));
}