... where it makes the code more readable.
Change-Id: I96f312601e9619b7f5186f00c3e759d0faebcf84
Signed-off-by: Stephen Kitt <skitt@redhat.com>
}
protected Callable<Integer> listSize(List<?> list) {
- return new Callable<Integer>() {
- public Integer call() throws Exception {
- return list.size(); // The condition supplier part
- }
- };
+ // The condition supplier part
+ return list::size;
}
}
package org.opendaylight.openflowplugin.applications.notification.supplier.impl;
import com.google.common.base.Preconditions;
-import java.util.concurrent.Callable;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.DataTreeChangeListener;
import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier;
SimpleTaskRetryLooper looper = new SimpleTaskRetryLooper(STARTUP_LOOP_TICK, STARTUP_LOOP_MAX_RETRIES);
try {
listenerRegistration = looper
- .loopUntilNoException(new Callable<ListenerRegistration<DataTreeChangeListener<O>>>() {
- @Override
- public ListenerRegistration<DataTreeChangeListener<O>> call() throws Exception {
- return db.registerDataTreeChangeListener(treeId, AbstractNotificationSupplierBase.this);
- }
- });
+ .loopUntilNoException(
+ () -> db.registerDataTreeChangeListener(treeId, AbstractNotificationSupplierBase.this));
} catch (final Exception ex) {
LOG.debug("AbstractNotificationSupplierBase DataTreeChange listener registration fail ..{}",
ex.getMessage());
SettableFuture<RpcResult<ReconcileOutput>> result = SettableFuture.create();
List<Long> nodeList = getAllNodes();
List<Long> nodesToReconcile = reconcileAllNodes ? nodeList :
- inputNodes.stream().distinct().map(node -> node.longValue()).collect(Collectors.toList());
+ inputNodes.stream().distinct().map(BigInteger::longValue).collect(Collectors.toList());
if (nodesToReconcile.size() > 0) {
List<Long> unresolvedNodes =
nodesToReconcile.stream().filter(node -> !nodeList.contains(node)).collect(Collectors.toList());
private List<Long> getAllNodes() {
List<OFNode> nodeList = ShellUtil.getAllNodes(broker);
- List<Long> nodes = nodeList.stream().distinct().map(node -> node.getNodeId()).collect(Collectors.toList());
+ List<Long> nodes = nodeList.stream().distinct().map(OFNode::getNodeId).collect(Collectors.toList());
return nodes;
}
protected Object doExecute() throws Exception {
List<BigInteger> nodes = (nodeIds == null)
? new ArrayList<>()
- : nodeIds.stream().distinct().map(node -> BigInteger.valueOf(node)).collect(Collectors.toList());
+ : nodeIds.stream().distinct().map(BigInteger::valueOf).collect(Collectors.toList());
LOG.debug("Triggering reconciliation for nodes {}", nodes);
ReconcileInput rpcInput = new ReconcileInputBuilder().setNodes(nodes)
.setReconcileAllNodes(reconcileAllNodes).build();
}
static void setReadFutureAsync(final Topology topology, final SettableFuture<Optional<Topology>> readFuture) {
- new Thread() {
- @Override
- public void run() {
- Uninterruptibles.sleepUninterruptibly(5, TimeUnit.SECONDS);
- readFuture.set(Optional.of(topology));
- }
- }.start();
+ new Thread(() -> {
+ Uninterruptibles.sleepUninterruptibly(5, TimeUnit.SECONDS);
+ readFuture.set(Optional.of(topology));
+ }).start();
}
static void waitForSubmit(CountDownLatch latch) {
protected boolean shuttingDown;
// Passed to executor to request triggering of flush
- protected final Runnable flushRunnable = () -> flush();
+ protected final Runnable flushRunnable = this::flush;
AbstractOutboundQueueManager(final ConnectionAdapterImpl parent, final InetSocketAddress address, final T handler) {
this.parent = Preconditions.checkNotNull(parent);
private static final Logger LOG = LoggerFactory.getLogger(ChannelOutboundQueue.class);
// Passed to executor to request triggering of flush
- private final Runnable flushRunnable = () -> ChannelOutboundQueue.this.flush();
+ private final Runnable flushRunnable = ChannelOutboundQueue.this::flush;
/*
* Instead of using an AtomicBoolean object, we use these two. It saves us
private int nonBarrierMessages;
// Passed to executor to request a periodic barrier check
- private final Runnable barrierRunnable = new Runnable() {
- @Override
- public void run() {
- barrier();
- }
- };
+ private final Runnable barrierRunnable = this::barrier;
OutboundQueueManager(final ConnectionAdapterImpl parent, final InetSocketAddress address, final T handler,
final int maxNonBarrierMessages, final long maxBarrierNanos) {
HelloInput hi = hib.build();
adapter.hello(hi);
LOGGER.debug("hello msg sent");
- new Thread(() -> getSwitchFeatures()).start();
+ new Thread(this::getSwitchFeatures).start();
}).start();
}
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortGrouping;
import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.FlowCapableNodeConnectorStatisticsData;
import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.FlowCapableNodeConnectorStatisticsDataBuilder;
+import org.opendaylight.yangtools.yang.common.RpcResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
new SingleLayerMultipartCollectorService(deviceContext, deviceContext);
return Futures.transform(service.handleServiceCall(multipartType),
- input -> input.isSuccessful(), MoreExecutors.directExecutor());
+ RpcResult::isSuccessful, MoreExecutors.directExecutor());
}
final MultiLayerMultipartCollectorService service =
new MultiLayerMultipartCollectorService(deviceContext, deviceContext);
return Futures.transform(service.handleServiceCall(multipartType),
- input -> input.isSuccessful(), MoreExecutors.directExecutor());
+ RpcResult::isSuccessful, MoreExecutors.directExecutor());
}
}
}
try {
- Futures.transform(Futures.catchingAsync(future, Throwable.class, throwable -> {
- return Futures.immediateFailedFuture(throwable);
- }, MoreExecutors.directExecutor()), (Function<Optional<FlowCapableNode>, Void>) flowCapNodeOpt -> {
+ Futures.transform(Futures.catchingAsync(future, Throwable.class, Futures::immediateFailedFuture,
+ MoreExecutors.directExecutor()), (Function<Optional<FlowCapableNode>, Void>) flowCapNodeOpt -> {
// we have to read actual tables with all information before we set empty Flow list,
// merge is expensive and not applicable for lists
if (flowCapNodeOpt != null && flowCapNodeOpt.isPresent()) {
for (final Table tableData : flowCapNodeOpt.get().getTable()) {
final Table table = new TableBuilder(tableData).setFlow(Collections.emptyList()).build();
final InstanceIdentifier<Table> iiToTable = instanceIdentifier
- .child(Table.class, tableData.key());
+ .child(Table.class, tableData.key());
txFacade.writeToTransaction(LogicalDatastoreType.OPERATIONAL, iiToTable, table);
}
}
.put(SetField.class, match -> {
final SetFieldBuilder matchBuilder = new SetFieldBuilder(match);
- resolveExtensions(match).ifPresent(extensionLists -> {
- matchBuilder
- .addAugmentation(GeneralAugMatchNodesNodeTableFlowWriteActionsSetField.class,
- new GeneralAugMatchNodesNodeTableFlowWriteActionsSetFieldBuilder()
- .setExtensionList(extensionLists)
- .build());
- });
+ resolveExtensions(match).ifPresent(extensionLists -> matchBuilder
+ .addAugmentation(GeneralAugMatchNodesNodeTableFlowWriteActionsSetField.class,
+ new GeneralAugMatchNodesNodeTableFlowWriteActionsSetFieldBuilder()
+ .setExtensionList(extensionLists)
+ .build()));
return matchBuilder.build();
})
makeCompletableFuture(bundleService.controlBundle(commitBundleInput));
return controlCommitFuture;
- }).thenAccept(voidRpcResult -> {
- LOG.debug("Commit successful: {}, msg: {}", voidRpcResult.isSuccessful(),
- voidRpcResult.getErrors());
- });
+ }).thenAccept(voidRpcResult -> LOG.debug("Commit successful: {}, msg: {}",
+ voidRpcResult.isSuccessful(), voidRpcResult.getErrors()));
}
}
}
private static final AtomicLong ID_COUNTER = new AtomicLong();
- private static final ThreadLocal<FlowBuilder> BUILDER = new ThreadLocal<FlowBuilder>() {
- @Override
- protected FlowBuilder initialValue() {
- final FlowBuilder fb = new FlowBuilder();
-
- fb.setPriority(PRIORITY);
- fb.setBufferId(BUFFER_ID);
- final FlowCookie cookie = new FlowCookie(BigInteger.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;
- }
- };
+ 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(BigInteger.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;
+ });
private NotificationService notificationService;
this.flowService = flowService;
}
- private static final ThreadLocal<AddFlowInputBuilder> BUILDER = new ThreadLocal<AddFlowInputBuilder>() {
- @Override
- protected AddFlowInputBuilder initialValue() {
- final AddFlowInputBuilder fb = new AddFlowInputBuilder();
-
- fb.setPriority(PRIORITY);
- fb.setBufferId(BUFFER_ID);
-
- final FlowCookie cookie = new FlowCookie(BigInteger.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;
- }
- };
+ 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(BigInteger.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;
+ });
private NotificationService notificationService;