use of alluxio.client.block.BlockWorkerInfo in project alluxio by Alluxio.
the class KeyValueInputSplit method getLocations.
@Override
public String[] getLocations() throws IOException {
try {
List<BlockWorkerInfo> workersInfo = mBlockStore.getWorkerInfoList();
int workersInfoSize = workersInfo.size();
String[] locations = new String[workersInfoSize];
for (int i = 0; i < workersInfoSize; i++) {
locations[i] = workersInfo.get(i).getNetAddress().getHost();
}
return locations;
} catch (AlluxioException e) {
throw new IOException(e);
}
}
use of alluxio.client.block.BlockWorkerInfo in project alluxio by Alluxio.
the class RoundRobinPolicyTest method getWorker.
/**
* Tests that the correct workers are chosen when round robin is used.
*/
@Test
public void getWorker() {
List<BlockWorkerInfo> workerInfoList = new ArrayList<>();
workerInfoList.add(new BlockWorkerInfo(new WorkerNetAddress().setHost("worker1").setRpcPort(PORT).setDataPort(PORT).setWebPort(PORT), Constants.GB, 0));
workerInfoList.add(new BlockWorkerInfo(new WorkerNetAddress().setHost("worker2").setRpcPort(PORT).setDataPort(PORT).setWebPort(PORT), 2 * (long) Constants.GB, 0));
workerInfoList.add(new BlockWorkerInfo(new WorkerNetAddress().setHost("worker3").setRpcPort(PORT).setDataPort(PORT).setWebPort(PORT), 3 * (long) Constants.GB, 0));
RoundRobinPolicy policy = new RoundRobinPolicy();
Assert.assertNotEquals(policy.getWorkerForNextBlock(workerInfoList, 2 * (long) Constants.GB).getHost(), policy.getWorkerForNextBlock(workerInfoList, 2 * (long) Constants.GB).getHost());
}
use of alluxio.client.block.BlockWorkerInfo in project alluxio by Alluxio.
the class SpecificHostPolicyTest method noMatchingHost.
/**
* Tests that no worker is chosen when the worker specified in the policy is not part of the
* worker list.
*/
@Test
public void noMatchingHost() {
SpecificHostPolicy policy = new SpecificHostPolicy("worker3");
List<BlockWorkerInfo> workerInfoList = new ArrayList<>();
workerInfoList.add(new BlockWorkerInfo(new WorkerNetAddress().setHost("worker1").setRpcPort(PORT).setDataPort(PORT).setWebPort(PORT), Constants.GB, 0));
workerInfoList.add(new BlockWorkerInfo(new WorkerNetAddress().setHost("worker2").setRpcPort(PORT).setDataPort(PORT).setWebPort(PORT), Constants.GB, 0));
Assert.assertNull(policy.getWorkerForNextBlock(workerInfoList, Constants.MB));
}
use of alluxio.client.block.BlockWorkerInfo in project alluxio by Alluxio.
the class SpecificHostPolicyTest method policy.
/**
* Tests that the correct worker is returned when using the policy.
*/
@Test
public void policy() {
SpecificHostPolicy policy = new SpecificHostPolicy("worker2");
List<BlockWorkerInfo> workerInfoList = new ArrayList<>();
workerInfoList.add(new BlockWorkerInfo(new WorkerNetAddress().setHost("worker1").setRpcPort(PORT).setDataPort(PORT).setWebPort(PORT), Constants.GB, 0));
workerInfoList.add(new BlockWorkerInfo(new WorkerNetAddress().setHost("worker2").setRpcPort(PORT).setDataPort(PORT).setWebPort(PORT), Constants.GB, 0));
Assert.assertEquals("worker2", policy.getWorkerForNextBlock(workerInfoList, Constants.MB).getHost());
}
use of alluxio.client.block.BlockWorkerInfo in project alluxio by Alluxio.
the class LocalFirstAvoidEvictionPolicyTest method getOthersWhenNotEnoughSpaceOnLocal.
/**
* Tests that another worker is picked in case the local host does not have enough space.
*/
@Test
public void getOthersWhenNotEnoughSpaceOnLocal() {
String localhostName = NetworkAddressUtils.getLocalHostName();
LocalFirstAvoidEvictionPolicy policy = new LocalFirstAvoidEvictionPolicy();
List<BlockWorkerInfo> workerInfoList = new ArrayList<>();
workerInfoList.add(new BlockWorkerInfo(new WorkerNetAddress().setHost("worker1").setRpcPort(PORT).setDataPort(PORT).setWebPort(PORT), Constants.GB, 0));
workerInfoList.add(new BlockWorkerInfo(new WorkerNetAddress().setHost(localhostName).setRpcPort(PORT).setDataPort(PORT).setWebPort(PORT), Constants.MB, Constants.MB));
Assert.assertEquals("worker1", policy.getWorkerForNextBlock(workerInfoList, Constants.MB).getHost());
}
Aggregations