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 record
class
static final record
static final record
static final record
static final record
private class
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 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 com.codahale.metrics.Timer
private org.apache.lucene.search.IndexSearcher
private final String
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.AbstractEngineIdleService
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) protected String
void
setExtendedCommitData
(String key, String value) protected void
shutDown()
protected void
startUp()
Methods inherited from class ch.rswk.meta.engine.AbstractEngineWorkQueueService
isWorkQueueEmpty, offerWorkUnit
Methods inherited from class ch.rswk.meta.engine.AbstractEngineIdleService
configClass, configReference, onConfigWatcherNotification, serviceName
Methods inherited from class com.google.common.util.concurrent.AbstractIdleService
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, handleConfigWatcherNotification, 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:
-
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
-
refreshCache
-
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
-
startUp
- Overrides:
startUp
in classAbstractEngineWorkQueueService<LuceneService.LuceneServiceConfig,
LuceneService.WorkUnit, Object> - Throws:
Exception
-
openIndex
- Throws:
IOException
-
getLiveCommitData
-
commit
public void commit() -
shutDown
- Overrides:
shutDown
in classAbstractEngineIdleService<LuceneService.LuceneServiceConfig>
- Throws:
Exception
-
closeIndex
- Throws:
IOException
-
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>
-
afterProcessWorkUnit
-
refreshReader
private void refreshReader() -
backupToArchive
-
restoreFromArchive
-
getWorkPath
-
isWriterOpen
public boolean isWriterOpen() -
serviceId
- Overrides:
serviceId
in classAbstractEngineIdleService<LuceneService.LuceneServiceConfig>
-
setExtendedCommitData
-