当前位置: 首页>>代码示例>>Java>>正文


Java NameResolver.Factory方法代码示例

本文整理汇总了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();
}
 
开发者ID:grpc,项目名称:grpc-java,代码行数:23,代码来源:OverrideAuthorityNameResolverTest.java

示例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
  }
}
 
开发者ID:grpc,项目名称:grpc-java,代码行数:22,代码来源:ManagedChannelImplGetNameResolverTest.java

示例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));
}
 
开发者ID:salesforce,项目名称:grpc-java-contrib,代码行数:11,代码来源:FallbackResolverTest.java

示例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));
}
 
开发者ID:salesforce,项目名称:grpc-java-contrib,代码行数:11,代码来源:FallbackResolverTest.java

示例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));
}
 
开发者ID:salesforce,项目名称:grpc-java-contrib,代码行数:9,代码来源:FallbackResolverTest.java

示例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());
}
 
开发者ID:salesforce,项目名称:grpc-java-contrib,代码行数:11,代码来源:FallbackResolverTest.java

示例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);
}
 
开发者ID:coreos,项目名称:jetcd,代码行数:14,代码来源:SmartNameResolverFactory.java

示例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();
}
 
开发者ID:grpc,项目名称:grpc-java,代码行数:13,代码来源:AbstractManagedChannelImplBuilder.java

示例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);
  }
}
 
开发者ID:grpc,项目名称:grpc-java,代码行数:11,代码来源:AbstractManagedChannelImplBuilder.java

示例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());
}
 
开发者ID:grpc,项目名称:grpc-java,代码行数:15,代码来源:OverrideAuthorityNameResolverTest.java

示例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));
}
 
开发者ID:grpc,项目名称:grpc-java,代码行数:10,代码来源:OverrideAuthorityNameResolverTest.java

示例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());
}
 
开发者ID:grpc,项目名称:grpc-java,代码行数:8,代码来源:AbstractManagedChannelImplBuilderTest.java

示例13: getNameResolverFactory

import io.grpc.NameResolver; //导入方法依赖的package包/类
@Override
public NameResolver.Factory getNameResolverFactory() {
  return nameResolverFactory;
}
 
开发者ID:grpc,项目名称:grpc-java,代码行数:5,代码来源:ManagedChannelImpl.java

示例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);
}
 
开发者ID:grpc,项目名称:grpc-java,代码行数:7,代码来源:ManagedChannelImplTest.java

示例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());
}
 
开发者ID:grpc,项目名称:grpc-java,代码行数:7,代码来源:AbstractManagedChannelImplBuilderTest.java


注:本文中的io.grpc.NameResolver.Factory方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。