Class PartedLogger<T,P extends T>
java.lang.Object
org.refcodes.logger.PartedLogger<T,P>
- Type Parameters:
T- the generic typeP- The type of theColumn's value used for partitioning theLogger.
- All Implemented Interfaces:
Flushable,org.refcodes.component.Closable,org.refcodes.component.ComponentComposite,org.refcodes.component.Decomposable,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.Resumable,org.refcodes.component.Startable,org.refcodes.component.Stoppable,LogDecorator,Logger<T>,org.refcodes.mixin.Disposable,org.refcodes.mixin.Resetable
public class PartedLogger<T,P extends T>
extends Object
implements org.refcodes.component.ComponentComposite
The
PartedLogger is a ready to use implementation of a parted
Logger extending the AbstractPartedLogger.- See Also:
-
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.ComponentComposite
org.refcodes.component.ComponentComposite.ExtendedComponentComposite<CTX,CON> Nested classes/interfaces inherited from interface org.refcodes.component.Decomposable
org.refcodes.component.Decomposable.DecomposeAutomatonNested classes/interfaces inherited from interface org.refcodes.component.Destroyable
org.refcodes.component.Destroyable.DestroyAutomatonNested 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.UncheckedInitializableNested classes/interfaces inherited from interface org.refcodes.component.LifecycleComponent
org.refcodes.component.LifecycleComponent.LifecycleAutomaton, org.refcodes.component.LifecycleComponent.UncheckedLifecycleComponentNested 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.UncheckedPausableNested 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.UncheckedResumableNested classes/interfaces inherited from interface org.refcodes.component.Startable
org.refcodes.component.Startable.StartAutomaton, org.refcodes.component.Startable.StartBuilder<B extends org.refcodes.component.Startable.StartBuilder<B>>, org.refcodes.component.Startable.UncheckedStartableNested classes/interfaces inherited from interface org.refcodes.component.Stoppable
org.refcodes.component.Stoppable.StopAutomaton, org.refcodes.component.Stoppable.StopBuilder<B extends org.refcodes.component.Stoppable.StopBuilder<B>>, org.refcodes.component.Stoppable.UncheckedStoppable -
Constructor Summary
ConstructorsConstructorDescriptionPartedLogger(org.refcodes.controlflow.ExecutionStrategy aComponentExecutionStrategy, org.refcodes.tabular.Column<P> aPartitionColumn, String aDefaultLoggerName, LoggerFactory<Logger<T>> aLoggerFactory, boolean isPartitionAutoInitialize) Similar to thePartedLogger(Column, LoggerFactory, boolean)with the additional option of determining the execution strategy of the state change request calls for the encapsulatedLoggerinstances (as ofComponentComposite).PartedLogger(org.refcodes.controlflow.ExecutionStrategy aComponentExecutionStrategy, org.refcodes.tabular.Column<P> aPartitionColumn, LoggerFactory<Logger<T>> aLoggerFactory, boolean isPartitionAutoInitialize) Similar to thePartedLogger(Column, LoggerFactory, boolean)with the additional option of determining the execution strategy of the state change request calls for the encapsulatedLoggerinstances (as ofComponentComposite).PartedLogger(org.refcodes.tabular.Column<P> aPartitionColumn, String aDefaultLoggerName, LoggerFactory<Logger<T>> aLoggerFactory, boolean isPartitionAutoInitialize) Instantiates a newPartedLoggerwith the according parameters.PartedLogger(org.refcodes.tabular.Column<P> aPartitionColumn, LoggerFactory<Logger<T>> aLoggerFactory, boolean isPartitionAutoInitialize) Instantiates a newPartedLoggerwith the according parameters. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()voidvoiddecomposePartition(P aPartition) Decomposes the given partition.voiddestroy()voiddestroyPartition(P aPartition) Destroys the given partition.voiddispose()voidflush()voidflushPartition(P aPartition) Flushes the given partition, all buffered data is to be forwarded to the physical data sink.Returns the fallbackLogger.protected Collection<Logger<T>> Provides access to the partitions managed by theAbstractPartedLogger.protected org.refcodes.tabular.Column<P> Provides access to theColumnused to identify partitions.getPartitionLogger(P aPartition) Returns theLoggerbeing responsible for the given partition.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 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.refcodes.component.Closable
closeIn, closeQuietly, closeUncheckedMethods inherited from interface org.refcodes.component.Flushable
flushUnchecked, isFlushableMethods inherited from interface org.refcodes.component.Initializable
initializeUncheckedMethods inherited from interface org.refcodes.logger.LogDecorator
printHead, printSeparator, printTailMethods inherited from interface org.refcodes.component.Openable
openUncheckedMethods inherited from interface org.refcodes.component.Pausable
pauseUncheckedMethods inherited from interface org.refcodes.component.Resumable
resumeUncheckedMethods inherited from interface org.refcodes.component.Startable
startUncheckedMethods inherited from interface org.refcodes.component.Stoppable
stopUnchecked
-
Constructor Details
-
PartedLogger
public PartedLogger(org.refcodes.tabular.Column<P> aPartitionColumn, LoggerFactory<Logger<T>> aLoggerFactory, boolean isPartitionAutoInitialize) Instantiates a newPartedLoggerwith 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.
-
PartedLogger
public PartedLogger(org.refcodes.tabular.Column<P> aPartitionColumn, String aDefaultLoggerName, LoggerFactory<Logger<T>> aLoggerFactory, boolean isPartitionAutoInitialize) Instantiates a newPartedLoggerwith 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 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.
-
PartedLogger
public PartedLogger(org.refcodes.controlflow.ExecutionStrategy aComponentExecutionStrategy, org.refcodes.tabular.Column<P> aPartitionColumn, LoggerFactory<Logger<T>> aLoggerFactory, boolean isPartitionAutoInitialize) Similar to thePartedLogger(Column, LoggerFactory, boolean)with the additional option of determining the execution strategy of the state change request calls for the encapsulatedLoggerinstances (as ofComponentComposite).- Parameters:
aComponentExecutionStrategy- The strategy to be used when invoking a component's (encapsulatedLoggerinstance's) state change request call (as ofComponentComposite).aPartitionColumn- theColumnidentifying partition column for sharding.aLoggerFactory- theLoggerFactorypopulating this composite with partitions.isPartitionAutoInitialize- the is partition auto initialize
-
PartedLogger
public PartedLogger(org.refcodes.controlflow.ExecutionStrategy aComponentExecutionStrategy, org.refcodes.tabular.Column<P> aPartitionColumn, String aDefaultLoggerName, LoggerFactory<Logger<T>> aLoggerFactory, boolean isPartitionAutoInitialize) Similar to thePartedLogger(Column, LoggerFactory, boolean)with the additional option of determining the execution strategy of the state change request calls for the encapsulatedLoggerinstances (as ofComponentComposite).- Parameters:
aComponentExecutionStrategy- The strategy to be used when invoking a component's (encapsulatedLoggerinstance'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- the is partition auto initialize
-
-
Method Details
-
initialize
public void initialize() throws org.refcodes.component.InitializeException- Specified by:
initializein interfaceorg.refcodes.component.Initializable- Throws:
org.refcodes.component.InitializeException
-
start
public void start() throws org.refcodes.component.StartException- Specified by:
startin interfaceorg.refcodes.component.Startable- Throws:
org.refcodes.component.StartException
-
pause
public void pause() throws org.refcodes.component.PauseException- Specified by:
pausein interfaceorg.refcodes.component.Pausable- Throws:
org.refcodes.component.PauseException
-
resume
public void resume() throws org.refcodes.component.ResumeException- Specified by:
resumein interfaceorg.refcodes.component.Resumable- Throws:
org.refcodes.component.ResumeException
-
stop
public void stop() throws org.refcodes.component.StopException- Specified by:
stopin interfaceorg.refcodes.component.Stoppable- Throws:
org.refcodes.component.StopException
-
decompose
public void decompose()- Specified by:
decomposein interfaceorg.refcodes.component.Decomposable
-
flush
- Specified by:
flushin interfaceFlushable- Specified by:
flushin interfaceorg.refcodes.component.Flushable- Throws:
IOException
-
destroy
public void destroy()- Specified by:
destroyin interfaceorg.refcodes.component.Destroyable
-
reset
public void reset()- Specified by:
resetin interfaceorg.refcodes.mixin.Resetable
-
open
- Specified by:
openin interfaceorg.refcodes.component.Openable- Throws:
IOException
-
close
public void close()- Specified by:
closein interfaceorg.refcodes.component.Closable
-
dispose
public void dispose()- Specified by:
disposein interfaceorg.refcodes.mixin.Disposable
-
log
Logs aRecord. The targeted data sink for theRecordinstances (where them are physically stored) depends on the implementation of theLogger. It can be a console, a file, a stream or a database. -
hasPartition
Tests whether the provided partition exists.- Parameters:
aPartition- The value of theColumnin aRecordspecifying the partition which is to be addressed (or even auto initialized).- Returns:
- True in case the partition exists, else false.
-
initPartition
Initializes the given partition.- Parameters:
aPartition- The value of theColumnin aRecordspecifying 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
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
Provides access to theColumnused to identify partitions.- Returns:
- The
Columnidentifying partitions.
-
getPartitionLogger
-
getFallbackLogger
-