Package ch.rswk.meta.engine
Class LuceneService
java.lang.Object
com.google.common.util.concurrent.AbstractIdleService
- 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 recordstatic final recordprivate classNested 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 com.codahale.metrics.Timerprivate org.apache.lucene.store.FSDirectoryprivate final com.google.common.util.concurrent.Monitorprivate final org.slf4j.Loggerprivate final LuceneService.LuceneContextprivate com.codahale.metrics.Timerprivate org.apache.lucene.search.IndexSearcherprivate final Stringprivate static final Stringprivate static final Stringprivate final AtomicBooleanprivate org.apache.lucene.index.IndexWriterFields inherited from class ch.rswk.meta.engine.AbstractEngineIdleService
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) protected StringvoidsetExtendedCommitData(String key, String value) protected voidshutDown()protected voidstartUp()Methods inherited from class ch.rswk.meta.engine.AbstractEngineWorkQueueService
isWorkQueueEmpty, offerWorkUnitMethods inherited from class ch.rswk.meta.engine.AbstractEngineIdleService
configClass, configReference, onConfigWatcherNotification, serviceNameMethods inherited from class com.google.common.util.concurrent.AbstractIdleService
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, handleConfigWatcherNotification, 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:
-
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
-
serviceId
-
writeFlag
-
analyzer
private org.apache.lucene.analysis.Analyzer analyzer -
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
-
backupToArchive
-
commit
public void commit() -
getWorkPath
-
beforeProcessWorkUnit
-
processWorkUnit
- Specified by:
processWorkUnitin classAbstractEngineWorkQueueService<LuceneService.LuceneServiceConfig,LuceneService.WorkUnit, Object>
-
afterProcessWorkUnit
-
startUp
- Overrides:
startUpin classAbstractEngineWorkQueueService<LuceneService.LuceneServiceConfig,LuceneService.WorkUnit, Object> - Throws:
Exception
-
openIndex
- Throws:
IOException
-
getLiveCommitData
-
serviceId
- Overrides:
serviceIdin classAbstractEngineIdleService<LuceneService.LuceneServiceConfig>
-
isWriterOpen
public boolean isWriterOpen() -
process
public <T> com.google.common.util.concurrent.ListenableFuture<T> process(Function<LuceneService.LuceneContext, T> func) -
refreshReader
private void refreshReader() -
restoreFromArchive
-
closeIndex
- Throws:
IOException
-
setExtendedCommitData
-
shutDown
- Overrides:
shutDownin classAbstractEngineIdleService<LuceneService.LuceneServiceConfig>- Throws:
Exception
-