/** * Test if the input address is serving an Alluxio service. This method make use of the * gRPC protocol for performing service communication. * * @param address the network address to ping * @param serviceType the Alluxio service type * @param conf Alluxio configuration * @throws UnauthenticatedException If the user is not authenticated * @throws StatusRuntimeException If the host not reachable or does not serve the given service */ public static void pingService(InetSocketAddress address, alluxio.grpc.ServiceType serviceType, AlluxioConfiguration conf) throws UnauthenticatedException, UnavailableException { Preconditions.checkNotNull(address, "address"); Preconditions.checkNotNull(serviceType, "serviceType"); GrpcChannel channel = GrpcChannelBuilder.newBuilder(address, conf).build(); ServiceVersionClientServiceGrpc.ServiceVersionClientServiceBlockingStub versionClient = ServiceVersionClientServiceGrpc.newBlockingStub(channel); versionClient.getServiceVersion( GetServiceVersionPRequest.newBuilder().setServiceType(serviceType).build()); channel.shutdown(); } }
private void pingMetaService(InetSocketAddress address) throws UnauthenticatedException, UnavailableException { GrpcChannel channel = GrpcChannelBuilder.newBuilder(address, mConfiguration).build(); ServiceVersionClientServiceGrpc.ServiceVersionClientServiceBlockingStub versionClient = ServiceVersionClientServiceGrpc.newBlockingStub(channel); versionClient.getServiceVersion(GetServiceVersionPRequest.newBuilder() .setServiceType(ServiceType.META_MASTER_CLIENT_SERVICE).build()); channel.shutdown(); }
.build(); mVersionService = ServiceVersionClientServiceGrpc.newBlockingStub(mChannel); mConnected = true; afterConnect();