use of alluxio.client.block.policy.options.GetWorkerOptions in project alluxio by Alluxio.
the class RoundRobinPolicyTest method getWorkerNoneEligibleAfterCache.
/**
* Tests that no workers are returned when subsequent calls to the policy have no eligible
* workers.
*/
@Test
public void getWorkerNoneEligibleAfterCache() {
List<BlockWorkerInfo> workerInfoList = new ArrayList<>();
workerInfoList.add(new BlockWorkerInfo(new WorkerNetAddress().setHost("worker1").setRpcPort(PORT).setDataPort(PORT).setWebPort(PORT), Constants.GB, 0));
RoundRobinPolicy policy = new RoundRobinPolicy(ConfigurationTestUtils.defaults());
GetWorkerOptions options = GetWorkerOptions.defaults().setBlockWorkerInfos(workerInfoList).setBlockInfo(new BlockInfo().setLength((long) Constants.MB));
assertNotNull(policy.getWorker(options));
options.setBlockWorkerInfos(new ArrayList<>());
assertNull(policy.getWorker(options));
}
use of alluxio.client.block.policy.options.GetWorkerOptions in project alluxio by Alluxio.
the class RoundRobinPolicyTest method getWorkerNoneEligible.
/**
* Tests that no workers are returned when there are no eligible workers.
*/
@Test
public void getWorkerNoneEligible() {
RoundRobinPolicy policy = new RoundRobinPolicy(ConfigurationTestUtils.defaults());
GetWorkerOptions options = GetWorkerOptions.defaults().setBlockWorkerInfos(new ArrayList<>()).setBlockInfo(new BlockInfo().setLength(2 * (long) Constants.GB));
assertNull(policy.getWorker(options));
}
use of alluxio.client.block.policy.options.GetWorkerOptions in project alluxio by Alluxio.
the class LocalFirstAvoidEvictionPolicyTest method getOthersWhenNotEnoughAvailabilityOnLocal.
/**
* Tests that another worker is picked in case the local host does not have enough availability.
*/
@Test
public void getOthersWhenNotEnoughAvailabilityOnLocal() {
String localhostName = NetworkAddressUtils.getLocalHostName(1000);
BlockLocationPolicy policy = new LocalFirstAvoidEvictionPolicy(mConf);
List<BlockWorkerInfo> workers = new ArrayList<>();
workers.add(worker(Constants.GB, 0, "worker1", ""));
workers.add(worker(Constants.MB, Constants.MB, localhostName, ""));
GetWorkerOptions options = GetWorkerOptions.defaults().setBlockWorkerInfos(workers).setBlockInfo(new BlockInfo().setLength(Constants.MB));
assertEquals("worker1", policy.getWorker(options).getHost());
}
use of alluxio.client.block.policy.options.GetWorkerOptions 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(null);
GetWorkerOptions options = GetWorkerOptions.defaults().setBlockWorkerInfos(workerInfoList).setBlockInfo(new BlockInfo().setLength(Constants.MB));
Assert.assertEquals("worker3", policy.getWorker(options).getHost());
}
use of alluxio.client.block.policy.options.GetWorkerOptions 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));
GetWorkerOptions options = GetWorkerOptions.defaults().setBlockWorkerInfos(workerInfoList).setBlockInfo(new BlockInfo().setLength(Constants.MB));
Assert.assertEquals("worker2", policy.getWorker(options).getHost());
}
Aggregations