Skip to content

Commit

Permalink
0004517: Illegal State Exception: There is no content to read. Memory
Browse files Browse the repository at this point in the history
buffer was empty
  • Loading branch information
erilong committed Aug 31, 2020
1 parent 97b7e03 commit 65b2959
Showing 1 changed file with 14 additions and 20 deletions.
Expand Up @@ -41,25 +41,27 @@

public class StagingManager implements IStagingManager {

private static final String LOCK_EXTENSION = ".lock";
protected static final String LOCK_EXTENSION = ".lock";

protected static final Logger log = LoggerFactory.getLogger(StagingManager.class);

protected File directory;

private Map<String, String> resourcePathsCache = new ConcurrentHashMap<String, String>();
protected Set<String> resourcePathsCache;

protected Map<String, IStagedResource> inUse = new ConcurrentHashMap<String, IStagedResource>();

boolean clusterEnabled;
protected boolean clusterEnabled;

long lowFreeSpaceThresholdMegabytes;
protected long lowFreeSpaceThresholdMegabytes;

public StagingManager(String directory, boolean clusterEnabled, long lowFreeSpaceThresholdMegabytes) {
log.info("The staging directory was initialized at the following location: " + directory);
this.directory = new File(directory);
this.directory.mkdirs();
this.clusterEnabled = clusterEnabled;
this.lowFreeSpaceThresholdMegabytes = lowFreeSpaceThresholdMegabytes;
this.resourcePathsCache = ConcurrentHashMap.newKeySet();
}

public StagingManager(String directory, boolean clusterEnabled) {
Expand All @@ -68,7 +70,7 @@ public StagingManager(String directory, boolean clusterEnabled) {

@Override
public Set<String> getResourceReferences() {
return new TreeSet<String>(resourcePathsCache.keySet());
return new TreeSet<String>(resourcePathsCache);
}

@Override
Expand Down Expand Up @@ -143,13 +145,13 @@ protected void clean(Path path, long ttlInMs, StagingPurgeContext context) throw
}

cleanPath(resource, ttlInMs, context); // this comes after stat collection because
// once the file is gone we loose visibility to size
// once the file is gone we lose visibility to size
} else {
resourcePathsCache.put(stagingPath,stagingPath);
resourcePathsCache.add(stagingPath);
}
}
} catch (IllegalStateException ex) {
log.warn("Failure during refreshResourceList ", ex);
log.warn("Failure during clean ", ex);
}
}
}
Expand Down Expand Up @@ -196,7 +198,7 @@ public IStagedResource create(Object... path) {
}

this.inUse.put(filePath, resource);
this.resourcePathsCache.put(filePath, filePath);
this.resourcePathsCache.add(filePath);
return resource;
}

Expand All @@ -222,16 +224,9 @@ protected String buildFilePath(Object... path) {
public IStagedResource find(String path) {
IStagedResource resource = inUse.get(path);
if (resource == null) {
boolean foundResourcePath = resourcePathsCache.containsKey(path);
if (!foundResourcePath) {
resource = createStagedResource(path);
if (resource.getState() == State.DONE) {
resourcePathsCache.put(path, path);
foundResourcePath = true;
}
} else if (foundResourcePath) {
resource = createStagedResource(path);
}
resource = createStagedResource(path);
inUse.put(path, resource);
resourcePathsCache.add(path);
}
return resource;
}
Expand Down Expand Up @@ -306,5 +301,4 @@ public boolean accept(Path entry) {
}
};


}

0 comments on commit 65b2959

Please sign in to comment.