Search in sources :

Example 1 with AlluxioTException

use of alluxio.thrift.AlluxioTException in project alluxio by Alluxio.

the class RetryHandlingFileSystemWorkerClient method sessionHeartbeat.

@Override
public void sessionHeartbeat(RetryPolicy retryPolicy) throws IOException, InterruptedException {
    TException exception;
    do {
        FileSystemWorkerClientService.Client client = mClientHeartbeatPool.acquire();
        try {
            client.sessionHeartbeat(mSessionId, null);
            Metrics.FILE_SYSTEM_WORKER_HEARTBEATS.inc();
            return;
        } catch (AlluxioTException | ThriftIOException e) {
            exception = e;
            LOG.warn(e.getMessage());
        } catch (TException e) {
            client.getOutputProtocol().getTransport().close();
            exception = e;
            LOG.warn(e.getMessage());
        } finally {
            mClientHeartbeatPool.release(client);
        }
    } while (retryPolicy.attemptRetry());
    Preconditions.checkNotNull(exception);
    throw new IOException(exception);
}
Also used : AlluxioTException(alluxio.thrift.AlluxioTException) TException(org.apache.thrift.TException) AlluxioTException(alluxio.thrift.AlluxioTException) ThriftIOException(alluxio.thrift.ThriftIOException) FileSystemWorkerClientService(alluxio.thrift.FileSystemWorkerClientService) ThriftIOException(alluxio.thrift.ThriftIOException) IOException(java.io.IOException)

Example 2 with AlluxioTException

use of alluxio.thrift.AlluxioTException in project alluxio by Alluxio.

the class RetryHandlingBlockWorkerClient method sessionHeartbeat.

/**
   * sessionHeartbeat is not retried because it is supposed to be called periodically.
   *
   * @throws IOException if it fails to heartbeat
   * @throws InterruptedException if heartbeat is interrupted
   */
@Override
public void sessionHeartbeat(RetryPolicy retryPolicy) throws IOException, InterruptedException {
    TException exception;
    do {
        BlockWorkerClientService.Client client = mClientHeartbeatPool.acquire();
        try {
            client.sessionHeartbeat(mSessionId, null);
            Metrics.BLOCK_WORKER_HEATBEATS.inc();
            return;
        } catch (AlluxioTException e) {
            AlluxioException ae = AlluxioException.fromThrift(e);
            LOG.warn(ae.getMessage());
            throw new IOException(ae);
        } catch (ThriftIOException e) {
            LOG.warn(e.getMessage());
            throw new IOException(e);
        } catch (TException e) {
            client.getOutputProtocol().getTransport().close();
            exception = e;
            LOG.warn(e.getMessage());
        } finally {
            mClientHeartbeatPool.release(client);
        }
    } while (retryPolicy.attemptRetry());
    Preconditions.checkNotNull(exception);
    throw new IOException(exception);
}
Also used : AlluxioTException(alluxio.thrift.AlluxioTException) TException(org.apache.thrift.TException) AlluxioTException(alluxio.thrift.AlluxioTException) ThriftIOException(alluxio.thrift.ThriftIOException) BlockWorkerClientService(alluxio.thrift.BlockWorkerClientService) ThriftIOException(alluxio.thrift.ThriftIOException) IOException(java.io.IOException) AlluxioException(alluxio.exception.AlluxioException)

Example 3 with AlluxioTException

use of alluxio.thrift.AlluxioTException in project alluxio by Alluxio.

the class DefaultBlockWorker method commitBlock.

@Override
public void commitBlock(long sessionId, long blockId) throws BlockAlreadyExistsException, BlockDoesNotExistException, InvalidWorkerStateException, IOException, WorkerOutOfSpaceException {
    // TODO(binfan): find a better way to handle retry logic
    try {
        mBlockStore.commitBlock(sessionId, blockId);
    } catch (BlockAlreadyExistsException e) {
        LOG.debug("Block {} has been in block store, this could be a retry due to master-side RPC " + "failure, therefore ignore the exception", blockId, e);
    }
    // TODO(calvin): Reconsider how to do this without heavy locking.
    // Block successfully committed, update master with new block metadata
    Long lockId = mBlockStore.lockBlock(sessionId, blockId);
    try {
        BlockMeta meta = mBlockStore.getBlockMeta(sessionId, blockId, lockId);
        BlockStoreLocation loc = meta.getBlockLocation();
        Long length = meta.getBlockSize();
        BlockStoreMeta storeMeta = mBlockStore.getBlockStoreMeta();
        Long bytesUsedOnTier = storeMeta.getUsedBytesOnTiers().get(loc.tierAlias());
        mBlockMasterClient.commitBlock(mWorkerId.get(), bytesUsedOnTier, loc.tierAlias(), blockId, length);
    } catch (AlluxioTException | IOException | ConnectionFailedException e) {
        throw new IOException(ExceptionMessage.FAILED_COMMIT_BLOCK_TO_MASTER.getMessage(blockId), e);
    } finally {
        mBlockStore.unlockBlock(lockId);
    }
}
Also used : AlluxioTException(alluxio.thrift.AlluxioTException) BlockAlreadyExistsException(alluxio.exception.BlockAlreadyExistsException) IOException(java.io.IOException) BlockMeta(alluxio.worker.block.meta.BlockMeta) TempBlockMeta(alluxio.worker.block.meta.TempBlockMeta) ConnectionFailedException(alluxio.exception.ConnectionFailedException)

