Skip to content
Snippets Groups Projects
Commit 1a81b264 authored by brinn's avatar brinn
Browse files

[DMV-31] ensure the DirectoryScanningTimerTask only finishes when no files /...

[DMV-31] ensure the DirectoryScanningTimerTask only finishes when no files / directories are left for processing (avoid going 'idle' in this case)

SVN: 7192
parent 3f45db81
No related branches found
No related tags found
No related merge requests found
...@@ -200,51 +200,55 @@ public final class DirectoryScanningTimerTask extends TimerTask ...@@ -200,51 +200,55 @@ public final class DirectoryScanningTimerTask extends TimerTask
} }
try try
{ {
final StoreItem[] storeItems = listStoreItems(); int numberOfItems;
directoryScanningHandler.beforeHandle(); do
int len = storeItems.length;
for (int i = 0; i < len; i++)
{ {
final StoreItem storeItem = storeItems[i]; final StoreItem[] storeItems = listStoreItems();
if (stopRun) numberOfItems = storeItems.length;
directoryScanningHandler.beforeHandle();
for (int i = 0; i < numberOfItems; i++)
{ {
if (operationLog.isDebugEnabled()) final StoreItem storeItem = storeItems[i];
if (stopRun)
{ {
operationLog.debug(String.format("Scan of store '%s' has been cancelled. " if (operationLog.isDebugEnabled())
+ "Following items have NOT been handled: %s.", sourceDirectory, {
CollectionUtils.abbreviate(ArrayUtils.subarray(storeItems, i + 1, operationLog.debug(String.format("Scan of store '%s' has been cancelled. "
len), 10))); + "Following items have NOT been handled: %s.", sourceDirectory,
CollectionUtils.abbreviate(ArrayUtils.subarray(storeItems, i + 1,
numberOfItems), 10)));
}
return;
} }
return; if (directoryScanningHandler.mayHandle(sourceDirectory, storeItem))
} {
if (directoryScanningHandler.mayHandle(sourceDirectory, storeItem)) try
{ {
try storeHandler.handle(storeItem);
if (operationLog.isTraceEnabled())
{
operationLog.trace(String.format(
"Following store item '%s' has been handled.", storeItem));
}
} catch (final Exception ex)
{
// Do not stop when processing of one file has failed,
// continue with other files.
printNotification(ex);
} finally
{
directoryScanningHandler.finishItemHandle(sourceDirectory, storeItem);
}
} else
{ {
storeHandler.handle(storeItem);
if (operationLog.isTraceEnabled()) if (operationLog.isTraceEnabled())
{ {
operationLog.trace(String.format( operationLog.trace(String.format(
"Following store item '%s' has been handled.", storeItem)); "Following store item '%s' has NOT been handled.", storeItem));
} }
} catch (final Exception ex)
{
// Do not stop when processing of one file has failed,
// continue with other files.
printNotification(ex);
} finally
{
directoryScanningHandler.finishItemHandle(sourceDirectory, storeItem);
}
} else
{
if (operationLog.isTraceEnabled())
{
operationLog.trace(String.format(
"Following store item '%s' has NOT been handled.", storeItem));
} }
} }
} } while (numberOfItems > 0);
} catch (final Exception ex) } catch (final Exception ex)
{ {
printNotification(ex); printNotification(ex);
......
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