io.grpc.SynchronizationContext Java Examples
The following examples show how to use
io.grpc.SynchronizationContext.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: InternalSubchannel.java From grpc-nebula-java with Apache License 2.0 | 6 votes |
InternalSubchannel(List<EquivalentAddressGroup> addressGroups, String authority, String userAgent, BackoffPolicy.Provider backoffPolicyProvider, ClientTransportFactory transportFactory, ScheduledExecutorService scheduledExecutor, Supplier<Stopwatch> stopwatchSupplier, SynchronizationContext syncContext, Callback callback, InternalChannelz channelz, CallTracer callsTracer, ChannelTracer channelTracer, InternalLogId logId, TimeProvider timeProvider) { Preconditions.checkNotNull(addressGroups, "addressGroups"); Preconditions.checkArgument(!addressGroups.isEmpty(), "addressGroups is empty"); checkListHasNoNulls(addressGroups, "addressGroups contains null entry"); this.addressIndex = new Index( Collections.unmodifiableList(new ArrayList<>(addressGroups))); this.authority = authority; this.userAgent = userAgent; this.backoffPolicyProvider = backoffPolicyProvider; this.transportFactory = transportFactory; this.scheduledExecutor = scheduledExecutor; this.connectingTimer = stopwatchSupplier.get(); this.syncContext = syncContext; this.callback = callback; this.channelz = channelz; this.callsTracer = callsTracer; this.channelTracer = Preconditions.checkNotNull(channelTracer, "channelTracer"); this.logId = Preconditions.checkNotNull(logId, "logId"); this.channelLogger = new ChannelLoggerImpl(channelTracer, timeProvider); }
Example #2
Source File: XdsClientImpl.java From grpc-java with Apache License 2.0 | 6 votes |
XdsClientImpl( String targetName, List<ServerInfo> servers, // list of management servers XdsChannelFactory channelFactory, Node node, SynchronizationContext syncContext, ScheduledExecutorService timeService, BackoffPolicy.Provider backoffPolicyProvider, Supplier<Stopwatch> stopwatchSupplier) { this.targetName = checkNotNull(targetName, "targetName"); this.channel = checkNotNull(channelFactory, "channelFactory") .createChannel(checkNotNull(servers, "servers")); this.node = checkNotNull(node, "node"); this.syncContext = checkNotNull(syncContext, "syncContext"); this.timeService = checkNotNull(timeService, "timeService"); this.backoffPolicyProvider = checkNotNull(backoffPolicyProvider, "backoffPolicyProvider"); this.stopwatchSupplier = checkNotNull(stopwatchSupplier, "stopwatch"); adsStreamRetryStopwatch = stopwatchSupplier.get(); logId = InternalLogId.allocate("xds-client", targetName); logger = XdsLogger.withLogId(logId); logger.log(XdsLogLevel.INFO, "Created"); }
Example #3
Source File: HealthCheckingLoadBalancerFactory.java From grpc-nebula-java with Apache License 2.0 | 5 votes |
HealthCheckState( HelperImpl helperImpl, LoadBalancer delegate, SynchronizationContext syncContext, ScheduledExecutorService timerService) { this.helperImpl = checkNotNull(helperImpl, "helperImpl"); this.delegate = checkNotNull(delegate, "delegate"); this.syncContext = checkNotNull(syncContext, "syncContext"); this.timerService = checkNotNull(timerService, "timerService"); }
Example #4
Source File: OobChannel.java From grpc-java with Apache License 2.0 | 5 votes |
OobChannel( String authority, ObjectPool<? extends Executor> executorPool, ScheduledExecutorService deadlineCancellationExecutor, SynchronizationContext syncContext, CallTracer callsTracer, ChannelTracer channelTracer, InternalChannelz channelz, TimeProvider timeProvider) { this.authority = checkNotNull(authority, "authority"); this.logId = InternalLogId.allocate(getClass(), authority); this.executorPool = checkNotNull(executorPool, "executorPool"); this.executor = checkNotNull(executorPool.getObject(), "executor"); this.deadlineCancellationExecutor = checkNotNull( deadlineCancellationExecutor, "deadlineCancellationExecutor"); this.delayedTransport = new DelayedClientTransport(executor, syncContext); this.channelz = Preconditions.checkNotNull(channelz); this.delayedTransport.start(new ManagedClientTransport.Listener() { @Override public void transportShutdown(Status s) { // Don't care } @Override public void transportTerminated() { subchannelImpl.shutdown(); } @Override public void transportReady() { // Don't care } @Override public void transportInUse(boolean inUse) { // Don't care } }); this.channelCallsTracer = callsTracer; this.channelTracer = checkNotNull(channelTracer, "channelTracer"); this.timeProvider = checkNotNull(timeProvider, "timeProvider"); }
Example #5
Source File: InternalSubchannel.java From grpc-java with Apache License 2.0 | 5 votes |
InternalSubchannel(List<EquivalentAddressGroup> addressGroups, String authority, String userAgent, BackoffPolicy.Provider backoffPolicyProvider, ClientTransportFactory transportFactory, ScheduledExecutorService scheduledExecutor, Supplier<Stopwatch> stopwatchSupplier, SynchronizationContext syncContext, Callback callback, InternalChannelz channelz, CallTracer callsTracer, ChannelTracer channelTracer, InternalLogId logId, ChannelLogger channelLogger) { Preconditions.checkNotNull(addressGroups, "addressGroups"); Preconditions.checkArgument(!addressGroups.isEmpty(), "addressGroups is empty"); checkListHasNoNulls(addressGroups, "addressGroups contains null entry"); List<EquivalentAddressGroup> unmodifiableAddressGroups = Collections.unmodifiableList(new ArrayList<>(addressGroups)); this.addressGroups = unmodifiableAddressGroups; this.addressIndex = new Index(unmodifiableAddressGroups); this.authority = authority; this.userAgent = userAgent; this.backoffPolicyProvider = backoffPolicyProvider; this.transportFactory = transportFactory; this.scheduledExecutor = scheduledExecutor; this.connectingTimer = stopwatchSupplier.get(); this.syncContext = syncContext; this.callback = callback; this.channelz = channelz; this.callsTracer = callsTracer; this.channelTracer = Preconditions.checkNotNull(channelTracer, "channelTracer"); this.logId = Preconditions.checkNotNull(logId, "logId"); this.channelLogger = Preconditions.checkNotNull(channelLogger, "channelLogger"); }
Example #6
Source File: OobChannel.java From grpc-nebula-java with Apache License 2.0 | 5 votes |
OobChannel( String authority, ObjectPool<? extends Executor> executorPool, ScheduledExecutorService deadlineCancellationExecutor, SynchronizationContext syncContext, CallTracer callsTracer, ChannelTracer channelTracer, InternalChannelz channelz, TimeProvider timeProvider) { this.authority = checkNotNull(authority, "authority"); this.executorPool = checkNotNull(executorPool, "executorPool"); this.executor = checkNotNull(executorPool.getObject(), "executor"); this.deadlineCancellationExecutor = checkNotNull( deadlineCancellationExecutor, "deadlineCancellationExecutor"); this.delayedTransport = new DelayedClientTransport(executor, syncContext); this.channelz = Preconditions.checkNotNull(channelz); this.delayedTransport.start(new ManagedClientTransport.Listener() { @Override public void transportShutdown(Status s) { // Don't care } @Override public void transportTerminated() { subchannelImpl.shutdown(); } @Override public void transportReady() { // Don't care } @Override public void transportInUse(boolean inUse) { // Don't care } }); this.channelCallsTracer = callsTracer; this.channelTracer = checkNotNull(channelTracer, "channelTracer"); this.timeProvider = checkNotNull(timeProvider, "timeProvider"); }
Example #7
Source File: HealthCheckingLoadBalancerFactory.java From grpc-java with Apache License 2.0 | 5 votes |
HealthCheckState( HelperImpl helperImpl, Subchannel subchannel, SynchronizationContext syncContext, ScheduledExecutorService timerService) { this.helperImpl = checkNotNull(helperImpl, "helperImpl"); this.subchannel = checkNotNull(subchannel, "subchannel"); this.subchannelLogger = checkNotNull(subchannel.getChannelLogger(), "subchannelLogger"); this.syncContext = checkNotNull(syncContext, "syncContext"); this.timerService = checkNotNull(timerService, "timerService"); }
Example #8
Source File: LoadReportClient.java From grpc-java with Apache License 2.0 | 5 votes |
LoadReportClient( InternalLogId logId, String targetName, ManagedChannel channel, Node node, SynchronizationContext syncContext, ScheduledExecutorService scheduledExecutorService, BackoffPolicy.Provider backoffPolicyProvider, Supplier<Stopwatch> stopwatchSupplier) { this.channel = checkNotNull(channel, "channel"); this.syncContext = checkNotNull(syncContext, "syncContext"); this.timerService = checkNotNull(scheduledExecutorService, "timeService"); this.backoffPolicyProvider = checkNotNull(backoffPolicyProvider, "backoffPolicyProvider"); this.stopwatchSupplier = checkNotNull(stopwatchSupplier, "stopwatchSupplier"); this.retryStopwatch = stopwatchSupplier.get(); checkNotNull(targetName, "targetName"); checkNotNull(node, "node"); Struct metadata = node.getMetadata() .toBuilder() .putFields( TARGET_NAME_METADATA_KEY, Value.newBuilder().setStringValue(targetName).build()) .build(); this.node = node.toBuilder().setMetadata(metadata).build(); String logPrefix = checkNotNull(logId, "logId").toString().concat("-lrs-client"); logger = XdsLogger.withPrefix(logPrefix); }
Example #9
Source File: OrcaOobUtil.java From grpc-java with Apache License 2.0 | 5 votes |
OrcaReportingState( OrcaReportingHelper orcaHelper, SynchronizationContext syncContext, ScheduledExecutorService timeService) { this.orcaHelper = checkNotNull(orcaHelper, "orcaHelper"); this.syncContext = checkNotNull(syncContext, "syncContext"); this.timeService = checkNotNull(timeService, "timeService"); }
Example #10
Source File: ForwardingLoadBalancerHelper.java From grpc-java with Apache License 2.0 | 4 votes |
@Override public SynchronizationContext getSynchronizationContext() { return delegate().getSynchronizationContext(); }
Example #11
Source File: ManagedChannelImpl.java From grpc-java with Apache License 2.0 | 4 votes |
@Override public SynchronizationContext getSynchronizationContext() { return syncContext; }
Example #12
Source File: HealthCheckingLoadBalancerFactoryTest.java From grpc-java with Apache License 2.0 | 4 votes |
@Override public SynchronizationContext getSynchronizationContext() { return syncContext; }
Example #13
Source File: CachingRlsLbClientTest.java From grpc-java with Apache License 2.0 | 4 votes |
@Override public SynchronizationContext getSynchronizationContext() { return syncContext; }
Example #14
Source File: RlsLoadBalancerTest.java From grpc-java with Apache License 2.0 | 4 votes |
@Override public SynchronizationContext getSynchronizationContext() { return syncContext; }
Example #15
Source File: OrcaOobUtilTest.java From grpc-java with Apache License 2.0 | 4 votes |
@Override public SynchronizationContext getSynchronizationContext() { return syncContext; }
Example #16
Source File: GrpclbLoadBalancerTest.java From grpc-java with Apache License 2.0 | 4 votes |
@Override public SynchronizationContext getSynchronizationContext() { return syncContext; }
Example #17
Source File: GrpclbState.java From grpc-java with Apache License 2.0 | 4 votes |
IdleSubchannelEntry(Subchannel subchannel, SynchronizationContext syncContext) { this.subchannel = checkNotNull(subchannel, "subchannel"); this.syncContext = checkNotNull(syncContext, "syncContext"); }
Example #18
Source File: AutoConfiguredLoadBalancerFactoryTest.java From grpc-nebula-java with Apache License 2.0 | 4 votes |
@Test public void channelTracing_lbPolicyChanged() { final FakeClock clock = new FakeClock(); List<EquivalentAddressGroup> servers = Collections.singletonList( new EquivalentAddressGroup(new SocketAddress(){}, Attributes.EMPTY)); Helper helper = new TestHelper() { @Override public Subchannel createSubchannel(List<EquivalentAddressGroup> addrs, Attributes attrs) { return new TestSubchannel(addrs, attrs); } @Override public ManagedChannel createOobChannel(EquivalentAddressGroup eag, String authority) { return mock(ManagedChannel.class, RETURNS_DEEP_STUBS); } @Override public String getAuthority() { return "fake_authority"; } @Override public void updateBalancingState(ConnectivityState newState, SubchannelPicker newPicker) { // noop } @Override public SynchronizationContext getSynchronizationContext() { return new SynchronizationContext( new Thread.UncaughtExceptionHandler() { @Override public void uncaughtException(Thread t, Throwable e) { throw new AssertionError(e); } }); } @Override public ScheduledExecutorService getScheduledExecutorService() { return clock.getScheduledExecutorService(); } }; LoadBalancer lb = new AutoConfiguredLoadBalancerFactory().newLoadBalancer(helper); lb.handleResolvedAddressGroups(servers, Attributes.EMPTY); verifyNoMoreInteractions(channelLogger); Map<String, Object> serviceConfig = new HashMap<String, Object>(); serviceConfig.put("loadBalancingPolicy", "round_robin"); lb.handleResolvedAddressGroups(servers, Attributes.newBuilder() .set(GrpcAttributes.NAME_RESOLVER_SERVICE_CONFIG, serviceConfig).build()); verify(channelLogger).log( eq(ChannelLogLevel.INFO), eq("Load balancer changed from {0} to {1}"), eq("PickFirstLoadBalancer"), eq("RoundRobinLoadBalancer")); verifyNoMoreInteractions(channelLogger); serviceConfig.put("loadBalancingPolicy", "round_robin"); lb.handleResolvedAddressGroups(servers, Attributes.newBuilder() .set(GrpcAttributes.NAME_RESOLVER_SERVICE_CONFIG, serviceConfig).build()); verifyNoMoreInteractions(channelLogger); servers = Collections.singletonList(new EquivalentAddressGroup( new SocketAddress(){}, Attributes.newBuilder().set(GrpcAttributes.ATTR_LB_ADDR_AUTHORITY, "ok").build())); lb.handleResolvedAddressGroups(servers, Attributes.EMPTY); verify(channelLogger).log( eq(ChannelLogLevel.INFO), eq("Load balancer changed from {0} to {1}"), eq("RoundRobinLoadBalancer"), eq("GrpclbLoadBalancer")); verifyNoMoreInteractions(channelLogger); }
Example #19
Source File: ForwardingLoadBalancerHelper.java From grpc-nebula-java with Apache License 2.0 | 4 votes |
@Override public SynchronizationContext getSynchronizationContext() { return delegate().getSynchronizationContext(); }
Example #20
Source File: ManagedChannelImpl.java From grpc-nebula-java with Apache License 2.0 | 4 votes |
@Override public SynchronizationContext getSynchronizationContext() { return syncContext; }
Example #21
Source File: HealthCheckingLoadBalancerFactoryTest.java From grpc-nebula-java with Apache License 2.0 | 4 votes |
@Override public SynchronizationContext getSynchronizationContext() { return syncContext; }
Example #22
Source File: DelayedClientTransport.java From grpc-nebula-java with Apache License 2.0 | 2 votes |
/** * Creates a new delayed transport. * * @param defaultAppExecutor pending streams will create real streams and run bufferred operations * in an application executor, which will be this executor, unless there is on provided in * {@link CallOptions}. * @param syncContext all listener callbacks of the delayed transport will be run from this * SynchronizationContext. */ DelayedClientTransport(Executor defaultAppExecutor, SynchronizationContext syncContext) { this.defaultAppExecutor = defaultAppExecutor; this.syncContext = syncContext; }
Example #23
Source File: DelayedClientTransport.java From grpc-java with Apache License 2.0 | 2 votes |
/** * Creates a new delayed transport. * * @param defaultAppExecutor pending streams will create real streams and run bufferred operations * in an application executor, which will be this executor, unless there is on provided in * {@link CallOptions}. * @param syncContext all listener callbacks of the delayed transport will be run from this * SynchronizationContext. */ DelayedClientTransport(Executor defaultAppExecutor, SynchronizationContext syncContext) { this.defaultAppExecutor = defaultAppExecutor; this.syncContext = syncContext; }