use of alluxio.client.block.policy.options.GetWorkerOptions in project alluxio by Alluxio.
the class LocalFirstAvoidEvictionPolicyTest method chooseClosestTierAvoidEviction.
@Test
public void chooseClosestTierAvoidEviction() throws Exception {
List<BlockWorkerInfo> workers = new ArrayList<>();
workers.add(worker(Constants.GB, Constants.MB, "node2", "rack3"));
workers.add(worker(Constants.GB, 0, "node3", "rack2"));
workers.add(worker(Constants.GB, 0, "node4", "rack3"));
BlockLocationPolicy policy;
WorkerNetAddress chosen;
// local rack with enough availability
policy = new LocalFirstAvoidEvictionPolicy(mConf.getBytes(PropertyKey.USER_BLOCK_AVOID_EVICTION_POLICY_RESERVED_BYTES), TieredIdentityFactory.fromString("node=node2,rack=rack3", mConf), mConf);
GetWorkerOptions options = GetWorkerOptions.defaults().setBlockWorkerInfos(workers).setBlockInfo(new BlockInfo().setLength(Constants.GB));
chosen = policy.getWorker(options);
assertEquals("node4", chosen.getTieredIdentity().getTier(0).getValue());
}
use of alluxio.client.block.policy.options.GetWorkerOptions in project alluxio by Alluxio.
the class LocalFirstPolicyTest method tieredLocalityEnoughSpace.
@Test
public void tieredLocalityEnoughSpace() throws Exception {
List<BlockWorkerInfo> workers = new ArrayList<>();
// Local node doesn't have enough space
workers.add(worker(Constants.MB, "node2", "rack3"));
workers.add(worker(Constants.GB, "node3", "rack2"));
// Local rack has enough space
workers.add(worker(Constants.GB, "node4", "rack3"));
LocalFirstPolicy policy = new LocalFirstPolicy(TieredIdentityFactory.fromString("node=node2,rack=rack3", sConf), sConf);
GetWorkerOptions options = GetWorkerOptions.defaults().setBlockWorkerInfos(workers).setBlockInfo(new BlockInfo().setLength(Constants.GB));
WorkerNetAddress chosen = policy.getWorker(options);
assertEquals(workers.get(2).getNetAddress(), chosen);
}
use of alluxio.client.block.policy.options.GetWorkerOptions in project alluxio by Alluxio.
the class LocalFirstPolicyTest method chooseClosestTier.
@Test
public void chooseClosestTier() throws Exception {
List<BlockWorkerInfo> workers = new ArrayList<>();
workers.add(worker(Constants.GB, "node2", "rack3"));
workers.add(worker(Constants.GB, "node3", "rack2"));
workers.add(worker(Constants.GB, "node4", "rack3"));
LocalFirstPolicy policy;
WorkerNetAddress chosen;
// local rack
policy = new LocalFirstPolicy(TieredIdentityFactory.fromString("node=node1,rack=rack2", sConf), sConf);
GetWorkerOptions options = GetWorkerOptions.defaults().setBlockWorkerInfos(workers).setBlockInfo(new BlockInfo().setLength(Constants.GB));
chosen = policy.getWorker(options);
assertEquals("rack2", chosen.getTieredIdentity().getTier(1).getValue());
// local node
policy = new LocalFirstPolicy(TieredIdentityFactory.fromString("node=node4,rack=rack3", sConf), sConf);
chosen = policy.getWorker(options);
assertEquals("node4", chosen.getTieredIdentity().getTier(0).getValue());
}
use of alluxio.client.block.policy.options.GetWorkerOptions in project alluxio by Alluxio.
the class LocalFirstPolicyTest method getLocalFirst.
/**
* Tests that the local host is returned first.
*/
@Test
public void getLocalFirst() {
String localhostName = NetworkAddressUtils.getLocalHostName(sResolutionTimeout);
LocalFirstPolicy policy = new LocalFirstPolicy(sConf);
List<BlockWorkerInfo> workers = new ArrayList<>();
workers.add(worker(Constants.GB, "worker1", ""));
workers.add(worker(Constants.GB, localhostName, ""));
GetWorkerOptions options = GetWorkerOptions.defaults().setBlockWorkerInfos(workers).setBlockInfo(new BlockInfo().setLength(Constants.MB));
assertEquals(localhostName, policy.getWorker(options).getHost());
}
use of alluxio.client.block.policy.options.GetWorkerOptions 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(ConfigurationTestUtils.defaults());
GetWorkerOptions options = GetWorkerOptions.defaults().setBlockWorkerInfos(workerInfoList).setBlockInfo(new BlockInfo().setLength(2 * (long) Constants.GB));
assertNotEquals(policy.getWorker(options).getHost(), policy.getWorker(options.setBlockInfo(options.getBlockInfo().setBlockId(123))).getHost());
assertEquals(policy.getWorker(options.setBlockInfo(options.getBlockInfo().setBlockId(555))).getHost(), policy.getWorker(options.setBlockInfo(options.getBlockInfo().setBlockId(555))).getHost());
}
Aggregations