Search in sources :

Example 56 with UnavailableException

use of alluxio.exception.status.UnavailableException in project alluxio by Alluxio.

the class DefaultBlockWorker method createBlockReader.

@Override
public BlockReader createBlockReader(BlockReadRequest request) throws BlockDoesNotExistException, IOException {
    long sessionId = request.getSessionId();
    long blockId = request.getId();
    RetryPolicy retryPolicy = new TimeoutRetry(UFS_BLOCK_OPEN_TIMEOUT_MS, Constants.SECOND_MS);
    while (retryPolicy.attempt()) {
        BlockReader reader = createLocalBlockReader(sessionId, blockId, request.getStart());
        if (reader != null) {
            Metrics.WORKER_ACTIVE_CLIENTS.inc();
            return reader;
        }
        boolean checkUfs = request.isPersisted() || (request.getOpenUfsBlockOptions() != null && request.getOpenUfsBlockOptions().hasBlockInUfsTier() && request.getOpenUfsBlockOptions().getBlockInUfsTier());
        if (!checkUfs) {
            throw new BlockDoesNotExistException(ExceptionMessage.NO_BLOCK_ID_FOUND, blockId);
        }
        // When the block does not exist in Alluxio but exists in UFS, try to open the UFS block.
        try {
            Metrics.WORKER_ACTIVE_CLIENTS.inc();
            return createUfsBlockReader(request.getSessionId(), request.getId(), request.getStart(), request.isPositionShort(), request.getOpenUfsBlockOptions());
        } catch (Exception e) {
            throw new UnavailableException(String.format("Failed to read block ID=%s from tiered storage and UFS tier: %s", request.getId(), e.toString()));
        }
    }
    throw new UnavailableException(ExceptionMessage.UFS_BLOCK_ACCESS_TOKEN_UNAVAILABLE.getMessage(request.getId(), request.getOpenUfsBlockOptions().getUfsPath()));
}
Also used : BlockReader(alluxio.worker.block.io.BlockReader) DelegatingBlockReader(alluxio.worker.block.io.DelegatingBlockReader) UnavailableException(alluxio.exception.status.UnavailableException) TimeoutRetry(alluxio.retry.TimeoutRetry) RetryPolicy(alluxio.retry.RetryPolicy) BlockDoesNotExistException(alluxio.exception.BlockDoesNotExistException) WorkerOutOfSpaceException(alluxio.exception.WorkerOutOfSpaceException) AlluxioException(alluxio.exception.AlluxioException) UnavailableException(alluxio.exception.status.UnavailableException) InvalidWorkerStateException(alluxio.exception.InvalidWorkerStateException) BlockAlreadyExistsException(alluxio.exception.BlockAlreadyExistsException) IOException(java.io.IOException) BlockDoesNotExistException(alluxio.exception.BlockDoesNotExistException)

Example 57 with UnavailableException

use of alluxio.exception.status.UnavailableException in project alluxio by Alluxio.

the class MultiProcessCluster method waitForAllNodesRegistered.

/**
 * Waits for all nodes to be registered.
 *
 * @param timeoutMs maximum amount of time to wait, in milliseconds
 */
