当前位置: 首页>>代码示例>>Java>>正文


Java JdkFutureAdapters.listenInPoolThread方法代码示例

本文整理汇总了Java中com.google.common.util.concurrent.JdkFutureAdapters.listenInPoolThread方法的典型用法代码示例。如果您正苦于以下问题:Java JdkFutureAdapters.listenInPoolThread方法的具体用法?Java JdkFutureAdapters.listenInPoolThread怎么用?Java JdkFutureAdapters.listenInPoolThread使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.common.util.concurrent.JdkFutureAdapters的用法示例。


在下文中一共展示了JdkFutureAdapters.listenInPoolThread方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: sendPacketOut

import com.google.common.util.concurrent.JdkFutureAdapters; //导入方法依赖的package包/类
private void sendPacketOut(byte[] payload, NodeConnectorRef egress) {
	if (egress == null) {
		LOG.info("Egress is null");
		return;
	}

	InstanceIdentifier<Node> egressNodePath = getNodePath(egress.getValue());

	TransmitPacketInput input = new TransmitPacketInputBuilder() //
			.setPayload(payload) //
			.setNode(new NodeRef(egressNodePath)) //
			.setEgress(egress) //
			.build();

	Future<RpcResult<Void>> future = packetService.transmitPacket(input);
	JdkFutureAdapters.listenInPoolThread(future);
}
 
开发者ID:onfsdn,项目名称:atrium-odl,代码行数:18,代码来源:TunnellingConnectivityManager.java

示例2: sendArpResponse

import com.google.common.util.concurrent.JdkFutureAdapters; //导入方法依赖的package包/类
public ListenableFuture<RpcResult<Void>> sendArpResponse(ArpMessageAddress senderAddress,
		ArpMessageAddress receiverAddress, InstanceIdentifier<NodeConnector> egressNc, Header8021q vlan) {
	checkNotNull(senderAddress);
	checkNotNull(receiverAddress);
	checkNotNull(egressNc);
	final Ethernet arpFrame = createArpFrame(senderAddress, receiverAddress, vlan);
	byte[] arpFrameAsBytes;
	try {
		arpFrameAsBytes = arpFrame.serialize();
	} catch (PacketException e) {
		LOG.warn("Serializition of ARP packet is not successful.", e);
		if (LOG.isDebugEnabled()) {
			LOG.debug("ARP packet: {}", ArpUtils.getArpFrameToStringFormat(arpFrame));
		}
		return Futures.immediateFailedFuture(e);
	}
	// Generate packet with destination switch and port
	LOG.debug("Egress for ARP packetOut: " + new NodeConnectorRef(egressNc).toString());
	TransmitPacketInput packet = new TransmitPacketInputBuilder().setEgress(new NodeConnectorRef(egressNc))
			.setNode(new NodeRef(egressNc.firstIdentifierOf(Node.class))).setPayload(arpFrameAsBytes).build();
	if (LOG.isTraceEnabled()) {
		LOG.trace("Sending ARP RESPONSE \n{}", ArpUtils.getArpFrameToStringFormat(arpFrame));
	}
	Future<RpcResult<Void>> futureTransmitPacketResult = packetProcessingService.transmitPacket(packet);
	return JdkFutureAdapters.listenInPoolThread(futureTransmitPacketResult);
}
 
开发者ID:onfsdn,项目名称:atrium-odl,代码行数:27,代码来源:ArpSender.java

示例3: makeBreakfast

