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
- LuceneConfigIndexerException
public org.apache.lucene.index.IndexReader getDeltaIndexReader(String id) throws IOException
id
- StringIOException
public org.apache.lucene.index.IndexWriter getDeltaIndexWriter(String id, org.apache.lucene.analysis.Analyzer analyzer) throws IOException
id
- Stringanalyzer
- AnalyzerIOException
public void closeDeltaIndexReader(String id) throws IOException
id
- StringIOException
public void closeDeltaIndexWriter(String id) throws IOException
id
- StringIOException
public void closeDelta(String id) throws IOException
id
- StringIOException
public Set<String> getDeletions(String id) throws IOException
id
- StringIOException
public 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)IOException
public org.apache.lucene.index.IndexReader getMainIndexReferenceCountingReadOnlyIndexReader() throws IOException
IOException
public org.apache.lucene.index.IndexReader getMainIndexReferenceCountingReadOnlyIndexReader(String id, Set<String> deletions, Set<String> containerDeletions, boolean deleteOnlyNodes) throws IOException
id
- StringdeleteOnlyNodes
- booleanIOException
public void setStatus(String id, TransactionStatus state, Set<org.apache.lucene.index.Term> toDelete, Set<org.apache.lucene.index.Term> read) throws IOException
IOException
public <R> R doReadOnly(IndexInfo.LockWork<R> lockWork)
public static void main(String[] args) throws Throwable
args
- String[]Throwable
public String getRelativePath()
IndexMonitor
getRelativePath
in interface IndexMonitor
public Map<String,Integer> getStatusSnapshot()
IndexMonitor
getStatusSnapshot
in interface IndexMonitor
public long getActualSize() throws IOException
IndexMonitor
getActualSize
in interface IndexMonitor
IOException
- Signals that an I/O exception has occurred.public long getUsedSize() throws IOException
IndexMonitor
IndexMonitor.getActualSize()
may indicate that there are unused data files.getUsedSize
in interface IndexMonitor
IOException
- Signals that an I/O exception has occurred.public int getNumberOfDocuments() throws IOException
IndexMonitor
getNumberOfDocuments
in interface IndexMonitor
IOException
- Signals that an I/O exception has occurred.public int getNumberOfFields() throws IOException
IndexMonitor
getNumberOfFields
in interface IndexMonitor
IOException
- Signals that an I/O exception has occurred.public int getNumberOfIndexedFields() throws IOException
IndexMonitor
getNumberOfIndexedFields
in interface IndexMonitor
IOException
- Signals that an I/O exception has occurred.public void addApplicationListener(org.springframework.context.ApplicationListener listener)
IndexMonitor
addApplicationListener
in interface IndexMonitor
listener
- the listenerCopyright © 2005–2017 Alfresco Software. All rights reserved.