Class PartedQueryLogger<T, P extends T>
java.lang.Object
org.refcodes.logger.PartedQueryLogger<T,P>
- Type Parameters:
T- The type of theRecordinstances managed by theLogger.P- The type of theColumn's value used for partitioning theLogger.
- All Implemented Interfaces:
Flushable, Closable, ComponentComposite, Decomposable, Destroyable, Flushable, Initializable, LifecycleComponent, LinkComponent, Openable, Pausable, Resumable, Startable, Stoppable, LogDecorator, Logger<T>, QueryLogger<T>, Disposable, Resetable
The
PartedQueryLogger is a ready to use implementation of a parted
QueryLogger extending the AbstractPartedQueryLogger.-
Nested Class Summary
Nested classes/interfaces inherited from interface Closable
Closable.CloseAutomaton, Closable.CloseBuilder<B>Nested classes/interfaces inherited from interface ComponentComposite
ComponentComposite.ExtendedComponentComposite<CTX,CON> Nested classes/interfaces inherited from interface Decomposable
Decomposable.DecomposeAutomatonNested classes/interfaces inherited from interface Destroyable
Destroyable.DestroyAutomatonNested classes/interfaces inherited from interface Flushable
Flushable.FlushBuilder<B>Nested classes/interfaces inherited from interface Initializable
Initializable.InitializeAutomaton, Initializable.InitializeBuilder<B>, Initializable.UncheckedInitializableNested classes/interfaces inherited from interface LifecycleComponent
LifecycleComponent.LifecycleAutomaton, LifecycleComponent.UncheckedLifecycleComponentNested classes/interfaces inherited from interface LinkComponent
LinkComponent.LinkAutomaton, LinkComponent.LinkComponentBuilder<B>Nested classes/interfaces inherited from interface Openable
Openable.OpenAutomaton, Openable.OpenBuilder<B>Nested classes/interfaces inherited from interface Pausable
Pausable.PauseAutomaton, Pausable.PauseBuilder<B>, Pausable.UncheckedPausableNested classes/interfaces inherited from interface Resumable
Resumable.ResumeAutomaton, Resumable.ResumeBuilder<B>, Resumable.UncheckedResumableNested classes/interfaces inherited from interface Startable
Startable.StartAutomaton, Startable.StartBuilder<B>, Startable.UncheckedStartableNested classes/interfaces inherited from interface Stoppable
Stoppable.StopAutomaton, Stoppable.StopBuilder<B>, Stoppable.UncheckedStoppable -
Constructor Summary
ConstructorsConstructorDescriptionPartedQueryLogger(ExecutionStrategy aComponentExecutionStrategy, Column<P> aPartitionColumn, String aDefaultLoggerName, LoggerFactory<QueryLogger<T>> aLoggerFactory, boolean isPartitionAutoInitialize) Similar to thePartedQueryLogger(Column, LoggerFactory, boolean)with the additional option of determining the execution strategy of the state change request calls for the encapsulatedQueryLoggerinstances (as ofComponentComposite).PartedQueryLogger(ExecutionStrategy aComponentExecutionStrategy, Column<P> aPartitionColumn, LoggerFactory<QueryLogger<T>> aLoggerFactory, boolean isPartitionAutoInitialize) Similar to thePartedQueryLogger(Column, LoggerFactory, boolean)with the additional option of determining the execution strategy of the state change request calls for the encapsulatedQueryLoggerinstances (as ofComponentComposite).PartedQueryLogger(Column<P> aPartitionColumn, String aDefaultLoggerName, LoggerFactory<QueryLogger<T>> aLoggerFactory, boolean isPartitionAutoInitialize) Instantiates a newPartedQueryLoggerwith the according parameters.PartedQueryLogger(Column<P> aPartitionColumn, LoggerFactory<QueryLogger<T>> aLoggerFactory, boolean isPartitionAutoInitialize) Instantiates a newPartedQueryLoggerwith the according parameters. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()voidvoiddecomposePartition(P aPartition) Decomposes the given partition.voiddestroy()voiddestroyPartition(P aPartition) Destroys the given partition.voiddispose()findLogs()Retrieves all availableRecordinstances being logged.findLogs(int aLimit) Retrieves all availableRecordinstances being logged matching the given criteria and restrictions.Retrieves all availableRecordinstances being logged matching the given criteria and restrictions.Retrieves all availableRecordinstances being logged matching the given criteria and restrictions.Retrieves all availableRecordinstances being logged matching the given criteria and restrictions.Retrieves all availableRecordinstances being logged matching the given criteria and restrictions.Retrieves all availableRecordinstances being logged matching the given criteria and restrictions.voidflush()voidflushPartition(P aPartition) Flushes the given partition, all buffered data is to be forwarded to the physical data sink.protected QueryLogger<T> Returns the fallbackLogger.protected Collection<QueryLogger<T>> Provides access to the partitions managed by theAbstractPartedLogger.Provides access to theColumnused to identify partitions.protected QueryLogger<T> getPartitionLogger(P aPartition) Returns theLoggerbeing responsible for the given partition.protected Collection<QueryLogger<T>> getPartitionLoggers(Set<P> aPartitions) Retrieves a collection withLoggerinstances managing the provided partitions.protected StringgetPartitionUid(P aPartition) Depending whether the partition object provides a Universal-TID or not we return the string representation of the partition's object or the UID.booleanhasPartition(P aPartition) Tests whether the provided partition exists.voidinitPartition(P aPartition) Initializes the given partition.voidLogs aRecord.voidopen()voidpause()voidreset()voidresume()voidstart()voidstop()Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Closable
closeIn, closeQuietly, closeUncheckedMethods inherited from interface Flushable
flushUnchecked, isFlushableMethods inherited from interface Initializable
initializeUncheckedMethods inherited from interface LogDecorator
printHead, printSeparator, printTailMethods inherited from interface Openable
openUncheckedMethods inherited from interface Pausable
pauseUncheckedMethods inherited from interface Resumable
resumeUncheckedMethods inherited from interface Startable
startUncheckedMethods inherited from interface Stoppable
stopUnchecked
-
Constructor Details
-
PartedQueryLogger
public PartedQueryLogger(Column<P> aPartitionColumn, LoggerFactory<QueryLogger<T>> aLoggerFactory, boolean isPartitionAutoInitialize) Instantiates a newPartedQueryLoggerwith the according parameters.- Parameters:
aPartitionColumn- theColumnidentifying partition column for sharding.aLoggerFactory- theLoggerFactorypopulating this composite with partitions.isPartitionAutoInitialize- True in case a partition not yet existing is to be created on the fly, e.g. in case a log is applied against a non existing partition, then theinitPartition(Object)method is invoked upon this partition. Find and delete operations are not considered.
-
PartedQueryLogger
public PartedQueryLogger(Column<P> aPartitionColumn, String aDefaultLoggerName, LoggerFactory<QueryLogger<T>> aLoggerFactory, boolean isPartitionAutoInitialize) Instantiates a newPartedQueryLoggerwith the according parameters.- Parameters:
aPartitionColumn- theColumnidentifying partition column for sharding.aDefaultLoggerName- In case a fallbackLoggeris to be used when no partition can be determined, then this parameter defines the name of the fallbackLogger.aLoggerFactory- theLoggerFactorypopulating this composite.isPartitionAutoInitialize- True in case a partition not yet existing is to be created on the fly, e.g. in case a log is applied against a non existing partition, then theinitPartition(Object)method is invoked upon this partition. Find and delete operations are not considered.
-
PartedQueryLogger
public PartedQueryLogger(ExecutionStrategy aComponentExecutionStrategy, Column<P> aPartitionColumn, LoggerFactory<QueryLogger<T>> aLoggerFactory, boolean isPartitionAutoInitialize) Similar to thePartedQueryLogger(Column, LoggerFactory, boolean)with the additional option of determining the execution strategy of the state change request calls for the encapsulatedQueryLoggerinstances (as ofComponentComposite).- Parameters:
aComponentExecutionStrategy- The strategy to be used when invoking a component's (encapsulatedQueryLoggerinstance's) state change request call (as ofComponentComposite).aPartitionColumn- theColumnidentifying partition column for sharding.aLoggerFactory- theLoggerFactorypopulating this composite with partitions.isPartitionAutoInitialize- True in case a partition not yet existing is to be created on the fly, e.g. in case a log is applied against a non existing partition, then theinitPartition(Object)method is invoked upon this partition. Find and delete operations are not considered.
-
PartedQueryLogger
public PartedQueryLogger(ExecutionStrategy aComponentExecutionStrategy, Column<P> aPartitionColumn, String aDefaultLoggerName, LoggerFactory<QueryLogger<T>> aLoggerFactory, boolean isPartitionAutoInitialize) Similar to thePartedQueryLogger(Column, LoggerFactory, boolean)with the additional option of determining the execution strategy of the state change request calls for the encapsulatedQueryLoggerinstances (as ofComponentComposite).- Parameters:
aComponentExecutionStrategy- The strategy to be used when invoking a component's (encapsulatedQueryLoggerinstance's) state change request call (as ofComponentComposite).aPartitionColumn- theColumnidentifying partition column for sharding.aDefaultLoggerName- In case a fallbackLoggeris to be used when no partition can be determined, then this parameter defines the name of the fallbackLogger.aLoggerFactory- theLoggerFactorypopulating this composite with partitions.isPartitionAutoInitialize- True in case a partition not yet existing is to be created on the fly, e.g. in case a log is applied against a non existing partition, then theinitPartition(Object)method is invoked upon this partition. Find and delete operations are not considered.
-
-
Method Details
-
initialize
- Specified by:
initializein interfaceInitializable- Throws:
InitializeException
-
start
- Specified by:
startin interfaceStartable- Throws:
StartException
-
pause
- Specified by:
pausein interfacePausable- Throws:
PauseException
-
resume
- Specified by:
resumein interfaceResumable- Throws:
ResumeException
-
stop
- Specified by:
stopin interfaceStoppable- Throws:
StopException
-
decompose
public void decompose()- Specified by:
decomposein interfaceDecomposable
-
flush
- Specified by:
flushin interfaceFlushable- Specified by:
flushin interfaceFlushable- Throws:
IOException
-
destroy
public void destroy()- Specified by:
destroyin interfaceDestroyable
-
reset
-
open
- Specified by:
openin interfaceOpenable- Throws:
IOException
-
close
-
dispose
public void dispose()- Specified by:
disposein interfaceDisposable
-
findLogs
Retrieves all availableRecordinstances being logged.- Specified by:
findLogsin interfaceQueryLogger<L extends QueryLogger<T>>- Returns:
- A
Recordsinstance containing all availableRecordinstances being logged.
-
findLogs
Retrieves all availableRecordinstances being logged matching the given criteria and restrictions.- Specified by:
findLogsin interfaceQueryLogger<L extends QueryLogger<T>>- Parameters:
aLimit- The maximumRecordinstances contained in the returnedRecordsinstance; there may be moreRecordinstances which are not contained in theRecordsinstance in case theRecordsinstance's size is that of the specified limit.- Returns:
- A
Recordsinstance containing all availableRecordinstances being logged matching the given criteria and restrictions.
-
findLogs
Retrieves all availableRecordinstances being logged matching the given criteria and restrictions.- Specified by:
findLogsin interfaceQueryLogger<L extends QueryLogger<T>>- Parameters:
aCriteria- TheCriteriato be applied to theRecordinstances- Returns:
- A
Recordsinstance containing all availableRecordinstances being logged matching the given criteria and restrictions.
-
findLogs
Retrieves all availableRecordinstances being logged matching the given criteria and restrictions.- Specified by:
findLogsin interfaceQueryLogger<L extends QueryLogger<T>>- Parameters:
aHeader- TheHeaderused to restrict the "columns" (key/value entries) in the retrievedRecordinstances (provided by theRecordsinstance).aLimit- The maximumRecordinstances contained in the returnedRecordsinstance; there may be moreRecordinstances which are not contained in theRecordsinstance in case theRecordsinstance's size is that of the specified limit.- Returns:
- A
Recordsinstance containing all availableRecordinstances being logged matching the given criteria and restrictions.
-
findLogs
Retrieves all availableRecordinstances being logged matching the given criteria and restrictions.- Specified by:
findLogsin interfaceQueryLogger<L extends QueryLogger<T>>- Parameters:
aCriteria- TheCriteriato be applied to theRecordinstancesaLimit- The maximumRecordinstances contained in the returnedRecordsinstance; there may be moreRecordinstances which are not contained in theRecordsinstance in case theRecordsinstance's size is that of the specified limit.- Returns:
- A
Recordsinstance containing all availableRecordinstances being logged matching the given criteria and restrictions. - Throws:
BadCriteriaException- thrown in case of problems related to someCriteria.
-
findLogs
Retrieves all availableRecordinstances being logged matching the given criteria and restrictions.- Specified by:
findLogsin interfaceQueryLogger<L extends QueryLogger<T>>- Parameters:
aCriteria- TheCriteriato be applied to theRecordinstancesaHeader- TheHeaderused to restrict the "columns" (key/value entries) in the retrievedRecordinstances (provided by theRecordsinstance).- Returns:
- A
Recordsinstance containing all availableRecordinstances being logged matching the given criteria and restrictions. - Throws:
BadCriteriaException- thrown in case of problems related to someCriteria.
-
findLogs
public Records<T> findLogs(Criteria aCriteria, Header<T> aHeader, int aLimit) throws BadCriteriaException Retrieves all availableRecordinstances being logged matching the given criteria and restrictions.- Specified by:
findLogsin interfaceQueryLogger<L extends QueryLogger<T>>- Parameters:
aCriteria- TheCriteriato be applied to theRecordinstancesaHeader- TheHeaderused to restrict the "columns" (key/value entries) in the retrievedRecordinstances (provided by theRecordsinstance).aLimit- The maximumRecordinstances contained in the returnedRecordsinstance; there may be moreRecordinstances which are not contained in theRecordsinstance in case theRecordsinstance's size is that of the specified limit.- Returns:
- A
Recordsinstance containing all availableRecordinstances being logged matching the given criteria and restrictions. - Throws:
BadCriteriaException- thrown in case of problems related to someCriteria.
-
getPartitionLoggers
Retrieves a collection withLoggerinstances managing the provided partitions.- Parameters:
aPartitions- The partitions for which to get theLoggerinstances.- Returns:
- A
Collectionwith none to manyLoggerinstances
-
log
-
hasPartition
-
initPartition
Initializes the given partition.- Parameters:
aPartition- The value of theColumnin aRecordspecifying the partition which is to be auto initialized.- Returns:
- the l
- Throws:
InitializeException- in case initialization failed e.g. when the partition already exists or the system was not able to create the required amount of endpoints.
-
destroyPartition
Destroys the given partition. External resources might stay untouched! In case the partition does not exist, then there is no partition to be destroyed. To make things easier, this is not considered an exceptional state as after the call we expect that there is none such partition (any more) which is not destroyed.- Parameters:
aPartition- the partition
-
flushPartition
Flushes the given partition, all buffered data is to be forwarded to the physical data sink.- Parameters:
aPartition- The partition to be flushed.- Throws:
IOException- in case there were problems when flushing, e.g. there is none such partition.
-
decomposePartition
Decomposes the given partition. External resources might get deleted (such as files or DB schemas)! In case the partition does not exist, then there is no partition to be decomposed. To make things easier, this is not considered an exceptional state as after the call we expect that there is none such partition (any more).- Parameters:
aPartition- The partition to be decomposed.
-
getLoggers
Provides access to the partitions managed by theAbstractPartedLogger. This is ehttps://www.metacodes.proly useful for extensions of this class such as theAbstractPartedQueryLoggeror theAbstractPartedTrimLogger.- Returns:
- The
Loggerinstances managed by theAbstractPartedLoggerinstance.
-
getPartitionUid
Depending whether the partition object provides a Universal-TID or not we return the string representation of the partition's object or the UID.- Parameters:
aPartition- The partition for which to get the identifier- Returns:
- The UID in case the partition provides a UID, else the partition's string representation.
-
getPartitionColumn
-
getPartitionLogger
Returns theLoggerbeing responsible for the given partition. -
getFallbackLogger
Returns the fallbackLogger.- Returns:
- The fallback logger or null if none was enabled.
-