public synchronized void waitForAllNodesRegistered(int timeoutMs) throws TimeoutException, InterruptedException {
    MetaMasterClient metaMasterClient = getMetaMasterClient();
    int nodeCount = mNumMasters + mNumWorkers;
    CommonUtils.waitFor("all nodes registered", () -> {
        try {
            MasterInfo masterInfo = metaMasterClient.getMasterInfo(Collections.emptySet());
            int liveNodeNum = masterInfo.getMasterAddressesList().size() + masterInfo.getWorkerAddressesList().size();
            if (liveNodeNum == nodeCount) {
                return true;
            } else {
                LOG.info("Master addresses: {}. Worker addresses: {}", masterInfo.getMasterAddressesList(), masterInfo.getWorkerAddressesList());
                return false;
            }
        } catch (UnavailableException e) {
            return false;
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }, WaitForOptions.defaults().setInterval(200).setTimeoutMs(timeoutMs));
}
Also used : MasterInfo(alluxio.grpc.MasterInfo) RetryHandlingMetaMasterClient(alluxio.client.meta.RetryHandlingMetaMasterClient) MetaMasterClient(alluxio.client.meta.MetaMasterClient) UnavailableException(alluxio.exception.status.UnavailableException) TimeoutException(java.util.concurrent.TimeoutException) UnavailableException(alluxio.exception.status.UnavailableException) IOException(java.io.IOException)

Example 58 with UnavailableException

use of alluxio.exception.status.UnavailableException in project alluxio by Alluxio.

the class ServiceSocketBindIntegrationTest method connectDifferentAddress.

@Test
public void connectDifferentAddress() throws Exception {
    startCluster(NetworkAddressUtils.getLocalHostName(100));
    // Connect to Master RPC service on loopback, while Master is listening on local hostname.
    InetSocketAddress masterRpcAddr = new InetSocketAddress("127.0.0.1", mLocalAlluxioCluster.getLocalAlluxioMaster().getRpcLocalPort());
    mBlockMasterClient = BlockMasterClient.Factory.create(MasterClientContext.newBuilder(ClientContext.create(ServerConfiguration.global())).setMasterInquireClient(new SingleMasterInquireClient(masterRpcAddr)).build());
    try {
        mBlockMasterClient.connect();
        Assert.fail("Client should not have successfully connected to master RPC service.");
    } catch (UnavailableException e) {
    // This is expected, since Master RPC service is NOT listening on loopback.
    }
    // Connect to Worker RPC service on loopback, while Worker is listening on local hostname.
    try {
        mBlockMasterClient.connect();
        Assert.fail("Client should not have successfully connected to Worker RPC service.");
    } catch (Exception e) {
    // This is expected, since Work RPC service is NOT listening on loopback.
    }
    // connect Worker data service on loopback, while Worker is listening on local hostname.
    InetSocketAddress workerDataAddr = new InetSocketAddress("127.0.0.1", mLocalAlluxioCluster.getWorkerProcess().getDataLocalPort());
    try {
        mWorkerDataService = SocketChannel.open(workerDataAddr);
        Assert.assertTrue(mWorkerDataService.isConnected());
        Assert.fail("Client should not have successfully connected to Worker RPC service.");
    } catch (IOException e) {
    // This is expected, since Worker data service is NOT listening on loopback.
    }
    // connect Master Web service on loopback, while Master is listening on local hostname.
    try {
        mMasterWebService = (HttpURLConnection) new URL("http://127.0.0.1:" + mLocalAlluxioCluster.getLocalAlluxioMaster().getMasterProcess().getWebAddress().getPort() + "/home").openConnection();
        Assert.assertEquals(200, mMasterWebService.getResponseCode());
        Assert.fail("Client should not have successfully connected to Master Web service.");
    } catch (IOException e) {
    // This is expected, since Master Web service is NOT listening on loopback.
    } finally {
        Assert.assertNotNull(mMasterWebService);
        mMasterWebService.disconnect();
    }
    // connect Worker Web service on loopback, while Worker is listening on local hostname.
    try {
        mWorkerWebService = (HttpURLConnection) new URL("http://127.0.0.1:" + mLocalAlluxioCluster.getWorkerProcess().getWebLocalPort() + "/home").openConnection();
        Assert.assertEquals(200, mWorkerWebService.getResponseCode());
        Assert.fail("Client should not have successfully connected to Worker Web service.");
    } catch (IOException e) {
    // This is expected, since Worker Web service is NOT listening on loopback.
    } finally {
        mWorkerWebService.disconnect();
    }
}
Also used : SingleMasterInquireClient(alluxio.master.SingleMasterInquireClient) InetSocketAddress(java.net.InetSocketAddress) UnavailableException(alluxio.exception.status.UnavailableException) IOException(java.io.IOException) ConnectionFailedException(alluxio.exception.ConnectionFailedException) IOException(java.io.IOException) UnavailableException(alluxio.exception.status.UnavailableException) URL(java.net.URL) Test(org.junit.Test) BaseIntegrationTest(alluxio.testutils.BaseIntegrationTest)

Aggregations

UnavailableException (alluxio.exception.status.UnavailableException)58 IOException (java.io.IOException)25 Test (org.junit.Test)14 ArrayList (java.util.ArrayList)10 AlluxioURI (alluxio.AlluxioURI)9 AlluxioStatusException (alluxio.exception.status.AlluxioStatusException)9 NotFoundException (alluxio.exception.status.NotFoundException)9 InetSocketAddress (java.net.InetSocketAddress)9 BlockInfo (alluxio.wire.BlockInfo)8 FileDoesNotExistException (alluxio.exception.FileDoesNotExistException)7 WorkerNetAddress (alluxio.wire.WorkerNetAddress)7 WorkerInfo (alluxio.wire.WorkerInfo)6 HashMap (java.util.HashMap)6 Map (java.util.Map)6 Set (java.util.Set)6 RetryPolicy (alluxio.retry.RetryPolicy)5 TimeoutException (java.util.concurrent.TimeoutException)5 BlockInfoException (alluxio.exception.BlockInfoException)4 ExceptionMessage (alluxio.exception.ExceptionMessage)4 InodeFile (alluxio.master.file.meta.InodeFile)4