Search in sources :

Example 1 with PollingMasterInquireClient

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.");
    }
}
Also used : PollingMasterInquireClient(alluxio.master.PollingMasterInquireClient) MasterInquireClient(alluxio.master.MasterInquireClient) FileSystemMasterClient(alluxio.client.file.FileSystemMasterClient) PollingMasterInquireClient(alluxio.master.PollingMasterInquireClient) InetSocketAddress(java.net.InetSocketAddress) ExponentialBackoffRetry(alluxio.retry.ExponentialBackoffRetry) UnavailableException(alluxio.exception.status.UnavailableException) FileSystemContext(alluxio.client.file.FileSystemContext) IOException(java.io.IOException)

Example 2 with PollingMasterInquireClient

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());
}
Also used : PollingMasterInquireClient(alluxio.master.PollingMasterInquireClient) InetSocketAddress(java.net.InetSocketAddress) BaseIntegrationTest(alluxio.testutils.BaseIntegrationTest) Test(org.junit.Test)

Example 3 with PollingMasterInquireClient

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;
}
Also used : PollingMasterInquireClient(alluxio.master.PollingMasterInquireClient) MasterInquireClient(alluxio.master.MasterInquireClient) FileSystemMasterClient(alluxio.client.file.FileSystemMasterClient) PollingMasterInquireClient(alluxio.master.PollingMasterInquireClient) InetSocketAddress(java.net.InetSocketAddress) ExponentialBackoffRetry(alluxio.retry.ExponentialBackoffRetry) UnavailableException(alluxio.exception.status.UnavailableException)

Aggregations

PollingMasterInquireClient (alluxio.master.PollingMasterInquireClient)3 InetSocketAddress (java.net.InetSocketAddress)3 FileSystemMasterClient (alluxio.client.file.FileSystemMasterClient)2 UnavailableException (alluxio.exception.status.UnavailableException)2 MasterInquireClient (alluxio.master.MasterInquireClient)2 ExponentialBackoffRetry (alluxio.retry.ExponentialBackoffRetry)2 FileSystemContext (alluxio.client.file.FileSystemContext)1 BaseIntegrationTest (alluxio.testutils.BaseIntegrationTest)1 IOException (java.io.IOException)1 Test (org.junit.Test)1