Search in sources :

Example 16 with BlockWorkerInfo

use of alluxio.client.block.BlockWorkerInfo 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 17 with BlockWorkerInfo

use of alluxio.client.block.BlockWorkerInfo 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 18 with BlockWorkerInfo

use of alluxio.client.block.BlockWorkerInfo 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

BlockWorkerInfo (alluxio.client.block.BlockWorkerInfo)18 WorkerNetAddress (alluxio.wire.WorkerNetAddress)16 ArrayList (java.util.ArrayList)11 Test (org.junit.Test)9 Before (org.junit.Before)3 AlluxioBlockStore (alluxio.client.block.AlluxioBlockStore)2 BufferedBlockOutStream (alluxio.client.block.BufferedBlockOutStream)2 TestBufferedBlockOutStream (alluxio.client.block.TestBufferedBlockOutStream)2 OutStreamOptions (alluxio.client.file.options.OutStreamOptions)2 FileInfo (alluxio.wire.FileInfo)2 HashMap (java.util.HashMap)2 InvocationOnMock (org.mockito.invocation.InvocationOnMock)2 AlluxioURI (alluxio.AlluxioURI)1 BufferedBlockInStream (alluxio.client.block.BufferedBlockInStream)1 TestBufferedBlockInStream (alluxio.client.block.TestBufferedBlockInStream)1 CreateUfsFileOptions (alluxio.client.file.options.CreateUfsFileOptions)1 InStreamOptions (alluxio.client.file.options.InStreamOptions)1 AlluxioException (alluxio.exception.AlluxioException)1 CreateOptions (alluxio.underfs.options.CreateOptions)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1