Example 4 with AlluxioTException

use of alluxio.thrift.AlluxioTException in project alluxio by Alluxio.

the class BlockServiceHandlerIntegrationTest method lockBlockFailure.

// Tests that lock block returns error on failure
@Test
public void lockBlockFailure() throws Exception {
    mFileSystem.createFile(new AlluxioURI("/testFile")).close();
    URIStatus file = mFileSystem.getStatus(new AlluxioURI("/testFile"));
    final long blockId = BlockId.createBlockId(BlockId.getContainerId(file.getFileId()), 0);
    Exception exception = null;
    try {
        mBlockWorkerServiceHandler.lockBlock(blockId, SESSION_ID, new LockBlockTOptions());
    } catch (AlluxioTException e) {
        exception = e;
    }
    // A file does not exist exception should have been thrown
    Assert.assertNotNull(exception);
}
Also used : AlluxioTException(alluxio.thrift.AlluxioTException) URIStatus(alluxio.client.file.URIStatus) LockBlockTOptions(alluxio.thrift.LockBlockTOptions) InvalidPathException(alluxio.exception.InvalidPathException) AlluxioTException(alluxio.thrift.AlluxioTException) TException(org.apache.thrift.TException) IOException(java.io.IOException) AlluxioURI(alluxio.AlluxioURI) Test(org.junit.Test)

Example 5 with AlluxioTException

use of alluxio.thrift.AlluxioTException in project alluxio by Alluxio.

the class BlockServiceHandlerIntegrationTest method requestSpace.

// Tests that space will be allocated when possible
@Test
public void requestSpace() throws Exception {
    final long blockId1 = 12345L;
    final long blockId2 = 12346L;
    final int chunkSize = (int) WORKER_CAPACITY_BYTES / 10;
    /* only a single tier, so SecondHighest still refers to the memory tier */
    final int writeTier = Constants.SECOND_TIER;
    mBlockWorkerServiceHandler.requestBlockLocation(SESSION_ID, blockId1, chunkSize, writeTier);
    boolean result = mBlockWorkerServiceHandler.requestSpace(SESSION_ID, blockId1, chunkSize);
    // Initial request and first additional request should succeed
    Assert.assertTrue(result);
    result = mBlockWorkerServiceHandler.requestSpace(SESSION_ID, blockId1, WORKER_CAPACITY_BYTES);
    // Impossible request should fail
    Assert.assertFalse(result);
    // Request for space on a nonexistent block should fail
    try {
        mBlockWorkerServiceHandler.requestSpace(SESSION_ID, blockId2, chunkSize);
        Assert.fail();
    } catch (AlluxioTException e) {
        Assert.assertEquals(ExceptionMessage.TEMP_BLOCK_META_NOT_FOUND.getMessage(blockId2), e.getMessage());
    }
    // Request for impossible initial space should fail
    Exception exception = null;
    try {
        mBlockWorkerServiceHandler.requestBlockLocation(SESSION_ID, blockId2, WORKER_CAPACITY_BYTES + 1, writeTier);
    } catch (AlluxioTException e) {
        exception = e;
    }
    Assert.assertNotNull(exception);
}
Also used : AlluxioTException(alluxio.thrift.AlluxioTException) InvalidPathException(alluxio.exception.InvalidPathException) AlluxioTException(alluxio.thrift.AlluxioTException) TException(org.apache.thrift.TException) IOException(java.io.IOException) Test(org.junit.Test)

Aggregations

AlluxioTException (alluxio.thrift.AlluxioTException)8 IOException (java.io.IOException)7 TException (org.apache.thrift.TException)6 ThriftIOException (alluxio.thrift.ThriftIOException)4 AlluxioException (alluxio.exception.AlluxioException)3 Test (org.junit.Test)3 InvalidPathException (alluxio.exception.InvalidPathException)2 ExponentialBackoffRetry (alluxio.retry.ExponentialBackoffRetry)2 RetryPolicy (alluxio.retry.RetryPolicy)2 AlluxioURI (alluxio.AlluxioURI)1 URIStatus (alluxio.client.file.URIStatus)1 BlockAlreadyExistsException (alluxio.exception.BlockAlreadyExistsException)1 ConnectionFailedException (alluxio.exception.ConnectionFailedException)1 BlockWorkerClientService (alluxio.thrift.BlockWorkerClientService)1 FileSystemWorkerClientService (alluxio.thrift.FileSystemWorkerClientService)1 LockBlockTOptions (alluxio.thrift.LockBlockTOptions)1 BlockMeta (alluxio.worker.block.meta.BlockMeta)1 TempBlockMeta (alluxio.worker.block.meta.TempBlockMeta)1