protected static final Uint16 IDLE_TIMEOUT = Uint16.valueOf(240);
protected static final Uint8 TABLE_ID = Uint8.ZERO;
- static final long STARTUP_LOOP_TICK = 500L;
- static final int STARTUP_LOOP_MAX_RETRIES = 8;
private static final int PROCESSING_POOL_SIZE = 10000;
private static final int POOL_THREAD_AMOUNT = 8;
private final ExecutorService executorService;
-
private static final AtomicIntegerFieldUpdater<AbstractDropTest> SENT_UPDATER = AtomicIntegerFieldUpdater
.newUpdater(AbstractDropTest.class, "sent");
private volatile int sent;
import org.opendaylight.mdsal.binding.api.NotificationService;
import org.opendaylight.mdsal.binding.api.ReadWriteTransaction;
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.FlowCapableNode;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table;
private static final AtomicLong ID_COUNTER = new AtomicLong();
private static final ThreadLocal<FlowBuilder> BUILDER = ThreadLocal.withInitial(() -> {
- final FlowBuilder fb = new FlowBuilder();
-
- fb.setPriority(PRIORITY);
- fb.setBufferId(BUFFER_ID);
- final FlowCookie cookie = new FlowCookie(Uint64.TEN);
- fb.setCookie(cookie);
- fb.setCookieMask(cookie);
-
- fb.setTableId(TABLE_ID);
- fb.setHardTimeout(HARD_TIMEOUT);
- fb.setIdleTimeout(IDLE_TIMEOUT);
- fb.setFlags(new FlowModFlags(false, false, false, false, false));
- return fb;
+ final var cookie = new FlowCookie(Uint64.TEN);
+ return new FlowBuilder()
+ .setPriority(PRIORITY)
+ .setBufferId(BUFFER_ID)
+ .setCookie(cookie)
+ .setCookieMask(cookie)
+ .setTableId(TABLE_ID)
+ .setHardTimeout(HARD_TIMEOUT)
+ .setIdleTimeout(IDLE_TIMEOUT)
+ .setFlags(new FlowModFlags(false, false, false, false, false));
});
private NotificationService notificationService;
/**
* start listening on packetIn.
*/
- @SuppressWarnings("checkstyle:IllegalCatch")
public void start() {
- final SimpleTaskRetryLooper looper = new SimpleTaskRetryLooper(STARTUP_LOOP_TICK,
- STARTUP_LOOP_MAX_RETRIES);
- try {
- notificationRegistration = looper.loopUntilNoException(
- () -> notificationService.registerListener(PacketReceived.class, this));
- } catch (Exception e) {
- LOG.warn("DropTest committer notification listener registration fail!");
- LOG.debug("DropTest committer notification listener registration fail! ..", e);
- throw new IllegalStateException("DropTest startup fail! Try again later.", e);
- }
+ notificationRegistration = notificationService.registerListener(PacketReceived.class, this);
}
public void setDataService(final DataBroker dataService) {
}
@Override
- @SuppressWarnings("checkstyle:IllegalCatch")
public void close() {
super.close();
- try {
- LOG.debug("DropTestProvider stopped.");
- if (notificationRegistration != null) {
- notificationRegistration.close();
- }
- } catch (RuntimeException e) {
- LOG.warn("unregistration of notification listener failed: {}", e.getMessage());
- LOG.debug("unregistration of notification listener failed.. ", e);
+ LOG.debug("DropTestProvider stopped.");
+ if (notificationRegistration != null) {
+ notificationRegistration.close();
}
}
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.MoreExecutors;
import org.opendaylight.mdsal.binding.api.NotificationService;
-import org.opendaylight.openflowplugin.common.wait.SimpleTaskRetryLooper;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowOutput;
}
private static final ThreadLocal<AddFlowInputBuilder> BUILDER = ThreadLocal.withInitial(() -> {
- final AddFlowInputBuilder fb = new AddFlowInputBuilder();
-
- fb.setPriority(PRIORITY);
- fb.setBufferId(BUFFER_ID);
-
- final FlowCookie cookie = new FlowCookie(Uint64.TEN);
- fb.setCookie(cookie);
- fb.setCookieMask(cookie);
- fb.setTableId(TABLE_ID);
- fb.setHardTimeout(HARD_TIMEOUT);
- fb.setIdleTimeout(IDLE_TIMEOUT);
- fb.setFlags(new FlowModFlags(false, false, false, false, false));
-
- return fb;
+ final var cookie = new FlowCookie(Uint64.TEN);
+ return new AddFlowInputBuilder()
+ .setPriority(PRIORITY)
+ .setBufferId(BUFFER_ID)
+ .setCookie(cookie)
+ .setCookieMask(cookie)
+ .setTableId(TABLE_ID)
+ .setHardTimeout(HARD_TIMEOUT)
+ .setIdleTimeout(IDLE_TIMEOUT)
+ .setFlags(new FlowModFlags(false, false, false, false, false));
});
private NotificationService notificationService;
/**
* Start listening on packetIn.
*/
- @SuppressWarnings("checkstyle:IllegalCatch")
public void start() {
- final SimpleTaskRetryLooper looper = new SimpleTaskRetryLooper(STARTUP_LOOP_TICK,
- STARTUP_LOOP_MAX_RETRIES);
- try {
- notificationRegistration = looper.loopUntilNoException(
- () -> notificationService.registerListener(PacketReceived.class, this));
- } catch (Exception e) {
- LOG.warn("DropTest sender notification listener registration fail!");
- LOG.debug("DropTest sender notification listener registration fail! ..", e);
- throw new IllegalStateException("DropTest startup fail! Try again later.", e);
- }
+ notificationRegistration = notificationService.registerListener(PacketReceived.class, this);
}
@Override
// Add flow
final AddFlowInput flow = fb.build();
- if (LOG.isDebugEnabled()) {
- LOG.debug("onPacketReceived - About to write flow (via SalFlowService) {}", flow);
- }
+ LOG.debug("onPacketReceived - About to write flow (via SalFlowService) {}", flow);
ListenableFuture<RpcResult<AddFlowOutput>> result = flowService.addFlow(flow);
Futures.addCallback(result, new FutureCallback<RpcResult<AddFlowOutput>>() {
@Override
}
@Override
- @SuppressWarnings("checkstyle:IllegalCatch")
public void close() {
super.close();
- try {
- LOG.debug("DropTestProvider stopped.");
- if (notificationRegistration != null) {
- notificationRegistration.close();
- }
- } catch (RuntimeException e) {
- LOG.warn("unregistration of notification listener failed: {}", e.getMessage());
- LOG.debug("unregistration of notification listener failed.. ", e);
+ LOG.debug("DropTestProvider stopped.");
+ if (notificationRegistration != null) {
+ notificationRegistration.close();
}
}
}