use of alluxio.master.PollingMasterInquireClient in project alluxio by Alluxio.
the class FileSystemAdminShellUtils method checkMasterClientService.
/**
* Checks if the master client service is available.
* Throws an exception if fails to determine that the master client service is running.
*
* @param alluxioConf Alluxio configuration
*/
public static void checkMasterClientService(AlluxioConfiguration alluxioConf) throws IOException {
try (FileSystemContext context = FileSystemContext.create(ClientContext.create(alluxioConf));
CloseableResource<FileSystemMasterClient> client = context.acquireMasterClientResource()) {
InetSocketAddress address = client.get().getAddress();
List<InetSocketAddress> addresses = Arrays.asList(address);
MasterInquireClient inquireClient = new PollingMasterInquireClient(addresses, () -> new ExponentialBackoffRetry(50, 100, 2), alluxioConf);
inquireClient.getPrimaryRpcAddress();
} catch (UnavailableException e) {
throw new IOException("Cannot connect to Alluxio leader master.");
}
}
use of alluxio.master.PollingMasterInquireClient in project alluxio by Alluxio.
the class MasterFaultToleranceIntegrationTest method queryStandby.
@Test(timeout = 30000)
public void queryStandby() throws Exception {
List<InetSocketAddress> addresses = mMultiMasterLocalAlluxioCluster.getMasterAddresses();
Collections.shuffle(addresses);
PollingMasterInquireClient inquireClient = new PollingMasterInquireClient(addresses, ServerConfiguration.global(), ServerUserState.global());
assertEquals(mMultiMasterLocalAlluxioCluster.getLocalAlluxioMaster().getAddress(), inquireClient.getPrimaryRpcAddress());
}
use of alluxio.master.PollingMasterInquireClient in project alluxio by Alluxio.
the class LeaderCommand method run.
@Override
public int run(CommandLine cl) {
System.out.println("This command will be deprecated as of v3.0, please use masterInfo command");
try (CloseableResource<FileSystemMasterClient> client = mFsContext.acquireMasterClientResource()) {
try {
InetSocketAddress address = client.get().getAddress();
System.out.println(address.getHostName());
List<InetSocketAddress> addresses = Arrays.asList(address);
MasterInquireClient inquireClient = new PollingMasterInquireClient(addresses, () -> new ExponentialBackoffRetry(50, 100, 2), mFsContext.getClusterConf());
try {
inquireClient.getPrimaryRpcAddress();
} catch (UnavailableException e) {
System.err.println("The leader is not currently serving requests.");
}
} catch (UnavailableException e) {
System.err.println("Failed to get the leader master.");
}
}
return 0;
}
Aggregations