import com.google.common.base.Strings;
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;
import java.util.Collection;
import java.util.Collections;
ListenableFuture<RpcResult<SendArpRequestOutput>> future = arpService.sendArpRequest(input);
final String msgFormat = String.format("Send ARP Request on interface %s to destination %s",
sourceInterface, targetIp);
- Futures.addCallback(JdkFutureAdapters.listenInPoolThread(future),
- new FutureCallback<RpcResult<SendArpRequestOutput>>() {
- @Override
- public void onFailure(Throwable error) {
- LOG.error("Error - {}", msgFormat, error);
- }
-
- @Override
- public void onSuccess(RpcResult<SendArpRequestOutput> result) {
- if (result != null && !result.isSuccessful()) {
- LOG.warn("Rpc call to {} failed {}", msgFormat, getErrorText(result.getErrors()));
- } else {
- LOG.debug("Successful RPC Result - {}", msgFormat);
- }
- }
- });
+ Futures.addCallback(future, new FutureCallback<RpcResult<SendArpRequestOutput>>() {
+ @Override
+ public void onFailure(Throwable error) {
+ LOG.error("Error - {}", msgFormat, error);
+ }
+
+ @Override
+ public void onSuccess(RpcResult<SendArpRequestOutput> result) {
+ if (result != null && !result.isSuccessful()) {
+ LOG.warn("Rpc call to {} failed {}", msgFormat, getErrorText(result.getErrors()));
+ } else {
+ LOG.debug("Successful RPC Result - {}", msgFormat);
+ }
+ }
+ }, MoreExecutors.directExecutor());
}
}
import com.google.common.cache.LoadingCache;
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;
.setPoolName(AlivenessMonitorConstants.MONITOR_IDPOOL_NAME)
.setLow(AlivenessMonitorConstants.MONITOR_IDPOOL_START)
.setHigh(AlivenessMonitorConstants.MONITOR_IDPOOL_SIZE).build();
- ListenableFuture<RpcResult<CreateIdPoolOutput>> resultFuture = idManager.createIdPool(createPool);
- Futures.addCallback(JdkFutureAdapters.listenInPoolThread(resultFuture),
- new FutureCallback<RpcResult<CreateIdPoolOutput>>() {
- @Override
- public void onFailure(Throwable error) {
- LOG.error("Failed to create idPool for Aliveness Monitor Service", error);
- }
+ Futures.addCallback(idManager.createIdPool(createPool), new FutureCallback<RpcResult<CreateIdPoolOutput>>() {
+ @Override
+ public void onFailure(Throwable error) {
+ LOG.error("Failed to create idPool for Aliveness Monitor Service", error);
+ }
- @Override
- public void onSuccess(@Nonnull RpcResult<CreateIdPoolOutput> result) {
- if (result.isSuccessful()) {
- LOG.debug("Created IdPool for Aliveness Monitor Service");
- } else {
- LOG.error("RPC to create Idpool failed {}", result.getErrors());
- }
- }
- }, callbackExecutorService);
+ @Override
+ public void onSuccess(@Nonnull RpcResult<CreateIdPoolOutput> result) {
+ if (result.isSuccessful()) {
+ LOG.debug("Created IdPool for Aliveness Monitor Service");
+ } else {
+ LOG.error("RPC to create Idpool failed {}", result.getErrors());
+ }
+ }
+ }, callbackExecutorService);
}
private int getUniqueId(final String idKey) {
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;
ListenableFuture<RpcResult<SendArpRequestOutput>> arpReqFt = sendArpRequest(builder.build());
final SettableFuture<RpcResult<GetMacOutput>> ft = SettableFuture.create();
- Futures.addCallback(JdkFutureAdapters.listenInPoolThread(arpReqFt, threadPool),
- new FutureCallback<RpcResult<SendArpRequestOutput>>() {
- @Override
- public void onFailure(Throwable ex) {
- RpcResultBuilder<GetMacOutput> resultBuilder = RpcResultBuilder.<GetMacOutput>failed()
- .withError(ErrorType.APPLICATION, ex.getMessage(), ex);
- ft.set(resultBuilder.build());
- }
-
- @Override
- public void onSuccess(RpcResult<SendArpRequestOutput> result) {
- LOG.trace("Successfully sent the arp pkt out for ip {}", dstIpAddress);
- }
- }, MoreExecutors.directExecutor());
+ Futures.addCallback(arpReqFt, new FutureCallback<RpcResult<SendArpRequestOutput>>() {
+ @Override
+ public void onFailure(Throwable ex) {
+ RpcResultBuilder<GetMacOutput> resultBuilder = RpcResultBuilder.<GetMacOutput>failed()
+ .withError(ErrorType.APPLICATION, ex.getMessage(), ex);
+ ft.set(resultBuilder.build());
+ }
+
+ @Override
+ public void onSuccess(RpcResult<SendArpRequestOutput> result) {
+ LOG.trace("Successfully sent the arp pkt out for ip {}", dstIpAddress);
+ }
+ }, MoreExecutors.directExecutor());
macAddrs.put(dstIpAddress, ft);
return ft;
package org.opendaylight.genius.interfacemanager.commons;
import com.google.common.base.Optional;
-import com.google.common.util.concurrent.JdkFutureAdapters;
import com.google.common.util.concurrent.ListenableFuture;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Future;
import javax.inject.Inject;
import javax.inject.Singleton;
-
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.ReadTransaction;
import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
MonitorStopInput input = new MonitorStopInputBuilder().setMonitorId(monitorId).build();
ListenableFuture<RpcResult<MonitorStopOutput>> future = alivenessMonitorService.monitorStop(input);
- ListenableFutures.addErrorLogging(JdkFutureAdapters.listenInPoolThread(future),
- LOG, "Stop LLDP monitoring for {}", trunkInterface);
+ ListenableFutures.addErrorLogging(future, LOG, "Stop LLDP monitoring for {}", trunkInterface);
removeMonitorIdInterfaceMap(tx, monitorId);
removeMonitorIdFromInterfaceMonitorIdMap(tx, interfaceName, monitorId);
ListenableFuture<RpcResult<MonitorProfileDeleteOutput>> future =
alivenessMonitorService.monitorProfileDelete(profileDeleteInput);
- ListenableFutures.addErrorLogging(JdkFutureAdapters.listenInPoolThread(future),
- LOG, "Delete monitor profile {}", interfaceName);
+ ListenableFutures.addErrorLogging(future, LOG, "Delete monitor profile {}", interfaceName);
}
}
}
import com.google.common.base.Optional;
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.ThreadFactoryBuilder;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.Executors;
-import java.util.concurrent.Future;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.ThreadFactory;
import javax.annotation.PreDestroy;
import javax.inject.Inject;
import javax.inject.Singleton;
-
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.genius.datastoreutils.AsyncClusteredDataTreeChangeListenerBase;
for (BigInteger node : nodes) {
LOG.trace("Requesting AllNodeConnectorStatistics and flow table statistics for node - {}", node);
// Call RPC to Get NodeConnector Stats for node
- Future<RpcResult<GetNodeConnectorStatisticsOutput>> ncStatsFuture = opendaylightDirectStatisticsService
- .getNodeConnectorStatistics(buildGetNodeConnectorStatisticsInput(node));
- //Create ListenableFuture to get RPC result asynchronously
- ListenableFuture<RpcResult<GetNodeConnectorStatisticsOutput>> ncStatsListenableFuture =
- JdkFutureAdapters.listenInPoolThread(ncStatsFuture);
+ ListenableFuture<RpcResult<GetNodeConnectorStatisticsOutput>> ncStatsFuture =
+ opendaylightDirectStatisticsService.getNodeConnectorStatistics(
+ buildGetNodeConnectorStatisticsInput(node));
- Futures.addCallback(ncStatsListenableFuture, new
- FutureCallback<RpcResult<GetNodeConnectorStatisticsOutput>>() {
+ Futures.addCallback(ncStatsFuture, new FutureCallback<RpcResult<GetNodeConnectorStatisticsOutput>>() {
@Override
public void onFailure(@Nonnull Throwable error) {
}, MoreExecutors.directExecutor());
// Call RPC to Get flow stats for node
- Future<RpcResult<GetFlowStatisticsOutput>> flowStatsFuture = opendaylightDirectStatisticsService
- .getFlowStatistics(buildGetFlowStatisticsInput(node));
- //Create ListenableFuture to get RPC result asynchronously
- ListenableFuture<RpcResult<GetFlowStatisticsOutput>> flowStatsListenableFuture =
- JdkFutureAdapters.listenInPoolThread(flowStatsFuture);
-
- Futures.addCallback(flowStatsListenableFuture, new
- FutureCallback<RpcResult<GetFlowStatisticsOutput>>() {
+ ListenableFuture<RpcResult<GetFlowStatisticsOutput>> flowStatsFuture =
+ opendaylightDirectStatisticsService.getFlowStatistics(buildGetFlowStatisticsInput(node));
+
+ Futures.addCallback(flowStatsFuture, new FutureCallback<RpcResult<GetFlowStatisticsOutput>>() {
@Override
public void onFailure(@Nonnull Throwable error) {