use of alluxio.hub.common.RpcClient in project alluxio by Alluxio.
the class ManagerProcessMonitor method pingService.
/**
* Attempts to ping the version service of the RPC server.
*
* @param addr The address to connect to
* @param policy the retry policy
* @param timeoutMs the timeout to wait for a ping response
* @throws Exception if the client can't connect
*/
static void pingService(InetSocketAddress addr, RetryPolicy policy, long timeoutMs) throws Exception {
ManagedChannel channel = NettyChannelBuilder.forAddress(addr).build();
RpcClient<ServiceVersionClientServiceGrpc.ServiceVersionClientServiceBlockingStub> versionClient = new RpcClient<>(ServerConfiguration.global(), addr, ServiceVersionClientServiceGrpc::newBlockingStub, () -> ExponentialTimeBoundedRetry.builder().withSkipInitialSleep().withMaxDuration(Duration.ofMillis(timeoutMs)).build());
try {
while (policy.attempt()) {
try {
versionClient.get().withDeadlineAfter(timeoutMs, TimeUnit.MILLISECONDS).getServiceVersion(GetServiceVersionPRequest.newBuilder().setServiceType(ServiceType.UNKNOWN_SERVICE).build());
return;
} catch (Throwable t) {
LOG.info("Failed to reach version service", t);
}
}
} finally {
channel.shutdown();
channel.awaitTermination(3, TimeUnit.SECONDS);
}
throw new Exception("Failed to reach the version service after " + policy.getAttemptCount() + " attempts");
}
use of alluxio.hub.common.RpcClient in project alluxio by Alluxio.
the class AgentProcessMonitor method pingService.
/**
* Attempts to ping the version service of the RPC server.
*
* @param addr The address to connect to
* @param policy the retry policy
* @param timeoutMs timeoutValue
* @throws Exception if the client can't connect
*/
static void pingService(InetSocketAddress addr, RetryPolicy policy, long timeoutMs) throws Exception {
ManagedChannel channel = NettyChannelBuilder.forAddress(addr).build();
RpcClient<ServiceVersionClientServiceGrpc.ServiceVersionClientServiceBlockingStub> versionClient = new RpcClient<>(ServerConfiguration.global(), addr, ServiceVersionClientServiceGrpc::newBlockingStub, () -> ExponentialTimeBoundedRetry.builder().withSkipInitialSleep().withMaxDuration(Duration.ofMillis(timeoutMs)).build());
try {
while (policy.attempt()) {
try {
versionClient.get().withDeadlineAfter(timeoutMs, TimeUnit.MILLISECONDS).getServiceVersion(GetServiceVersionPRequest.newBuilder().setServiceType(ServiceType.UNKNOWN_SERVICE).build());
return;
} catch (Throwable t) {
LOG.info("Failed to reach version service", t);
}
}
} finally {
channel.shutdown();
channel.awaitTermination(3, TimeUnit.SECONDS);
}
throw new Exception("Failed to reach the version service after " + policy.getAttemptCount() + " attempts");
}
Aggregations