use of org.apache.storm.generated.KeyNotFoundException 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;
}
use of org.apache.storm.generated.KeyNotFoundException in project storm by apache.
the class LeaderListenerCallback method getTopologyDependencyKeys.
private Set<String> getTopologyDependencyKeys(Set<String> activeTopologyCodeKeys) {
Set<String> activeTopologyDependencies = new TreeSet<>();
Subject subject = ReqContext.context().subject();
for (String activeTopologyCodeKey : activeTopologyCodeKeys) {
try (InputStreamWithMeta blob = blobStore.getBlob(activeTopologyCodeKey, subject)) {
byte[] blobContent = IOUtils.readFully(blob, new Long(blob.getFileLength()).intValue());
StormTopology stormCode = Utils.deserialize(blobContent, StormTopology.class);
if (stormCode.is_set_dependency_jars()) {
activeTopologyDependencies.addAll(stormCode.get_dependency_jars());
}
if (stormCode.is_set_dependency_artifacts()) {
activeTopologyDependencies.addAll(stormCode.get_dependency_artifacts());
}
} catch (AuthorizationException | KeyNotFoundException | IOException e) {
LOG.error("Exception occurs while reading blob for key: " + activeTopologyCodeKey + ", exception: " + e, e);
throw new RuntimeException("Exception occurs while reading blob for key: " + activeTopologyCodeKey + ", exception: " + e, e);
}
}
return activeTopologyDependencies;
}
use of org.apache.storm.generated.KeyNotFoundException in project storm by apache.
the class Nimbus method getResourcesForTopology.
private TopologyResources getResourcesForTopology(String topoId, StormBase base) throws NotAliveException, AuthorizationException, InvalidTopologyException, IOException {
TopologyResources ret = idToResources.get().get(topoId);
if (ret == null) {
try {
IStormClusterState state = stormClusterState;
TopologyDetails details = readTopologyDetails(topoId, base);
Assignment assignment = state.assignmentInfo(topoId, null);
ret = new TopologyResources(details, assignment);
} catch (KeyNotFoundException e) {
// This can happen when a topology is first coming up
// It's thrown by the blobstore code
LOG.error("Failed to get topology details", e);
ret = new TopologyResources();
}
}
return ret;
}
Aggregations