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());
}
}
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());
}
}
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--;
}
}
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");
}
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));
}
Aggregations