use of alluxio.wire.WorkerInfo in project alluxio by Alluxio.
the class AlluxioMasterRestApiTest method getWorkers.
@Test
public void getWorkers() throws Exception {
List<WorkerInfo> workerInfos = getInfo(NO_PARAMS).getWorkers();
Assert.assertEquals(1, workerInfos.size());
WorkerInfo workerInfo = workerInfos.get(0);
Assert.assertEquals(0, workerInfo.getUsedBytes());
long bytes = Configuration.getBytes(PropertyKey.WORKER_MEMORY_SIZE);
Assert.assertEquals(bytes, workerInfo.getCapacityBytes());
}
use of alluxio.wire.WorkerInfo in project alluxio by Alluxio.
the class FileSystemContext method getWorkerAddresses.
/**
* @return if there are any local workers, the returned list will ONLY contain the local workers,
* otherwise a list of all remote workers will be returned
* @throws IOException if an error occurs communicating with the master
*/
private List<WorkerNetAddress> getWorkerAddresses() throws IOException {
List<WorkerInfo> infos;
BlockMasterClient blockMasterClient = mBlockMasterClientPool.acquire();
try {
infos = blockMasterClient.getWorkerInfoList();
} catch (AlluxioException e) {
throw new IOException(e);
} finally {
mBlockMasterClientPool.release(blockMasterClient);
}
if (infos.isEmpty()) {
throw new IOException(ExceptionMessage.NO_WORKER_AVAILABLE.getMessage());
}
// Convert the worker infos into net addresses, if there are local addresses, only keep those
List<WorkerNetAddress> workerNetAddresses = new ArrayList<>();
List<WorkerNetAddress> localWorkerNetAddresses = new ArrayList<>();
String localHostname = NetworkAddressUtils.getClientHostName();
for (WorkerInfo info : infos) {
WorkerNetAddress netAddress = info.getAddress();
if (netAddress.getHost().equals(localHostname)) {
localWorkerNetAddresses.add(netAddress);
}
workerNetAddresses.add(netAddress);
}
return localWorkerNetAddresses.isEmpty() ? workerNetAddresses : localWorkerNetAddresses;
}
Aggregations