use of alluxio.grpc.WorkerLostStorageInfo in project alluxio by Alluxio.
the class DefaultBlockMaster method getWorkerLostStorage.
@Override
public List<WorkerLostStorageInfo> getWorkerLostStorage() {
List<WorkerLostStorageInfo> workerLostStorageList = new ArrayList<>();
for (MasterWorkerInfo worker : mWorkers) {
try (LockResource r = worker.lockWorkerMeta(EnumSet.of(WorkerMetaLockSection.USAGE), true)) {
if (worker.hasLostStorage()) {
Map<String, StorageList> lostStorage = worker.getLostStorage().entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, e -> StorageList.newBuilder().addAllStorage(e.getValue()).build()));
workerLostStorageList.add(WorkerLostStorageInfo.newBuilder().setAddress(GrpcUtils.toProto(worker.getWorkerAddress())).putAllLostStorage(lostStorage).build());
}
}
}
return workerLostStorageList;
}
use of alluxio.grpc.WorkerLostStorageInfo in project alluxio by Alluxio.
the class BlockMasterTest method workerHeartbeatUpdatesLostStorage.
@Test
public void workerHeartbeatUpdatesLostStorage() throws Exception {
// Create two workers.
long worker1 = mBlockMaster.getWorkerId(NET_ADDRESS_1);
mBlockMaster.workerRegister(worker1, Arrays.asList(Constants.MEDIUM_MEM, Constants.MEDIUM_SSD), ImmutableMap.of(Constants.MEDIUM_MEM, 100L, Constants.MEDIUM_SSD, 200L), ImmutableMap.of(Constants.MEDIUM_MEM, 0L, Constants.MEDIUM_SSD, 0L), NO_BLOCKS_ON_LOCATION, NO_LOST_STORAGE, RegisterWorkerPOptions.getDefaultInstance());
long worker2 = mBlockMaster.getWorkerId(NET_ADDRESS_2);
mBlockMaster.workerRegister(worker2, Arrays.asList(Constants.MEDIUM_MEM, Constants.MEDIUM_HDD), ImmutableMap.of(Constants.MEDIUM_MEM, 100L, Constants.MEDIUM_HDD, 300L), ImmutableMap.of(Constants.MEDIUM_MEM, 0L, Constants.MEDIUM_HDD, 0L), NO_BLOCKS_ON_LOCATION, NO_LOST_STORAGE, RegisterWorkerPOptions.getDefaultInstance());
Map<String, StorageList> lostStorageOnWorker1 = new HashMap<>();
lostStorageOnWorker1.put(Constants.MEDIUM_SSD, StorageList.newBuilder().addAllStorage(Arrays.asList("/ssd/one", "/ssd/two")).build());
Map<String, StorageList> lostStorageOnWorker2 = new HashMap<>();
lostStorageOnWorker2.put(Constants.MEDIUM_HDD, StorageList.newBuilder().addStorage("/hdd/one").build());
mBlockMaster.workerHeartbeat(worker1, ImmutableMap.of(Constants.MEDIUM_MEM, 100L, Constants.MEDIUM_SSD, 0L), ImmutableMap.of(Constants.MEDIUM_MEM, 0L, Constants.MEDIUM_SSD, 0L), NO_BLOCKS, NO_BLOCKS_ON_LOCATION, lostStorageOnWorker1, mMetrics);
mBlockMaster.workerHeartbeat(worker2, ImmutableMap.of(Constants.MEDIUM_MEM, 100L, Constants.MEDIUM_HDD, 200L), ImmutableMap.of(Constants.MEDIUM_MEM, 0L, Constants.MEDIUM_HDD, 0L), NO_BLOCKS, NO_BLOCKS_ON_LOCATION, lostStorageOnWorker2, mMetrics);
// Two workers have lost storage paths
assertEquals(2, mBlockMaster.getWorkerLostStorage().size());
int lostStorageNum = 0;
for (WorkerLostStorageInfo info : mBlockMaster.getWorkerLostStorage()) {
for (StorageList list : info.getLostStorageMap().values()) {
lostStorageNum += list.getStorageList().size();
}
}
assertEquals(3, lostStorageNum);
}
Aggregations