Part 2 of ALF-9413 RSOLR 022: Fine-grained control of full-text indexing

- big switch to turn off content indexing is working for lucene sub-system - catches up (eventually) via FTS as expected
- includes further improvements to subsystem shutdown which also relates to: ALF-9079 RSOLR 019: Lucene to SOLR switchover administration
- lucene indexes can be deleted after subsystem shutdown
- at subsystem  star the  index rebuilds if required and restarts FTS on load
- subsystem shutdown requires more work if two lucene subsytems are ever to exist together
   - does not shutdown existing IndexInfo work nicely -> possible exceptions as IndexInfo resources are cremoved and cleaned up from those expecting them to be there ... may regrab resourcse

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@29097 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Andrew Hind
2011-07-16 11:15:25 +00:00
parent 248997cb48
commit 6018d8defa

View File

@@ -139,37 +139,51 @@ import com.werken.saxpath.XPathReader;
*/
public class IndexInfo implements IndexMonitor
{
public static void destroy()
public static synchronized void destroy()
{
timer.cancel();
timer = new Timer(true);
for(IndexInfo indexInfo : indexInfos.values())
{
try
indexInfo.destroyInstance();
}
indexInfos.clear();
ReferenceCountingReadOnlyIndexReaderFactory.destroy();
}
public void destroyInstance()
{
getWriteLock();
try
{
if(mainIndexReader != null)
{
((ReferenceCounting) indexInfo.mainIndexReader).setInvalidForReuse();
}
catch (IOException e)
{
// OK filed to close
}
indexInfo.mainIndexReader = null;
for(IndexReader reader : indexInfo.referenceCountingReadOnlyIndexReaders.values())
{
ReferenceCounting referenceCounting = (ReferenceCounting) reader;
try
{
referenceCounting.setInvalidForReuse();
((ReferenceCounting) mainIndexReader).setInvalidForReuse();
}
catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
// OK filed to close
}
mainIndexReader = null;
for(IndexReader reader : referenceCountingReadOnlyIndexReaders.values())
{
ReferenceCounting referenceCounting = (ReferenceCounting) reader;
try
{
referenceCounting.setInvalidForReuse();
}
catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
for(IndexReader reader : indexInfo.indexReaders.values())
for(IndexReader reader : indexReaders.values())
{
try
{
@@ -181,8 +195,9 @@ public class IndexInfo implements IndexMonitor
e.printStackTrace();
}
}
indexReaders.clear();
for(IndexWriter writer : indexInfo.indexWriters.values())
for(IndexWriter writer : indexWriters.values())
{
try
{
@@ -199,9 +214,41 @@ public class IndexInfo implements IndexMonitor
e.printStackTrace();
}
}
indexWriters.clear();
if(indexInfoRAF != null)
{
try
{
indexInfoRAF.close();
}
catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
if(indexInfoBackupRAF != null)
{
try
{
indexInfoBackupRAF.close();
}
catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
// TODO: should set some running flag .... to abort ungoing stuff
// at the moment it will die ungracefully ....
}
finally
{
releaseWriteLock();
}
indexInfos.clear();
ReferenceCountingReadOnlyIndexReaderFactory.destroy();
}
public static final String MAIN_READER = "MainReader";