import com.google.common.util.concurrent.JdkFutureAdapters; //导入方法依赖的package包/类
@Override
public Future<RpcResult<Void>> makeBreakfast(EggsType eggsType, Class<? extends ToastType> toastType,
        int toastDoneness) {
    // Call makeToast and use JdkFutureAdapters to convert the Future to a ListenableFuture, The
    // OpendaylightToaster impl already returns a ListenableFuture so the conversion is actually a no-op.

    ListenableFuture<RpcResult<Void>> makeToastFuture = JdkFutureAdapters
            .listenInPoolThread(makeToast(toastType, toastDoneness), executor);

    ListenableFuture<RpcResult<Void>> makeEggsFuture = makeEggs(eggsType);

    // Combine the 2 ListenableFutures into 1 containing a list RpcResults.

    ListenableFuture<List<RpcResult<Void>>> combinedFutures = Futures
            .allAsList(ImmutableList.of(makeToastFuture, makeEggsFuture));

    // Then transform the RpcResults into 1.

    return Futures.transformAsync(combinedFutures, results -> {
        boolean atLeastOneSucceeded = false;
        Builder<RpcError> errorList = ImmutableList.builder();
        for (RpcResult<Void> result : results) {
            if (result.isSuccessful()) {
                atLeastOneSucceeded = true;
            }

            if (result.getErrors() != null) {
                errorList.addAll(result.getErrors());
            }
        }

        return Futures.immediateFuture(RpcResultBuilder.<Void>status(atLeastOneSucceeded)
                .withRpcErrors(errorList.build()).build());
    });
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:36,代码来源:KitchenServiceImpl.java

示例4: asyncGet

import com.google.common.util.concurrent.JdkFutureAdapters; //导入方法依赖的package包/类
@Override
public ListenableFuture<String> asyncGet(final String url) {
  return JdkFutureAdapters.listenInPoolThread(executor.submit(new Callable<String>() {
    @Override
    public String call() throws RobotConnectionException {
      return get(url);
    }
  }));
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:10,代码来源:HttpRobotConnection.java

示例5: asyncPostJson

import com.google.common.util.concurrent.JdkFutureAdapters; //导入方法依赖的package包/类
@Override
public ListenableFuture<String> asyncPostJson(final String url, final String body) {
  return JdkFutureAdapters.listenInPoolThread(executor.submit(new Callable<String>() {
    @Override
    public String call() throws RobotConnectionException {
      return postJson(url, body);
    }
  }));
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:10,代码来源:HttpRobotConnection.java

示例6: sendArp

import com.google.common.util.concurrent.JdkFutureAdapters; //导入方法依赖的package包/类
/**
 * Sends ARP Request as packet-out from the given port (node connector).
 *
 * @param senderAddress
 *            the addresses used in sender part of ARP packet
 * @param tpa
 *            the target protocol address, in this case IPv4 address for
 *            which MAC should be discovered
 * @param egressNc
 *            the path to node connector from where the ARP packet will be
 *            sent
 * @return future result about success of packet-out
 */
public ListenableFuture<RpcResult<Void>> sendArp(ArpMessageAddress senderAddress, Ipv4Address tpa,
		InstanceIdentifier<NodeConnector> egressNc) {
	checkNotNull(senderAddress);
	checkNotNull(tpa);
	checkNotNull(egressNc);
	final Ethernet arpFrame = createArpFrame(senderAddress, tpa);
	byte[] arpFrameAsBytes;
	try {
		arpFrameAsBytes = arpFrame.serialize();
	} catch (PacketException e) {
		LOG.warn("Serializition of ARP packet is not successful.", e);
		if (LOG.isDebugEnabled()) {
			LOG.debug("ARP packet: {}", ArpUtils.getArpFrameToStringFormat(arpFrame));
		}
		return Futures.immediateFailedFuture(e);
	}
	// Generate packet with destination switch and port

	TransmitPacketInput packet = new TransmitPacketInputBuilder().setEgress(new NodeConnectorRef(egressNc))
			.setNode(new NodeRef(egressNc.firstIdentifierOf(Node.class))).setPayload(arpFrameAsBytes).build();
	if (LOG.isTraceEnabled()) {
		LOG.trace("Sending ARP REQUEST \n{}", ArpUtils.getArpFrameToStringFormat(arpFrame));
	}
	Future<RpcResult<Void>> futureTransmitPacketResult = packetProcessingService.transmitPacket(packet);
	return JdkFutureAdapters.listenInPoolThread(futureTransmitPacketResult);
}
 
开发者ID:onfsdn,项目名称:atrium-odl,代码行数:40,代码来源:ArpSender.java

示例7: executeRequest

import com.google.common.util.concurrent.JdkFutureAdapters; //导入方法依赖的package包/类
/**
 * <p>executeRequest.</p>
 *
 * @param httpRequest a {@link org.apache.http.client.methods.HttpRequestBase} object.
 * @return a {@link org.apache.http.HttpResponse} object.
 * @throws java.io.IOException if any.
 */
public ListenableFuture<HttpResponse> executeRequest(
            final HttpRequest httpRequest)
        throws IOException {
    acquireRequestPermit();
    Future<HttpResponse> response = null;
    try {
        URL url = new URL(httpRequest.getRequestLine().getUri());
        HttpHost httphost =
            new HttpHost(url.getHost(),
                         ((url.getPort() == -1)
                             ? url.getDefaultPort()
                             : url.getPort()),
                         (url.toString().startsWith("https")
                             ? "https" : "http"));
        response = httpClient.execute(httphost, httpRequest, null);
    } catch (Exception e) {
        System.err.println("Exception occurred during asynchronous "
                           + "HTTP request: " + e.toString());
    }
    if (response == null) {
        return null;
    }
    ListenableFuture<HttpResponse> hr =
        JdkFutureAdapters.listenInPoolThread(response, executorService);
    return hr;
}
 
开发者ID:APNIC-net,项目名称:rdap-conformance,代码行数:34,代码来源:Context.java

示例8: invoke

import com.google.common.util.concurrent.JdkFutureAdapters; //导入方法依赖的package包/类
private ListenableFuture<RpcResult<?>> invoke(final SchemaPath schemaPath, final DataObject input) {
    return JdkFutureAdapters.listenInPoolThread(invoker.invokeRpc(delegate, schemaPath.getLastComponent(), input));
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:4,代码来源:BindingDOMRpcImplementationAdapter.java

示例9: publishMessagesAsync

import com.google.common.util.concurrent.JdkFutureAdapters; //导入方法依赖的package包/类
public ListenableFuture<List<String>> publishMessagesAsync(
		GroupedMessage groupedMessage) {
	return JdkFutureAdapters.listenInPoolThread(client
			.publishAsync(groupedMessage.getTopic(), groupedMessage.getMessages()));
}
 
开发者ID:viniciusccarvalho,项目名称:spring-cloud-stream-binder-pubsub,代码行数:6,代码来源:PubSubResourceManager.java

示例10: processResultFuture

import com.google.common.util.concurrent.JdkFutureAdapters; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public Object processResultFuture(final Future<?> future, final ExecutorService executor) {
    return JdkFutureAdapters.listenInPoolThread(future, executor);
}
 
开发者ID:vbauer,项目名称:caesar,代码行数:8,代码来源:ListenableFutureMethodRunner.java

示例11: submittedScheduledTask

import com.google.common.util.concurrent.JdkFutureAdapters; //导入方法依赖的package包/类
protected ScheduledTask<V> submittedScheduledTask(ScheduledFuture delegate) {
    this.submissionDate = System.currentTimeMillis();
    this.scheduledFuture = delegate;
    this.future = JdkFutureAdapters.listenInPoolThread(delegate);
    return this;
}
 
开发者ID:wisdom-framework,项目名称:wisdom,代码行数:7,代码来源:ScheduledTask.java


注:本文中的com.google.common.util.concurrent.JdkFutureAdapters.listenInPoolThread方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。