Class InMemoryJobExecutionLogServiceImpl

java.lang.Object
org.quartzplus.service.InMemoryJobExecutionLogServiceImpl
All Implemented Interfaces:
JobExecutionLogService

public class InMemoryJobExecutionLogServiceImpl extends Object implements JobExecutionLogService
In-memory implementation of the JobExecutionLogService that uses a circular buffer to store logs.

This implementation is ideal for development environments or lightweight applications where persistent history is not required. It utilizes a thread-safe CircularFifoQueue to automatically evict the oldest log entries once the maximum size is reached.

Note: Clustering support (getQuartzExecutionNodeList()) and database table prefixes are not supported by this volatile implementation.

See Also:
  • Constructor Details

    • InMemoryJobExecutionLogServiceImpl

      public InMemoryJobExecutionLogServiceImpl(int maxSize)
      Constructs a new service instance with a fixed maximum buffer size.
      Parameters:
      maxSize - the maximum number of JobExecutionLog entries to retain.
  • Method Details

    • getJobExecutionLogList

      public org.springframework.data.domain.Page<JobExecutionLog> getJobExecutionLogList(Integer pageSize, Integer currentPage, @Nullable String groupName, @Nullable String jobName, @Nullable String triggerName, @Nullable String instanceClass)
      Filters and retrieves a paged list of logs from memory.

      Filtering is performed via stream predicates. If a filter parameter is blank or null, it is ignored during the search.

      Specified by:
      getJobExecutionLogList in interface JobExecutionLogService
      Parameters:
      pageSize - the number of logs per page.
      currentPage - the current page index (zero-based).
      groupName - (Optional) filter by job group.
      jobName - (Optional) filter by job name.
      triggerName - (Optional) filter by trigger name.
      instanceClass - (Optional) filter by the job class name.
      Returns:
      a Page containing the filtered logs.
    • getJobExecutionLog

      public Optional<JobExecutionLog> getJobExecutionLog(String jobExecutionLogId)
      Searches the in-memory queue for a log entry with the specified unique ID.
      Specified by:
      getJobExecutionLog in interface JobExecutionLogService
      Parameters:
      jobExecutionLogId - the UUID of the log entry.
      Returns:
      an Optional containing the log if found.
    • insertJobExecutionLog

      public void insertJobExecutionLog(JobExecutionLog jobExecutionLog)
      Adds a new log entry to the buffer. If the buffer is full, the oldest entry is automatically evicted.
      Specified by:
      insertJobExecutionLog in interface JobExecutionLogService
      Parameters:
      jobExecutionLog - the log entry to store.
    • clearJobExecutionLog

      public int clearJobExecutionLog(Instant since)
      Removes log entries from the buffer that were created before the specified timestamp.
      Specified by:
      clearJobExecutionLog in interface JobExecutionLogService
      Parameters:
      since - the cutoff timestamp for removal.
      Returns:
      the total number of entries removed from memory.
    • getQuartzExecutionNodeList

      public List<QuartzExecutionNode> getQuartzExecutionNodeList()
      This implementation does not track cluster nodes.
      Specified by:
      getQuartzExecutionNodeList in interface JobExecutionLogService
      Returns:
      an empty list.
    • getTablePrefix

      public String getTablePrefix()
      This implementation does not use database tables.
      Specified by:
      getTablePrefix in interface JobExecutionLogService
      Returns:
      an empty string.