Skip to content
Snippets Groups Projects
Commit 5816be7c authored by brinn's avatar brinn
Browse files

change: make rereading of faulty paths file only report to logs if the faulty...

change: make rereading of faulty paths file only report to logs if the faulty paths file actually changed

SVN: 23317
parent 8e5899e4
No related branches found
No related tags found
No related merge requests found
...@@ -44,8 +44,8 @@ import ch.systemsx.cisd.common.utilities.IStopSignaler; ...@@ -44,8 +44,8 @@ import ch.systemsx.cisd.common.utilities.IStopSignaler;
public final class FaultyPathDirectoryScanningHandler implements IDirectoryScanningHandler public final class FaultyPathDirectoryScanningHandler implements IDirectoryScanningHandler
{ {
private static final Logger operationLog = private static final Logger operationLog = LogFactory.getLogger(LogCategory.OPERATION,
LogFactory.getLogger(LogCategory.OPERATION, FaultyPathDirectoryScanningHandler.class); FaultyPathDirectoryScanningHandler.class);
private final Set<StoreItem> faultyPaths; private final Set<StoreItem> faultyPaths;
...@@ -62,7 +62,7 @@ public final class FaultyPathDirectoryScanningHandler implements IDirectoryScann ...@@ -62,7 +62,7 @@ public final class FaultyPathDirectoryScanningHandler implements IDirectoryScann
this.faultyPathsFile = new File(faultyPathDirectory, Constants.FAULTY_PATH_FILENAME); this.faultyPathsFile = new File(faultyPathDirectory, Constants.FAULTY_PATH_FILENAME);
this.stopSignaler = stopSignaler; this.stopSignaler = stopSignaler;
} }
private Set<String> faultyPathsAsStrings(IScannedStore scannedStore) private Set<String> faultyPathsAsStrings(IScannedStore scannedStore)
{ {
final Set<String> faultyPathStrings = new HashSet<String>(faultyPaths.size()); final Set<String> faultyPathStrings = new HashSet<String>(faultyPaths.size());
...@@ -72,7 +72,7 @@ public final class FaultyPathDirectoryScanningHandler implements IDirectoryScann ...@@ -72,7 +72,7 @@ public final class FaultyPathDirectoryScanningHandler implements IDirectoryScann
} }
return faultyPathStrings; return faultyPathStrings;
} }
private void setFaultyPathsFromStrings(IScannedStore scannedStore, Set<String> faultyPathStrings) private void setFaultyPathsFromStrings(IScannedStore scannedStore, Set<String> faultyPathStrings)
{ {
faultyPaths.clear(); faultyPaths.clear();
...@@ -89,23 +89,33 @@ public final class FaultyPathDirectoryScanningHandler implements IDirectoryScann ...@@ -89,23 +89,33 @@ public final class FaultyPathDirectoryScanningHandler implements IDirectoryScann
// Handles manual manipulation. // Handles manual manipulation.
if (faultyPathsFile.lastModified() > faultyPathsLastChanged) if (faultyPathsFile.lastModified() > faultyPathsLastChanged)
{ {
faultyPaths.clear();
final Set<String> faultyPathStrings = new HashSet<String>(); final Set<String> faultyPathStrings = new HashSet<String>();
CollectionIO.readCollection(faultyPathsFile, faultyPathStrings); CollectionIO.readCollection(faultyPathsFile, faultyPathStrings);
final Set<StoreItem> faultyPathsCopy =
operationLog.isInfoEnabled() ? new HashSet<StoreItem>(faultyPaths) : null;
setFaultyPathsFromStrings(scannedStore, faultyPathStrings); setFaultyPathsFromStrings(scannedStore, faultyPathStrings);
faultyPathsLastChanged = faultyPathsFile.lastModified(); faultyPathsLastChanged = faultyPathsFile.lastModified();
if (operationLog.isInfoEnabled()) if (operationLog.isInfoEnabled())
{ {
operationLog.info(String.format( if (faultyPaths.equals(faultyPathsCopy) == false)
"Reread faulty paths file '%s'. New entries are '%s'.", {
getLocationDescription(faultyPathsFile), CollectionUtils.abbreviate( operationLog.info(String.format(
faultyPaths, 10))); "Reread faulty paths file '%s'. New entries are '%s'.",
getLocationDescription(faultyPathsFile),
CollectionUtils.abbreviate(faultyPaths, 10)));
}
} }
} }
} else } else
{ {
// Handles manual removal. // Handles manual removal.
faultyPaths.clear(); faultyPaths.clear();
if (operationLog.isInfoEnabled())
{
operationLog.info(String.format(
"Faulty paths file '%s' has been removed manually.",
getLocationDescription(faultyPathsFile)));
}
} }
} }
...@@ -127,9 +137,8 @@ public final class FaultyPathDirectoryScanningHandler implements IDirectoryScann ...@@ -127,9 +137,8 @@ public final class FaultyPathDirectoryScanningHandler implements IDirectoryScann
if (operationLog.isDebugEnabled()) if (operationLog.isDebugEnabled())
{ {
final String path = scannedStore.getLocationDescription(item); final String path = scannedStore.getLocationDescription(item);
operationLog.debug(String.format( operationLog.debug(String.format("Path '%s' has been added to faulty paths file '%s'",
"Path '%s' has been added to faulty paths file '%s'", path, path, faultyPathsFile.getAbsolutePath()));
faultyPathsFile.getAbsolutePath()));
} }
faultyPaths.add(item); faultyPaths.add(item);
refreshFaultyPathsFile(scannedStore); refreshFaultyPathsFile(scannedStore);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment