Search in sources :

Example 1 with LocalResource

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);
    }
}
Also used : AuthorizationException(org.apache.storm.generated.AuthorizationException) Map(java.util.Map) KeyNotFoundException(org.apache.storm.generated.KeyNotFoundException) LocalResource(org.apache.storm.localizer.LocalResource)

Example 2 with LocalResource

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;
}
Also used : ArrayList(java.util.ArrayList) HashMap(java.util.HashMap) Map(java.util.Map) LocalResource(org.apache.storm.localizer.LocalResource)

Aggregations

Map (java.util.Map)2 LocalResource (org.apache.storm.localizer.LocalResource)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 AuthorizationException (org.apache.storm.generated.AuthorizationException)1 KeyNotFoundException (org.apache.storm.generated.KeyNotFoundException)1