import java.util.concurrent.Future;
import org.opendaylight.infrautils.utils.concurrent.LoggingFutures;
import org.opendaylight.mdsal.binding.api.DataBroker;
-import org.opendaylight.mdsal.binding.api.DataTreeIdentifier;
import org.opendaylight.mdsal.binding.api.ReadTransaction;
import org.opendaylight.mdsal.binding.api.WriteTransaction;
import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
private ListenerRegistration<FlowForwarder> listenerRegistration;
- public FlowForwarder(final ForwardingRulesManager manager, final DataBroker db) {
- super(manager, db);
- }
+ private final BundleFlowForwarder bundleFlowForwarder;
- @Override
- @SuppressWarnings("IllegalCatch")
- public void registerListener() {
- final DataTreeIdentifier<Flow> treeId = DataTreeIdentifier.create(LogicalDatastoreType.CONFIGURATION,
- getWildCardPath());
- try {
- listenerRegistration = dataBroker.registerDataTreeChangeListener(treeId, FlowForwarder.this);
- } catch (final Exception e) {
- LOG.warn("FRM Flow DataTreeChange listener registration fail!");
- LOG.debug("FRM Flow DataTreeChange listener registration fail ..", e);
- throw new IllegalStateException("FlowForwarder startup fail! System needs restart.", e);
- }
+ public FlowForwarder(final ForwardingRulesManager manager, final DataBroker db,
+ final ListenerRegistrationHelper registrationHelper) {
+ super(manager, db, registrationHelper);
+ bundleFlowForwarder = new BundleFlowForwarder(manager);
}
-
@Override
public void deregisterListener() {
close();
return true;
}
- private StaleFlow makeStaleFlow(InstanceIdentifier<Flow> identifier, Flow del,
+ private static StaleFlow makeStaleFlow(InstanceIdentifier<Flow> identifier, Flow del,
InstanceIdentifier<FlowCapableNode> nodeIdent) {
StaleFlowBuilder staleFlowBuilder = new StaleFlowBuilder(del);
return staleFlowBuilder.setId(del.getId()).build();
private void persistStaleFlow(StaleFlow staleFlow, InstanceIdentifier<FlowCapableNode> nodeIdent) {
WriteTransaction writeTransaction = dataBroker.newWriteOnlyTransaction();
writeTransaction.put(LogicalDatastoreType.CONFIGURATION, getStaleFlowInstanceIdentifier(staleFlow, nodeIdent),
- staleFlow, false);
+ staleFlow);
FluentFuture<?> submitFuture = writeTransaction.commit();
handleStaleFlowResultFuture(submitFuture);
}
- private void handleStaleFlowResultFuture(FluentFuture<?> submitFuture) {
+ private static void handleStaleFlowResultFuture(FluentFuture<?> submitFuture) {
submitFuture.addCallback(new FutureCallback<Object>() {
@Override
public void onSuccess(Object result) {
}
- private InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.opendaylight
+ private static InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.opendaylight
.flow.inventory.rev130819.tables.table.StaleFlow> getStaleFlowInstanceIdentifier(
StaleFlow staleFlow, InstanceIdentifier<FlowCapableNode> nodeIdent) {
return nodeIdent.child(Table.class, new TableKey(staleFlow.getTableId())).child(
resultFuture.setException(throwable);
}
}
-}
+}
\ No newline at end of file