use of alluxio.exception.AlluxioException in project alluxio by Alluxio.
the class KeyValueInputSplit method getLocations.
@Override
public String[] getLocations() throws IOException {
try {
List<BlockWorkerInfo> workersInfo = mBlockStore.getWorkerInfoList();
int workersInfoSize = workersInfo.size();
String[] locations = new String[workersInfoSize];
for (int i = 0; i < workersInfoSize; i++) {
locations[i] = workersInfo.get(i).getNetAddress().getHost();
}
return locations;
} catch (AlluxioException e) {
throw new IOException(e);
}
}
use of alluxio.exception.AlluxioException in project alluxio by Alluxio.
the class KeyValueRecordReader method initialize.
@Override
public void initialize(InputSplit split, TaskAttemptContext context) throws IOException, InterruptedException {
try {
mReader = KeyValuePartitionReader.Factory.create(((KeyValueInputSplit) split).getPartitionId());
mKeyValuePairIterator = mReader.iterator();
mNumVisitedKeyValuePairs = 0;
mNumKeyValuePairs = mReader.size();
mCurrentKey = new BytesWritable();
mCurrentValue = new BytesWritable();
} catch (AlluxioException e) {
throw new IOException(e);
}
}
use of alluxio.exception.AlluxioException in project alluxio by Alluxio.
the class AlluxioShellUtils method getAlluxioURIs.
/**
* The utility function used to implement getAlluxioURIs.
*
* Basically, it recursively iterates through the directory from the parent directory of inputURI
* (e.g., for input "/a/b/*", it will start from "/a/b") until it finds all the matches;
* It does not go into a directory if the prefix mismatches
* (e.g., for input "/a/b/*", it won't go inside directory "/a/c")
*
* @param alluxioClient the client used to fetch metadata of Alluxio files
* @param inputURI the input URI (could contain wildcards)
* @param parentDir the {@link AlluxioURI} of the directory in which we are searching matched
* files
* @return a list of {@link AlluxioURI}s of the files that match the inputURI in parentDir
* @throws IOException if any filesystem errors are encountered when expanding paths with
* wildcards
*/
private static List<AlluxioURI> getAlluxioURIs(FileSystem alluxioClient, AlluxioURI inputURI, AlluxioURI parentDir) throws IOException {
List<AlluxioURI> res = new LinkedList<>();
List<URIStatus> statuses;
try {
statuses = alluxioClient.listStatus(parentDir);
} catch (AlluxioException e) {
throw new IOException(e);
}
for (URIStatus status : statuses) {
AlluxioURI fileURI = new AlluxioURI(inputURI.getScheme(), inputURI.getAuthority(), status.getPath());
if (match(fileURI, inputURI)) {
// if it matches
res.add(fileURI);
} else {
if (status.isFolder()) {
// if it is a folder, we do it recursively
AlluxioURI dirURI = new AlluxioURI(inputURI.getScheme(), inputURI.getAuthority(), status.getPath());
String prefix = inputURI.getLeadingPath(dirURI.getDepth());
if (prefix != null && match(dirURI, new AlluxioURI(prefix))) {
res.addAll(getAlluxioURIs(alluxioClient, inputURI, dirURI));
}
}
}
}
return res;
}
use of alluxio.exception.AlluxioException in project alluxio by Alluxio.
the class AlluxioBlockStore method promote.
/**
* Attempts to promote a block in Alluxio space. If the block is not present, this method will
* return without an error. If the block is present in multiple workers, only one worker will
* receive the promotion request.
*
* @param blockId the id of the block to promote
* @throws IOException if the block does not exist
*/
public void promote(long blockId) throws IOException {
BlockInfo info;
try (CloseableResource<BlockMasterClient> blockMasterClientResource = mContext.acquireBlockMasterClientResource()) {
info = blockMasterClientResource.get().getBlockInfo(blockId);
} catch (AlluxioException e) {
throw new IOException(e);
}
if (info.getLocations().isEmpty()) {
// Nothing to promote
return;
}
// Get the first worker address for now, as this will likely be the location being read from
// TODO(calvin): Get this location via a policy (possibly location is a parameter to promote)
BlockWorkerClient blockWorkerClient = mContext.createBlockWorkerClient(info.getLocations().get(0).getWorkerAddress(), null);
try {
blockWorkerClient.promoteBlock(blockId);
} catch (AlluxioException e) {
throw new IOException(e);
} finally {
blockWorkerClient.close();
}
}
use of alluxio.exception.AlluxioException in project alluxio by Alluxio.
the class AbstractThriftClient method retryRPC.
/**
* Similar to {@link #retryRPC(RpcCallable)} except that the RPC call may throw
* {@link AlluxioTException} and once it is thrown, it will be transformed into
* {@link AlluxioException} and be thrown.
*
* @param rpc the RPC call to be executed
* @param <V> type of return value of the RPC call
* @return the return value of the RPC call
* @throws AlluxioException when {@link AlluxioTException} is thrown by the RPC call
* @throws IOException when retries exceeds {@link #RPC_MAX_NUM_RETRY} or some server
* side IOException occurred.
*/
protected <V> V retryRPC(RpcCallableThrowsAlluxioTException<V, C> rpc) throws AlluxioException, IOException {
TException exception = null;
RetryPolicy retryPolicy = new ExponentialBackoffRetry(BASE_SLEEP_MS, MAX_SLEEP_MS, RPC_MAX_NUM_RETRY);
do {
C client = acquireClient();
try {
return rpc.call(client);
} catch (AlluxioTException e) {
AlluxioException ae = AlluxioException.fromThrift(e);
processException(client, ae);
exception = new TException(ae);
} catch (ThriftIOException e) {
throw new IOException(e);
} catch (TException e) {
LOG.error(e.getMessage(), e);
closeClient(client);
exception = e;
} finally {
releaseClient(client);
}
} while (retryPolicy.attemptRetry());
LOG.error("Failed after " + retryPolicy.getRetryCount() + " retries.");
Preconditions.checkNotNull(exception);
throw new IOException(exception);
}
Aggregations