use of org.apache.storm.utils.WrappedKeyNotFoundException in project storm by apache.
the class AsyncLocalizer method getBlobs.
/**
* This function either returns the blobs in the existing cache or if they don't exist in the cache, it downloads them in parallel (up
* to SUPERVISOR_BLOBSTORE_DOWNLOAD_THREAD_COUNT) and will block until all of them have been downloaded.
*/
List<LocalizedResource> getBlobs(List<LocalResource> localResources, PortAndAssignment pna, BlobChangingCallback cb) throws AuthorizationException, KeyNotFoundException, IOException {
if ((boolean) conf.getOrDefault(Config.DISABLE_SYMLINKS, false)) {
throw new WrappedKeyNotFoundException("symlinks are disabled so blobs cannot be downloaded.");
}
String user = pna.getOwner();
ArrayList<LocalizedResource> results = new ArrayList<>();
List<CompletableFuture<?>> futures = new ArrayList<>();
try {
for (LocalResource localResource : localResources) {
String key = localResource.getBlobName();
boolean uncompress = localResource.shouldUncompress();
LocalizedResource lrsrc = uncompress ? getUserArchive(user, key) : getUserFile(user, key);
// go off to blobstore and get it
// assume dir passed in exists and has correct permission
LOG.debug("fetching blob: {}", key);
lrsrc.addReference(pna, localResource.needsCallback() ? cb : null);
futures.add(downloadOrUpdate(lrsrc));
results.add(lrsrc);
}
for (CompletableFuture<?> futureRsrc : futures) {
futureRsrc.get();
}
} catch (ExecutionException e) {
Utils.unwrapAndThrow(AuthorizationException.class, e);
Utils.unwrapAndThrow(KeyNotFoundException.class, e);
throw new IOException("Error getting blobs", e);
} catch (RejectedExecutionException re) {
throw new IOException("RejectedExecutionException: ", re);
} catch (InterruptedException ie) {
throw new IOException("Interrupted Exception", ie);
}
return results;
}
Aggregations