use of alluxio.wire.WorkerInfo in project alluxio by Alluxio.
the class CapacityCommand method printShortWorkerInfo.
/**
* Prints worker information when only one tier exists.
*
* @param workerInfoList the worker info list to get info from
*/
private void printShortWorkerInfo(List<WorkerInfo> workerInfoList) {
String tier = mCapacityTierInfoMap.firstKey();
String shortInfoFormat = getInfoFormat(workerInfoList, true);
print(String.format("%n" + shortInfoFormat, "Worker Name", "Last Heartbeat", "Storage", tier));
for (WorkerInfo info : workerInfoList) {
long capacityBytes = info.getCapacityBytes();
long usedBytes = info.getUsedBytes();
String usedPercentageInfo = "";
if (capacityBytes != 0) {
int usedPercentage = (int) (100L * usedBytes / capacityBytes);
usedPercentageInfo = String.format(" (%s%%)", usedPercentage);
}
print(String.format(shortInfoFormat, info.getAddress().getHost(), info.getLastContactSec(), "capacity", FormatUtils.getSizeFromBytes(capacityBytes)));
print(String.format(shortInfoFormat, "", "", "used", FormatUtils.getSizeFromBytes(usedBytes) + usedPercentageInfo));
}
}
use of alluxio.wire.WorkerInfo in project alluxio by Alluxio.
the class CapacityCommandTest method prepareLongWorkerNameInfoList.
/**
* @return long worker name info list to test
*/
private List<WorkerInfo> prepareLongWorkerNameInfoList() {
List<WorkerInfo> infoList = new ArrayList<>();
Map<String, Long> capacityBytesOnTiersOne = new HashMap<>();
capacityBytesOnTiersOne.put(Constants.MEDIUM_MEM, 600000000L);
capacityBytesOnTiersOne.put(Constants.MEDIUM_HDD, 200000000L);
Map<String, Long> usedBytesOnTiersOne = new HashMap<>();
usedBytesOnTiersOne.put(Constants.MEDIUM_MEM, 300000000L);
usedBytesOnTiersOne.put(Constants.MEDIUM_HDD, 200000000L);
WorkerInfo firstInfo = new WorkerInfo().setAddress(new WorkerNetAddress().setHost("org.alluxio.long.host1")).setCapacityBytes(1200000000L).setCapacityBytesOnTiers(capacityBytesOnTiersOne).setId(1).setLastContactSec(6211).setStartTimeMs(1529222699127L).setState("In Service").setUsedBytes(1000000000L).setUsedBytesOnTiers(usedBytesOnTiersOne);
Map<String, Long> capacityBytesOnTiersSec = new HashMap<>();
capacityBytesOnTiersSec.put(Constants.MEDIUM_MEM, 600000000L);
capacityBytesOnTiersSec.put(Constants.MEDIUM_SSD, 600000000L);
Map<String, Long> usedBytesOnTiersSec = new HashMap<>();
usedBytesOnTiersSec.put(Constants.MEDIUM_MEM, 20000000L);
usedBytesOnTiersSec.put(Constants.MEDIUM_SSD, 30000000L);
WorkerInfo secondInfo = new WorkerInfo().setAddress(new WorkerNetAddress().setHost("org.apache.hdp1")).setCapacityBytes(2000000000L).setCapacityBytesOnTiers(capacityBytesOnTiersSec).setId(2).setLastContactSec(681).setStartTimeMs(1529222699127L).setState("In Service").setUsedBytes(100000000L).setUsedBytesOnTiers(usedBytesOnTiersSec);
infoList.add(firstInfo);
infoList.add(secondInfo);
return infoList;
}
use of alluxio.wire.WorkerInfo in project alluxio by Alluxio.
the class CapacityCommandTest method longCapacity.
@Test
public void longCapacity() throws IOException {
List<WorkerInfo> longInfoList = prepareLongInfoList();
Mockito.when(mBlockMasterClient.getWorkerReport(Mockito.any())).thenReturn(longInfoList);
try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
PrintStream printStream = new PrintStream(outputStream, true, "utf-8")) {
CapacityCommand capacityCommand = new CapacityCommand(mBlockMasterClient, printStream);
capacityCommand.generateCapacityReport(GetWorkerReportOptions.defaults());
String output = new String(outputStream.toByteArray(), StandardCharsets.UTF_8);
// CHECKSTYLE.OFF: LineLengthExceed - Much more readable
List<String> expectedOutput = Arrays.asList("Capacity information for all workers: ", " Total Capacity: 29.80GB", " Tier: MEM Size: 8.38GB", " Tier: SSD Size: 4768.37MB", " Tier: HDD Size: 1907.35MB", " Tier: DOM Size: 9.31GB", " Tier: RAM Size: 5.59GB", " Used Capacity: 10.24GB", " Tier: MEM Size: 3051.76MB", " Tier: SSD Size: 286.10MB", " Tier: HDD Size: 1907.35MB", " Tier: DOM Size: 476.84MB", " Tier: RAM Size: 4768.37MB", " Used Percentage: 34%", " Free Percentage: 66%", "", "Worker Name Last Heartbeat Storage Total MEM SSD HDD DOM RAM ", "216.239.33.96 542 capacity 18.63GB 4768.37MB 4768.37MB - 9.31GB - ", " used 953.67MB (5%) 190.73MB 286.10MB - 476.84MB - ", "64.68.90.1 3123 capacity 11.18GB 3814.70MB - 1907.35MB - 5.59GB ", " used 9.31GB (83%) 2861.02MB - 1907.35MB - 4768.37MB ");
// CHECKSTYLE.ON: LineLengthExceed
List<String> testOutput = Arrays.asList(output.split("\n"));
Assert.assertThat(testOutput, IsIterableContainingInOrder.contains(expectedOutput.toArray()));
}
}
use of alluxio.wire.WorkerInfo in project alluxio by Alluxio.
the class CapacityCommandTest method longWorkerNameCapacity.
@Test
public void longWorkerNameCapacity() throws IOException {
List<WorkerInfo> longWorkerNameInfoList = prepareLongWorkerNameInfoList();
Mockito.when(mBlockMasterClient.getWorkerReport(Mockito.any())).thenReturn(longWorkerNameInfoList);
try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
PrintStream printStream = new PrintStream(outputStream, true, "utf-8")) {
CapacityCommand capacityCommand = new CapacityCommand(mBlockMasterClient, printStream);
capacityCommand.generateCapacityReport(GetWorkerReportOptions.defaults());
String output = new String(outputStream.toByteArray(), StandardCharsets.UTF_8);
List<String> testRst = Arrays.asList(output.split("\n"));
// CHECKSTYLE.OFF: LineLengthExceed - Much more readable
List<String> expectedOutput = Arrays.asList("Capacity information for all workers: ", " Total Capacity: 3051.76MB", " Tier: MEM Size: 1144.41MB", " Tier: SSD Size: 572.20MB", " Tier: HDD Size: 190.73MB", " Used Capacity: 1049.04MB", " Tier: MEM Size: 305.18MB", " Tier: SSD Size: 28.61MB", " Tier: HDD Size: 190.73MB", " Used Percentage: 34%", " Free Percentage: 66%", "", "Worker Name Last Heartbeat Storage Total MEM SSD HDD ", "org.apache.hdp1 681 capacity 1907.35MB 572.20MB 572.20MB - ", " used 95.37MB (5%) 19.07MB 28.61MB - ", "org.alluxio.long.host1 6211 capacity 1144.41MB 572.20MB - 190.73MB ", " used 953.67MB (83%) 286.10MB - 190.73MB ");
// CHECKSTYLE.ON: LineLengthExceed
List<String> testOutput = Arrays.asList(output.split("\n"));
Assert.assertThat(testOutput, IsIterableContainingInOrder.contains(expectedOutput.toArray()));
}
}
use of alluxio.wire.WorkerInfo in project alluxio by Alluxio.
the class JobMasterIntegrationTest method restartMasterAndReregisterWorker.
@Test
@LocalAlluxioClusterResource.Config(confParams = { PropertyKey.Name.JOB_MASTER_LOST_WORKER_INTERVAL, "10000000" })
public void restartMasterAndReregisterWorker() throws Exception {
long jobId = mJobMaster.run(new SleepJobConfig(1));
JobTestUtils.waitForJobStatus(mJobMaster, jobId, Status.COMPLETED);
mJobMaster.stop();
mJobMaster.start(true);
CommonUtils.waitFor("Worker to register with restarted job master", () -> !mJobMaster.getWorkerInfoList().isEmpty(), WaitForOptions.defaults().setTimeoutMs(10 * Constants.SECOND_MS));
final long firstWorkerId = mJobMaster.getWorkerInfoList().get(0).getId();
mLocalAlluxioJobCluster.restartWorker();
CommonUtils.waitFor("Restarted worker to register with job master", () -> {
List<WorkerInfo> workerInfo = mJobMaster.getWorkerInfoList();
return !workerInfo.isEmpty() && workerInfo.get(0).getId() != firstWorkerId;
}, WaitForOptions.defaults().setTimeoutMs(10 * Constants.SECOND_MS));
// The restarted worker should replace the original worker since they have the same address.
assertEquals(1, mJobMaster.getWorkerInfoList().size());
}
Aggregations