本文整理汇总了Java中io.grpc.NameResolver.Factory方法的典型用法代码示例。如果您正苦于以下问题:Java NameResolver.Factory方法的具体用法?Java NameResolver.Factory怎么用?Java NameResolver.Factory使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.grpc.NameResolver
的用法示例。
在下文中一共展示了NameResolver.Factory方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: forwardsNonOverridenCalls
import io.grpc.NameResolver; //导入方法依赖的package包/类
@Test
public void forwardsNonOverridenCalls() {
NameResolver.Factory wrappedFactory = mock(NameResolver.Factory.class);
NameResolver mockResolver = mock(NameResolver.class);
when(wrappedFactory.newNameResolver(any(URI.class), any(Attributes.class)))
.thenReturn(mockResolver);
NameResolver.Factory factory =
new OverrideAuthorityNameResolverFactory(wrappedFactory, "override:5678");
NameResolver overrideResolver =
factory.newNameResolver(URI.create("dns:///localhost:443"), Attributes.EMPTY);
assertNotNull(overrideResolver);
NameResolver.Listener listener = mock(NameResolver.Listener.class);
overrideResolver.start(listener);
verify(mockResolver).start(listener);
overrideResolver.shutdown();
verify(mockResolver).shutdown();
overrideResolver.refresh();
verify(mockResolver).refresh();
}
示例2: validTargetNoResovler
import io.grpc.NameResolver; //导入方法依赖的package包/类
@Test
public void validTargetNoResovler() {
Factory nameResolverFactory = new NameResolver.Factory() {
@Override
public NameResolver newNameResolver(URI targetUri, Attributes params) {
return null;
}
@Override
public String getDefaultScheme() {
return "defaultscheme";
}
};
try {
ManagedChannelImpl.getNameResolver(
"foo.googleapis.com:8080", nameResolverFactory, NAME_RESOLVER_PARAMS);
fail("Should fail");
} catch (IllegalArgumentException e) {
// expected
}
}
示例3: firstShouldFind
import io.grpc.NameResolver; //导入方法依赖的package包/类
@Test
public void firstShouldFind() throws Exception {
NameResolver fakeResolver = new FakeResolver();
FakeResolverProvider canResolve = new FakeResolverProvider("aaa://", fakeResolver);
FakeResolverProvider cannotResolve = new FakeResolverProvider("bbb://", null);
NameResolver.Factory factory = FallbackResolver.startWith(canResolve).thenCheck(cannotResolve);
assertEquals(fakeResolver, factory.newNameResolver(new URI("aaa://foo"), Attributes.EMPTY));
}
示例4: secondShouldFind
import io.grpc.NameResolver; //导入方法依赖的package包/类
@Test
public void secondShouldFind() throws Exception {
NameResolver fakeResolver = new FakeResolver();
FakeResolverProvider canResolve = new FakeResolverProvider("aaa://", fakeResolver);
FakeResolverProvider cannotResolve = new FakeResolverProvider("bbb://", null);
NameResolver.Factory factory = FallbackResolver.startWith(cannotResolve).thenCheck(canResolve);
assertEquals(fakeResolver, factory.newNameResolver(new URI("bbb://foo"), Attributes.EMPTY));
}
示例5: neitherShouldFind
import io.grpc.NameResolver; //导入方法依赖的package包/类
@Test
public void neitherShouldFind() throws Exception {
FakeResolverProvider cannotResolve = new FakeResolverProvider("bbb://", null);
NameResolver.Factory factory = FallbackResolver.startWith(cannotResolve).thenCheck(cannotResolve);
assertNull(factory.newNameResolver(new URI("bbb://foo"), Attributes.EMPTY));
}
示例6: firstSchemeIsDefaultScheme
import io.grpc.NameResolver; //导入方法依赖的package包/类
@Test
public void firstSchemeIsDefaultScheme() {
NameResolver fakeResolver = new FakeResolver();
FakeResolverProvider canResolve = new FakeResolverProvider("aaa://", fakeResolver);
FakeResolverProvider cannotResolve = new FakeResolverProvider("bbb://", null);
NameResolver.Factory factory = FallbackResolver.startWith(canResolve).thenCheck(cannotResolve);
assertEquals("aaa://", factory.getDefaultScheme());
}
示例7: forEndpoints
import io.grpc.NameResolver; //导入方法依赖的package包/类
public static NameResolver.Factory forEndpoints(
String authority, Collection<String> endpoints, URIResolverLoader loader) {
List<URI> uris = endpoints.stream().map(endpoint -> {
try {
return new URI(endpoint);
} catch (URISyntaxException e) {
throw new IllegalArgumentException(e);
}
}).collect(Collectors.toList());
return new SmartNameResolverFactory(authority, uris, loader);
}
示例8: nameResolverFactory
import io.grpc.NameResolver; //导入方法依赖的package包/类
@Override
public final T nameResolverFactory(NameResolver.Factory resolverFactory) {
Preconditions.checkState(directServerAddress == null,
"directServerAddress is set (%s), which forbids the use of NameResolverFactory",
directServerAddress);
if (resolverFactory != null) {
this.nameResolverFactory = resolverFactory;
} else {
this.nameResolverFactory = DEFAULT_NAME_RESOLVER_FACTORY;
}
return thisT();
}
示例9: getNameResolverFactory
import io.grpc.NameResolver; //导入方法依赖的package包/类
/**
* Returns a {@link NameResolver.Factory} for the channel.
*/
NameResolver.Factory getNameResolverFactory() {
if (authorityOverride == null) {
return nameResolverFactory;
} else {
return new OverrideAuthorityNameResolverFactory(nameResolverFactory, authorityOverride);
}
}
示例10: overridesAuthority
import io.grpc.NameResolver; //导入方法依赖的package包/类
@Test
public void overridesAuthority() {
NameResolver nameResolverMock = mock(NameResolver.class);
NameResolver.Factory wrappedFactory = mock(NameResolver.Factory.class);
when(wrappedFactory.newNameResolver(any(URI.class), any(Attributes.class)))
.thenReturn(nameResolverMock);
String override = "override:5678";
NameResolver.Factory factory =
new OverrideAuthorityNameResolverFactory(wrappedFactory, override);
NameResolver nameResolver = factory.newNameResolver(URI.create("dns:///localhost:443"),
Attributes.EMPTY);
assertNotNull(nameResolver);
assertEquals(override, nameResolver.getServiceAuthority());
}
示例11: wontWrapNull
import io.grpc.NameResolver; //导入方法依赖的package包/类
@Test
public void wontWrapNull() {
NameResolver.Factory wrappedFactory = mock(NameResolver.Factory.class);
when(wrappedFactory.newNameResolver(any(URI.class), any(Attributes.class))).thenReturn(null);
NameResolver.Factory factory =
new OverrideAuthorityNameResolverFactory(wrappedFactory, "override:5678");
assertEquals(null,
factory.newNameResolver(URI.create("dns:///localhost:443"), Attributes.EMPTY));
}
示例12: nameResolverFactory_null
import io.grpc.NameResolver; //导入方法依赖的package包/类
@Test
public void nameResolverFactory_null() {
NameResolver.Factory defaultValue = builder.getNameResolverFactory();
builder.nameResolverFactory(mock(NameResolver.Factory.class));
assertEquals(builder, builder.nameResolverFactory(null));
assertEquals(defaultValue, builder.getNameResolverFactory());
}
示例13: getNameResolverFactory
import io.grpc.NameResolver; //导入方法依赖的package包/类
@Override
public NameResolver.Factory getNameResolverFactory() {
return nameResolverFactory;
}
示例14: createChannel
import io.grpc.NameResolver; //导入方法依赖的package包/类
private void createChannel(
NameResolver.Factory nameResolverFactory, List<ClientInterceptor> interceptors) {
createChannel(
nameResolverFactory, interceptors, true /* requestConnection */,
ManagedChannelImpl.IDLE_TIMEOUT_MILLIS_DISABLE);
}
示例15: nameResolverFactory_normal
import io.grpc.NameResolver; //导入方法依赖的package包/类
@Test
public void nameResolverFactory_normal() {
NameResolver.Factory nameResolverFactory = mock(NameResolver.Factory.class);
assertEquals(builder, builder.nameResolverFactory(nameResolverFactory));
assertEquals(nameResolverFactory, builder.getNameResolverFactory());
}