use of alluxio.wire.WorkerNetAddress 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.wire.WorkerNetAddress 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());
}
use of alluxio.wire.WorkerNetAddress in project alluxio by Alluxio.
the class LocalFirstAvoidEvictionPolicyTest method getLocalWhenNoneHasSpace.
/**
* Tests that local host is picked if none of the workers has enough availability.
*/
@Test
public void getLocalWhenNoneHasSpace() {
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, Constants.MB));
workerInfoList.add(new BlockWorkerInfo(new WorkerNetAddress().setHost(localhostName).setRpcPort(PORT).setDataPort(PORT).setWebPort(PORT), Constants.GB, Constants.MB));
Assert.assertEquals(localhostName, policy.getWorkerForNextBlock(workerInfoList, Constants.GB).getHost());
}
use of alluxio.wire.WorkerNetAddress in project alluxio by Alluxio.
the class LocalFirstPolicyTest 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();
LocalFirstPolicy policy = new LocalFirstPolicy();
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.GB).getHost());
}
use of alluxio.wire.WorkerNetAddress in project alluxio by Alluxio.
the class MostAvailableFirstPolicyTest method getMostAvailableWorker.
/**
* Tests that the worker with the most available space is chosen.
*/
@Test
public void getMostAvailableWorker() {
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));
MostAvailableFirstPolicy policy = new MostAvailableFirstPolicy();
Assert.assertEquals("worker3", policy.getWorkerForNextBlock(workerInfoList, Constants.MB).getHost());
}
Aggregations