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