mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merged HEAD-BUG-FIX (4.3/Cloud) to HEAD (4.3/Cloud)
60177: Merged V4.2-BUG-FIX (4.2.2) to HEAD-BUG-FIX (Cloud/4.3) 60156: Merged V4.1-BUG-FIX (4.1.8) to V4.2-BUG-FIX (4.2.2) 60155: MNT-10399 AutomaticBuilds: Alfresco doesn't shut down because of FullTextSearchIndexerImpl - TABs to spaces git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@62296 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -84,52 +84,52 @@ public class FullTextSearchIndexerImpl implements FTSIndexerAware, FullTextSearc
|
|||||||
// Helper class to keep track of which Thread has the lock, so we can give up if it dies.
|
// Helper class to keep track of which Thread has the lock, so we can give up if it dies.
|
||||||
private abstract class SynchronizedHelper<Result>
|
private abstract class SynchronizedHelper<Result>
|
||||||
{
|
{
|
||||||
public Result executeNoInterruptedException()
|
public Result executeNoInterruptedException()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
return execute();
|
return execute();
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
// ignore
|
// ignore
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("finally")
|
@SuppressWarnings("finally")
|
||||||
public Result execute() throws InterruptedException
|
public Result execute() throws InterruptedException
|
||||||
{
|
{
|
||||||
Thread origThreadHoldingLock = threadHoldingLock;
|
Thread origThreadHoldingLock = threadHoldingLock;
|
||||||
threadHoldingLock = Thread.currentThread();
|
threadHoldingLock = Thread.currentThread();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return run();
|
return run();
|
||||||
}
|
}
|
||||||
catch (ThreadDeath threadDeath)
|
catch (ThreadDeath threadDeath)
|
||||||
{
|
{
|
||||||
origThreadHoldingLock = null;
|
origThreadHoldingLock = null;
|
||||||
throw threadDeath;
|
throw threadDeath;
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
threadHoldingLock = origThreadHoldingLock;
|
threadHoldingLock = origThreadHoldingLock;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract Result run() throws InterruptedException;
|
public abstract Result run() throws InterruptedException;
|
||||||
|
|
||||||
// Does a wait(10000). Returns true if the Thread that had the lock has died.
|
// Does a wait(10000). Returns true if the Thread that had the lock has died.
|
||||||
public boolean waitAndCheckForSubsystemShutdown() throws InterruptedException
|
public boolean waitAndCheckForSubsystemShutdown() throws InterruptedException
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
threadHoldingLock = null;
|
threadHoldingLock = null;
|
||||||
FullTextSearchIndexerImpl.this.wait(10000);
|
FullTextSearchIndexerImpl.this.wait(10000);
|
||||||
return threadHoldingLock != null && !threadHoldingLock.isAlive();
|
return threadHoldingLock != null && !threadHoldingLock.isAlive();
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
threadHoldingLock = Thread.currentThread();
|
threadHoldingLock = Thread.currentThread();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -148,18 +148,18 @@ public class FullTextSearchIndexerImpl implements FTSIndexerAware, FullTextSearc
|
|||||||
*/
|
*/
|
||||||
public synchronized void requiresIndex(final StoreRef storeRef)
|
public synchronized void requiresIndex(final StoreRef storeRef)
|
||||||
{
|
{
|
||||||
new SynchronizedHelper<Void>()
|
new SynchronizedHelper<Void>()
|
||||||
{
|
{
|
||||||
public Void run()
|
public Void run()
|
||||||
{
|
{
|
||||||
if(s_logger.isDebugEnabled())
|
if(s_logger.isDebugEnabled())
|
||||||
{
|
{
|
||||||
s_logger.debug("FTS index request for "+storeRef);
|
s_logger.debug("FTS index request for "+storeRef);
|
||||||
}
|
}
|
||||||
requiresIndex.add(storeRef);
|
requiresIndex.add(storeRef);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}.executeNoInterruptedException();
|
}.executeNoInterruptedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -169,10 +169,10 @@ public class FullTextSearchIndexerImpl implements FTSIndexerAware, FullTextSearc
|
|||||||
*/
|
*/
|
||||||
public synchronized void indexCompleted(final StoreRef storeRef, final int remaining, final Throwable t)
|
public synchronized void indexCompleted(final StoreRef storeRef, final int remaining, final Throwable t)
|
||||||
{
|
{
|
||||||
new SynchronizedHelper<Void>()
|
new SynchronizedHelper<Void>()
|
||||||
{
|
{
|
||||||
public Void run()
|
public Void run()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if(s_logger.isDebugEnabled())
|
if(s_logger.isDebugEnabled())
|
||||||
@@ -191,11 +191,11 @@ public class FullTextSearchIndexerImpl implements FTSIndexerAware, FullTextSearc
|
|||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
FullTextSearchIndexerImpl.this.notifyAll();
|
FullTextSearchIndexerImpl.this.notifyAll();
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}.executeNoInterruptedException();
|
}.executeNoInterruptedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -205,11 +205,11 @@ public class FullTextSearchIndexerImpl implements FTSIndexerAware, FullTextSearc
|
|||||||
*/
|
*/
|
||||||
public synchronized void pause() throws InterruptedException
|
public synchronized void pause() throws InterruptedException
|
||||||
{
|
{
|
||||||
new SynchronizedHelper<Void>()
|
new SynchronizedHelper<Void>()
|
||||||
{
|
{
|
||||||
public Void run() throws InterruptedException
|
public Void run() throws InterruptedException
|
||||||
{
|
{
|
||||||
pauseCount++;
|
pauseCount++;
|
||||||
if(s_logger.isTraceEnabled())
|
if(s_logger.isTraceEnabled())
|
||||||
{
|
{
|
||||||
s_logger.trace("..Waiting "+pauseCount+" id is "+this);
|
s_logger.trace("..Waiting "+pauseCount+" id is "+this);
|
||||||
@@ -223,7 +223,7 @@ public class FullTextSearchIndexerImpl implements FTSIndexerAware, FullTextSearc
|
|||||||
|
|
||||||
if (waitAndCheckForSubsystemShutdown())
|
if (waitAndCheckForSubsystemShutdown())
|
||||||
{
|
{
|
||||||
indexing.clear();
|
indexing.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pauseCount--;
|
pauseCount--;
|
||||||
@@ -236,9 +236,9 @@ public class FullTextSearchIndexerImpl implements FTSIndexerAware, FullTextSearc
|
|||||||
{
|
{
|
||||||
s_logger.trace("..Remaining "+pauseCount +" paused = "+paused+" id is "+this);
|
s_logger.trace("..Remaining "+pauseCount +" paused = "+paused+" id is "+this);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}.execute();
|
}.execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -248,10 +248,10 @@ public class FullTextSearchIndexerImpl implements FTSIndexerAware, FullTextSearc
|
|||||||
*/
|
*/
|
||||||
public synchronized void resume() throws InterruptedException
|
public synchronized void resume() throws InterruptedException
|
||||||
{
|
{
|
||||||
new SynchronizedHelper<Void>()
|
new SynchronizedHelper<Void>()
|
||||||
{
|
{
|
||||||
public Void run() throws InterruptedException
|
public Void run() throws InterruptedException
|
||||||
{
|
{
|
||||||
if (pauseCount == 0)
|
if (pauseCount == 0)
|
||||||
{
|
{
|
||||||
if(s_logger.isTraceEnabled())
|
if(s_logger.isTraceEnabled())
|
||||||
@@ -271,23 +271,23 @@ public class FullTextSearchIndexerImpl implements FTSIndexerAware, FullTextSearc
|
|||||||
|
|
||||||
if (waitAndCheckForSubsystemShutdown())
|
if (waitAndCheckForSubsystemShutdown())
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
paused = false;
|
paused = false;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}.execute();
|
}.execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
private synchronized boolean isPaused() throws InterruptedException
|
private synchronized boolean isPaused() throws InterruptedException
|
||||||
{
|
{
|
||||||
return new SynchronizedHelper<Boolean>()
|
return new SynchronizedHelper<Boolean>()
|
||||||
{
|
{
|
||||||
public Boolean run() throws InterruptedException
|
public Boolean run() throws InterruptedException
|
||||||
{
|
{
|
||||||
if (pauseCount == 0)
|
if (pauseCount == 0)
|
||||||
{
|
{
|
||||||
return paused;
|
return paused;
|
||||||
@@ -298,13 +298,13 @@ public class FullTextSearchIndexerImpl implements FTSIndexerAware, FullTextSearc
|
|||||||
{
|
{
|
||||||
if (waitAndCheckForSubsystemShutdown())
|
if (waitAndCheckForSubsystemShutdown())
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return paused;
|
return paused;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}.execute();
|
}.execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -378,10 +378,10 @@ public class FullTextSearchIndexerImpl implements FTSIndexerAware, FullTextSearc
|
|||||||
|
|
||||||
private synchronized StoreRef getNextRef()
|
private synchronized StoreRef getNextRef()
|
||||||
{
|
{
|
||||||
return new SynchronizedHelper<StoreRef>()
|
return new SynchronizedHelper<StoreRef>()
|
||||||
{
|
{
|
||||||
public StoreRef run()
|
public StoreRef run()
|
||||||
{
|
{
|
||||||
if (paused || (pauseCount > 0))
|
if (paused || (pauseCount > 0))
|
||||||
{
|
{
|
||||||
if(s_logger.isTraceEnabled())
|
if(s_logger.isTraceEnabled())
|
||||||
@@ -410,8 +410,8 @@ public class FullTextSearchIndexerImpl implements FTSIndexerAware, FullTextSearc
|
|||||||
}
|
}
|
||||||
|
|
||||||
return nextStoreRef;
|
return nextStoreRef;
|
||||||
}
|
}
|
||||||
}.executeNoInterruptedException();
|
}.executeNoInterruptedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user