Search in sources :

Example 26 with WorkerNetAddress

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

Example 27 with WorkerNetAddress

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

Example 28 with WorkerNetAddress

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

Example 29 with WorkerNetAddress

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

Example 30 with WorkerNetAddress

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

Aggregations

WorkerNetAddress (alluxio.wire.WorkerNetAddress)30 BlockWorkerInfo (alluxio.client.block.BlockWorkerInfo)15 Test (org.junit.Test)15 ArrayList (java.util.ArrayList)13 IOException (java.io.IOException)7 AlluxioURI (alluxio.AlluxioURI)6 AlluxioException (alluxio.exception.AlluxioException)5 BlockInfo (alluxio.wire.BlockInfo)5 RemoteBlockInStream (alluxio.client.block.RemoteBlockInStream)4 InetSocketAddress (java.net.InetSocketAddress)4 AlluxioBlockStore (alluxio.client.block.AlluxioBlockStore)2 OutStreamOptions (alluxio.client.file.options.OutStreamOptions)2 FileWriteLocationPolicy (alluxio.client.file.policy.FileWriteLocationPolicy)2 BlockLocation (alluxio.wire.BlockLocation)2 FileInfo (alluxio.wire.FileInfo)2 HashMap (java.util.HashMap)2 Before (org.junit.Before)2 BlockMasterClient (alluxio.client.block.BlockMasterClient)1 BufferedBlockOutStream (alluxio.client.block.BufferedBlockOutStream)1 TestBufferedBlockOutStream (alluxio.client.block.TestBufferedBlockOutStream)1