Class PersistentQueryHandleBase
java.lang.Object
com.illumon.iris.controller.handle.PersistentQueryHandleBase
- All Implemented Interfaces:
PersistentQueryHandle
- Direct Known Subclasses:
CommunityPersistentQueryHandle,DoNothingHandle,EnterprisePersistentQueryHandle
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final PersistentQueryConfigurationprotected final ControllerConfigurationTypeprotected final ControllerDispatcherHandlerprotected final PublicPrivateKeyEncryptionprotected final ThreadPoolExecutorprotected final IrisGroupProviderprotected final ScriptPathLoaderprotected final com.fishlib.io.logger.Loggerprotected final Stringprotected PersistentQueryStateprotected final Objectprotected final String -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedPersistentQueryHandleBase(com.fishlib.io.logger.Logger log, Object queryHandleContext) Create a new PQ Handle. -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanprotected abstract WorkerHandlecreateWorkerHandle(RemoteProcessingRequest request, QueryDispatcherConnection dispatcherConnection) protected voidensureShutdown(boolean awaitDisconnection) protected com.fishlib.io.log.LogEntryerrorLog()protected StringgetState()Get the current state object for the Persistent Query.This method exposes the lock for the sole purpose of atomically swapping a single replica and spare.longGet the currently running version of the Persistent Query.Get theWorkerHandlefor an active worker.protected com.fishlib.io.log.LogEntryinfoLog()protected booleanmaybeSetTerminalStatus(Supplier<PersistentQueryState.Status> statusSupplier) protected abstract booleanonDispatcherConnected(QueryDispatcherConnection connection) protected voidprotected voidprotected voidprotected abstract voidprotected voidprotected booleanrestore(WorkerHandle workerHandle, PersistentQueryState oldState) If this PQ Handle object is being recreated from saved state, instead ofstartbeing called this method restores the object.voidsetReplicaSlot(int replicaSlot) Set the replica slot for this handle.voidshutdown(UserContext userContext) Shutdown the worker, if it is running.voidstart(long whenToStopMillis) Start the worker.protected com.fishlib.io.log.LogEntrywarnLog()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.illumon.iris.controller.handle.PersistentQueryHandle
canTryToRestore, restore
-
Field Details
-
log
protected final com.fishlib.io.logger.Logger log -
logPrefix
-
state
-
stateLock
-
workerProcessInfoId
-
configurationType
-
config
-
loader
-
executorService
-
dispatcherConnectionHandler
-
encryption
-
groupProvider
-
workerRequestHandle
-
-
Constructor Details
-
PersistentQueryHandleBase
protected PersistentQueryHandleBase(@NotNull com.fishlib.io.logger.Logger log, @NotNull Object queryHandleContext) Create a new PQ Handle. Note after creating the object, one of two things should happen: eitherstartorrestoreshould be called.- Parameters:
log- the log.queryHandleContext- A context object containing the required parameters for this object.
-
-
Method Details
-
onStartRequested
protected abstract void onStartRequested() -
onDispatcherConnected
-
createWorkerHandle
protected abstract WorkerHandle createWorkerHandle(RemoteProcessingRequest request, QueryDispatcherConnection dispatcherConnection) -
getWorkerHandle
Description copied from interface:PersistentQueryHandleGet theWorkerHandlefor an active worker. May return null if the worker is not running.- Specified by:
getWorkerHandlein interfacePersistentQueryHandle- Returns:
- the
WorkerHandleor null if the worker is not running
-
getVersion
public long getVersion()Description copied from interface:PersistentQueryHandleGet the currently running version of the Persistent Query.- Specified by:
getVersionin interfacePersistentQueryHandle- Returns:
- the version of the running query
-
getState
Description copied from interface:PersistentQueryHandleGet the current state object for the Persistent Query.- Specified by:
getStatein interfacePersistentQueryHandle- Returns:
- the current state
-
start
public void start(long whenToStopMillis) Description copied from interface:PersistentQueryHandleStart the worker. Only one ofstart()orrestore()should be called after construction.- Specified by:
startin interfacePersistentQueryHandle- Parameters:
whenToStopMillis- The scheduled stopping time for scheduled configs, or zero otherwise.
-
restore
If this PQ Handle object is being recreated from saved state, instead ofstartbeing called this method restores the object.- Parameters:
workerHandle- a worker handle to use as our own- Returns:
- true if we were able to restore this object, false otherwise
-
shutdown
Description copied from interface:PersistentQueryHandleShutdown the worker, if it is running. This method blocks until shutdown is complete.- Specified by:
shutdownin interfacePersistentQueryHandle- Parameters:
userContext- the user attempting the shutdownnullindicates the controller itself.
-
setReplicaSlot
public void setReplicaSlot(int replicaSlot) Description copied from interface:PersistentQueryHandleSet the replica slot for this handle.- Specified by:
setReplicaSlotin interfacePersistentQueryHandle- Parameters:
replicaSlot- the replica slot.
-
ensureShutdown
protected void ensureShutdown(boolean awaitDisconnection) - Parameters:
awaitDisconnection- Used to communicate whether we need to care further about ensuring disconnection, or not. If true, we block until interrupted or until another thread calls ensureShutdown(false). If false, we're asserting that the DB is already disconnected, or that we don't care (because no script was run yet).
-
checkQueryTerminatingOrTerminal
protected boolean checkQueryTerminatingOrTerminal() -
maybeSetTerminalStatus
-
onError
-
onFailure
-
onFailure
-
publishState
protected void publishState() -
getScriptCode
-
infoLog
protected com.fishlib.io.log.LogEntry infoLog() -
warnLog
protected com.fishlib.io.log.LogEntry warnLog() -
errorLog
protected com.fishlib.io.log.LogEntry errorLog() -
getStateLock
This method exposes the lock for the sole purpose of atomically swapping a single replica and spare. This currently lives in QueryTracker#ReshuffleRequest. Any further uses of this method MUST take care to avoid locking multiple states or avoiding a lock inversion.- Specified by:
getStateLockin interfacePersistentQueryHandle- Returns:
- the state lock
-