Package org.apache.maven.index.context
Interface IndexingContext
-
- All Known Implementing Classes:
AbstractIndexingContext
,DefaultIndexingContext
,MergedIndexingContext
public interface IndexingContext
An indexing context is representing artifact repository for indexing and searching. Indexing context is a statefull component, it keeps state of index readers and writers.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
INDEX_CHAIN_ID
An id that defines the current incremental chain.static java.lang.String
INDEX_CHUNK_COUNTER
A counter used to id the chunksstatic java.lang.String
INDEX_CHUNK_PREFIX
A prefix used to specify an incremental update chunk namestatic java.lang.String
INDEX_FILE_PREFIX
Standard name of the full repository index that is used when clients requesting index information have nothing to start with.static java.lang.String
INDEX_ID
A property name used to specify index idstatic java.lang.String
INDEX_LEGACY_TIMESTAMP
A property name used to specify legacy index timestamp (the last update time)static java.lang.String
INDEX_PACKER_PROPERTIES_FILE
static java.lang.String
INDEX_PROPERTY_PREFIX
A prefix used for all index property namesstatic java.lang.String
INDEX_REMOTE_PROPERTIES_FILE
static java.lang.String
INDEX_TIME_DAY_FORMAT
A date format used for incremental update chunk namesstatic java.lang.String
INDEX_TIME_FORMAT
A date format used for index timestampstatic java.lang.String
INDEX_TIMESTAMP
A property name used to specify index timtestampstatic java.lang.String
INDEX_UPDATER_PROPERTIES_FILE
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description org.apache.lucene.search.IndexSearcher
acquireIndexSearcher()
Acquires a fresh instance ofIndexSearcher
.void
close(boolean deleteFiles)
Shuts down this context.void
commit()
Commits changes to context, eventually refreshing readers/searchers too.java.util.Set<java.lang.String>
getAllGroups()
Gets all group names stored in the current indexing contextorg.apache.lucene.analysis.Analyzer
getAnalyzer()
Returns the Lucene Analyzer of this context used for by IndexWriter and IndexSearcher.GavCalculator
getGavCalculator()
Returns the GavCalculator for this Context.java.lang.String
getId()
Returns this indexing context id.java.util.List<IndexCreator>
getIndexCreators()
List of IndexCreators used in this context.org.apache.lucene.store.Directory
getIndexDirectory()
java.io.File
getIndexDirectoryFile()
java.lang.String
getIndexUpdateUrl()
Returns url for the index updateorg.apache.lucene.index.IndexWriter
getIndexWriter()
Returns the Lucene IndexWriter (thread safe, shared instance) of this context.java.io.File
getRepository()
Returns location for the local repository.java.lang.String
getRepositoryId()
Returns repository id.java.lang.String
getRepositoryUrl()
Returns public repository url.java.util.Set<java.lang.String>
getRootGroups()
Gets root group names stored in the current indexing contextint
getSize()
Returns a number that represents the "size" useful for doing comparisons between contexts (which one has more data indexed?).java.util.Date
getTimestamp()
Returns index update timeboolean
isReceivingUpdates()
Returns true if this context is receiving updates from remote via IndexUpdater.boolean
isSearchable()
Is the context searchable when doing "non-targeted" searches? Ie.void
merge(org.apache.lucene.store.Directory directory)
Merges content of given Lucene directory with this context.void
merge(org.apache.lucene.store.Directory directory, DocumentFilter filter)
Merges content of given Lucene directory with this context, but filters out the unwanted ones.void
optimize()
Optimizes index.void
purge()
Purge (cleans) the context, deletes/empties the index and restores the context to new/empty state.void
rebuildGroups()
Rebuilds stored group names from the indexvoid
releaseIndexSearcher(org.apache.lucene.search.IndexSearcher s)
Releases theIndexSearcher
instance.void
replace(org.apache.lucene.store.Directory directory)
Replaces the Lucene index with the one from supplied directory.void
replace(org.apache.lucene.store.Directory directory, java.util.Set<java.lang.String> allGroups, java.util.Set<java.lang.String> rootGroups)
void
rollback()
Rolls back changes to context, eventually refreshing readers/searchers too.void
setAllGroups(java.util.Collection<java.lang.String> groups)
Sets all group names stored in the current indexing contextvoid
setRootGroups(java.util.Collection<java.lang.String> groups)
Sets root group names stored in the current indexing contextvoid
setSearchable(boolean searchable)
Sets is the context searchable when doing "non-targeted" searches.void
updateTimestamp()
void
updateTimestamp(boolean save)
void
updateTimestamp(boolean save, java.util.Date date)
-
-
-
Field Detail
-
INDEX_FILE_PREFIX
static final java.lang.String INDEX_FILE_PREFIX
Standard name of the full repository index that is used when clients requesting index information have nothing to start with.- See Also:
- Constant Field Values
-
INDEX_REMOTE_PROPERTIES_FILE
static final java.lang.String INDEX_REMOTE_PROPERTIES_FILE
- See Also:
- Constant Field Values
-
INDEX_UPDATER_PROPERTIES_FILE
static final java.lang.String INDEX_UPDATER_PROPERTIES_FILE
- See Also:
- Constant Field Values
-
INDEX_PACKER_PROPERTIES_FILE
static final java.lang.String INDEX_PACKER_PROPERTIES_FILE
- See Also:
- Constant Field Values
-
INDEX_PROPERTY_PREFIX
static final java.lang.String INDEX_PROPERTY_PREFIX
A prefix used for all index property names- See Also:
- Constant Field Values
-
INDEX_ID
static final java.lang.String INDEX_ID
A property name used to specify index id- See Also:
- Constant Field Values
-
INDEX_LEGACY_TIMESTAMP
static final java.lang.String INDEX_LEGACY_TIMESTAMP
A property name used to specify legacy index timestamp (the last update time)- See Also:
- Constant Field Values
-
INDEX_TIMESTAMP
static final java.lang.String INDEX_TIMESTAMP
A property name used to specify index timtestamp- See Also:
- Constant Field Values
-
INDEX_CHUNK_PREFIX
static final java.lang.String INDEX_CHUNK_PREFIX
A prefix used to specify an incremental update chunk name- See Also:
- Constant Field Values
-
INDEX_TIME_FORMAT
static final java.lang.String INDEX_TIME_FORMAT
A date format used for index timestamp- See Also:
- Constant Field Values
-
INDEX_TIME_DAY_FORMAT
static final java.lang.String INDEX_TIME_DAY_FORMAT
A date format used for incremental update chunk names- See Also:
- Constant Field Values
-
INDEX_CHUNK_COUNTER
static final java.lang.String INDEX_CHUNK_COUNTER
A counter used to id the chunks- See Also:
- Constant Field Values
-
INDEX_CHAIN_ID
static final java.lang.String INDEX_CHAIN_ID
An id that defines the current incremental chain. If when checking remote repo, the index chain doesn't match you'll know that you need to download the full index- See Also:
- Constant Field Values
-
-
Method Detail
-
getId
java.lang.String getId()
Returns this indexing context id.
-
getRepositoryId
java.lang.String getRepositoryId()
Returns repository id.
-
getRepository
java.io.File getRepository()
Returns location for the local repository.
-
getRepositoryUrl
java.lang.String getRepositoryUrl()
Returns public repository url.
-
getIndexUpdateUrl
java.lang.String getIndexUpdateUrl()
Returns url for the index update
-
isSearchable
boolean isSearchable()
Is the context searchable when doing "non-targeted" searches? Ie. Should it take a part when searching without specifying context?- Returns:
-
setSearchable
void setSearchable(boolean searchable)
Sets is the context searchable when doing "non-targeted" searches.- Parameters:
searchable
-
-
getTimestamp
java.util.Date getTimestamp()
Returns index update time
-
updateTimestamp
void updateTimestamp() throws java.io.IOException
- Throws:
java.io.IOException
-
updateTimestamp
void updateTimestamp(boolean save) throws java.io.IOException
- Throws:
java.io.IOException
-
updateTimestamp
void updateTimestamp(boolean save, java.util.Date date) throws java.io.IOException
- Throws:
java.io.IOException
-
getSize
int getSize() throws java.io.IOException
Returns a number that represents the "size" useful for doing comparisons between contexts (which one has more data indexed?). The number return does not represent the count of ArtifactInfos, neither other "meaningful" info, it is purely to be used for inter-context comparisons only!- Returns:
- Throws:
java.io.IOException
-
acquireIndexSearcher
org.apache.lucene.search.IndexSearcher acquireIndexSearcher() throws java.io.IOException
Acquires a fresh instance ofIndexSearcher
. You have to release the received instance withreleaseIndexSearcher(IndexSearcher)
otherwise you are about to introduce leak.- Returns:
- Throws:
java.io.IOException
-
releaseIndexSearcher
void releaseIndexSearcher(org.apache.lucene.search.IndexSearcher s) throws java.io.IOException
Releases theIndexSearcher
instance.- Parameters:
s
-- Throws:
java.io.IOException
-
getIndexWriter
org.apache.lucene.index.IndexWriter getIndexWriter() throws java.io.IOException
Returns the Lucene IndexWriter (thread safe, shared instance) of this context.- Returns:
- indexWriter
- Throws:
java.io.IOException
-
getIndexCreators
java.util.List<IndexCreator> getIndexCreators()
List of IndexCreators used in this context.- Returns:
- list of index creators.
-
getAnalyzer
org.apache.lucene.analysis.Analyzer getAnalyzer()
Returns the Lucene Analyzer of this context used for by IndexWriter and IndexSearcher. Note: this method always creates a new instance of analyzer!- Returns:
-
commit
void commit() throws java.io.IOException
Commits changes to context, eventually refreshing readers/searchers too.- Throws:
java.io.IOException
-
rollback
void rollback() throws java.io.IOException
Rolls back changes to context, eventually refreshing readers/searchers too.- Throws:
java.io.IOException
-
optimize
void optimize() throws java.io.IOException
Optimizes index. According to Lucene 3.6+ Javadoc, there is no more sense to optimize, so this method might become "noop".- Throws:
java.io.IOException
-
close
void close(boolean deleteFiles) throws java.io.IOException
Shuts down this context.- Throws:
java.io.IOException
-
purge
void purge() throws java.io.IOException
Purge (cleans) the context, deletes/empties the index and restores the context to new/empty state.- Throws:
java.io.IOException
-
merge
void merge(org.apache.lucene.store.Directory directory) throws java.io.IOException
Merges content of given Lucene directory with this context.- Parameters:
directory
- - the directory to merge- Throws:
java.io.IOException
-
merge
void merge(org.apache.lucene.store.Directory directory, DocumentFilter filter) throws java.io.IOException
Merges content of given Lucene directory with this context, but filters out the unwanted ones.- Parameters:
directory
- - the directory to merge- Throws:
java.io.IOException
-
replace
void replace(org.apache.lucene.store.Directory directory) throws java.io.IOException
Replaces the Lucene index with the one from supplied directory.- Parameters:
directory
-- Throws:
java.io.IOException
-
replace
void replace(org.apache.lucene.store.Directory directory, java.util.Set<java.lang.String> allGroups, java.util.Set<java.lang.String> rootGroups) throws java.io.IOException
- Throws:
java.io.IOException
-
getIndexDirectory
org.apache.lucene.store.Directory getIndexDirectory()
-
getIndexDirectoryFile
java.io.File getIndexDirectoryFile()
-
getGavCalculator
GavCalculator getGavCalculator()
Returns the GavCalculator for this Context. Implies repository layout.
-
setAllGroups
void setAllGroups(java.util.Collection<java.lang.String> groups) throws java.io.IOException
Sets all group names stored in the current indexing context- Throws:
java.io.IOException
-
getAllGroups
java.util.Set<java.lang.String> getAllGroups() throws java.io.IOException
Gets all group names stored in the current indexing context- Throws:
java.io.IOException
-
setRootGroups
void setRootGroups(java.util.Collection<java.lang.String> groups) throws java.io.IOException
Sets root group names stored in the current indexing context- Throws:
java.io.IOException
-
getRootGroups
java.util.Set<java.lang.String> getRootGroups() throws java.io.IOException
Gets root group names stored in the current indexing context- Throws:
java.io.IOException
-
rebuildGroups
void rebuildGroups() throws java.io.IOException
Rebuilds stored group names from the index- Throws:
java.io.IOException
-
isReceivingUpdates
boolean isReceivingUpdates()
Returns true if this context is receiving updates from remote via IndexUpdater.- Returns:
-
-