use of alluxio.wire.WorkerNetAddress in project alluxio by Alluxio.
the class GetWorkerOptionsTest method setBlockWorkerInfoTest.
/**
* Tests for setBlockWorkerInfo.
*/
@Test
public void setBlockWorkerInfoTest() {
mWorkerInfos.clear();
mWorkerInfos.add(new BlockWorkerInfo(new WorkerNetAddress().setHost("worker1").setRpcPort(PORT).setDataPort(PORT).setWebPort(PORT), Constants.GB, 0));
mWorkerInfos.add(new BlockWorkerInfo(new WorkerNetAddress().setHost("worker2").setRpcPort(PORT).setDataPort(PORT).setWebPort(PORT), 2 * (long) Constants.GB, 0));
GetWorkerOptions options = GetWorkerOptions.defaults();
options.setBlockWorkerInfos(mWorkerInfos);
assertEquals(mWorkerInfos, options.getBlockWorkerInfos());
}
use of alluxio.wire.WorkerNetAddress in project alluxio by Alluxio.
the class BlockOutStreamTest method packetWriteException.
@Test
public void packetWriteException() throws Exception {
DataWriter writer = new FailingTestDataWriter(ByteBuffer.allocate(CHUNK_SIZE));
BlockOutStream bos = new BlockOutStream(writer, CHUNK_SIZE, new WorkerNetAddress());
try {
bos.write(new byte[CHUNK_SIZE]);
Assert.fail("Expected write to throw an exception.");
} catch (IOException e) {
// Exception expected, continue.
}
// After an exception, we should still be able to cancel the stream.
// Test succeeds if we do not throw an exception in cancel.
bos.cancel();
}
use of alluxio.wire.WorkerNetAddress in project alluxio by Alluxio.
the class SharedGrpcDataReaderTest method before.
@Before
public void before() {
WorkerNetAddress address = new WorkerNetAddress();
BlockWorkerClient client = Mockito.mock(BlockWorkerClient.class);
GrpcBlockingStream<ReadRequest, ReadResponse> unusedStream = new GrpcBlockingStream<>(client::readBlock, 5, "test message");
mReadRequest = ReadRequest.newBuilder().setOffset(0).setLength(mBlockSize).setChunkSize(CHUNK_SIZE).setBlockId(BLOCK_ID).build();
mBufferCachingDataReader = new TestBufferCachingGrpcDataReader(address, new NoopClosableResource<>(client), TIMEOUT, mReadRequest, unusedStream, CHUNK_SIZE, mBlockSize);
}
use of alluxio.wire.WorkerNetAddress in project alluxio by Alluxio.
the class LocalFirstAvoidEvictionPolicyTest method chooseClosestTierAvoidEviction.
@Test
public void chooseClosestTierAvoidEviction() throws Exception {
List<BlockWorkerInfo> workers = new ArrayList<>();
workers.add(worker(Constants.GB, Constants.MB, "node2", "rack3"));
workers.add(worker(Constants.GB, 0, "node3", "rack2"));
workers.add(worker(Constants.GB, 0, "node4", "rack3"));
BlockLocationPolicy policy;
WorkerNetAddress chosen;
// local rack with enough availability
policy = new LocalFirstAvoidEvictionPolicy(mConf.getBytes(PropertyKey.USER_BLOCK_AVOID_EVICTION_POLICY_RESERVED_BYTES), TieredIdentityFactory.fromString("node=node2,rack=rack3", mConf), mConf);
GetWorkerOptions options = GetWorkerOptions.defaults().setBlockWorkerInfos(workers).setBlockInfo(new BlockInfo().setLength(Constants.GB));
chosen = policy.getWorker(options);
assertEquals("node4", chosen.getTieredIdentity().getTier(0).getValue());
}
use of alluxio.wire.WorkerNetAddress in project alluxio by Alluxio.
the class BlockLocationUtilsTest method chooseLocalAccessibleDomainSocket.
@Test
public void chooseLocalAccessibleDomainSocket() throws Exception {
List<BlockWorkerInfo> workers = new ArrayList<>();
workers.add(worker(Constants.GB, "node2", "rack2"));
// create worker info with domain socket path
BlockWorkerInfo workerWithDomainSocket = worker(Constants.GB, "node3", "rack3");
String domainSocketPath = "/tmp/domain/uuid-node3";
workerWithDomainSocket.getNetAddress().setDomainSocketPath(domainSocketPath);
workers.add(workerWithDomainSocket);
// mock NettyUtils
PowerMockito.mockStatic(NettyUtils.class);
when(NettyUtils.isDomainSocketAccessible(eq(workerWithDomainSocket.getNetAddress()), any(AlluxioConfiguration.class))).thenReturn(true);
// choose worker with domain socket accessible ignoring rack
InstancedConfiguration conf = ConfigurationTestUtils.defaults();
conf.set(PropertyKey.WORKER_DATA_SERVER_DOMAIN_SOCKET_AS_UUID, true);
List<WorkerNetAddress> addresses = workers.stream().map(worker -> worker.getNetAddress()).filter(Objects::nonNull).collect(Collectors.toList());
Optional<Pair<WorkerNetAddress, Boolean>> chosen = BlockLocationUtils.nearest(TieredIdentityFactory.fromString("node=node1,rack=rack2", conf), addresses, conf);
assertTrue(chosen.isPresent());
assertTrue(chosen.get().getSecond());
assertEquals(domainSocketPath, chosen.get().getFirst().getDomainSocketPath());
assertEquals("node3", chosen.get().getFirst().getHost());
}
Aggregations