本文整理汇总了Java中io.grpc.internal.SharedResourceHolder类的典型用法代码示例。如果您正苦于以下问题:Java SharedResourceHolder类的具体用法?Java SharedResourceHolder怎么用?Java SharedResourceHolder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SharedResourceHolder类属于io.grpc.internal包,在下文中一共展示了SharedResourceHolder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: shutdown
import io.grpc.internal.SharedResourceHolder; //导入依赖的package包/类
@Override
public final synchronized void shutdown() {
if (shutdown) {
return;
}
shutdown = true;
if (resolutionTask != null) {
resolutionTask.cancel(false);
resolutionTask = null;
}
if (timerService != null) {
timerService = SharedResourceHolder.release(timerServiceResource, timerService);
}
if (executor != null) {
executor = SharedResourceHolder.release(executorResource, executor);
}
}
开发者ID:indeedeng-alpha,项目名称:indeed-grpc-java,代码行数:21,代码来源:ConsulNameResolver.java
示例2: refresh
import io.grpc.internal.SharedResourceHolder; //导入依赖的package包/类
@Override
@GuardedBy("this")
public void refresh() {
if (refreshing) return;
try {
refreshing = true;
Endpoints endpoints = kubernetesClient.endpoints().inNamespace(namespace)
.withName(name)
.get();
if (endpoints == null) {
// Didn't find anything, retrying
ScheduledExecutorService timerService = SharedResourceHolder.get(timerServiceResource);
timerService.schedule(() -> {
refresh();
}, 30, TimeUnit.SECONDS);
return;
}
update(endpoints);
watch();
} finally {
refreshing = false;
}
}
开发者ID:saturnism,项目名称:grpc-java-by-example,代码行数:27,代码来源:KubernetesNameResolver.java
示例3: deallocate
import io.grpc.internal.SharedResourceHolder; //导入依赖的package包/类
@Override
protected void deallocate() {
try {
if (usingSharedBossGroup && bossGroup != null) {
SharedResourceHolder.release(Utils.DEFAULT_BOSS_EVENT_LOOP_GROUP, bossGroup);
}
} finally {
bossGroup = null;
try {
if (usingSharedWorkerGroup && workerGroup != null) {
SharedResourceHolder.release(Utils.DEFAULT_WORKER_EVENT_LOOP_GROUP, workerGroup);
}
} finally {
workerGroup = null;
}
}
}
开发者ID:grpc,项目名称:grpc-java,代码行数:18,代码来源:NettyServer.java
示例4: start
import io.grpc.internal.SharedResourceHolder; //导入依赖的package包/类
@Override
public final synchronized void start(final Listener listener) {
checkState(this.listener == null, "ConsulNameResolver already started");
timerService = SharedResourceHolder.get(timerServiceResource);
executor = SharedResourceHolder.get(executorResource);
this.listener = checkNotNull(listener, "listener cannot be null");
resolve();
}
开发者ID:indeedeng-alpha,项目名称:indeed-grpc-java,代码行数:9,代码来源:ConsulNameResolver.java
示例5: start
import io.grpc.internal.SharedResourceHolder; //导入依赖的package包/类
@Override
public void start(Listener listener) {
synchronized (lock) {
Preconditions.checkState(this.listener == null, "already started");
this.executor = SharedResourceHolder.get(GrpcUtil.SHARED_CHANNEL_EXECUTOR);
this.listener = Preconditions.checkNotNull(listener, "listener");
resolve();
}
}
开发者ID:coreos,项目名称:jetcd,代码行数:10,代码来源:SmartNameResolver.java
示例6: shutdown
import io.grpc.internal.SharedResourceHolder; //导入依赖的package包/类
@Override
public void shutdown() {
if (shutdown) {
return;
}
shutdown = true;
synchronized (lock) {
if (executor != null) {
executor = SharedResourceHolder.release(GrpcUtil.SHARED_CHANNEL_EXECUTOR, executor);
}
}
}
开发者ID:coreos,项目名称:jetcd,代码行数:14,代码来源:SmartNameResolver.java
示例7: KubernetesNameResolver
import io.grpc.internal.SharedResourceHolder; //导入依赖的package包/类
public KubernetesNameResolver(String namespace, String name, int port, Attributes params, SharedResourceHolder.Resource<ScheduledExecutorService> timerServiceResource, SharedResourceHolder.Resource<ExecutorService> sharedChannelExecutorResource) {
this.namespace = namespace;
this.name = name;
this.port = port;
this.params = params;
this.timerServiceResource = timerServiceResource;
this.sharedChannelExecutorResource = sharedChannelExecutorResource;
this.kubernetesClient = new DefaultKubernetesClient();
}
开发者ID:saturnism,项目名称:grpc-java-by-example,代码行数:10,代码来源:KubernetesNameResolver.java
示例8: stopIfNecessary
import io.grpc.internal.SharedResourceHolder; //导入依赖的package包/类
/**
* When the transport is in goAway state, we should stop it once all active streams finish.
*/
@GuardedBy("lock")
private void stopIfNecessary() {
if (!(goAwayStatus != null && streams.isEmpty() && pendingStreams.isEmpty())) {
return;
}
if (stopped) {
return;
}
stopped = true;
if (keepAliveManager != null) {
keepAliveManager.onTransportTermination();
// KeepAliveManager should stop using the scheduler after onTransportTermination gets called.
scheduler = SharedResourceHolder.release(TIMER_SERVICE, scheduler);
}
if (ping != null) {
ping.failed(getPingFailure());
ping = null;
}
if (!goAwaySent) {
// Send GOAWAY with lastGoodStreamId of 0, since we don't expect any server-initiated
// streams. The GOAWAY is part of graceful shutdown.
goAwaySent = true;
frameWriter.goAway(0, ErrorCode.NO_ERROR, new byte[0]);
}
// We will close the underlying socket in the writing thread to break out the reader
// thread, which will close the frameReader and notify the listener.
frameWriter.close();
}
开发者ID:grpc,项目名称:grpc-java,代码行数:36,代码来源:OkHttpClientTransport.java
示例9: OkHttpTransportFactory
import io.grpc.internal.SharedResourceHolder; //导入依赖的package包/类
private OkHttpTransportFactory(Executor executor,
@Nullable SSLSocketFactory socketFactory,
@Nullable HostnameVerifier hostnameVerifier,
ConnectionSpec connectionSpec,
int maxMessageSize,
boolean enableKeepAlive,
long keepAliveTimeNanos,
long keepAliveTimeoutNanos,
boolean keepAliveWithoutCalls,
TransportTracer.Factory transportTracerFactory) {
this.socketFactory = socketFactory;
this.hostnameVerifier = hostnameVerifier;
this.connectionSpec = connectionSpec;
this.maxMessageSize = maxMessageSize;
this.enableKeepAlive = enableKeepAlive;
this.keepAliveTimeNanos = new AtomicBackoff("keepalive time nanos", keepAliveTimeNanos);
this.keepAliveTimeoutNanos = keepAliveTimeoutNanos;
this.keepAliveWithoutCalls = keepAliveWithoutCalls;
usingSharedExecutor = executor == null;
this.transportTracerFactory =
Preconditions.checkNotNull(transportTracerFactory, "transportTracerFactory");
if (usingSharedExecutor) {
// The executor was unspecified, using the shared executor.
this.executor = SharedResourceHolder.get(SHARED_EXECUTOR);
} else {
this.executor = executor;
}
}
开发者ID:grpc,项目名称:grpc-java,代码行数:30,代码来源:OkHttpChannelBuilder.java
示例10: close
import io.grpc.internal.SharedResourceHolder; //导入依赖的package包/类
@Override
public void close() {
if (closed) {
return;
}
closed = true;
SharedResourceHolder.release(GrpcUtil.TIMER_SERVICE, timeoutService);
if (usingSharedExecutor) {
SharedResourceHolder.release(SHARED_EXECUTOR, (ExecutorService) executor);
}
}
开发者ID:grpc,项目名称:grpc-java,代码行数:13,代码来源:OkHttpChannelBuilder.java
示例11: allocateSharedGroups
import io.grpc.internal.SharedResourceHolder; //导入依赖的package包/类
private void allocateSharedGroups() {
if (bossGroup == null) {
bossGroup = SharedResourceHolder.get(Utils.DEFAULT_BOSS_EVENT_LOOP_GROUP);
}
if (workerGroup == null) {
workerGroup = SharedResourceHolder.get(Utils.DEFAULT_WORKER_EVENT_LOOP_GROUP);
}
}
开发者ID:grpc,项目名称:grpc-java,代码行数:9,代码来源:NettyServer.java
示例12: NettyTransportFactory
import io.grpc.internal.SharedResourceHolder; //导入依赖的package包/类
NettyTransportFactory(TransportCreationParamsFilterFactory transportCreationParamsFilterFactory,
Class<? extends Channel> channelType, Map<ChannelOption<?>, ?> channelOptions,
NegotiationType negotiationType, SslContext sslContext, EventLoopGroup group,
int flowControlWindow, int maxMessageSize, int maxHeaderListSize,
long keepAliveTimeNanos, long keepAliveTimeoutNanos, boolean keepAliveWithoutCalls,
TransportTracer transportTracer) {
this.channelType = channelType;
this.negotiationType = negotiationType;
this.channelOptions = new HashMap<ChannelOption<?>, Object>(channelOptions);
this.transportTracer = transportTracer;
if (transportCreationParamsFilterFactory == null) {
transportCreationParamsFilterFactory =
new DefaultNettyTransportCreationParamsFilterFactory(sslContext);
}
this.transportCreationParamsFilterFactory = transportCreationParamsFilterFactory;
this.flowControlWindow = flowControlWindow;
this.maxMessageSize = maxMessageSize;
this.maxHeaderListSize = maxHeaderListSize;
this.keepAliveTimeNanos = new AtomicBackoff("keepalive time nanos", keepAliveTimeNanos);
this.keepAliveTimeoutNanos = keepAliveTimeoutNanos;
this.keepAliveWithoutCalls = keepAliveWithoutCalls;
usingSharedGroup = group == null;
if (usingSharedGroup) {
// The group was unspecified, using the shared group.
this.group = SharedResourceHolder.get(Utils.DEFAULT_WORKER_EVENT_LOOP_GROUP);
} else {
this.group = group;
}
}
开发者ID:grpc,项目名称:grpc-java,代码行数:32,代码来源:NettyChannelBuilder.java
示例13: close
import io.grpc.internal.SharedResourceHolder; //导入依赖的package包/类
@Override
public void close() {
if (closed) {
return;
}
closed = true;
if (usingSharedGroup) {
SharedResourceHolder.release(Utils.DEFAULT_WORKER_EVENT_LOOP_GROUP, group);
}
}
开发者ID:grpc,项目名称:grpc-java,代码行数:12,代码来源:NettyChannelBuilder.java
示例14: close
import io.grpc.internal.SharedResourceHolder; //导入依赖的package包/类
@Override
public void close() {
if (closed) {
return;
}
closed = true;
SharedResourceHolder.release(GrpcUtil.TIMER_SERVICE, timerService);
}
开发者ID:grpc,项目名称:grpc-java,代码行数:9,代码来源:InProcessChannelBuilder.java
示例15: close
import io.grpc.internal.SharedResourceHolder; //导入依赖的package包/类
@Override
public void close() {
SharedResourceHolder.release(GrpcUtil.TIMER_SERVICE, timeoutService);
}
开发者ID:grpc,项目名称:grpc-java,代码行数:5,代码来源:CronetChannelBuilder.java
注:本文中的io.grpc.internal.SharedResourceHolder类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论