Search in sources :

Example 1 with MasterInfo

use of alluxio.grpc.MasterInfo in project alluxio by Alluxio.

the class MetaMasterIntegrationTest method getMasterInfoWebPort.

@Test
public void getMasterInfoWebPort() throws Exception {
    try (MetaMasterClient client = new RetryHandlingMetaMasterClient(MasterClientContext.newBuilder(ClientContext.create(ServerConfiguration.global())).build())) {
        MasterInfo info = client.getMasterInfo(new HashSet<>(Arrays.asList(MasterInfoField.WEB_PORT)));
        assertEquals(mWebPort, info.getWebPort());
    }
}
Also used : MasterInfo(alluxio.grpc.MasterInfo) Test(org.junit.Test) BaseIntegrationTest(alluxio.testutils.BaseIntegrationTest)

Example 2 with MasterInfo

use of alluxio.grpc.MasterInfo in project alluxio by Alluxio.

the class MetaMasterIntegrationTest method getInfoAllFields.

@Test
public void getInfoAllFields() throws Exception {
    try (MetaMasterClient client = new RetryHandlingMetaMasterClient(MasterClientContext.newBuilder(ClientContext.create(ServerConfiguration.global())).build())) {
        MasterInfo info = client.getMasterInfo(Collections.emptySet());
        assertEquals(mWebPort, info.getWebPort());
    }
}
Also used : MasterInfo(alluxio.grpc.MasterInfo) Test(org.junit.Test) BaseIntegrationTest(alluxio.testutils.BaseIntegrationTest)

Example 3 with MasterInfo

use of alluxio.grpc.MasterInfo in project alluxio by Alluxio.

the class SummaryCommand method printMetaMasterInfo.

/**
 * Prints Alluxio meta master information.
 */
private void printMetaMasterInfo() throws IOException {
    mIndentationLevel++;
    Set<MasterInfoField> masterInfoFilter = new HashSet<>(Arrays.asList(MasterInfoField.LEADER_MASTER_ADDRESS, MasterInfoField.WEB_PORT, MasterInfoField.RPC_PORT, MasterInfoField.START_TIME_MS, MasterInfoField.UP_TIME_MS, MasterInfoField.VERSION, MasterInfoField.SAFE_MODE, MasterInfoField.ZOOKEEPER_ADDRESSES));
    MasterInfo masterInfo = mMetaMasterClient.getMasterInfo(masterInfoFilter);
    print("Master Address: " + masterInfo.getLeaderMasterAddress());
    print("Web Port: " + masterInfo.getWebPort());
    print("Rpc Port: " + masterInfo.getRpcPort());
    print("Started: " + CommonUtils.convertMsToDate(masterInfo.getStartTimeMs(), mDateFormatPattern));
    print("Uptime: " + CommonUtils.convertMsToClockTime(masterInfo.getUpTimeMs()));
    print("Version: " + masterInfo.getVersion());
    print("Safe Mode: " + masterInfo.getSafeMode());
    List<String> zookeeperAddresses = masterInfo.getZookeeperAddressesList();
    if (zookeeperAddresses == null || zookeeperAddresses.isEmpty()) {
        print("Zookeeper Enabled: false");
    } else {
        print("Zookeeper Enabled: true");
        print("Zookeeper Addresses: ");
        mIndentationLevel++;
        for (String zkAddress : zookeeperAddresses) {
            print(zkAddress);
        }
        mIndentationLevel--;
    }
}
Also used : BlockMasterInfo(alluxio.wire.BlockMasterInfo) MasterInfo(alluxio.grpc.MasterInfo) BlockMasterInfoField(alluxio.wire.BlockMasterInfo.BlockMasterInfoField) MasterInfoField(alluxio.grpc.MasterInfoField) HashSet(java.util.HashSet)

Example 4 with MasterInfo

use of alluxio.grpc.MasterInfo in project alluxio by Alluxio.

the class SummaryCommandTest method prepareDependencies.

