com.atlassian.bamboo.index
Class IndexerServiceImpl

java.lang.Object
  extended by com.atlassian.bamboo.index.IndexerServiceImpl
All Implemented Interfaces:
IndexerService, org.springframework.beans.factory.DisposableBean

public class IndexerServiceImpl
extends Object
implements IndexerService, org.springframework.beans.factory.DisposableBean

This service takes care of adding/updating/removing documents from Lucene. All indexers should use it. Some facts - Lucene doesn't allow concurrent writes on the same connection and design decisions - each document add/update/remove operation is submitted to ExecutorService - ExecutorServices are created for Lucene connections - per Lucene connection ExecutorService is single threaded and has queue capacity limited to MAX_QUEUE_SIZE_PER_CONNECTION - if the capacity of ExecutorService queue is exceeded, the thread that submits add/update/remove operation will be blocked


Constructor Summary
IndexerServiceImpl()
           
 
Method Summary
 com.google.common.util.concurrent.ListenableFuture addDocument(IndexerContext indexerContext, org.apache.lucene.document.Document document)
          Submit add document request
 com.google.common.util.concurrent.ListenableFuture addDocuments(IndexerContext indexerContext, Iterable<org.apache.lucene.document.Document> documents)
          Submit add documents request
 com.google.common.util.concurrent.ListenableFuture batchUpdate(IndexerContext indexerContext, IndexerTask task)
          Submit batch update request
static
<V> com.google.common.util.concurrent.ListenableFutureTask<V>
createAuthorisedTask(Callable<V> callable)
           
 IndexerContext createNewIndexerContext(com.atlassian.bonnie.ILuceneConnection connection)
          Create new default indexer context.
 com.google.common.util.concurrent.ListenableFuture deleteDocuments(IndexerContext indexerContext, org.apache.lucene.index.Term term)
          Submit delete documents request
 void destroy()
           
 void flushAndUnlockIndexerQueue(IndexerContext indexerContext)
          Unlock indexer and submit for execution all operations that were queued while index was locked
<T> List<T>
getMatchingDocuments(IndexerContext indexerContext, IndexSearcherTask<T> innerTask)
          Submit a custom search task for execution
 List<org.apache.lucene.document.Document> getMatchingDocuments(IndexerContext indexerContext, org.apache.lucene.search.Query query)
          Submit a document search query
 IndexerContext lockIndexerQueue(com.atlassian.bonnie.ILuceneConnection connection)
          Lock indexer and return a context that will allow executing operations while indexer is locked.
 com.google.common.util.concurrent.ListenableFuture recreateIndexDirectory(IndexerContext indexerContext)
          Submit recreate index directory request
 com.google.common.util.concurrent.ListenableFuture updateDocument(IndexerContext indexerContext, org.apache.lucene.index.Term term, org.apache.lucene.document.Document document)
          Submit update document request
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IndexerServiceImpl

public IndexerServiceImpl()
Method Detail

destroy

public void destroy()
Specified by:
destroy in interface org.springframework.beans.factory.DisposableBean

createNewIndexerContext

@NotNull
public IndexerContext createNewIndexerContext(@NotNull
                                                      com.atlassian.bonnie.ILuceneConnection connection)
Description copied from interface: IndexerService
Create new default indexer context. Operations executed with this context might be queued when indexer is locked.

Specified by:
createNewIndexerContext in interface IndexerService
Parameters:
connection - Lucene connection
Returns:
indexer context

lockIndexerQueue

@NotNull
public IndexerContext lockIndexerQueue(@NotNull
                                               com.atlassian.bonnie.ILuceneConnection connection)
Description copied from interface: IndexerService
Lock indexer and return a context that will allow executing operations while indexer is locked. All operations submitted with returned context will be scheduled for execution immediately, operations submitted with default context will be queued until indexer is unlocked. This is used for reindexing

Specified by:
lockIndexerQueue in interface IndexerService
Parameters:
connection - Lucene connection
Returns:
indexer context

flushAndUnlockIndexerQueue

public void flushAndUnlockIndexerQueue(@NotNull
                                       IndexerContext indexerContext)
Description copied from interface: IndexerService
Unlock indexer and submit for execution all operations that were queued while index was locked

Specified by:
flushAndUnlockIndexerQueue in interface IndexerService
Parameters:
indexerContext - indexer context

