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 record
class
static final record
static final record
static final record
(package private) static final record
private class
Nested classes/interfaces inherited from class ch.rswk.meta.engine.AbstractEngineWorkQueueService
AbstractEngineWorkQueueService.ShutdownType
Nested 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.Analyzer
private static final int
private static final String
private static final String
private ScheduledFuture
<?> private com.codahale.metrics.Timer
private org.apache.lucene.store.FSDirectory
private final com.google.common.util.concurrent.Monitor
private final org.slf4j.Logger
private final LuceneService.LuceneContext
private static final int
private static final int
private com.codahale.metrics.Timer
private org.apache.lucene.search.IndexSearcher
private static final String
private static final String
private final AtomicBoolean
private org.apache.lucene.index.IndexWriter
Fields inherited from class ch.rswk.meta.engine.AbstractEngineWorkQueueService
capacity, offerTimeout, serviceId, shutdownType, workQueue
Fields inherited from class ch.rswk.meta.engine.AbstractEngineExecutionThreadService
runtime
-
Constructor Summary
ConstructorsConstructorDescriptionLuceneService
(LuceneService.LuceneServiceConfig config, EngineRuntime runtime, String serviceId) -
Method Summary
Modifier and TypeMethodDescriptionprotected void
protected void
private void
void
commit()
protected static Path
getWorkPath
(String indexDir) boolean
private void
<T> com.google.common.util.concurrent.ListenableFuture
<T> process
(Function<LuceneService.LuceneContext, T> func) protected Object
private void
boolean
restoreFromArchive
(Path archive) void
setExtendedCommitData
(String key, String value) protected void
shutDown()
protected void
startUp()
Methods inherited from class ch.rswk.meta.engine.AbstractEngineWorkQueueService
getCapacityThreshold, getRemainingCapacity, offerWorkUnit, run, serviceName, triggerShutdown
Methods inherited from class ch.rswk.meta.engine.AbstractEngineExecutionThreadService
configClass, configReference
Methods inherited from class com.google.common.util.concurrent.AbstractExecutionThreadService
addListener, awaitRunning, awaitRunning, awaitRunning, awaitTerminated, awaitTerminated, awaitTerminated, executor, failureCause, isRunning, startAsync, state, stopAsync, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface ch.rswk.meta.engine.EngineServices.ConfigurableService
config, onConfigChanged
Methods 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:
startUp
in classAbstractEngineWorkQueueService<LuceneService.LuceneServiceConfig,
LuceneService.WorkUnit, Object> - Throws:
Exception
-
openIndex
- Throws:
IOException
-
getWorkPath
-
shutDown
- Overrides:
shutDown
in 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:
processWorkUnit
in classAbstractEngineWorkQueueService<LuceneService.LuceneServiceConfig,
LuceneService.WorkUnit, Object>
-
refreshReader
private void refreshReader() -
afterProcessWorkUnit
-