import com.google.common.base.Preconditions;
import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.Futures;
-import com.google.common.util.concurrent.JdkFutureAdapters;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.MoreExecutors;
import com.google.common.util.concurrent.SettableFuture;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.ForkJoinPool;
-import java.util.concurrent.Future;
import javax.management.InstanceAlreadyExistsException;
import javax.management.MBeanRegistrationException;
import javax.management.MBeanServer;
final NodeRef nodeRef = bulkFlow.getNode();
flowInputBuilder.setNode(nodeRef);
flowInputBuilder.setTableId(bulkFlow.getTableId());
- Future<RpcResult<AddFlowOutput>> rpcAddFlowResult = flowService.addFlow(flowInputBuilder.build());
- bulkResults.add(JdkFutureAdapters.listenInPoolThread(rpcAddFlowResult));
+ bulkResults.add(flowService.addFlow(flowInputBuilder.build()));
}
return Futures.transform(handleResultFuture(Futures.allAsList(bulkResults)), voidRpcResult -> {
if (voidRpcResult.isSuccessful()) {
final NodeRef nodeRef = bulkFlow.getNode();
flowInputBuilder.setNode(nodeRef);
flowInputBuilder.setTableId(bulkFlow.getTableId());
- Future<RpcResult<RemoveFlowOutput>> rpcAddFlowResult = flowService.removeFlow(flowInputBuilder.build());
- bulkResults.add(JdkFutureAdapters.listenInPoolThread(rpcAddFlowResult));
+ bulkResults.add(flowService.removeFlow(flowInputBuilder.build()));
}
return Futures.transform(handleResultFuture(Futures.allAsList(bulkResults)), voidRpcResult -> {
if (voidRpcResult.isSuccessful()) {
-/**
+/*
* Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
package org.opendaylight.openflowplugin.applications.frsync;
-import java.util.concurrent.Future;
+import com.google.common.util.concurrent.ListenableFuture;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
* @param nodeIdent - Node InstanceIdentifier
* @return RpcResult of action
*/
- Future<RpcResult<A>> add(InstanceIdentifier<D> identifier, D add, InstanceIdentifier<FlowCapableNode> nodeIdent);
+ ListenableFuture<RpcResult<A>> add(InstanceIdentifier<D> identifier, D add,
+ InstanceIdentifier<FlowCapableNode> nodeIdent);
}
-/**
+/*
* Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
package org.opendaylight.openflowplugin.applications.frsync;
-import java.util.concurrent.Future;
+import com.google.common.util.concurrent.ListenableFuture;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
* @param nodeIdent - Node InstanceIdentifier
* @return RpcResult of action
*/
- Future<RpcResult<R>> remove(InstanceIdentifier<D> identifier, D del, InstanceIdentifier<FlowCapableNode> nodeIdent);
+ ListenableFuture<RpcResult<R>> remove(InstanceIdentifier<D> identifier, D del,
+ InstanceIdentifier<FlowCapableNode> nodeIdent);
}
-/**
+/*
* Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-
package org.opendaylight.openflowplugin.applications.frsync;
-import java.util.concurrent.Future;
+import com.google.common.util.concurrent.ListenableFuture;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
* @param nodeIdent - Node InstanceIdentifier
* @return RpcResult of action
*/
- Future<RpcResult<U>> update(InstanceIdentifier<D> identifier, D original, D update,
+ ListenableFuture<RpcResult<U>> update(InstanceIdentifier<D> identifier, D original, D update,
InstanceIdentifier<FlowCapableNode> nodeIdent);
package org.opendaylight.openflowplugin.applications.frsync.impl.strategy;
import com.google.common.base.Preconditions;
-import java.util.concurrent.Future;
+import com.google.common.util.concurrent.ListenableFuture;
import org.opendaylight.openflowplugin.applications.frsync.ForwardingRulesCommitter;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table;
}
@Override
- public Future<RpcResult<RemoveFlowOutput>> remove(final InstanceIdentifier<Flow> identifier,
+ public ListenableFuture<RpcResult<RemoveFlowOutput>> remove(final InstanceIdentifier<Flow> identifier,
final Flow removeDataObj,
final InstanceIdentifier<FlowCapableNode> nodeIdent) {
LOG.trace("Forwarding Flow REMOVE request Tbl id, node Id {} {}",
}
@Override
- public Future<RpcResult<UpdateFlowOutput>> update(final InstanceIdentifier<Flow> identifier,
+ public ListenableFuture<RpcResult<UpdateFlowOutput>> update(final InstanceIdentifier<Flow> identifier,
final Flow original, final Flow update,
final InstanceIdentifier<FlowCapableNode> nodeIdent) {
LOG.trace("Forwarding Flow UPDATE request [Tbl id, node Id {} {} {}",
identifier, nodeIdent, update);
- final Future<RpcResult<UpdateFlowOutput>> output;
+ final ListenableFuture<RpcResult<UpdateFlowOutput>> output;
final TableKey tableKey = identifier.firstKeyOf(Table.class);
if (tableIdValidationPrecondition(tableKey, update)) {
final UpdateFlowInputBuilder builder = new UpdateFlowInputBuilder();
}
@Override
- public Future<RpcResult<AddFlowOutput>> add(final InstanceIdentifier<Flow> identifier,
+ public ListenableFuture<RpcResult<AddFlowOutput>> add(final InstanceIdentifier<Flow> identifier,
final Flow addDataObj,
final InstanceIdentifier<FlowCapableNode> nodeIdent) {
LOG.trace("Forwarding the Flow ADD request [Tbl id, node Id {} {} {}",
identifier, nodeIdent, addDataObj);
- final Future<RpcResult<AddFlowOutput>> output;
+ final ListenableFuture<RpcResult<AddFlowOutput>> output;
final TableKey tableKey = identifier.firstKeyOf(Table.class);
if (tableIdValidationPrecondition(tableKey, addDataObj)) {
final AddFlowInputBuilder builder = new AddFlowInputBuilder(addDataObj);
package org.opendaylight.openflowplugin.applications.frsync.impl.strategy;
-import java.util.concurrent.Future;
+import com.google.common.util.concurrent.ListenableFuture;
import org.opendaylight.openflowplugin.applications.frsync.ForwardingRulesCommitter;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupInputBuilder;
}
@Override
- public Future<RpcResult<RemoveGroupOutput>> remove(final InstanceIdentifier<Group> identifier,
+ public ListenableFuture<RpcResult<RemoveGroupOutput>> remove(final InstanceIdentifier<Group> identifier,
final Group removeDataObj, final InstanceIdentifier<FlowCapableNode> nodeIdent) {
LOG.trace("Forwarding Table REMOVE request [Tbl id, node Id {} {}",
identifier, nodeIdent);
}
@Override
- public Future<RpcResult<UpdateGroupOutput>> update(final InstanceIdentifier<Group> identifier,
+ public ListenableFuture<RpcResult<UpdateGroupOutput>> update(final InstanceIdentifier<Group> identifier,
final Group original, final Group update,
final InstanceIdentifier<FlowCapableNode> nodeIdent) {
LOG.trace("Forwarding Group UPDATE request [Tbl id, node Id {} {} {}",
}
@Override
- public Future<RpcResult<AddGroupOutput>> add(final InstanceIdentifier<Group> identifier, final Group addDataObj,
- final InstanceIdentifier<FlowCapableNode> nodeIdent) {
+ public ListenableFuture<RpcResult<AddGroupOutput>> add(final InstanceIdentifier<Group> identifier,
+ final Group addDataObj, final InstanceIdentifier<FlowCapableNode> nodeIdent) {
LOG.trace("Forwarding Group ADD request [Tbl id, node Id {} {} {}",
identifier, nodeIdent, addDataObj);
package org.opendaylight.openflowplugin.applications.frsync.impl.strategy;
-import java.util.concurrent.Future;
+import com.google.common.util.concurrent.ListenableFuture;
import org.opendaylight.openflowplugin.applications.frsync.ForwardingRulesCommitter;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter;
}
@Override
- public Future<RpcResult<RemoveMeterOutput>> remove(final InstanceIdentifier<Meter> identifier,
+ public ListenableFuture<RpcResult<RemoveMeterOutput>> remove(final InstanceIdentifier<Meter> identifier,
final Meter removeDataObj, final InstanceIdentifier<FlowCapableNode> nodeIdent) {
LOG.trace("Received the Meter REMOVE request [Tbl id, node Id {} {}",
}
@Override
- public Future<RpcResult<UpdateMeterOutput>> update(final InstanceIdentifier<Meter> identifier,
+ public ListenableFuture<RpcResult<UpdateMeterOutput>> update(final InstanceIdentifier<Meter> identifier,
final Meter original, final Meter update,
final InstanceIdentifier<FlowCapableNode> nodeIdent) {
LOG.trace("Received the Meter UPDATE request [Tbl id, node Id {} {} {}",
}
@Override
- public Future<RpcResult<AddMeterOutput>> add(final InstanceIdentifier<Meter> identifier, final Meter addDataObj,
- final InstanceIdentifier<FlowCapableNode> nodeIdent) {
+ public ListenableFuture<RpcResult<AddMeterOutput>> add(final InstanceIdentifier<Meter> identifier,
+ final Meter addDataObj, final InstanceIdentifier<FlowCapableNode> nodeIdent) {
LOG.trace("Received the Meter ADD request [Tbl id, node Id {} {} {}",
identifier, nodeIdent, addDataObj);
import com.google.common.collect.Range;
import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.Futures;
-import com.google.common.util.concurrent.JdkFutureAdapters;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.MoreExecutors;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
-import java.util.concurrent.Future;
import org.opendaylight.openflowplugin.applications.frsync.SyncPlanPushStrategy;
import org.opendaylight.openflowplugin.applications.frsync.util.ItemSyncBox;
import org.opendaylight.openflowplugin.applications.frsync.util.PathUtil;
.setBatch(batchBag)
.build();
- final Future<RpcResult<ProcessFlatBatchOutput>> rpcResultFuture =
+ final ListenableFuture<RpcResult<ProcessFlatBatchOutput>> rpcResultFuture =
flatBatchService.processFlatBatch(flatBatchInput);
if (LOG.isDebugEnabled()) {
- Futures.addCallback(JdkFutureAdapters.listenInPoolThread(rpcResultFuture),
- createCounterCallback(batchBag, batchOrder, counters), MoreExecutors.directExecutor());
+ Futures.addCallback(rpcResultFuture, createCounterCallback(batchBag, batchOrder, counters),
+ MoreExecutors.directExecutor());
}
- return Futures.transform(JdkFutureAdapters.listenInPoolThread(rpcResultFuture),
+ return Futures.transform(rpcResultFuture,
ReconcileUtil.createRpcResultToVoidFunction("flat-batch"),
MoreExecutors.directExecutor());
}, MoreExecutors.directExecutor());
-/**
+/*
* Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-
package org.opendaylight.openflowplugin.applications.frsync.impl.strategy;
import com.google.common.collect.Iterables;
import com.google.common.util.concurrent.Futures;
-import com.google.common.util.concurrent.JdkFutureAdapters;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.MoreExecutors;
import java.util.ArrayList;
LOG.trace("adding flow {} in table {} - absent on device {} match{}",
flow.getId(), tableKey, nodeId, flow.getMatch());
- allResults.add(JdkFutureAdapters.listenInPoolThread(
- flowForwarder.add(flowIdent, flow, nodeIdent)));
+ allResults.add(flowForwarder.add(flowIdent, flow, nodeIdent));
flowCrudCounts.incAdded();
}
LOG.trace("flow {} in table {} - needs update on device {} match{}",
updatedFlow.getId(), tableKey, nodeId, updatedFlow.getMatch());
- allUpdateResults.add(JdkFutureAdapters.listenInPoolThread(
- flowForwarder.update(flowIdent, existingFlow, updatedFlow, nodeIdent)));
+ allUpdateResults.add(flowForwarder.update(flowIdent, existingFlow, updatedFlow, nodeIdent));
flowCrudCounts.incUpdated();
}
}
for (final Flow flow : flowsPerTable.getValue().getItemsToPush()) {
final KeyedInstanceIdentifier<Flow, FlowKey> flowIdent =
tableIdent.child(Flow.class, flow.key());
- allResults.add(JdkFutureAdapters.listenInPoolThread(
- flowForwarder.remove(flowIdent, flow, nodeIdent)));
+ allResults.add(flowForwarder.remove(flowIdent, flow, nodeIdent));
flowCrudCounts.incRemoved();
}
}
meter.getMeterId(), nodeId);
final KeyedInstanceIdentifier<Meter, MeterKey> meterIdent =
nodeIdent.child(Meter.class, meter.key());
- allResults.add(JdkFutureAdapters.listenInPoolThread(
- meterForwarder.remove(meterIdent, meter, nodeIdent)));
+ allResults.add(meterForwarder.remove(meterIdent, meter, nodeIdent));
meterCrudCounts.incRemoved();
}
List<ListenableFuture<RpcResult<RemoveGroupOutput>>> allResults = new ArrayList<>();
for (Group group : groupsPortion.getItemsToPush()) {
final KeyedInstanceIdentifier<Group, GroupKey> groupIdent = nodeIdent.child(Group.class, group.key());
- allResults.add(JdkFutureAdapters.listenInPoolThread(groupForwarder.remove(groupIdent, group, nodeIdent)));
+ allResults.add(groupForwarder.remove(groupIdent, group, nodeIdent));
}
final ListenableFuture<RpcResult<Void>> singleVoidResult = Futures.transform(
for (Group group : groupsPortion.getItemsToPush()) {
final KeyedInstanceIdentifier<Group, GroupKey> groupIdent = nodeIdent.child(Group.class, group.key());
- allResults.add(JdkFutureAdapters.listenInPoolThread(groupForwarder.add(groupIdent, group, nodeIdent)));
+ allResults.add(groupForwarder.add(groupIdent, group, nodeIdent));
}
final Group group = groupTuple.getUpdated();
final KeyedInstanceIdentifier<Group, GroupKey> groupIdent = nodeIdent.child(Group.class, group.key());
- allUpdateResults.add(JdkFutureAdapters.listenInPoolThread(
- groupForwarder.update(groupIdent, existingGroup, group, nodeIdent)));
+ allUpdateResults.add(groupForwarder.update(groupIdent, existingGroup, group, nodeIdent));
}
final ListenableFuture<RpcResult<Void>> singleVoidAddResult = Futures.transform(
final KeyedInstanceIdentifier<Meter, MeterKey> meterIdent = nodeIdent.child(Meter.class, meter.key());
LOG.debug("adding meter {} - absent on device {}",
meter.getMeterId(), nodeId);
- allResults.add(JdkFutureAdapters.listenInPoolThread(
- meterForwarder.add(meterIdent, meter, nodeIdent)));
+ allResults.add(meterForwarder.add(meterIdent, meter, nodeIdent));
meterCrudCounts.incAdded();
}
final Meter updated = meterTuple.getUpdated();
final KeyedInstanceIdentifier<Meter, MeterKey> meterIdent = nodeIdent.child(Meter.class, updated.key());
LOG.trace("meter {} - needs update on device {}", updated.getMeterId(), nodeId);
- allUpdateResults.add(JdkFutureAdapters.listenInPoolThread(
- meterForwarder.update(meterIdent, existingMeter, updated, nodeIdent)));
+ allUpdateResults.add(meterForwarder.update(meterIdent, existingMeter, updated, nodeIdent));
meterCrudCounts.incUpdated();
}
package org.opendaylight.openflowplugin.applications.frsync.impl.strategy;
+import com.google.common.util.concurrent.ListenableFuture;
import java.util.Collections;
-import java.util.concurrent.Future;
import org.opendaylight.openflowplugin.applications.frsync.ForwardingRulesUpdateCommitter;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table;
}
@Override
- public Future<RpcResult<UpdateTableOutput>> update(final InstanceIdentifier<TableFeatures> identifier,
+ public ListenableFuture<RpcResult<UpdateTableOutput>> update(final InstanceIdentifier<TableFeatures> identifier,
final TableFeatures original, final TableFeatures update,
final InstanceIdentifier<FlowCapableNode> nodeIdent) {
LOG.debug("Forwarding Table Update request [Tbl id, node Id {} {}",
import com.google.common.annotations.VisibleForTesting;
import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.Futures;
-import com.google.common.util.concurrent.JdkFutureAdapters;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.MoreExecutors;
import com.google.common.util.concurrent.SettableFuture;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.util.List;
import java.util.Objects;
-import java.util.concurrent.Future;
import org.opendaylight.openflowjava.protocol.api.connection.ConnectionAdapter;
import org.opendaylight.openflowplugin.api.OFConstants;
import org.opendaylight.openflowplugin.api.openflow.md.core.ErrorHandler;
LOG.debug("sending hello message: version{}, xid={}, version bitmap={}", helloVersion, helloXid,
MessageFactory.digVersions(helloInput.getElements()));
- Future<RpcResult<HelloOutput>> helloResult = connectionAdapter.hello(helloInput);
-
- ListenableFuture<RpcResult<HelloOutput>> rpcResultListenableFuture
- = JdkFutureAdapters.listenInPoolThread(helloResult);
- Futures.addCallback(rpcResultListenableFuture, new FutureCallback<RpcResult<HelloOutput>>() {
+ Futures.addCallback(connectionAdapter.hello(helloInput), new FutureCallback<RpcResult<HelloOutput>>() {
@Override
public void onSuccess(RpcResult<HelloOutput> result) {
if (result.isSuccessful()) {
GetFeaturesInputBuilder featuresBuilder = new GetFeaturesInputBuilder();
featuresBuilder.setVersion(version).setXid(xid);
LOG.debug("sending feature request for version={} and xid={}", version, xid);
- Future<RpcResult<GetFeaturesOutput>> featuresFuture = connectionAdapter.getFeatures(featuresBuilder.build());
- Futures.addCallback(JdkFutureAdapters.listenInPoolThread(featuresFuture),
+ Futures.addCallback(connectionAdapter.getFeatures(featuresBuilder.build()),
new FutureCallback<RpcResult<GetFeaturesOutput>>() {
@Override
public void onSuccess(RpcResult<GetFeaturesOutput> rpcFeatures) {
import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.Futures;
-import com.google.common.util.concurrent.JdkFutureAdapters;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.MoreExecutors;
import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext;
.setXid(xid)
.setVersion(version)
.build();
- return JdkFutureAdapters.listenInPoolThread(
- this.connectionContext.getConnectionAdapter().barrier(barrierInput));
+ return this.connectionContext.getConnectionAdapter().barrier(barrierInput);
}
@Override
import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.Futures;
-import com.google.common.util.concurrent.JdkFutureAdapters;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.MoreExecutors;
import io.netty.util.HashedWheelTimer;
import java.util.HashSet;
import java.util.concurrent.CancellationException;
import java.util.concurrent.Executors;
-import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
import javax.annotation.Nonnull;
.setNode(new NodeRef(deviceInfo.getNodeInstanceIdentifier()))
.build();
- final Future<RpcResult<SetRoleOutput>> setRoleOutputFuture = roleService.setRole(setRoleInput);
+ final ListenableFuture<RpcResult<SetRoleOutput>> setRoleOutputFuture = roleService.setRole(setRoleInput);
final TimerTask timerTask = timeout -> {
if (!setRoleOutputFuture.isDone()) {
};
timer.newTimeout(timerTask, SET_ROLE_TIMEOUT, TimeUnit.MILLISECONDS);
- return JdkFutureAdapters.listenInPoolThread(setRoleOutputFuture);
+ return setRoleOutputFuture;
}
LOG.info("Device: {} with version: {} does not support role {}", deviceInfo, deviceInfo.getVersion(), newRole);
import java.math.BigInteger;
import java.util.Collection;
import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Future;
import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
import org.opendaylight.openflowplugin.api.openflow.device.Xid;
return input.build();
}
- public Future<BigInteger> getGenerationIdFromDevice(final Short version) {
+ public ListenableFuture<BigInteger> getGenerationIdFromDevice(final Short version) {
LOG.info("getGenerationIdFromDevice called for device: {}", getDeviceInfo().getNodeId().getValue());
// send a dummy no-change role request to get the generation-id of the switch
}
- public Future<RpcResult<SetRoleOutput>> submitRoleChange(final OfpRole ofpRole,
- final Short version,
+ public ListenableFuture<RpcResult<SetRoleOutput>> submitRoleChange(final OfpRole ofpRole, final Short version,
final BigInteger generationId) {
LOG.info("submitRoleChange called for device:{}, role:{}",
getDeviceInfo().getNodeId(), ofpRole);
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Function;
import com.google.common.util.concurrent.Futures;
-import com.google.common.util.concurrent.JdkFutureAdapters;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.MoreExecutors;
import java.util.ArrayList;
import java.util.List;
-import java.util.concurrent.Future;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.ProcessFlatBatchOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.ProcessFlatBatchOutputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.add.flow._case.FlatBatchAddFlow;
* @return ListenableFuture with converted result {@link ProcessFlatBatchOutput}
*/
public static <T extends BatchFlowOutputListGrouping> ListenableFuture<RpcResult<ProcessFlatBatchOutput>>
- convertFlowBatchFutureForChain(final Future<RpcResult<T>> resultUpdateFlowFuture,
+ convertFlowBatchFutureForChain(final ListenableFuture<RpcResult<T>> resultUpdateFlowFuture,
final int currentOffset) {
- return Futures.transform(JdkFutureAdapters.listenInPoolThread(resultUpdateFlowFuture),
- FlatBatchFlowAdapters.convertBatchFlowResult(currentOffset),
+ return Futures.transform(resultUpdateFlowFuture, FlatBatchFlowAdapters.convertBatchFlowResult(currentOffset),
MoreExecutors.directExecutor());
}
}
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Function;
import com.google.common.util.concurrent.Futures;
-import com.google.common.util.concurrent.JdkFutureAdapters;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.MoreExecutors;
import java.util.ArrayList;
import java.util.List;
-import java.util.concurrent.Future;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.ProcessFlatBatchOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.ProcessFlatBatchOutputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.add.group._case.FlatBatchAddGroup;
@VisibleForTesting
static <T extends BatchGroupOutputListGrouping> Function<RpcResult<T>, RpcResult<ProcessFlatBatchOutput>>
convertBatchGroupResult(final int stepOffset) {
- return new Function<RpcResult<T>, RpcResult<ProcessFlatBatchOutput>>() {
- @Override
- public RpcResult<ProcessFlatBatchOutput> apply(final RpcResult<T> input) {
- List<BatchFailure> batchFailures = wrapBatchGroupFailuresForFlat(input, stepOffset);
- ProcessFlatBatchOutputBuilder outputBuilder =
- new ProcessFlatBatchOutputBuilder().setBatchFailure(batchFailures);
- return RpcResultBuilder.<ProcessFlatBatchOutput>status(input.isSuccessful())
- .withRpcErrors(input.getErrors())
- .withResult(outputBuilder.build())
- .build();
- }
+ return input -> {
+ List<BatchFailure> batchFailures = wrapBatchGroupFailuresForFlat(input, stepOffset);
+ ProcessFlatBatchOutputBuilder outputBuilder =
+ new ProcessFlatBatchOutputBuilder().setBatchFailure(batchFailures);
+ return RpcResultBuilder.<ProcessFlatBatchOutput>status(input.isSuccessful())
+ .withRpcErrors(input.getErrors())
+ .withResult(outputBuilder.build())
+ .build();
};
}
* @return ListenableFuture with converted result {@link ProcessFlatBatchOutput}
*/
public static <T extends BatchGroupOutputListGrouping> ListenableFuture<RpcResult<ProcessFlatBatchOutput>>
- convertGroupBatchFutureForChain(final Future<RpcResult<T>> resultUpdateGroupFuture,
+ convertGroupBatchFutureForChain(final ListenableFuture<RpcResult<T>> resultUpdateGroupFuture,
final int currentOffset) {
- return Futures.transform(JdkFutureAdapters.listenInPoolThread(resultUpdateGroupFuture),
- FlatBatchGroupAdapters.convertBatchGroupResult(currentOffset),
- MoreExecutors.directExecutor());
+ return Futures.transform(resultUpdateGroupFuture,
+ FlatBatchGroupAdapters.convertBatchGroupResult(currentOffset), MoreExecutors.directExecutor());
}
}
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Function;
import com.google.common.util.concurrent.Futures;
-import com.google.common.util.concurrent.JdkFutureAdapters;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.MoreExecutors;
import java.util.ArrayList;
import java.util.List;
-import java.util.concurrent.Future;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.ProcessFlatBatchOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.ProcessFlatBatchOutputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.add.meter._case.FlatBatchAddMeter;
* @return ListenableFuture with converted result {@link ProcessFlatBatchOutput}
*/
public static <T extends BatchMeterOutputListGrouping> ListenableFuture<RpcResult<ProcessFlatBatchOutput>>
- convertMeterBatchFutureForChain(final Future<RpcResult<T>> resultUpdateMeterFuture,
+ convertMeterBatchFutureForChain(final ListenableFuture<RpcResult<T>> resultUpdateMeterFuture,
final int currentOffset) {
- return Futures.transform(JdkFutureAdapters.listenInPoolThread(resultUpdateMeterFuture),
+ return Futures.transform(resultUpdateMeterFuture,
FlatBatchMeterAdapters.convertBatchMeterResult(currentOffset),
MoreExecutors.directExecutor());
}
import com.google.common.base.Preconditions;
import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.Futures;
-import com.google.common.util.concurrent.JdkFutureAdapters;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.MoreExecutors;
import com.google.common.util.concurrent.SettableFuture;
dataBuilder.setBundleInnerMessage(message.getBundleInnerMessage());
experimenterInputBuilder.setExperimenterMessageOfChoice(
bundleAddMessageBuilder.setSalAddMessageData(dataBuilder.build()).build());
- ListenableFuture<RpcResult<SendExperimenterOutput>> res = JdkFutureAdapters
- .listenInPoolThread(experimenterMessageService.sendExperimenter(experimenterInputBuilder.build()));
- partialResults.add(res);
+ partialResults.add(experimenterMessageService.sendExperimenter(experimenterInputBuilder.build()));
}
return processResults(partialResults);
}
import com.google.common.util.concurrent.MoreExecutors;
import java.util.ArrayList;
import java.util.List;
-import java.util.concurrent.Future;
import org.opendaylight.openflowplugin.impl.services.batch.BatchPlanStep;
import org.opendaylight.openflowplugin.impl.services.batch.BatchStepJob;
import org.opendaylight.openflowplugin.impl.services.batch.FlatBatchFlowAdapters;
firedJobs.add(Futures.transformAsync(chainSummaryResult, batchJob.getStepFunction(),
MoreExecutors.directExecutor()));
// if barrier after actual job is needed or it is the last job -> merge fired job results with chain result
- if ((batchJob.getPlanStep().isBarrierAfter()) || (i == batchJobsChain.size() - 1)) {
+ if (batchJob.getPlanStep().isBarrierAfter() || i == batchJobsChain.size() - 1) {
firedJobs.add(0, chainSummaryResult);
chainSummaryResult = FlatBatchUtil.mergeJobsResultsFutures(firedJobs);
firedJobs.clear();
case FLOW_ADD:
final AddFlowsBatchInput addFlowsBatchInput =
FlatBatchFlowAdapters.adaptFlatBatchAddFlow(planStep, node);
- final Future<RpcResult<AddFlowsBatchOutput>> resultAddFlowFuture =
+ final ListenableFuture<RpcResult<AddFlowsBatchOutput>> resultAddFlowFuture =
salFlowService.addFlowsBatch(addFlowsBatchInput);
chainOutput = FlatBatchFlowAdapters.convertFlowBatchFutureForChain(resultAddFlowFuture, currentOffset);
break;
case FLOW_REMOVE:
final RemoveFlowsBatchInput removeFlowsBatchInput =
FlatBatchFlowAdapters.adaptFlatBatchRemoveFlow(planStep, node);
- final Future<RpcResult<RemoveFlowsBatchOutput>> resultRemoveFlowFuture =
+ final ListenableFuture<RpcResult<RemoveFlowsBatchOutput>> resultRemoveFlowFuture =
salFlowService.removeFlowsBatch(removeFlowsBatchInput);
chainOutput =
FlatBatchFlowAdapters.convertFlowBatchFutureForChain(resultRemoveFlowFuture, currentOffset);
case FLOW_UPDATE:
final UpdateFlowsBatchInput updateFlowsBatchInput =
FlatBatchFlowAdapters.adaptFlatBatchUpdateFlow(planStep, node);
- final Future<RpcResult<UpdateFlowsBatchOutput>> resultUpdateFlowFuture =
+ final ListenableFuture<RpcResult<UpdateFlowsBatchOutput>> resultUpdateFlowFuture =
salFlowService.updateFlowsBatch(updateFlowsBatchInput);
chainOutput =
FlatBatchFlowAdapters.convertFlowBatchFutureForChain(resultUpdateFlowFuture, currentOffset);
case GROUP_ADD:
final AddGroupsBatchInput addGroupsBatchInput =
FlatBatchGroupAdapters.adaptFlatBatchAddGroup(planStep, node);
- final Future<RpcResult<AddGroupsBatchOutput>> resultAddGroupFuture =
+ final ListenableFuture<RpcResult<AddGroupsBatchOutput>> resultAddGroupFuture =
salGroupService.addGroupsBatch(addGroupsBatchInput);
chainOutput =
FlatBatchGroupAdapters.convertGroupBatchFutureForChain(resultAddGroupFuture, currentOffset);
case GROUP_REMOVE:
final RemoveGroupsBatchInput removeGroupsBatchInput =
FlatBatchGroupAdapters.adaptFlatBatchRemoveGroup(planStep, node);
- final Future<RpcResult<RemoveGroupsBatchOutput>> resultRemoveGroupFuture =
+ final ListenableFuture<RpcResult<RemoveGroupsBatchOutput>> resultRemoveGroupFuture =
salGroupService.removeGroupsBatch(removeGroupsBatchInput);
chainOutput =
FlatBatchGroupAdapters.convertGroupBatchFutureForChain(resultRemoveGroupFuture, currentOffset);
case GROUP_UPDATE:
final UpdateGroupsBatchInput updateGroupsBatchInput =
FlatBatchGroupAdapters.adaptFlatBatchUpdateGroup(planStep, node);
- final Future<RpcResult<UpdateGroupsBatchOutput>> resultUpdateGroupFuture =
+ final ListenableFuture<RpcResult<UpdateGroupsBatchOutput>> resultUpdateGroupFuture =
salGroupService.updateGroupsBatch(updateGroupsBatchInput);
chainOutput =
FlatBatchGroupAdapters.convertGroupBatchFutureForChain(resultUpdateGroupFuture, currentOffset);
case METER_ADD:
final AddMetersBatchInput addMetersBatchInput =
FlatBatchMeterAdapters.adaptFlatBatchAddMeter(planStep, node);
- final Future<RpcResult<AddMetersBatchOutput>> resultAddMeterFuture =
+ final ListenableFuture<RpcResult<AddMetersBatchOutput>> resultAddMeterFuture =
salMeterService.addMetersBatch(addMetersBatchInput);
chainOutput =
FlatBatchMeterAdapters.convertMeterBatchFutureForChain(resultAddMeterFuture, currentOffset);
case METER_REMOVE:
final RemoveMetersBatchInput removeMetersBatchInput =
FlatBatchMeterAdapters.adaptFlatBatchRemoveMeter(planStep, node);
- final Future<RpcResult<RemoveMetersBatchOutput>> resultRemoveMeterFuture =
+ final ListenableFuture<RpcResult<RemoveMetersBatchOutput>> resultRemoveMeterFuture =
salMeterService.removeMetersBatch(removeMetersBatchInput);
chainOutput =
FlatBatchMeterAdapters.convertMeterBatchFutureForChain(resultRemoveMeterFuture, currentOffset);
case METER_UPDATE:
final UpdateMetersBatchInput updateMetersBatchInput =
FlatBatchMeterAdapters.adaptFlatBatchUpdateMeter(planStep, node);
- final Future<RpcResult<UpdateMetersBatchOutput>> resultUpdateMeterFuture =
+ final ListenableFuture<RpcResult<UpdateMetersBatchOutput>> resultUpdateMeterFuture =
salMeterService.updateMetersBatch(updateMetersBatchInput);
chainOutput =
FlatBatchMeterAdapters.convertMeterBatchFutureForChain(resultUpdateMeterFuture, currentOffset);
import com.google.common.base.Preconditions;
import com.google.common.util.concurrent.Futures;
-import com.google.common.util.concurrent.JdkFutureAdapters;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.MoreExecutors;
import java.util.ArrayList;
.setFlowRef(createFlowRef(input.getNode(), batchFlow))
.setNode(input.getNode())
.build();
- resultsLot.add(JdkFutureAdapters.listenInPoolThread(salFlowService.removeFlow(removeFlowInput)));
+ resultsLot.add(salFlowService.removeFlow(removeFlowInput));
}
final ListenableFuture<RpcResult<List<BatchFailedFlowsOutput>>> commonResult =
.setFlowRef(createFlowRef(input.getNode(), batchFlow))
.setNode(input.getNode())
.build();
- resultsLot.add(JdkFutureAdapters.listenInPoolThread(salFlowService.addFlow(addFlowInput)));
+ resultsLot.add(salFlowService.addFlow(addFlowInput));
}
final ListenableFuture<RpcResult<List<BatchFailedFlowsOutput>>> commonResult =
.setFlowRef(createFlowRef(input.getNode(), batchFlow))
.setNode(input.getNode())
.build();
- resultsLot.add(JdkFutureAdapters.listenInPoolThread(salFlowService.updateFlow(updateFlowInput)));
+ resultsLot.add(salFlowService.updateFlow(updateFlowInput));
}
final ListenableFuture<RpcResult<List<BatchFailedFlowsOutput>>> commonResult =
import com.google.common.base.Preconditions;
import com.google.common.util.concurrent.Futures;
-import com.google.common.util.concurrent.JdkFutureAdapters;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.MoreExecutors;
import java.util.ArrayList;
.setOriginalGroup(new OriginalGroupBuilder(batchGroup.getOriginalBatchedGroup()).build())
.setUpdatedGroup(new UpdatedGroupBuilder(batchGroup.getUpdatedBatchedGroup()).build())
.setGroupRef(createGroupRef(input.getNode(), batchGroup)).setNode(input.getNode()).build();
- resultsLot.add(JdkFutureAdapters.listenInPoolThread(salGroupService.updateGroup(updateGroupInput)));
+ resultsLot.add(salGroupService.updateGroup(updateGroupInput));
}
final Iterable<Group> groups = batchUpdateGroups.stream()
for (BatchAddGroups addGroup : input.getBatchAddGroups()) {
final AddGroupInput addGroupInput = new AddGroupInputBuilder(addGroup)
.setGroupRef(createGroupRef(input.getNode(), addGroup)).setNode(input.getNode()).build();
- resultsLot.add(JdkFutureAdapters.listenInPoolThread(salGroupService.addGroup(addGroupInput)));
+ resultsLot.add(salGroupService.addGroup(addGroupInput));
}
final ListenableFuture<RpcResult<List<BatchFailedGroupsOutput>>> commonResult = Futures
for (BatchRemoveGroups addGroup : input.getBatchRemoveGroups()) {
final RemoveGroupInput removeGroupInput = new RemoveGroupInputBuilder(addGroup)
.setGroupRef(createGroupRef(input.getNode(), addGroup)).setNode(input.getNode()).build();
- resultsLot.add(JdkFutureAdapters.listenInPoolThread(salGroupService.removeGroup(removeGroupInput)));
+ resultsLot.add(salGroupService.removeGroup(removeGroupInput));
}
final ListenableFuture<RpcResult<List<BatchFailedGroupsOutput>>> commonResult = Futures
import com.google.common.base.Preconditions;
import com.google.common.util.concurrent.Futures;
-import com.google.common.util.concurrent.JdkFutureAdapters;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.MoreExecutors;
import java.util.ArrayList;
.setMeterRef(createMeterRef(input.getNode(), batchMeter))
.setNode(input.getNode())
.build();
- resultsLot.add(JdkFutureAdapters.listenInPoolThread(salMeterService.updateMeter(updateMeterInput)));
+ resultsLot.add(salMeterService.updateMeter(updateMeterInput));
}
final Iterable<Meter> meters = batchUpdateMeters.stream()
.setMeterRef(createMeterRef(input.getNode(), addMeter))
.setNode(input.getNode())
.build();
- resultsLot.add(JdkFutureAdapters.listenInPoolThread(salMeterService.addMeter(addMeterInput)));
+ resultsLot.add(salMeterService.addMeter(addMeterInput));
}
final ListenableFuture<RpcResult<List<BatchFailedMetersOutput>>> commonResult =
.setMeterRef(createMeterRef(input.getNode(), addMeter))
.setNode(input.getNode())
.build();
- resultsLot.add(JdkFutureAdapters.listenInPoolThread(salMeterService.removeMeter(removeMeterInput)));
+ resultsLot.add(salMeterService.removeMeter(removeMeterInput));
}
final ListenableFuture<RpcResult<List<BatchFailedMetersOutput>>> commonResult =
-/**
+/*
* Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
import com.google.common.base.Preconditions;
import com.google.common.util.concurrent.Futures;
-import com.google.common.util.concurrent.JdkFutureAdapters;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.MoreExecutors;
import java.math.BigInteger;
-import java.util.concurrent.Future;
import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext.CONNECTION_STATE;
import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
private ListenableFuture<RpcResult<SetRoleOutput>> tryToChangeRole(final OfpRole role) {
LOG.info("RoleChangeTask called on device:{} OFPRole:{}", getDeviceInfo().getNodeId().getValue(), role);
- final Future<BigInteger> generationFuture = roleService.getGenerationIdFromDevice(getVersion());
-
- return Futures.transformAsync(JdkFutureAdapters.listenInPoolThread(generationFuture), generationId -> {
+ return Futures.transformAsync(roleService.getGenerationIdFromDevice(getVersion()), generationId -> {
LOG.debug("RoleChangeTask, GenerationIdFromDevice from device {} is {}",
getDeviceInfo().getNodeId().getValue(), generationId);
final BigInteger nextGenerationId = getNextGenerationId(generationId);
LOG.debug("nextGenerationId received from device:{} is {}",
getDeviceInfo().getNodeId().getValue(), nextGenerationId);
- final Future<RpcResult<SetRoleOutput>> submitRoleFuture =
- roleService.submitRoleChange(role, getVersion(), nextGenerationId);
- return JdkFutureAdapters.listenInPoolThread(submitRoleFuture);
+ return roleService.submitRoleChange(role, getVersion(), nextGenerationId);
}, MoreExecutors.directExecutor());
}
import com.google.common.base.Function;
import com.google.common.util.concurrent.Futures;
-import com.google.common.util.concurrent.JdkFutureAdapters;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.MoreExecutors;
import org.apache.commons.lang3.tuple.MutablePair;
interInput -> {
resultPair.setLeft(interInput);
final SendBarrierInput barrierInput = createSendBarrierInput(nodeRef);
- return JdkFutureAdapters.listenInPoolThread(transactionService.sendBarrier(barrierInput));
+ return transactionService.sendBarrier(barrierInput);
}, MoreExecutors.directExecutor());
// store barrier result and return initiated pair
final ListenableFuture<Pair<RpcResult<T>, RpcResult<SendBarrierOutput>>> compositeResult = Futures.transform(
import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.Futures;
-import com.google.common.util.concurrent.JdkFutureAdapters;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.MoreExecutors;
import java.math.BigInteger;
if (LOG.isDebugEnabled()) {
LOG.debug("onPacketReceived - About to write flow (via SalFlowService) {}", flow);
}
- ListenableFuture<RpcResult<AddFlowOutput>> result =
- JdkFutureAdapters.listenInPoolThread(flowService.addFlow(flow));
+ ListenableFuture<RpcResult<AddFlowOutput>> result = flowService.addFlow(flow);
Futures.addCallback(result, new FutureCallback<RpcResult<AddFlowOutput>>() {
@Override
public void onSuccess(final RpcResult<AddFlowOutput> result) {