Package org.refcodes.logger
Class PartedQueryLoggerImpl<T,P extends T>
- java.lang.Object
-
- org.refcodes.logger.PartedQueryLoggerImpl<T,P>
-
- Type Parameters:
T
- The type of theRecord
instances managed by theLogger
.P
- The type of theColumn
's value used for partitioning theLogger
.
- All Implemented Interfaces:
java.io.Flushable
,org.refcodes.component.Closable
,org.refcodes.component.CompositeComponent
,org.refcodes.component.Decomposeable
,org.refcodes.component.Destroyable
,org.refcodes.component.Flushable
,org.refcodes.component.Initializable
,org.refcodes.component.LifeCycleComponent
,org.refcodes.component.LinkComponent
,org.refcodes.component.Openable
,org.refcodes.component.Pausable
,org.refcodes.component.Resetable
,org.refcodes.component.Resumable
,org.refcodes.component.Startable
,org.refcodes.component.Stoppable
,Logger<T>
,QueryLogger<T>
,org.refcodes.mixin.Disposable
public class PartedQueryLoggerImpl<T,P extends T> extends java.lang.Object implements org.refcodes.component.CompositeComponent
ThePartedQueryLoggerImpl
is a ready to use implementation of a partedQueryLogger
extending theAbstractPartedQueryLogger
.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.refcodes.component.Closable
org.refcodes.component.Closable.CloseAutomaton, org.refcodes.component.Closable.CloseBuilder<B extends org.refcodes.component.Closable.CloseBuilder<B>>
-
Nested classes/interfaces inherited from interface org.refcodes.component.CompositeComponent
org.refcodes.component.CompositeComponent.ExtendedCompositeComponent<CTX extends java.lang.Object,CON extends java.lang.Object>
-
Nested classes/interfaces inherited from interface org.refcodes.component.Decomposeable
org.refcodes.component.Decomposeable.DecomposeAutomaton
-
Nested classes/interfaces inherited from interface org.refcodes.component.Destroyable
org.refcodes.component.Destroyable.DestroyAutomaton
-
Nested classes/interfaces inherited from interface org.refcodes.mixin.Disposable
org.refcodes.mixin.Disposable.Disposedable
-
Nested classes/interfaces inherited from interface org.refcodes.component.Flushable
org.refcodes.component.Flushable.FlushBuilder<B extends org.refcodes.component.Flushable.FlushBuilder<B>>
-
Nested classes/interfaces inherited from interface org.refcodes.component.Initializable
org.refcodes.component.Initializable.InitializeAutomaton, org.refcodes.component.Initializable.InitializeBuilder<B extends org.refcodes.component.Initializable.InitializeBuilder<B>>, org.refcodes.component.Initializable.UncheckedInitializable
-
Nested classes/interfaces inherited from interface org.refcodes.component.LifeCycleComponent
org.refcodes.component.LifeCycleComponent.LifeCycleAutomaton, org.refcodes.component.LifeCycleComponent.UncheckedLifeCycleComponent
-
Nested classes/interfaces inherited from interface org.refcodes.component.LinkComponent
org.refcodes.component.LinkComponent.LinkAutomaton, org.refcodes.component.LinkComponent.LinkComponentBuilder<B extends org.refcodes.component.LinkComponent.LinkComponentBuilder<B>>
-
Nested classes/interfaces inherited from interface org.refcodes.component.Openable
org.refcodes.component.Openable.OpenAutomaton, org.refcodes.component.Openable.OpenBuilder<B extends org.refcodes.component.Openable.OpenBuilder<B>>
-
Nested classes/interfaces inherited from interface org.refcodes.component.Pausable
org.refcodes.component.Pausable.PauseAutomaton, org.refcodes.component.Pausable.PauseBuilder<B extends org.refcodes.component.Pausable.PauseBuilder<B>>, org.refcodes.component.Pausable.UncheckedPausable
-
Nested classes/interfaces inherited from interface org.refcodes.component.Resumable
org.refcodes.component.Resumable.ResumeAutomaton, org.refcodes.component.Resumable.ResumeBuilder<B extends org.refcodes.component.Resumable.ResumeBuilder<B>>, org.refcodes.component.Resumable.UncheckedResumable
-
-
Field Summary
Fields Modifier and Type Field Description protected static RuntimeLogger
LOGGER
-
Constructor Summary
Constructors Constructor Description PartedQueryLoggerImpl(org.refcodes.controlflow.ExecutionStrategy aComponentExecutionStrategy, org.refcodes.tabular.Column<P> aPartitionColumn, java.lang.String aDefaultLoggerName, LoggerFactory<QueryLogger<T>> aLoggerFactory, boolean isPartitionAutoInitialize)
Similar to thePartedQueryLoggerImpl(Column, LoggerFactory, boolean)
with the additional option of determining the execution strategy of the state change request calls for the encapsulatedQueryLogger
instances (as ofCompositeComponent
).PartedQueryLoggerImpl(org.refcodes.controlflow.ExecutionStrategy aComponentExecutionStrategy, org.refcodes.tabular.Column<P> aPartitionColumn, LoggerFactory<QueryLogger<T>> aLoggerFactory, boolean isPartitionAutoInitialize)
Similar to thePartedQueryLoggerImpl(Column, LoggerFactory, boolean)
with the additional option of determining the execution strategy of the state change request calls for the encapsulatedQueryLogger
instances (as ofCompositeComponent
).PartedQueryLoggerImpl(org.refcodes.tabular.Column<P> aPartitionColumn, java.lang.String aDefaultLoggerName, LoggerFactory<QueryLogger<T>> aLoggerFactory, boolean isPartitionAutoInitialize)
Instantiates a new parted query logger impl.PartedQueryLoggerImpl(org.refcodes.tabular.Column<P> aPartitionColumn, LoggerFactory<QueryLogger<T>> aLoggerFactory, boolean isPartitionAutoInitialize)
Instantiates a new parted query logger impl.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
void
decompose()
void
decomposePartition(P aPartition)
Decomposes the given partition.void
destroy()
void
destroyPartition(P aPartition)
Destroys the given partition.void
dispose()
org.refcodes.tabular.Records<T>
findLogs()
Retrieves all availableRecord
instances being logged.org.refcodes.tabular.Records<T>
findLogs(int aLimit)
Retrieves all availableRecord
instances being logged matching the given criteria and restrictions.org.refcodes.tabular.Records<T>
findLogs(org.refcodes.criteria.Criteria aCriteria)
Retrieves all availableRecord
instances being logged matching the given criteria and restrictions.org.refcodes.tabular.Records<T>
findLogs(org.refcodes.criteria.Criteria aCriteria, int aLimit)
Retrieves all availableRecord
instances being logged matching the given criteria and restrictions.org.refcodes.tabular.Records<T>
findLogs(org.refcodes.criteria.Criteria aCriteria, org.refcodes.tabular.Header<T> aHeader)
Retrieves all availableRecord
instances being logged matching the given criteria and restrictions.org.refcodes.tabular.Records<T>
findLogs(org.refcodes.criteria.Criteria aCriteria, org.refcodes.tabular.Header<T> aHeader, int aLimit)
Retrieves all availableRecord
instances being logged matching the given criteria and restrictions.org.refcodes.tabular.Records<T>
findLogs(org.refcodes.tabular.Header<T> aHeader, int aLimit)
Retrieves all availableRecord
instances being logged matching the given criteria and restrictions.void
flush()
void
flushPartition(P aPartition)
Flushes the given partition, all buffered data is to be forwarded to the physical data sink.protected L
getFallbackLogger()
Returns the fallbackLogger
.protected java.util.Collection<L>
getLoggers()
Provides access to the partitions managed by theAbstractPartedLogger
.protected org.refcodes.tabular.Column<P>
getPartitionColumn()
Provides access to theColumn
used to identify partitions.protected L
getPartitionLogger(P aPartition)
Returns theLogger
being responsible for the given partition.protected java.util.Collection<L>
getPartitionLoggers(java.util.Set<P> aPartitions)
Retrieves a collection withLogger
instances managing the provided partitions.protected java.lang.String
getPartitionUid(P aPartition)
Depending whether the partition object provides a Universal-ID or not we return the string representation of the partition's object or the UID.boolean
hasPartition(P aPartition)
Tests whether the provided partition exists.void
initialize()
L
initPartition(P aPartition)
Initializes the given partition.void
log(org.refcodes.tabular.Record<? extends T> aRecord)
Logs aRecord
.void
open()
void
pause()
void
reset()
void
resume()
void
start()
void
stop()
-
Methods inherited from interface org.refcodes.component.Closable
closeIn, closeQuietly, closeUnchecked
-
Methods inherited from interface org.refcodes.logger.Logger
log, printSeparator
-
-
-
-
Field Detail
-
LOGGER
protected static RuntimeLogger LOGGER
-
-
Constructor Detail
-
PartedQueryLoggerImpl
public PartedQueryLoggerImpl(org.refcodes.tabular.Column<P> aPartitionColumn, LoggerFactory<QueryLogger<T>> aLoggerFactory, boolean isPartitionAutoInitialize)
Instantiates a new parted query logger impl.- Parameters:
aPartitionColumn
- the partition columnaLoggerFactory
- the logger factoryisPartitionAutoInitialize
- the is partition auto initialize
-
PartedQueryLoggerImpl
public PartedQueryLoggerImpl(org.refcodes.tabular.Column<P> aPartitionColumn, java.lang.String aDefaultLoggerName, LoggerFactory<QueryLogger<T>> aLoggerFactory, boolean isPartitionAutoInitialize)
Instantiates a new parted query logger impl.- Parameters:
aPartitionColumn
- the partition columnaDefaultLoggerName
- the default logger nameaLoggerFactory
- the logger factoryisPartitionAutoInitialize
- the is partition auto initialize
-
PartedQueryLoggerImpl
public PartedQueryLoggerImpl(org.refcodes.controlflow.ExecutionStrategy aComponentExecutionStrategy, org.refcodes.tabular.Column<P> aPartitionColumn, LoggerFactory<QueryLogger<T>> aLoggerFactory, boolean isPartitionAutoInitialize)
Similar to thePartedQueryLoggerImpl(Column, LoggerFactory, boolean)
with the additional option of determining the execution strategy of the state change request calls for the encapsulatedQueryLogger
instances (as ofCompositeComponent
).- Parameters:
aComponentExecutionStrategy
- The strategy to be used when invoking a component's (encapsulatedQueryLogger
instance's) state change request call (as ofCompositeComponent
).
-
PartedQueryLoggerImpl
public PartedQueryLoggerImpl(org.refcodes.controlflow.ExecutionStrategy aComponentExecutionStrategy, org.refcodes.tabular.Column<P> aPartitionColumn, java.lang.String aDefaultLoggerName, LoggerFactory<QueryLogger<T>> aLoggerFactory, boolean isPartitionAutoInitialize)
Similar to thePartedQueryLoggerImpl(Column, LoggerFactory, boolean)
with the additional option of determining the execution strategy of the state change request calls for the encapsulatedQueryLogger
instances (as ofCompositeComponent
).- Parameters:
aComponentExecutionStrategy
- The strategy to be used when invoking a component's (encapsulatedQueryLogger
instance's) state change request call (as ofCompositeComponent
).
-
-
Method Detail
-
initialize
public void initialize() throws org.refcodes.component.InitializeException
- Specified by:
initialize
in interfaceorg.refcodes.component.Initializable
- Throws:
org.refcodes.component.InitializeException
-
start
public void start() throws org.refcodes.component.StartException
- Specified by:
start
in interfaceorg.refcodes.component.Startable
- Throws:
org.refcodes.component.StartException
-
pause
public void pause() throws org.refcodes.component.PauseException
- Specified by:
pause
in interfaceorg.refcodes.component.Pausable
- Throws:
org.refcodes.component.PauseException
-
resume
public void resume() throws org.refcodes.component.ResumeException
- Specified by:
resume
in interfaceorg.refcodes.component.Resumable
- Throws:
org.refcodes.component.ResumeException
-
stop
public void stop() throws org.refcodes.component.StopException
- Specified by:
stop
in interfaceorg.refcodes.component.Stoppable
- Throws:
org.refcodes.component.StopException
-
decompose
public void decompose()
- Specified by:
decompose
in interfaceorg.refcodes.component.Decomposeable
-
flush
public void flush() throws org.refcodes.component.OpenException
- Specified by:
flush
in interfacejava.io.Flushable
- Specified by:
flush
in interfaceorg.refcodes.component.Flushable
- Throws:
org.refcodes.component.OpenException
-
destroy
public void destroy()
- Specified by:
destroy
in interfaceorg.refcodes.component.Destroyable
-
reset
public void reset()
- Specified by:
reset
in interfaceorg.refcodes.component.Resetable
-
open
public void open() throws org.refcodes.component.OpenException
- Specified by:
open
in interfaceorg.refcodes.component.Openable
- Throws:
org.refcodes.component.OpenException
-
close
public void close()
- Specified by:
close
in interfaceorg.refcodes.component.Closable
-
dispose
public void dispose()
- Specified by:
dispose
in interfaceorg.refcodes.mixin.Disposable
-
findLogs
public org.refcodes.tabular.Records<T> findLogs()
Retrieves all availableRecord
instances being logged.- Specified by:
findLogs
in interfaceQueryLogger<L extends QueryLogger<T>>
- Returns:
- A
Records
instance containing all availableRecord
instances being logged.
-
findLogs
public org.refcodes.tabular.Records<T> findLogs(int aLimit)
Retrieves all availableRecord
instances being logged matching the given criteria and restrictions.- Specified by:
findLogs
in interfaceQueryLogger<L extends QueryLogger<T>>
- Parameters:
aLimit
- The maximumRecord
instances contained in the returnedRecords
instance; there may be moreRecord
instances which are not contained in theRecords
instance in case theRecords
instance's size is that of the specified limit.- Returns:
- A
Records
instance containing all availableRecord
instances being logged matching the given criteria and restrictions.
-
findLogs
public org.refcodes.tabular.Records<T> findLogs(org.refcodes.criteria.Criteria aCriteria)
Retrieves all availableRecord
instances being logged matching the given criteria and restrictions.- Specified by:
findLogs
in interfaceQueryLogger<L extends QueryLogger<T>>
- Parameters:
aCriteria
- TheCriteria
to be applied to theRecord
instances- Returns:
- A
Records
instance containing all availableRecord
instances being logged matching the given criteria and restrictions.
-
findLogs
public org.refcodes.tabular.Records<T> findLogs(org.refcodes.tabular.Header<T> aHeader, int aLimit)
Retrieves all availableRecord
instances being logged matching the given criteria and restrictions.- Specified by:
findLogs
in interfaceQueryLogger<L extends QueryLogger<T>>
- Parameters:
aHeader
- TheHeader
used to restrict the "columns" (key/value entries) in the retrievedRecord
instances (provided by theRecords
instance).aLimit
- The maximumRecord
instances contained in the returnedRecords
instance; there may be moreRecord
instances which are not contained in theRecords
instance in case theRecords
instance's size is that of the specified limit.- Returns:
- A
Records
instance containing all availableRecord
instances being logged matching the given criteria and restrictions.
-
findLogs
public org.refcodes.tabular.Records<T> findLogs(org.refcodes.criteria.Criteria aCriteria, int aLimit)
Retrieves all availableRecord
instances being logged matching the given criteria and restrictions.- Specified by:
findLogs
in interfaceQueryLogger<L extends QueryLogger<T>>
- Parameters:
aCriteria
- TheCriteria
to be applied to theRecord
instancesaLimit
- The maximumRecord
instances contained in the returnedRecords
instance; there may be moreRecord
instances which are not contained in theRecords
instance in case theRecords
instance's size is that of the specified limit.- Returns:
- A
Records
instance containing all availableRecord
instances being logged matching the given criteria and restrictions.
-
findLogs
public org.refcodes.tabular.Records<T> findLogs(org.refcodes.criteria.Criteria aCriteria, org.refcodes.tabular.Header<T> aHeader)
Retrieves all availableRecord
instances being logged matching the given criteria and restrictions.- Specified by:
findLogs
in interfaceQueryLogger<L extends QueryLogger<T>>
- Parameters:
aCriteria
- TheCriteria
to be applied to theRecord
instancesaHeader
- TheHeader
used to restrict the "columns" (key/value entries) in the retrievedRecord
instances (provided by theRecords
instance).- Returns:
- A
Records
instance containing all availableRecord
instances being logged matching the given criteria and restrictions.
-
findLogs
public org.refcodes.tabular.Records<T> findLogs(org.refcodes.criteria.Criteria aCriteria, org.refcodes.tabular.Header<T> aHeader, int aLimit)
Retrieves all availableRecord
instances being logged matching the given criteria and restrictions.- Specified by:
findLogs
in interfaceQueryLogger<L extends QueryLogger<T>>
- Parameters:
aCriteria
- TheCriteria
to be applied to theRecord
instancesaHeader
- TheHeader
used to restrict the "columns" (key/value entries) in the retrievedRecord
instances (provided by theRecords
instance).aLimit
- The maximumRecord
instances contained in the returnedRecords
instance; there may be moreRecord
instances which are not contained in theRecords
instance in case theRecords
instance's size is that of the specified limit.- Returns:
- A
Records
instance containing all availableRecord
instances being logged matching the given criteria and restrictions.
-
getPartitionLoggers
protected java.util.Collection<L> getPartitionLoggers(java.util.Set<P> aPartitions)
Retrieves a collection withLogger
instances managing the provided partitions.
-
log
public void log(org.refcodes.tabular.Record<? extends T> aRecord) throws IllegalRecordRuntimeException, UnexpectedLogRuntimeException
Logs aRecord
. The targeted data sink for theRecord
instances (where them are physically stored) depends on the implementation of theLogger
. It can be a console, a file, a stream or a database.- Specified by:
log
in interfaceLogger<L extends Logger<T>>
- Parameters:
aRecord
- TheRecord
to be logged.- Throws:
IllegalRecordRuntimeException
- Thrown in case the record cannot be logged as a specific implementation might expect some dedicatedColumn
instances to be contained in the provided Record.UnexpectedLogRuntimeException
- Thrown in case some other problems regarding logging occurred, e.g. the data sink (physical system where to log to) experiences problems.
-
hasPartition
public boolean hasPartition(P aPartition)
Tests whether the provided partition exists.- Parameters:
aPartition
- The value of theColumn
in aRecord
specifying the partition which is to be addressed (or even auto initialized).- Returns:
- True in case the partition exists, else false.
-
initPartition
public L initPartition(P aPartition) throws org.refcodes.component.InitializeException
Initializes the given partition.- Parameters:
aPartition
- The value of theColumn
in aRecord
specifying the partition which is to be auto initialized.- Returns:
- the l
- Throws:
org.refcodes.component.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
public void destroyPartition(P aPartition)
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
public void flushPartition(P aPartition) throws java.io.IOException
Flushes the given partition, all buffered data is to be forwarded to the physical data sink.- Parameters:
aPartition
- The partition to be flushed.- Throws:
java.io.IOException
- in case there were problems when flushing, e.g. there is none such partition.
-
decomposePartition
public void decomposePartition(P aPartition)
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
protected java.util.Collection<L> getLoggers()
Provides access to the partitions managed by theAbstractPartedLogger
. This is especially useful for extensions of this class such as theAbstractPartedQueryLogger
or theAbstractPartedTrimLogger
.- Returns:
- The
Logger
instances managed by theAbstractPartedLogger
instance.
-
getPartitionUid
protected java.lang.String getPartitionUid(P aPartition)
Depending whether the partition object provides a Universal-ID 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
protected org.refcodes.tabular.Column<P> getPartitionColumn()
Provides access to theColumn
used to identify partitions.- Returns:
- The
Column
identifying partitions.
-
getPartitionLogger
protected L getPartitionLogger(P aPartition)
Returns theLogger
being responsible for the given partition.
-
getFallbackLogger
protected L getFallbackLogger()
Returns the fallbackLogger
.- Returns:
- The fallback logger or null if none was enabled.
-
-