Github user revans2 commented on a diff in the pull request:

    https://github.com/apache/storm/pull/2148#discussion_r120134652
  
    --- Diff: storm-client/src/jvm/org/apache/storm/daemon/worker/Worker.java 
---
    @@ -299,6 +313,33 @@ public void doExecutorHeartbeats() {
             }
         }
     
    +    public Map<String, Long> getCurrentBlobVersions() throws IOException {
    +        Map<String, Long> results = new HashMap();
    +        Map<String, Map<String, Object>> blobstoreMap = (Map<String, 
Map<String, Object>>) 
workerState.getTopologyConf().get(Config.TOPOLOGY_BLOBSTORE_MAP);
    +        if (blobstoreMap != null) {
    +            String stormRoot = 
ConfigUtils.supervisorStormDistRoot(workerState.getTopologyConf(), 
workerState.getTopologyId());
    +            for (Map.Entry<String, Map<String, Object>> entry : 
blobstoreMap.entrySet()) {
    +                String keyName = entry.getKey();
    +                String localFileName = keyName;
    +                Map<String, Object> blobInfo = blobstoreMap.get(keyName);
    +                if (blobInfo != null && blobInfo.containsKey("localname")) 
{
    +                    localFileName = (String) blobInfo.get("localname");
    +                }
    +                String blobPath = new File(stormRoot, 
localFileName).getCanonicalPath();
    +                File versionFile = new 
File(blobPath.replaceAll(".[0-9]+$", DEFAULT_BLOB_VERSION_SUFFIX));
    +                results.put(localFileName, 
Utils.getVersionFromBlobVersionFile(versionFile));
    --- End diff --
    
    Can we please do this slightly differently?  The way it currently works 
`$whatever.version` can be updated before we officially commit the changes (I 
know that is not good and I am trying to change it), but for now we really 
should do it more like.
    
    ````
    private static final Pattern BLOB_VERSION_EXTRACTION = 
Pattern.compile(".*\\.([0-9]+)$");
    //...
    String blobWithVersion = new File("./", 
localFileName).getCanonicalFile().getName();
    Matcher m = BLOB_VERSION_EXTRACTION.matcher(blobWithVersion);
    if (m.matches()) {
        results.put(localFileName, Long.valueOf(m.group(1)));
    }
    ````


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to