Package ch.rswk.meta.engine
Class LuceneService
java.lang.Object
com.google.common.util.concurrent.AbstractExecutionThreadService
- All Implemented Interfaces:
EngineServices.ConfigurableService<LuceneService.LuceneServiceConfig>,EngineServices.InfoProvidingService,com.google.common.util.concurrent.Service
public class LuceneService
extends AbstractEngineWorkQueueService<LuceneService.LuceneServiceConfig,LuceneService.WorkUnit,Object>
LuceneService handles writing and searching a single Lucene index via a work
queue.
Multiple instances of this service exist in any given runtime. Services that want to have their own Lucene index must create their own
instance of LuceneService.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordclassstatic final recordstatic final recordstatic final record(package private) static final recordprivate classNested classes/interfaces inherited from class ch.rswk.meta.engine.AbstractEngineWorkQueueService
AbstractEngineWorkQueueService.ShutdownTypeNested classes/interfaces inherited from interface com.google.common.util.concurrent.Service
com.google.common.util.concurrent.Service.Listener, com.google.common.util.concurrent.Service.State -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate org.apache.lucene.analysis.Analyzerprivate static final intprivate static final Stringprivate static final Stringprivate ScheduledFuture<?> private com.codahale.metrics.Timerprivate org.apache.lucene.store.FSDirectoryprivate final com.google.common.util.concurrent.Monitorprivate final org.slf4j.Loggerprivate final LuceneService.LuceneContextprivate static final intprivate static final intprivate com.codahale.metrics.Timerprivate org.apache.lucene.search.IndexSearcherprivate static final Stringprivate static final Stringprivate final AtomicBooleanprivate org.apache.lucene.index.IndexWriterFields inherited from class ch.rswk.meta.engine.AbstractEngineWorkQueueService
capacity, offerTimeout, serviceId, shutdownType, workQueueFields inherited from class ch.rswk.meta.engine.AbstractEngineExecutionThreadService
runtime -
Constructor Summary
ConstructorsConstructorDescriptionLuceneService(LuceneService.LuceneServiceConfig config, EngineRuntime runtime, String serviceId) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidprotected voidprivate voidvoidcommit()protected static PathgetWorkPath(String indexDir) booleanprivate void<T> com.google.common.util.concurrent.ListenableFuture<T> process(Function<LuceneService.LuceneContext, T> func) protected Objectprivate voidbooleanrestoreFromArchive(Path archive) voidsetExtendedCommitData(String key, String value) protected voidshutDown()protected voidstartUp()Methods inherited from class ch.rswk.meta.engine.AbstractEngineWorkQueueService
getCapacityThreshold, getRemainingCapacity, offerWorkUnit, run, serviceName, triggerShutdownMethods inherited from class ch.rswk.meta.engine.AbstractEngineExecutionThreadService
configClass, configReferenceMethods inherited from class com.google.common.util.concurrent.AbstractExecutionThreadService
addListener, awaitRunning, awaitRunning, awaitRunning, awaitTerminated, awaitTerminated, awaitTerminated, executor, failureCause, isRunning, startAsync, state, stopAsync, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface ch.rswk.meta.engine.EngineServices.ConfigurableService
config, onConfigChangedMethods inherited from interface ch.rswk.meta.engine.EngineServices.InfoProvidingService
getServiceInfo
-
Field Details
-
COMMIT_SCHEDULE
private static final int COMMIT_SCHEDULE- See Also:
-
COMMIT_SEQUENCE_NUMBER_KEY
- See Also:
-
COMMIT_TIMESTAMP_KEY
- See Also:
-
QUEUE_CAPACITY
private static final int QUEUE_CAPACITY- See Also:
-
QUEUE_OFFER_TIMEOUT
private static final int QUEUE_OFFER_TIMEOUT- See Also:
-
WORK_DIR
- See Also:
-
WRITE_LOCK_FILE
- See Also:
-
extendedCommitData
-
indexMonitor
private final com.google.common.util.concurrent.Monitor indexMonitor -
log
private final org.slf4j.Logger log -
luceneContext
-
writeFlag
-
analyzer
private org.apache.lucene.analysis.Analyzer analyzer -
commitHandle
-
commitTimer
private com.codahale.metrics.Timer commitTimer -
directory
private org.apache.lucene.store.FSDirectory directory -
refreshTimer
private com.codahale.metrics.Timer refreshTimer -
searcher
private org.apache.lucene.search.IndexSearcher searcher -
writer
private org.apache.lucene.index.IndexWriter writer
-
-
Constructor Details
-
LuceneService
public LuceneService(LuceneService.LuceneServiceConfig config, EngineRuntime runtime, String serviceId)
-
-
Method Details
-
startUp
- Overrides:
startUpin classAbstractEngineWorkQueueService<LuceneService.LuceneServiceConfig,LuceneService.WorkUnit, Object> - Throws:
Exception
-
openIndex
- Throws:
IOException
-
getWorkPath
-
shutDown
- Overrides:
shutDownin classAbstractEngineExecutionThreadService<LuceneService.LuceneServiceConfig>- Throws:
Exception
-
closeIndex
- Throws:
IOException
-
isWriterOpen
public boolean isWriterOpen() -
getLiveCommitData
-
backupToArchive
-
setExtendedCommitData
-
commit
public void commit() -
restoreFromArchive
-
process
public <T> com.google.common.util.concurrent.ListenableFuture<T> process(Function<LuceneService.LuceneContext, T> func) -
beforeProcessWorkUnit
-
processWorkUnit
- Specified by:
processWorkUnitin classAbstractEngineWorkQueueService<LuceneService.LuceneServiceConfig,LuceneService.WorkUnit, Object>
-
refreshReader
private void refreshReader() -
afterProcessWorkUnit
-