Search in sources :

Example 6 with WorkerInfo

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());
}
Also used : WorkerInfo(alluxio.wire.WorkerInfo) Test(org.junit.Test) RestApiTest(alluxio.rest.RestApiTest)

Example 7 with WorkerInfo

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;
}
Also used : BlockMasterClient(alluxio.client.block.BlockMasterClient) WorkerNetAddress(alluxio.wire.WorkerNetAddress) ArrayList(java.util.ArrayList) WorkerInfo(alluxio.wire.WorkerInfo) IOException(java.io.IOException) AlluxioException(alluxio.exception.AlluxioException)

Aggregations

WorkerInfo (alluxio.wire.WorkerInfo)7 Test (org.junit.Test)4 BlockMasterClient (alluxio.client.block.BlockMasterClient)1 AlluxioException (alluxio.exception.AlluxioException)1 FileDoesNotExistException (alluxio.exception.FileDoesNotExistException)1 InvalidPathException (alluxio.exception.InvalidPathException)1 RestApiTest (alluxio.rest.RestApiTest)1 BlockLocation (alluxio.wire.BlockLocation)1 FileBlockInfo (alluxio.wire.FileBlockInfo)1 WorkerNetAddress (alluxio.wire.WorkerNetAddress)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Random (java.util.Random)1 Response (javax.ws.rs.core.Response)1