本文整理汇总了Java中io.grpc.CallOptions.getExecutor方法的典型用法代码示例。如果您正苦于以下问题:Java CallOptions.getExecutor方法的具体用法?Java CallOptions.getExecutor怎么用?Java CallOptions.getExecutor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.grpc.CallOptions
的用法示例。
在下文中一共展示了CallOptions.getExecutor方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ArmeriaClientCall
import io.grpc.CallOptions; //导入方法依赖的package包/类
ArmeriaClientCall(
ClientRequestContext ctx,
Client<HttpRequest, HttpResponse> httpClient,
HttpRequestWriter req,
MethodDescriptor<I, O> method,
int maxOutboundMessageSizeBytes,
int maxInboundMessageSizeBytes,
CallOptions callOptions,
CompressorRegistry compressorRegistry,
DecompressorRegistry decompressorRegistry,
SerializationFormat serializationFormat,
@Nullable MessageMarshaller jsonMarshaller) {
this.ctx = ctx;
this.httpClient = httpClient;
this.req = req;
this.callOptions = callOptions;
this.compressorRegistry = compressorRegistry;
this.decompressorRegistry = decompressorRegistry;
this.messageFramer = new ArmeriaMessageFramer(ctx.alloc(), maxOutboundMessageSizeBytes);
this.marshaller = new GrpcMessageMarshaller<>(
ctx.alloc(), serializationFormat, method, jsonMarshaller);
responseReader = new HttpStreamReader(
decompressorRegistry,
new ArmeriaMessageDeframer(this, maxInboundMessageSizeBytes, ctx.alloc()),
this);
executor = callOptions.getExecutor();
}
示例2: getCallExecutor
import io.grpc.CallOptions; //导入方法依赖的package包/类
private Executor getCallExecutor(CallOptions callOptions) {
Executor executor = callOptions.getExecutor();
if (executor == null) {
executor = this.executor;
}
return executor;
}
示例3: newCall
import io.grpc.CallOptions; //导入方法依赖的package包/类
@Override
public <RequestT, ResponseT> ClientCall<RequestT, ResponseT> newCall(
MethodDescriptor<RequestT, ResponseT> methodDescriptor, CallOptions callOptions) {
return new ClientCallImpl<RequestT, ResponseT>(methodDescriptor,
callOptions.getExecutor() == null ? executor : callOptions.getExecutor(),
callOptions, transportProvider, deadlineCancellationExecutor, channelCallsTracer);
}
示例4: reprocess
import io.grpc.CallOptions; //导入方法依赖的package包/类
/**
* Use the picker to try picking a transport for every pending stream, proceed the stream if the
* pick is successful, otherwise keep it pending.
*
* <p>This method may be called concurrently with {@code newStream()}, and it's safe. All pending
* streams will be served by the latest picker (if a same picker is given more than once, they are
* considered different pickers) as soon as possible.
*
* <p>This method <strong>must not</strong> be called concurrently with itself.
*/
final void reprocess(SubchannelPicker picker) {
ArrayList<PendingStream> toProcess;
ArrayList<PendingStream> toRemove = new ArrayList<PendingStream>();
synchronized (lock) {
lastPicker = picker;
lastPickerVersion++;
if (!hasPendingStreams()) {
return;
}
toProcess = new ArrayList<PendingStream>(pendingStreams);
}
for (final PendingStream stream : toProcess) {
PickResult pickResult = picker.pickSubchannel(stream.args);
CallOptions callOptions = stream.args.getCallOptions();
final ClientTransport transport = GrpcUtil.getTransportFromPickResult(pickResult,
callOptions.isWaitForReady());
if (transport != null) {
Executor executor = defaultAppExecutor;
// createRealStream may be expensive. It will start real streams on the transport. If
// there are pending requests, they will be serialized too, which may be expensive. Since
// we are now on transport thread, we need to offload the work to an executor.
if (callOptions.getExecutor() != null) {
executor = callOptions.getExecutor();
}
executor.execute(new Runnable() {
@Override
public void run() {
stream.createRealStream(transport);
}
});
toRemove.add(stream);
} // else: stay pending
}
synchronized (lock) {
// Between this synchronized and the previous one:
// - Streams may have been cancelled, which may turn pendingStreams into emptiness.
// - shutdown() may be called, which may turn pendingStreams into null.
if (!hasPendingStreams()) {
return;
}
pendingStreams.removeAll(toRemove);
// Because delayed transport is long-lived, we take this opportunity to down-size the
// hashmap.
if (pendingStreams.isEmpty()) {
pendingStreams = new LinkedHashSet<PendingStream>();
}
if (!hasPendingStreams()) {
// There may be a brief gap between delayed transport clearing in-use state, and first real
// transport starting streams and setting in-use state. During the gap the whole channel's
// in-use state may be false. However, it shouldn't cause spurious switching to idleness
// (which would shutdown the transports and LoadBalancer) because the gap should be shorter
// than IDLE_MODE_DEFAULT_TIMEOUT_MILLIS (1 second).
channelExecutor.executeLater(reportTransportNotInUse);
if (shutdownStatus != null && reportTransportTerminated != null) {
channelExecutor.executeLater(reportTransportTerminated);
reportTransportTerminated = null;
}
}
}
channelExecutor.drain();
}