本文整理汇总了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);
}
}
示例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;
}
}
示例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;
}
}
}
示例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();
}
示例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();
}
}
示例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);
}
}
}
示例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();
}
示例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();
}
示例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;
}
}
示例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);
}
}
示例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);
}
}
示例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;
}
}
示例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);
}
}
示例14: close
import io.grpc.internal.SharedResourceHolder; //导入依赖的package包/类
@Override
public void close() {
if (closed) {
return;
}
closed = true;
SharedResourceHolder.release(GrpcUtil.TIMER_SERVICE, timerService);
}
示例15: close
import io.grpc.internal.SharedResourceHolder; //导入依赖的package包/类
@Override
public void close() {
SharedResourceHolder.release(GrpcUtil.TIMER_SERVICE, timeoutService);
}