Package com.moesif.servlet
Class BatchProcessor
- java.lang.Object
-
- java.util.TimerTask
-
- com.moesif.servlet.BatchProcessor
-
- All Implemented Interfaces:
Runnable
public class BatchProcessor extends TimerTask
TimerTask to maintain the events queue and send it to moesif periodically. Task runner method sends event in batches if at least one batch of events available. It maintains : 1. queue to hold events and events related configuration settings. 2. flag to show if a job is in-progress/running. It prints few helpful log statements, if debug has been enabled.
-
-
Constructor Summary
Constructors Constructor Description BatchProcessor(com.moesif.api.MoesifAPIClient moesifApi, MoesifConfiguration moesifConfig, boolean debug)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddEvent(com.moesif.api.models.EventModel event)Method to add event into a queue for batch-based event transfer.intgetBatchMaxTime()Returns time in secondsintgetUpdateConfigTime()Returns time in secondsbooleanisJobRunning()Method to check if job is running or not.voidrun()Task runner method to send events in batches if at least a batch of events available.-
Methods inherited from class java.util.TimerTask
cancel, scheduledExecutionTime
-
-
-
-
Constructor Detail
-
BatchProcessor
public BatchProcessor(com.moesif.api.MoesifAPIClient moesifApi, MoesifConfiguration moesifConfig, boolean debug)
-
-
Method Detail
-
getBatchMaxTime
public int getBatchMaxTime()
Returns time in seconds- Returns:
-
getUpdateConfigTime
public int getUpdateConfigTime()
Returns time in seconds- Returns:
-
addEvent
public void addEvent(com.moesif.api.models.EventModel event)
Method to add event into a queue for batch-based event transfer. It maintains time when the last event was added to the event queue.- Parameters:
event- : EventModel
-
isJobRunning
public boolean isJobRunning()
Method to check if job is running or not.- Returns:
- boolean Returns true if job is running otherwise false.
-
run
public void run()
Task runner method to send events in batches if at least a batch of events available. It also keeps track of a flag to show if job is in-progress. If debug has been enabled then it prints how many batches were sent with total events count.
-
-