Search in sources :

Example 11 with GetWorkerOptions

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));
}
Also used : WorkerNetAddress(alluxio.wire.WorkerNetAddress) BlockInfo(alluxio.wire.BlockInfo) BlockWorkerInfo(alluxio.client.block.BlockWorkerInfo) ArrayList(java.util.ArrayList) GetWorkerOptions(alluxio.client.block.policy.options.GetWorkerOptions) Test(org.junit.Test)

Example 12 with GetWorkerOptions

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));
}
Also used : BlockInfo(alluxio.wire.BlockInfo) ArrayList(java.util.ArrayList) GetWorkerOptions(alluxio.client.block.policy.options.GetWorkerOptions) Test(org.junit.Test)

Example 13 with GetWorkerOptions

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());
}
Also used : BlockInfo(alluxio.wire.BlockInfo) BlockWorkerInfo(alluxio.client.block.BlockWorkerInfo) ArrayList(java.util.ArrayList) GetWorkerOptions(alluxio.client.block.policy.options.GetWorkerOptions) Test(org.junit.Test)

Example 14 with GetWorkerOptions

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());
}
Also used : WorkerNetAddress(alluxio.wire.WorkerNetAddress) BlockInfo(alluxio.wire.BlockInfo) BlockWorkerInfo(alluxio.client.block.BlockWorkerInfo) ArrayList(java.util.ArrayList) GetWorkerOptions(alluxio.client.block.policy.options.GetWorkerOptions) Test(org.junit.Test)

Example 15 with GetWorkerOptions

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());
}
Also used : WorkerNetAddress(alluxio.wire.WorkerNetAddress) BlockInfo(alluxio.wire.BlockInfo) BlockWorkerInfo(alluxio.client.block.BlockWorkerInfo) ArrayList(java.util.ArrayList) GetWorkerOptions(alluxio.client.block.policy.options.GetWorkerOptions) Test(org.junit.Test)

Aggregations

GetWorkerOptions (alluxio.client.block.policy.options.GetWorkerOptions)18 BlockInfo (alluxio.wire.BlockInfo)16 ArrayList (java.util.ArrayList)16 BlockWorkerInfo (alluxio.client.block.BlockWorkerInfo)15 Test (org.junit.Test)14 WorkerNetAddress (alluxio.wire.WorkerNetAddress)12 BlockLocationPolicy (alluxio.client.block.policy.BlockLocationPolicy)3 Lists (com.google.common.collect.Lists)3 HashMap (java.util.HashMap)3 List (java.util.List)3 AlluxioConfiguration (alluxio.conf.AlluxioConfiguration)2 UnavailableException (alluxio.exception.status.UnavailableException)2 TieredIdentity (alluxio.wire.TieredIdentity)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)2 MoreObjects (com.google.common.base.MoreObjects)2 Objects (com.google.common.base.Objects)2 Map (java.util.Map)2 Set (java.util.Set)2 WriteType (alluxio.client.WriteType)1 BlockInStream (alluxio.client.block.stream.BlockInStream)1