Search in sources :

Example 51 with WorkerNetAddress

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

Example 52 with WorkerNetAddress

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();
}
Also used : WorkerNetAddress(alluxio.wire.WorkerNetAddress) IOException(java.io.IOException) Test(org.junit.Test)

Example 53 with WorkerNetAddress

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);
}
Also used : ReadResponse(alluxio.grpc.ReadResponse) WorkerNetAddress(alluxio.wire.WorkerNetAddress) ReadRequest(alluxio.grpc.ReadRequest) Before(org.junit.Before)

Example 54 with WorkerNetAddress

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());
}
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 55 with WorkerNetAddress

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());
}
Also used : InstancedConfiguration(alluxio.conf.InstancedConfiguration) WorkerNetAddress(alluxio.wire.WorkerNetAddress) BlockWorkerInfo(alluxio.client.block.BlockWorkerInfo) ArrayList(java.util.ArrayList) AlluxioConfiguration(alluxio.conf.AlluxioConfiguration) Pair(alluxio.collections.Pair) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) 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