use of org.apache.storm.localizer.LocalResource in project storm by apache.
the class UpdateBlobs method updateBlobsForTopology.
/**
* Update each blob listed in the topology configuration if the latest version of the blob has not been downloaded.
*
* @param conf
* @param stormId
* @param localizer
* @throws IOException
*/
private void updateBlobsForTopology(Map conf, String stormId, Localizer localizer) throws IOException {
Map stormConf = ConfigUtils.readSupervisorStormConf(conf, stormId);
Map<String, Map<String, Object>> blobstoreMap = (Map<String, Map<String, Object>>) stormConf.get(Config.TOPOLOGY_BLOBSTORE_MAP);
String user = (String) stormConf.get(Config.TOPOLOGY_SUBMITTER_USER);
List<LocalResource> localresources = SupervisorUtils.blobstoreMapToLocalresources(blobstoreMap);
try {
localizer.updateBlobs(localresources, user);
} catch (AuthorizationException authExp) {
LOG.error("AuthorizationException error", authExp);
} catch (KeyNotFoundException knf) {
LOG.error("KeyNotFoundException error", knf);
}
}
use of org.apache.storm.localizer.LocalResource in project storm by apache.
the class SupervisorUtils method blobstoreMapToLocalresources.
/**
* Returns a list of LocalResources based on the blobstore-map passed in.
*/
public static List<LocalResource> blobstoreMapToLocalresources(Map<String, Map<String, Object>> blobstoreMap) {
List<LocalResource> localResourceList = new ArrayList<>();
if (blobstoreMap != null) {
for (Map.Entry<String, Map<String, Object>> map : blobstoreMap.entrySet()) {
Map<String, Object> blobConf = map.getValue();
LocalResource localResource = new LocalResource(map.getKey(), shouldUncompressBlob(blobConf), blobNeedsWorkerRestart(blobConf));
localResourceList.add(localResource);
}
}
return localResourceList;
}
Aggregations