io.grpc.NameResolverRegistry Java Examples
The following examples show how to use
io.grpc.NameResolverRegistry.
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: XdsSdsClientServerTest.java From grpc-java with Apache License 2.0 | 6 votes |
private SimpleServiceGrpc.SimpleServiceBlockingStub getBlockingStub( final UpstreamTlsContext upstreamTlsContext, String overrideAuthority) throws URISyntaxException { URI expectedUri = new URI("sdstest://localhost:" + port); fakeNameResolverFactory = new FakeNameResolverFactory.Builder(expectedUri).build(); NameResolverRegistry.getDefaultRegistry().register(fakeNameResolverFactory); XdsChannelBuilder channelBuilder = XdsChannelBuilder.forTarget("sdstest://localhost:" + port); if (overrideAuthority != null) { channelBuilder = channelBuilder.overrideAuthority(overrideAuthority); } InetSocketAddress socketAddress = new InetSocketAddress(Inet4Address.getLoopbackAddress(), port); Attributes attrs = (upstreamTlsContext != null) ? Attributes.newBuilder() .set(XdsAttributes.ATTR_UPSTREAM_TLS_CONTEXT, upstreamTlsContext) .build() : Attributes.EMPTY; fakeNameResolverFactory.setServers( ImmutableList.of(new EquivalentAddressGroup(socketAddress, attrs))); return SimpleServiceGrpc.newBlockingStub(cleanupRule.register(channelBuilder.build())); }
Example #2
Source File: NameResolverRegistration.java From grpc-spring-boot-starter with MIT License | 5 votes |
/** * Register all NameResolverProviders in the given registry and store a reference to it for later de-registration. * * @param registry The registry to add the providers to. */ public void register(NameResolverRegistry registry) { this.registries.add(registry); for (NameResolverProvider provider : this.providers) { try { registry.register(provider); log.info("{} is available -> Added to the NameResolverRegistry", provider); } catch (IllegalArgumentException e) { log.info("{} is not available -> Not added to the NameResolverRegistry", provider); } } }
Example #3
Source File: NameResolverRegistration.java From grpc-spring-boot-starter with MIT License | 5 votes |
@Override public void destroy() { for (NameResolverRegistry registry : this.registries) { for (NameResolverProvider provider : this.providers) { registry.deregister(provider); log.info("{} was removed from the NameResolverRegistry", provider); } } this.registries.clear(); }
Example #4
Source File: GrpcClientAutoConfiguration.java From grpc-spring-boot-starter with MIT License | 5 votes |
/** * Creates a new NameResolverRegistration. This ensures that the NameResolverProvider's get unregistered when spring * shuts down. This is mostly required for tests/when running multiple application contexts within the same JVM. * * @param nameResolverProviders The spring managed providers to manage. * @return The newly created NameResolverRegistration bean. */ @ConditionalOnMissingBean @Lazy @Bean NameResolverRegistration grpcNameResolverRegistration( @Autowired(required = false) final List<NameResolverProvider> nameResolverProviders) { NameResolverRegistration nameResolverRegistration = new NameResolverRegistration(nameResolverProviders); nameResolverRegistration.register(NameResolverRegistry.getDefaultRegistry()); return nameResolverRegistration; }
Example #5
Source File: NameResolverRegistration.java From grpc-spring-boot-starter with MIT License | 5 votes |
/** * Register all NameResolverProviders in the given registry and store a reference to it for later de-registration. * * @param registry The registry to add the providers to. */ public void register(NameResolverRegistry registry) { this.registries.add(registry); for (NameResolverProvider provider : this.providers) { try { registry.register(provider); log.info("{} is available -> Added to the NameResolverRegistry", provider); } catch (IllegalArgumentException e) { log.info("{} is not available -> Not added to the NameResolverRegistry", provider); } } }
Example #6
Source File: NameResolverRegistration.java From grpc-spring-boot-starter with MIT License | 5 votes |
@Override public void destroy() { for (NameResolverRegistry registry : this.registries) { for (NameResolverProvider provider : this.providers) { registry.deregister(provider); log.info("{} was removed from the NameResolverRegistry", provider); } } this.registries.clear(); }
Example #7
Source File: GrpcClientAutoConfiguration.java From grpc-spring-boot-starter with MIT License | 5 votes |
/** * Creates a new NameResolverRegistration. This ensures that the NameResolverProvider's get unregistered when spring * shuts down. This is mostly required for tests/when running multiple application contexts within the same JVM. * * @param nameResolverProviders The spring managed providers to manage. * @return The newly created NameResolverRegistration bean. */ @ConditionalOnMissingBean @Lazy @Bean NameResolverRegistration grpcNameResolverRegistration( @Autowired(required = false) final List<NameResolverProvider> nameResolverProviders) { NameResolverRegistration nameResolverRegistration = new NameResolverRegistration(nameResolverProviders); nameResolverRegistration.register(NameResolverRegistry.getDefaultRegistry()); return nameResolverRegistration; }
Example #8
Source File: GrpcChannelControllerImpl.java From onos with Apache License 2.0 | 5 votes |
@Activate public void activate() { componentConfigService.registerProperties(getClass()); channels = new ConcurrentHashMap<>(); interceptors = new ConcurrentHashMap<>(); LoadBalancerRegistry.getDefaultRegistry() .register(PICK_FIRST_LOAD_BALANCER_PROVIDER); NameResolverRegistry.getDefaultRegistry() .register(DNS_NAME_RESOLVER_PROVIDER); log.info("Started"); }
Example #9
Source File: GrpcChannelControllerImpl.java From onos with Apache License 2.0 | 5 votes |
@Deactivate public void deactivate() { LoadBalancerRegistry.getDefaultRegistry() .deregister(PICK_FIRST_LOAD_BALANCER_PROVIDER); NameResolverRegistry.getDefaultRegistry() .register(DNS_NAME_RESOLVER_PROVIDER); componentConfigService.unregisterProperties(getClass(), false); channels.values().forEach(ManagedChannel::shutdownNow); channels.clear(); channels = null; interceptors.values().forEach(GrpcLoggingInterceptor::close); interceptors.clear(); interceptors = null; log.info("Stopped"); }
Example #10
Source File: ManagedChannelImplTest.java From grpc-java with Apache License 2.0 | 5 votes |
@Test public void lbHelper_getNameResolverRegistry() { createChannel(); assertThat(helper.getNameResolverRegistry()) .isSameInstanceAs(NameResolverRegistry.getDefaultRegistry()); }
Example #11
Source File: XdsSdsClientServerTest.java From grpc-java with Apache License 2.0 | 4 votes |
@After public void tearDown() { if (fakeNameResolverFactory != null) { NameResolverRegistry.getDefaultRegistry().deregister(fakeNameResolverFactory); } }
Example #12
Source File: ManagedChannelImpl.java From grpc-java with Apache License 2.0 | 4 votes |
@Override public NameResolverRegistry getNameResolverRegistry() { return nameResolverRegistry; }
Example #13
Source File: ForwardingLoadBalancerHelper.java From grpc-java with Apache License 2.0 | 4 votes |
@Override public NameResolverRegistry getNameResolverRegistry() { return delegate().getNameResolverRegistry(); }