getMatchingDocuments

@NotNull
public List<org.apache.lucene.document.Document> getMatchingDocuments(@NotNull
                                                                              IndexerContext indexerContext,
                                                                              @NotNull
                                                                              org.apache.lucene.search.Query query)
Description copied from interface: IndexerService
Submit a document search query

Specified by:
getMatchingDocuments in interface IndexerService
Parameters:
indexerContext - indexer context
query - query that will be executed on Lucene connection
Returns:
list of documents matching the query

getMatchingDocuments

@NotNull
public <T> List<T> getMatchingDocuments(@NotNull
                                                IndexerContext indexerContext,
                                                @NotNull
                                                IndexSearcherTask<T> innerTask)
Description copied from interface: IndexerService
Submit a custom search task for execution

Specified by:
getMatchingDocuments in interface IndexerService
Parameters:
indexerContext - indexer context
innerTask - search task to get executed
Returns:
list of documents returned by the tasl

addDocument

@NotNull
public com.google.common.util.concurrent.ListenableFuture addDocument(@NotNull
                                                                              IndexerContext indexerContext,
                                                                              @NotNull
                                                                              org.apache.lucene.document.Document document)
Description copied from interface: IndexerService
Submit add document request

Specified by:
addDocument in interface IndexerService
Parameters:
indexerContext - indexer context
document - document to be added to index
Returns:
ListenableFuture that will finish when document is added to index

addDocuments

@NotNull
public com.google.common.util.concurrent.ListenableFuture addDocuments(@NotNull
                                                                               IndexerContext indexerContext,
                                                                               @NotNull
                                                                               Iterable<org.apache.lucene.document.Document> documents)
Description copied from interface: IndexerService
Submit add documents request

Specified by:
addDocuments in interface IndexerService
Parameters:
indexerContext - indexer context
documents - documents to be added to index
Returns:
ListenableFuture that will finish when all documents is added to index

updateDocument

@NotNull
public com.google.common.util.concurrent.ListenableFuture updateDocument(@NotNull
                                                                                 IndexerContext indexerContext,
                                                                                 @NotNull
                                                                                 org.apache.lucene.index.Term term,
                                                                                 @NotNull
                                                                                 org.apache.lucene.document.Document document)
Description copied from interface: IndexerService
Submit update document request

Specified by:
updateDocument in interface IndexerService
Parameters:
indexerContext - indexer context
term - term that identifies document that is about to be updated
document - new document that will be added to index
Returns:
ListenableFuture that will finish when document is update

deleteDocuments

@NotNull
public com.google.common.util.concurrent.ListenableFuture deleteDocuments(@NotNull
                                                                                  IndexerContext indexerContext,
                                                                                  @NotNull
                                                                                  org.apache.lucene.index.Term term)
Description copied from interface: IndexerService
Submit delete documents request

Specified by:
deleteDocuments in interface IndexerService
Parameters:
indexerContext - indexer context
term - term that identifies documents to be deleted
Returns:
ListenableFuture that will finish when documents will be deleted

batchUpdate

@NotNull
public com.google.common.util.concurrent.ListenableFuture batchUpdate(@NotNull
                                                                              IndexerContext indexerContext,
                                                                              @NotNull
                                                                              IndexerTask task)
Description copied from interface: IndexerService
Submit batch update request

Specified by:
batchUpdate in interface IndexerService
Parameters:
indexerContext - indexer context
task - task to be executed within ILuceneConnection.withBatchUpdate(com.atlassian.bonnie.ILuceneConnection.BatchUpdateAction)
Returns:
ListenableFuture that will finish when batch update is completed

recreateIndexDirectory

@NotNull
public com.google.common.util.concurrent.ListenableFuture recreateIndexDirectory(@NotNull
                                                                                         IndexerContext indexerContext)
Description copied from interface: IndexerService
Submit recreate index directory request

Specified by:
recreateIndexDirectory in interface IndexerService
Parameters:
indexerContext - indexer context
Returns:
ListenableFuture that will finish when request is completed

createAuthorisedTask

public static <V> com.google.common.util.concurrent.ListenableFutureTask<V> createAuthorisedTask(@NotNull
                                                                                                 Callable<V> callable)


Copyright © 2015 Atlassian Software Systems Pty Ltd. All rights reserved.