Skip to content

Commit

Permalink
0003807: Symmetric startup is very slow when there are lots of stagin…
Browse files Browse the repository at this point in the history
…g files on a SAN (3.9) Fix commit
  • Loading branch information
mmichalek committed Nov 29, 2018
1 parent ef2592d commit ea4cce7
Showing 1 changed file with 9 additions and 5 deletions.
Expand Up @@ -44,7 +44,7 @@ public class StagingManager implements IStagingManager {

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

private File directory;
protected File directory;

private Map<String, String> resourcePathsCache = new ConcurrentHashMap<String, String>();
protected Map<String, IStagedResource> inUse = new ConcurrentHashMap<String, IStagedResource>();
Expand Down Expand Up @@ -114,7 +114,7 @@ protected void clean(Path path, long ttlInMs, StagingPurgeContext context) throw
try {
String stagingPath = StagedResource.toPath(directory,
new File((entry.getParent().toString() + "/" + entry.getFileName().toString())));
IStagedResource resource = new StagedResource(directory, stagingPath, this);
IStagedResource resource = createStagedResource(stagingPath);
if (stagingPath != null) {
if (shouldCleanPath(resource, ttlInMs, context)) {
if (resource.getFile() != null) {
Expand Down Expand Up @@ -158,14 +158,18 @@ protected boolean cleanPath(IStagedResource resource, long ttlInMs, StagingPurge
*/
public IStagedResource create(Object... path) {
String filePath = buildFilePath(path);
IStagedResource resource = new StagedResource(directory, filePath, this);
IStagedResource resource = createStagedResource(filePath);
if (resource.exists()) {
resource.delete();
}
this.inUse.put(filePath, resource);
this.resourcePathsCache.put(filePath, filePath);
return resource;
}

protected IStagedResource createStagedResource(String filePath) {
return new StagedResource(directory, filePath, this);
}

protected String buildFilePath(Object... path) {
StringBuilder buffer = new StringBuilder();
Expand All @@ -188,15 +192,15 @@ public IStagedResource find(String path) {
boolean foundResourcePath = resourcePathsCache.containsKey(path);
if (!foundResourcePath && clusterEnabled) {
synchronized (this) {
StagedResource staged = new StagedResource(directory, path, this);
IStagedResource staged = createStagedResource(path);
if (staged.exists() && staged.getState() == State.DONE) {
resourcePathsCache.put(path, path);
resource = staged;
foundResourcePath = true;
}
}
} else if (foundResourcePath) {
resource = new StagedResource(directory, path, this);
resource = createStagedResource(path);
}
}
return resource;
Expand Down

0 comments on commit ea4cce7

Please sign in to comment.