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());
}
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());
}
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());
}
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());
}
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));
}
Aggregations