public class IndexInfo extends Object implements IndexMonitor
The index structure is duplicated to two files. If one is currupted the second is used.
TODO:
| Modifier and Type | Class and Description |
|---|---|
static interface |
IndexInfo.LockWork<Result> |
| Modifier and Type | Field and Description |
|---|---|
static String |
MAIN_READER |
| Modifier and Type | Method and Description |
|---|---|
void |
addApplicationListener(org.springframework.context.ApplicationListener listener)
Registers a listener for events on this index.
|
void |
closeDelta(String id)
Make sure the writer and reader for TX data are closed.
|
void |
closeDeltaIndexReader(String id)
Manage closing and unregistering an index reader.
|
void |
closeDeltaIndexWriter(String id)
Manage closing and unregistering an index writer .
|
void |
delete(String deltaId) |
static void |
destroy() |
void |
destroyInstance() |
<R> R |
doReadOnly(IndexInfo.LockWork<R> lockWork) |
long |
getActualSize()
Gets the actual size of the index in bytes.
|
Set<String> |
getDeletions(String id)
Get the deletions for a given index (there is no check if they should be applied that is up to the calling layer)
|
org.apache.lucene.index.IndexReader |
getDeltaIndexReader(String id)
This method should only be called from one thread as it is bound to a transaction.
|
org.apache.lucene.index.IndexWriter |
getDeltaIndexWriter(String id,
org.apache.lucene.analysis.Analyzer analyzer)
Manage getting a lucene index writer for transactional data - looks after registration and checking there is no
active reader.
|
static IndexInfo |
getIndexInfo(File file,
LuceneConfig config)
Get the IndexInfo object based in the given directory.
|
org.apache.lucene.index.IndexReader |
getMainIndexReferenceCountingReadOnlyIndexReader()
Get the main reader for committed index data
|
org.apache.lucene.index.IndexReader |
getMainIndexReferenceCountingReadOnlyIndexReader(String id,
Set<String> deletions,
Set<String> containerDeletions,
boolean deleteOnlyNodes)
Get the main index reader augmented with the specified TX data As above but we add the TX data
|
int |
getNumberOfDocuments()
Gets the number of documents in the index.
|
int |
getNumberOfFields()
Gets the number of fields known to the index.
|
int |
getNumberOfIndexedFields()
Gets the number of indexed fields.
|
String |
getRelativePath()
Gets the relative path of the index directory.
|
Map<String,Integer> |
getStatusSnapshot()
Gets a snapshot of the statuses of the individual entries in this index.
|
long |
getUsedSize()
Gets the size used on disk by the index directory.
|
static void |
main(String[] args)
Helper to print out index information
|
void |
setPreparedState(String id,
Set<String> toDelete,
Set<String> containersToDelete,
long documents,
boolean deleteNodesOnly)
Set the aux data for the index entry for a transactional unit of work.
|
void |
setStatus(String id,
TransactionStatus state,
Set<org.apache.lucene.index.Term> toDelete,
Set<org.apache.lucene.index.Term> read) |
String |
toString() |
public static final String MAIN_READER
public static void destroy()
public void destroyInstance()
public void delete(String deltaId)
public static IndexInfo getIndexInfo(File file, LuceneConfig config) throws IndexerException
file - Fileconfig - LuceneConfigIndexerExceptionpublic org.apache.lucene.index.IndexReader getDeltaIndexReader(String id) throws IOException
id - StringIOExceptionpublic org.apache.lucene.index.IndexWriter getDeltaIndexWriter(String id, org.apache.lucene.analysis.Analyzer analyzer) throws IOException
id - Stringanalyzer - AnalyzerIOExceptionpublic void closeDeltaIndexReader(String id) throws IOException
id - StringIOExceptionpublic void closeDeltaIndexWriter(String id) throws IOException
id - StringIOExceptionpublic void closeDelta(String id) throws IOException
id - StringIOExceptionpublic Set<String> getDeletions(String id) throws IOException
id - StringIOExceptionpublic void setPreparedState(String id, Set<String> toDelete, Set<String> containersToDelete, long documents, boolean deleteNodesOnly) throws IOException
id - -
the tx idtoDelete - -
noderefs that should be deleted from previous indexes (not this one)documents - -
the number of docs in the indexdeleteNodesOnly - -
should deletions on apply to nodes (ie not to containers)IOExceptionpublic org.apache.lucene.index.IndexReader getMainIndexReferenceCountingReadOnlyIndexReader()
throws IOException
IOExceptionpublic org.apache.lucene.index.IndexReader getMainIndexReferenceCountingReadOnlyIndexReader(String id, Set<String> deletions, Set<String> containerDeletions, boolean deleteOnlyNodes) throws IOException
id - StringdeleteOnlyNodes - booleanIOExceptionpublic void setStatus(String id, TransactionStatus state, Set<org.apache.lucene.index.Term> toDelete, Set<org.apache.lucene.index.Term> read) throws IOException
IOExceptionpublic <R> R doReadOnly(IndexInfo.LockWork<R> lockWork)
public static void main(String[] args) throws Throwable
args - String[]Throwablepublic String getRelativePath()
IndexMonitorgetRelativePath in interface IndexMonitorpublic Map<String,Integer> getStatusSnapshot()
IndexMonitorgetStatusSnapshot in interface IndexMonitorpublic long getActualSize()
throws IOException
IndexMonitorgetActualSize in interface IndexMonitorIOException - Signals that an I/O exception has occurred.public long getUsedSize()
throws IOException
IndexMonitorIndexMonitor.getActualSize() may indicate that there are unused data files.getUsedSize in interface IndexMonitorIOException - Signals that an I/O exception has occurred.public int getNumberOfDocuments()
throws IOException
IndexMonitorgetNumberOfDocuments in interface IndexMonitorIOException - Signals that an I/O exception has occurred.public int getNumberOfFields()
throws IOException
IndexMonitorgetNumberOfFields in interface IndexMonitorIOException - Signals that an I/O exception has occurred.public int getNumberOfIndexedFields()
throws IOException
IndexMonitorgetNumberOfIndexedFields in interface IndexMonitorIOException - Signals that an I/O exception has occurred.public void addApplicationListener(org.springframework.context.ApplicationListener listener)
IndexMonitoraddApplicationListener in interface IndexMonitorlistener - the listenerCopyright © 2005–2018 Alfresco Software. All rights reserved.