本文整理汇总了Java中io.grpc.internal.GrpcUtil.TIMER_SERVICE属性的典型用法代码示例。如果您正苦于以下问题:Java GrpcUtil.TIMER_SERVICE属性的具体用法?Java GrpcUtil.TIMER_SERVICE怎么用?Java GrpcUtil.TIMER_SERVICE使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类io.grpc.internal.GrpcUtil
的用法示例。
在下文中一共展示了GrpcUtil.TIMER_SERVICE属性的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: newNameResolver
@Nullable
@Override
public NameResolver newNameResolver(URI targetUri, Attributes params) {
if (SCHEME.equals(targetUri.getScheme())) {
String targetPath = Preconditions.checkNotNull(targetUri.getPath(), "targetPath");
Preconditions.checkArgument(targetPath.startsWith("/"),
"the path component (%s) of the target (%s) must start with '/'", targetPath, targetUri);
String[] parts = targetPath.split("/");
if (parts.length != 4) {
throw new IllegalArgumentException("Must be formatted like kubernetes:///{namespace}/{service}/{port}");
}
try {
int port = Integer.valueOf(parts[3]);
return new KubernetesNameResolver(parts[1], parts[2], port, params, GrpcUtil.TIMER_SERVICE,
GrpcUtil.SHARED_CHANNEL_EXECUTOR);
} catch (NumberFormatException e) {
throw new IllegalArgumentException("Unable to parse port number", e);
}
} else {
return null;
}
}
示例2: newNameResolver
@Nullable
@Override
public ConsulNameResolver newNameResolver(final URI targetUri, final Attributes params) {
if (!SCHEME.equals(targetUri.getScheme())) {
return null;
}
final String targetPath = checkNotNull(targetUri.getPath(), "targetPath");
checkArgument(targetPath.startsWith("/"));
final String serviceName = targetPath.substring(1);
checkArgument(serviceName.length() > 0, "serviceName");
String consulHost = targetUri.getHost();
if (Strings.isNullOrEmpty(consulHost)) {
consulHost = DEFAULT_HOST;
}
int consulPort = targetUri.getPort();
if (consulPort == -1) {
consulPort = DEFAULT_PORT;
}
final String tag = Strings.emptyToNull(targetUri.getFragment());
final ConsulClient consulClient = ConsulClientManager.getInstance(consulHost, consulPort);
return new ConsulNameResolver(
consulClient /* CatalogClient */,
consulClient /* KeyValueClient */,
serviceName,
Optional.ofNullable(tag),
GrpcUtil.TIMER_SERVICE,
GrpcUtil.SHARED_CHANNEL_EXECUTOR
);
}
示例3: setup
@Before
public void setup() {
resolver = new ConsulNameResolver(
catalogClient,
keyValueClient,
SERVICE_NAME,
Optional.empty(),
GrpcUtil.TIMER_SERVICE,
GrpcUtil.SHARED_CHANNEL_EXECUTOR,
1, TimeUnit.SECONDS
);
}
示例4: getPort_notStarted
@Test
public void getPort_notStarted() throws Exception {
InProcessServer s =
new InProcessServer("name", GrpcUtil.TIMER_SERVICE,
Collections.<ServerStreamTracer.Factory>emptyList());
Truth.assertThat(s.getPort()).isEqualTo(-1);
}
示例5: buildTransportServer
@Override
protected InProcessServer buildTransportServer(
List<ServerStreamTracer.Factory> streamTracerFactories) {
return new InProcessServer(name, GrpcUtil.TIMER_SERVICE, streamTracerFactories);
}
示例6: newServer
@Override
protected InternalServer newServer(List<ServerStreamTracer.Factory> streamTracerFactories) {
return new InProcessServer(TRANSPORT_NAME, GrpcUtil.TIMER_SERVICE, streamTracerFactories);
}