Class PartedTrimLogger<T,P extends T>

java.lang.Object
org.refcodes.logger.PartedTrimLogger<T,P>
Type Parameters:
T - The type of the Record instances managed by the Logger.
P - The type of the Column's value used for partitioning the Logger.
All Implemented Interfaces:
Flushable, org.refcodes.component.Closable, org.refcodes.component.ComponentComposite, 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.Resumable, org.refcodes.component.Startable, org.refcodes.component.Stoppable, LogDecorator, Logger<T>, QueryLogger<T>, TrimLogger<T>, org.refcodes.mixin.Clearable, org.refcodes.mixin.Disposable, org.refcodes.mixin.Resetable

public class PartedTrimLogger<T,P extends T> extends Object implements org.refcodes.component.ComponentComposite
The PartedTrimLogger is a ready to use implementation of a parted TrimLogger extending the AbstractPartedTrimLogger.
  • 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 extends Object,CON extends 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.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

    Nested 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.UncheckedStartable

    Nested 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

    Constructors
    Constructor
    Description
    PartedTrimLogger(org.refcodes.controlflow.ExecutionStrategy aComponentExecutionStrategy, org.refcodes.tabular.Column<P> aPartitionColumn, String aDefaultLoggerName, LoggerFactory<TrimLogger<T>> aLoggerFactory, boolean isPartitionAutoInitialize)
    Similar to the PartedTrimLogger(Column, LoggerFactory, boolean) constructor with the additional option of determining the execution strategy of the state change request calls for the encapsulated TrimLogger instances (as of ComponentComposite).
    PartedTrimLogger(org.refcodes.controlflow.ExecutionStrategy aComponentExecutionStrategy, org.refcodes.tabular.Column<P> aPartitionColumn, LoggerFactory<TrimLogger<T>> aLoggerFactory, boolean isPartitionAutoInitialize)
    Similar to the PartedTrimLogger(Column, LoggerFactory, boolean) constructor with the additional option of determining the execution strategy of the state change request calls for the encapsulated TrimLogger instances (as of ComponentComposite).
    PartedTrimLogger(org.refcodes.tabular.Column<P> aPartitionColumn, String aDefaultLoggerName, LoggerFactory<TrimLogger<T>> aLoggerFactory, boolean isPartitionAutoInitialize)
    Instantiates a new PartedTrimLogger with the according parameters.
    PartedTrimLogger(org.refcodes.tabular.Column<P> aPartitionColumn, LoggerFactory<TrimLogger<T>> aLoggerFactory, boolean isPartitionAutoInitialize)
    Instantiates a new PartedTrimLogger with the according parameters.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    void
    void
    void
    decomposePartition(P aPartition)
    Decomposes the given partition.
    void
    deleteLogs(org.refcodes.criteria.Criteria aCriteria)
    Deletes logged Record instances according to the provided Criteria.
    void
    void
    destroyPartition(P aPartition)
    Destroys the given partition.
    void
    org.refcodes.tabular.Records<T>
    Retrieves all available Record instances being logged.
    org.refcodes.tabular.Records<T>
    findLogs(int aLimit)
    Retrieves all available Record instances being logged matching the given criteria and restrictions.
    org.refcodes.tabular.Records<T>
    findLogs(org.refcodes.criteria.Criteria aCriteria)
    Retrieves all available Record instances being logged matching the given criteria and restrictions.
    org.refcodes.tabular.Records<T>
    findLogs(org.refcodes.criteria.Criteria aCriteria, int aLimit)
    Retrieves all available Record 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 available Record 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 available Record 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 available Record instances being logged matching the given criteria and restrictions.
    void
    void
    flushPartition(P aPartition)
    Flushes the given partition, all buffered data is to be forwarded to the physical data sink.
    protected TrimLogger<T>
    Returns the fallback Logger.
    protected Collection<TrimLogger<T>>
    Provides access to the partitions managed by the AbstractPartedLogger.
    protected org.refcodes.tabular.Column<P>
    Provides access to the Column used to identify partitions.
    protected TrimLogger<T>
    getPartitionLogger(P aPartition)
    Returns the Logger being responsible for the given partition.
    protected Collection<TrimLogger<T>>
    getPartitionLoggers(Set<P> aPartitions)
    Retrieves a collection with Logger instances managing the provided partitions.
    protected String
    getPartitionUid(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.
    boolean
    hasPartition(P aPartition)
    Tests whether the provided partition exists.
    void
    initPartition(P aPartition)
    Initializes the given partition.
    void
    log(org.refcodes.tabular.Record<? extends T> aRecord)
    Logs a Record.
    void
    void
    void
    void
    void
    void

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.refcodes.component.Closable

    closeIn, closeQuietly, closeUnchecked

    Methods inherited from interface org.refcodes.component.Flushable

    flushUnchecked, isFlushable

    Methods inherited from interface org.refcodes.component.Initializable

    initializeUnchecked

    Methods inherited from interface org.refcodes.logger.LogDecorator

    printHead, printSeparator, printTail

    Methods inherited from interface org.refcodes.logger.Logger

    log

    Methods inherited from interface org.refcodes.component.Openable

    openUnchecked

    Methods inherited from interface org.refcodes.component.Pausable

    pauseUnchecked

    Methods inherited from interface org.refcodes.logger.QueryLogger

    findLogs, findLogs, findLogs, findLogs, findLogs, findLogs, findLogs

    Methods inherited from interface org.refcodes.component.Resumable

    resumeUnchecked

    Methods inherited from interface org.refcodes.component.Startable

    startUnchecked

    Methods inherited from interface org.refcodes.component.Stoppable

    stopUnchecked
  • Constructor Details

    • PartedTrimLogger

      public PartedTrimLogger(org.refcodes.tabular.Column<P> aPartitionColumn, LoggerFactory<TrimLogger<T>> aLoggerFactory, boolean isPartitionAutoInitialize)
      Instantiates a new PartedTrimLogger with the according parameters.
      Parameters:
      aPartitionColumn - the Column identifying partition column for sharding.
      aLoggerFactory - the LoggerFactory populating 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 the initPartition(Object) method is invoked upon this partition. Find and delete operations are not considered.
    • PartedTrimLogger

      public PartedTrimLogger(org.refcodes.tabular.Column<P> aPartitionColumn, String aDefaultLoggerName, LoggerFactory<TrimLogger<T>> aLoggerFactory, boolean isPartitionAutoInitialize)
      Instantiates a new PartedTrimLogger with the according parameters.
      Parameters:
      aPartitionColumn - the Column identifying partition column for sharding.
      aDefaultLoggerName - In case a fallback Logger is to be used when no partition can be determined, then this parameter defines the name of the fallback Logger.
      aLoggerFactory - the LoggerFactory populating 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 the initPartition(Object) method is invoked upon this partition. Find and delete operations are not considered.
    • PartedTrimLogger

      public PartedTrimLogger(org.refcodes.controlflow.ExecutionStrategy aComponentExecutionStrategy, org.refcodes.tabular.Column<P> aPartitionColumn, LoggerFactory<TrimLogger<T>> aLoggerFactory, boolean isPartitionAutoInitialize)
      Similar to the PartedTrimLogger(Column, LoggerFactory, boolean) constructor with the additional option of determining the execution strategy of the state change request calls for the encapsulated TrimLogger instances (as of ComponentComposite).
      Parameters:
      aComponentExecutionStrategy - The strategy to be used when invoking a component's (encapsulated TrimLogger instance's) state change request call (as of ComponentComposite).
      aPartitionColumn - the Column identifying partition column for sharding.
      aLoggerFactory - the LoggerFactory populating this composite with partitions.
      isPartitionAutoInitialize - the is partition auto initialize
    • PartedTrimLogger

      public PartedTrimLogger(org.refcodes.controlflow.ExecutionStrategy aComponentExecutionStrategy, org.refcodes.tabular.Column<P> aPartitionColumn, String aDefaultLoggerName, LoggerFactory<TrimLogger<T>> aLoggerFactory, boolean isPartitionAutoInitialize)
      Similar to the PartedTrimLogger(Column, LoggerFactory, boolean) constructor with the additional option of determining the execution strategy of the state change request calls for the encapsulated TrimLogger instances (as of ComponentComposite).
      Parameters:
      aComponentExecutionStrategy - The strategy to be used when invoking a component's (encapsulated TrimLogger instance's) state change request call (as of ComponentComposite).
      aPartitionColumn - the Column identifying partition column for sharding.
      aDefaultLoggerName - In case a fallback Logger is to be used when no partition can be determined, then this parameter defines the name of the fallback Logger.
      aLoggerFactory - the LoggerFactory populating this composite with partitions.
      isPartitionAutoInitialize - the is partition auto initialize
  • Method Details

    • initialize

      public void initialize() throws org.refcodes.component.InitializeException
      Specified by:
      initialize in interface org.refcodes.component.Initializable
      Throws:
      org.refcodes.component.InitializeException
    • start

      public void start() throws org.refcodes.component.StartException
      Specified by:
      start in interface org.refcodes.component.Startable
      Throws:
      org.refcodes.component.StartException
    • pause

      public void pause() throws org.refcodes.component.PauseException
      Specified by:
      pause in interface org.refcodes.component.Pausable
      Throws:
      org.refcodes.component.PauseException
    • resume

      public void resume() throws org.refcodes.component.ResumeException
      Specified by:
      resume in interface org.refcodes.component.Resumable
      Throws:
      org.refcodes.component.ResumeException
    • stop

      public void stop() throws org.refcodes.component.StopException
      Specified by:
      stop in interface org.refcodes.component.Stoppable
      Throws:
      org.refcodes.component.StopException
    • decompose

      public void decompose()
      Specified by:
      decompose in interface org.refcodes.component.Decomposeable
    • flush

      public void flush() throws IOException
      Specified by:
      flush in interface Flushable
      Specified by:
      flush in interface org.refcodes.component.Flushable
      Throws:
      IOException
    • destroy

      public void destroy()
      Specified by:
      destroy in interface org.refcodes.component.Destroyable
    • reset

      public void reset()
      Specified by:
      reset in interface org.refcodes.mixin.Resetable
    • open

      public void open() throws IOException
      Specified by:
      open in interface org.refcodes.component.Openable
      Throws:
      IOException
    • close

      public void close() throws IOException
      Specified by:
      close in interface org.refcodes.component.Closable
      Throws:
      IOException
    • dispose

      public void dispose()
      Specified by:
      dispose in interface org.refcodes.mixin.Disposable
    • deleteLogs

      public void deleteLogs(org.refcodes.criteria.Criteria aCriteria) throws org.refcodes.criteria.CriteriaException.BadCriteriaException
      Deletes logged Record instances according to the provided Criteria.
      Specified by:
      deleteLogs in interface TrimLogger<L extends TrimLogger<T>>
      Parameters:
      aCriteria - The Criteria to be applied when deleting previously logged Record instances.
      Throws:
      org.refcodes.criteria.CriteriaException.BadCriteriaException - thrown in case of problems related to some Criteria.
    • clear

      public void clear()
      Specified by:
      clear in interface org.refcodes.mixin.Clearable
    • findLogs

      public org.refcodes.tabular.Records<T> findLogs()
      Retrieves all available Record instances being logged.
      Specified by:
      findLogs in interface QueryLogger<L extends QueryLogger<T>>
      Returns:
      A Records instance containing all available Record instances being logged.
    • findLogs

      public org.refcodes.tabular.Records<T> findLogs(int aLimit)
      Retrieves all available Record instances being logged matching the given criteria and restrictions.
      Specified by:
      findLogs in interface QueryLogger<L extends QueryLogger<T>>
      Parameters:
      aLimit - The maximum Record instances contained in the returned Records instance; there may be more Record instances which are not contained in the Records instance in case the Records instance's size is that of the specified limit.
      Returns:
      A Records instance containing all available Record instances being logged matching the given criteria and restrictions.
    • findLogs

      public org.refcodes.tabular.Records<T> findLogs(org.refcodes.criteria.Criteria aCriteria)
      Retrieves all available Record instances being logged matching the given criteria and restrictions.
      Specified by:
      findLogs in interface QueryLogger<L extends QueryLogger<T>>
      Parameters:
      aCriteria - The Criteria to be applied to the Record instances
      Returns:
      A Records instance containing all available Record 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 available Record instances being logged matching the given criteria and restrictions.
      Specified by:
      findLogs in interface QueryLogger<L extends QueryLogger<T>>
      Parameters:
      aHeader - The Header used to restrict the "columns" (key/value entries) in the retrieved Record instances (provided by the Records instance).
      aLimit - The maximum Record instances contained in the returned Records instance; there may be more Record instances which are not contained in the Records instance in case the Records instance's size is that of the specified limit.
      Returns:
      A Records instance containing all available Record instances being logged matching the given criteria and restrictions.
    • findLogs

      public org.refcodes.tabular.Records<T> findLogs(org.refcodes.criteria.Criteria aCriteria, int aLimit) throws org.refcodes.criteria.CriteriaException.BadCriteriaException
      Retrieves all available Record instances being logged matching the given criteria and restrictions.
      Specified by:
      findLogs in interface QueryLogger<L extends QueryLogger<T>>
      Parameters:
      aCriteria - The Criteria to be applied to the Record instances
      aLimit - The maximum Record instances contained in the returned Records instance; there may be more Record instances which are not contained in the Records instance in case the Records instance's size is that of the specified limit.
      Returns:
      A Records instance containing all available Record instances being logged matching the given criteria and restrictions.
      Throws:
      org.refcodes.criteria.CriteriaException.BadCriteriaException - thrown in case of problems related to some Criteria.
    • findLogs

      public org.refcodes.tabular.Records<T> findLogs(org.refcodes.criteria.Criteria aCriteria, org.refcodes.tabular.Header<T> aHeader) throws org.refcodes.criteria.CriteriaException.BadCriteriaException
      Retrieves all available Record instances being logged matching the given criteria and restrictions.
      Specified by:
      findLogs in interface QueryLogger<L extends QueryLogger<T>>
      Parameters:
      aCriteria - The Criteria to be applied to the Record instances
      aHeader - The Header used to restrict the "columns" (key/value entries) in the retrieved Record instances (provided by the Records instance).
      Returns:
      A Records instance containing all available Record instances being logged matching the given criteria and restrictions.
      Throws:
      org.refcodes.criteria.CriteriaException.BadCriteriaException - thrown in case of problems related to some Criteria.
    • findLogs

      public org.refcodes.tabular.Records<T> findLogs(org.refcodes.criteria.Criteria aCriteria, org.refcodes.tabular.Header<T> aHeader, int aLimit) throws org.refcodes.criteria.CriteriaException.BadCriteriaException
      Retrieves all available Record instances being logged matching the given criteria and restrictions.
      Specified by:
      findLogs in interface QueryLogger<L extends QueryLogger<T>>
      Parameters:
      aCriteria - The Criteria to be applied to the Record instances
      aHeader - The Header used to restrict the "columns" (key/value entries) in the retrieved Record instances (provided by the Records instance).
      aLimit - The maximum Record instances contained in the returned Records instance; there may be more Record instances which are not contained in the Records instance in case the Records instance's size is that of the specified limit.
      Returns:
      A Records instance containing all available Record instances being logged matching the given criteria and restrictions.
      Throws:
      org.refcodes.criteria.CriteriaException.BadCriteriaException - thrown in case of problems related to some Criteria.
    • getPartitionLoggers

      protected Collection<TrimLogger<T>> getPartitionLoggers(Set<P> aPartitions)
      Retrieves a collection with Logger instances managing the provided partitions.
      Parameters:
      aPartitions - The partitions for which to get the Logger instances.
      Returns:
      A Collection with none to many Logger instances
    • log

      public void log(org.refcodes.tabular.Record<? extends T> aRecord) throws IllegalRecordRuntimeException, UnexpectedLogRuntimeException
      Logs a Record. The targeted data sink for the Record instances (where them are physically stored) depends on the implementation of the Logger. It can be a console, a file, a stream or a database.
      Specified by:
      log in interface Logger<L extends Logger<T>>
      Parameters:
      aRecord - The Record to be logged.
      Throws:
      IllegalRecordRuntimeException - Thrown in case the record cannot be logged as a specific implementation might expect some dedicated Column 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 the Column in a Record specifying the partition which is to be addressed (or even auto initialized).
      Returns:
      True in case the partition exists, else false.
    • initPartition

      public TrimLogger<T> initPartition(P aPartition) throws org.refcodes.component.InitializeException
      Initializes the given partition.
      Parameters:
      aPartition - The value of the Column in a Record 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 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:
      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 Collection<TrimLogger<T>> getLoggers()
      Provides access to the partitions managed by the AbstractPartedLogger. This is ehttps://www.metacodes.proly useful for extensions of this class such as the AbstractPartedQueryLogger or the AbstractPartedTrimLogger.
      Returns:
      The Logger instances managed by the AbstractPartedLogger instance.
    • getPartitionUid

      protected String getPartitionUid(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.
      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 the Column used to identify partitions.
      Returns:
      The Column identifying partitions.
    • getPartitionLogger

      protected TrimLogger<T> getPartitionLogger(P aPartition)
      Returns the Logger being responsible for the given partition.
      Parameters:
      aPartition - The partition for which to get the responsible Logger.
      Returns:
      The Logger responsible for the given partition or null if none was found for the partition.
    • getFallbackLogger

      protected TrimLogger<T> getFallbackLogger()
      Returns the fallback Logger.
      Returns:
      The fallback logger or null if none was enabled.