Search in sources :

Example 81 with WorkerNetAddress

use of alluxio.wire.WorkerNetAddress in project alluxio by Alluxio.

the class BlockInStreamTest method createUfs.

@Test
public void createUfs() throws Exception {
    WorkerNetAddress dataSource = new WorkerNetAddress();
    BlockInStream.BlockInStreamSource dataSourceType = BlockInStream.BlockInStreamSource.UFS;
    BlockInStream stream = BlockInStream.create(mMockContext, mInfo, dataSource, dataSourceType, mOptions);
    assertEquals(GrpcDataReader.Factory.class.getName(), stream.getDataReaderFactory().getClass().getName());
}
Also used : WorkerNetAddress(alluxio.wire.WorkerNetAddress) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 82 with WorkerNetAddress

use of alluxio.wire.WorkerNetAddress in project alluxio by Alluxio.

the class BlockInStreamTest method createProcessLocal.

@Test
public void createProcessLocal() throws Exception {
    WorkerNetAddress dataSource = new WorkerNetAddress();
    when(mMockContext.getNodeLocalWorker()).thenReturn(dataSource);
    when(mMockContext.getClientContext()).thenReturn(ClientContext.create(mConf));
    BlockWorker blockWorker = Mockito.mock(BlockWorker.class);
    when(mMockContext.getProcessLocalWorker()).thenReturn(blockWorker);
    BlockInStream.BlockInStreamSource dataSourceType = BlockInStream.BlockInStreamSource.PROCESS_LOCAL;
    BlockInStream stream = BlockInStream.create(mMockContext, mInfo, dataSource, dataSourceType, mOptions);
    assertEquals(BlockWorkerDataReader.Factory.class.getName(), stream.getDataReaderFactory().getClass().getName());
}
Also used : WorkerNetAddress(alluxio.wire.WorkerNetAddress) BlockWorker(alluxio.worker.block.BlockWorker) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 83 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(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 84 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));
    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)

Example 85 with WorkerNetAddress

use of alluxio.wire.WorkerNetAddress in project alluxio by Alluxio.

the class SpecificHostPolicyTest method noMatchingHost.

/**
 * Tests that no worker is chosen when the worker specified in the policy is not part of the
 * worker list.
 */
@Test
public void noMatchingHost() {
    SpecificHostPolicy policy = new SpecificHostPolicy("worker3");
    List<BlockWorkerInfo> workerInfoList = new ArrayList<>();
    workerInfoList.add(new BlockWorkerInfo(new WorkerNetAddress().setHost("worker1F").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(2 * (long) Constants.GB));
    Assert.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)

Aggregations

WorkerNetAddress (alluxio.wire.WorkerNetAddress)117 Test (org.junit.Test)63 BlockWorkerInfo (alluxio.client.block.BlockWorkerInfo)43 ArrayList (java.util.ArrayList)38 BlockInfo (alluxio.wire.BlockInfo)36 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)32 URIStatus (alluxio.client.file.URIStatus)22 IOException (java.io.IOException)21 AlluxioURI (alluxio.AlluxioURI)20 FileBlockInfo (alluxio.wire.FileBlockInfo)20 InStreamOptions (alluxio.client.file.options.InStreamOptions)19 FileInfo (alluxio.wire.FileInfo)16 GetWorkerOptions (alluxio.client.block.policy.options.GetWorkerOptions)15 List (java.util.List)14 FileSystemContext (alluxio.client.file.FileSystemContext)12 OpenFilePOptions (alluxio.grpc.OpenFilePOptions)12 BlockLocation (alluxio.wire.BlockLocation)12 BlockInStream (alluxio.client.block.stream.BlockInStream)11 AlluxioConfiguration (alluxio.conf.AlluxioConfiguration)11 Before (org.junit.Before)11