@Before
public void prepareDependencies() throws IOException {
    // Generate random values for MasterInfo and BlockMasterInfo
    // Prepare mock meta master client
    mMetaMasterClient = mock(MetaMasterClient.class);
    MasterInfo masterInfo = MasterInfo.newBuilder().setLeaderMasterAddress("testAddress").setWebPort(1231).setRpcPort(8462).setStartTimeMs(1131242343122L).setUpTimeMs(12412412312L).setVersion("testVersion").setSafeMode(false).addAllZookeeperAddresses(Arrays.asList("[zookeeper_hostname1]:2181", "[zookeeper_hostname2]:2181", "[zookeeper_hostname3]:2181")).build();
    when(mMetaMasterClient.getMasterInfo(any())).thenReturn(masterInfo);
    // Prepare mock block master client
    mBlockMasterClient = mock(BlockMasterClient.class);
    Map<String, Long> capacityBytesOnTiers = new HashMap<>();
    Map<String, Long> usedBytesOnTiers = new HashMap<>();
    capacityBytesOnTiers.put(Constants.MEDIUM_MEM, 1341353L);
    capacityBytesOnTiers.put("RAM", 23112L);
    capacityBytesOnTiers.put("DOM", 236501L);
    usedBytesOnTiers.put(Constants.MEDIUM_MEM, 62434L);
    usedBytesOnTiers.put("RAM", 6243L);
    usedBytesOnTiers.put("DOM", 74235L);
    BlockMasterInfo blockMasterInfo = new BlockMasterInfo().setLiveWorkerNum(12).setLostWorkerNum(4).setCapacityBytes(1341353L).setCapacityBytesOnTiers(capacityBytesOnTiers).setUsedBytes(62434L).setUsedBytesOnTiers(usedBytesOnTiers).setFreeBytes(1278919L);
    when(mBlockMasterClient.getBlockMasterInfo(any())).thenReturn(blockMasterInfo);
    // Prepare print stream
    mOutputStream = new ByteArrayOutputStream();
    mPrintStream = new PrintStream(mOutputStream, true, "utf-8");
}
Also used : BlockMasterInfo(alluxio.wire.BlockMasterInfo) BlockMasterInfo(alluxio.wire.BlockMasterInfo) MasterInfo(alluxio.grpc.MasterInfo) PrintStream(java.io.PrintStream) MetaMasterClient(alluxio.client.meta.MetaMasterClient) HashMap(java.util.HashMap) BlockMasterClient(alluxio.client.block.BlockMasterClient) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Before(org.junit.Before)

Example 5 with MasterInfo

use of alluxio.grpc.MasterInfo in project alluxio by Alluxio.

the class MultiProcessCluster method waitForAllNodesRegistered.

/**
 * Waits for all nodes to be registered.
 *
 * @param timeoutMs maximum amount of time to wait, in milliseconds
 */
public synchronized void waitForAllNodesRegistered(int timeoutMs) throws TimeoutException, InterruptedException {
    MetaMasterClient metaMasterClient = getMetaMasterClient();
    int nodeCount = mNumMasters + mNumWorkers;
    CommonUtils.waitFor("all nodes registered", () -> {
        try {
            MasterInfo masterInfo = metaMasterClient.getMasterInfo(Collections.emptySet());
            int liveNodeNum = masterInfo.getMasterAddressesList().size() + masterInfo.getWorkerAddressesList().size();
            if (liveNodeNum == nodeCount) {
                return true;
            } else {
                LOG.info("Master addresses: {}. Worker addresses: {}", masterInfo.getMasterAddressesList(), masterInfo.getWorkerAddressesList());
                return false;
            }
        } catch (UnavailableException e) {
            return false;
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }, WaitForOptions.defaults().setInterval(200).setTimeoutMs(timeoutMs));
}
Also used : MasterInfo(alluxio.grpc.MasterInfo) RetryHandlingMetaMasterClient(alluxio.client.meta.RetryHandlingMetaMasterClient) MetaMasterClient(alluxio.client.meta.MetaMasterClient) UnavailableException(alluxio.exception.status.UnavailableException) TimeoutException(java.util.concurrent.TimeoutException) UnavailableException(alluxio.exception.status.UnavailableException) IOException(java.io.IOException)

Aggregations

MasterInfo (alluxio.grpc.MasterInfo)5 MetaMasterClient (alluxio.client.meta.MetaMasterClient)2 BaseIntegrationTest (alluxio.testutils.BaseIntegrationTest)2 BlockMasterInfo (alluxio.wire.BlockMasterInfo)2 Test (org.junit.Test)2 BlockMasterClient (alluxio.client.block.BlockMasterClient)1 RetryHandlingMetaMasterClient (alluxio.client.meta.RetryHandlingMetaMasterClient)1 UnavailableException (alluxio.exception.status.UnavailableException)1 MasterInfoField (alluxio.grpc.MasterInfoField)1 BlockMasterInfoField (alluxio.wire.BlockMasterInfo.BlockMasterInfoField)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 IOException (java.io.IOException)1 PrintStream (java.io.PrintStream)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 TimeoutException (java.util.concurrent.TimeoutException)1 Before (org.junit.Before)1