public abstract class DispatchingHandler extends AuditEventHandlerAdapter
Modifier and Type | Field and Description |
---|---|
static int |
PROPERTY_DEFAULT_BATCHSIZE
Default value for Handler property PROPERTY_NAME_BATCHSIZE.
|
static String |
PROPERTY_NAME_BATCHSIZE
Handler property that specifies the batch size to use for selecting
AuditEvents (an INTEGER).
|
static String |
PROPERTY_NAME_CONTINUOUS_WORKER_MODE_ENABLED
Handler property used to indicate if Continuous Worker mode is enabled.
|
static String |
PROPERTY_NAME_DISPATCHINGHANDLERSPECIFICATION
Handler property that specifies the DispatchingHandlerSpecification
which encapsulates the details about the Workers
(a SystemObject specifying the DispatchingHandlerSpecification).
|
static String |
PROPERTY_NAME_DYNAMIC_BATCHSIZE_ENABLED
Handler property used to track whether dynamic BatchSize is enabled -
where the batchsize is modified based on current conditions,
such as taking into account DispatchedEvents in a fail/retry phase.
|
static String |
PROPERTY_NAME_FORCE_RETRY_OF_FAILURES
Handler property used to track whether to force a retry
of the first previous failure once we see a successful event processed.
|
static String |
PROPERTY_NAME_MAXIMUM_WORKER_QUEUE_SIZE
Handler property used to track the maximum event queue size for
any single Worker (Integer).
|
static String |
PROPERTY_NAME_PENDING_EVENTSET_NAMES
Handler property that holds the pending Event Set names, for Event Sets
dispatched and now awaiting completion.
|
static String |
PROPERTY_NAME_PROCESS_EVENTS_WHEN_NEW_EVENT_POSTED
Handler property used to track whether event processing should occur
when a new event is posted (BOOLEAN).
|
static String |
PROPERTY_NAME_PROCESS_EVENTS_WITH_TIMER
Handler property used to track whether event processing should occur
as part of timer handling (BOOLEAN).
|
static String |
PROPERTY_NAME_REQUEUE_UPON_FAILURE
Handler property used to track whether failed event processing
should result in requeuing back to dispatcher.
|
static String |
PROPERTY_NAME_RETRY_PHASE_PERIODS
Handler property used to hold the time periods
for each retry-upon-failure phase.
|
static String |
PROPERTY_NAME_RETRY_UPON_FAILURE
Handler property used to indicate if retry-upon-failure is enabled.
|
DEFAULT_BATCHSIZE
Constructor and Description |
---|
DispatchingHandler() |
Modifier and Type | Method and Description |
---|---|
protected void |
addPendingEventSetName(AuditEventHandlerContext context,
String setName)
Adds a new pending Event Set name.
|
protected void |
checkDispatchingHandlerSpecificationRequests(AuditEventHandlerContext context)
Checks to see if there are any DispatchingHandlerSpecification requests.
|
void |
checkForCompletedEventSets(AuditEventHandlerContext context)
Checks any pending Event Sets to see if all associated DispatchedEvents
have been completed.
|
protected void |
checkForNewPendingEventSetName(AuditEventHandlerContext context,
AuditEvent event)
Check to see if we now have a new Pending Event Set name that
the dispatcher should track to see when all of the events have
been processed.
|
protected void |
completeEventSet(AuditEventHandlerContext context,
String setName)
Perform operations associated with a completed Event Set.
|
protected DispatchingHandlerState |
constructDispatchingHandlerState()
Constructs the DispatchingHandlerState.
|
protected int |
deriveDispatcherDynamicBatchSize(LibrarySession session,
DispatchingHandlerState state,
int baseSize)
Gets the dynamic batch size, dervied as adjustments
to the base batchSize specified.
|
protected int |
deriveWorkerDynamicBatchSize(LibrarySession session,
int baseSize)
Gets the dynamic batch size, dervied as adjustments
to the base batchSize specified.
|
protected DispatchingHandlerSpecification |
determineDispatchingHandlerSpecification(LibrarySession session,
AuditEvent event)
Determine the DispatchingHandlerSpecification that should
be used for the specificed event.
|
protected int |
getBatchSize()
Gets the batch size.
|
protected String |
getCommonName()
Gets the common name for this handler, useful for logging.
|
protected DispatchingHandlerSpecification |
getDispatchingHandlerSpecification(AuditEventHandlerContext context)
Gets the DispatchingHandlerSpecification.
|
protected DispatchingHandlerState |
getDispatchingHandlerState()
Gets the DispatchingHandlerState.
|
protected int |
getDynamicBatchSize(LibrarySession session,
int baseSize)
Gets the dynamic batch size, dervied as adjustments
to the base batchSize specified.
|
Integer |
getEstimatedCost(LibrarySession session,
AuditEvent event)
Gets the estimated cost of processing the specified event.
|
String |
getEventSetName(LibrarySession session,
AuditEvent event)
Gets the EventSet name from the specified event.
|
int |
getMaximumWorkerQueueSize()
Gets maximum event queue size for any single Worker.
|
protected String[] |
getPendingEventSetNames(LibrarySession session)
Gets the current Event set names.
|
protected String[] |
getRetryPhasePeriods()
Gets the retry-upon-failure time periods, as Strings such as "5M".
|
void |
handleEventPosted(AuditEventHandlerContext context)
Called when at least one registered event is posted.
|
void |
handleInitialize(AuditEventHandlerContext context)
Initializes this handler.
|
void |
handleTimerExpired(AuditEventHandlerContext context)
Called when the timer for this AuditEventHandler expires.
|
protected boolean |
hasAuxDispatchingHandlerSpecifications(AuditEventHandlerContext context)
Checks if auxiliary DispatchingHandlerSpecifications will be used.
|
void |
incrementSkipCount()
Increment our "skipped event" count.
|
protected void |
initializeNonDynamicProperties(AuditEventHandlerContext context)
Initialize the member variables for the non-dynamic handler properties
Any updates to these properties are not recognized by the handler while
it is running.
|
protected boolean |
isContinuousWorkerModeEnabled()
Gets whether Continuous Worker Mode is enabled.
|
protected boolean |
isDynamicBatchSizeEnabled()
Gets whether dynamic BatchSize is enabled,
where the batchsize is modified based on current conditions,
such as taking into account DispatchedEvents in a fail/retry phase.
|
protected boolean |
isForceRetryFailuresEnabled()
Gets whether to force a retry of the first previous failure
once we see a successful event processed.
|
protected boolean |
isProcessEventsWhenNewEventPostedEnabled()
Gets whether event processing should occur when a new event gets posted.
|
protected boolean |
isProcessEventsWithTimerEnabled()
Gets whether event processing should occur as part of timer handling.
|
protected boolean |
isRequeueUponFailureEnabled()
Gets whether failed event processing should result in requeuing
back to dispatcher.
|
protected boolean |
isRetryUponFailureEnabled()
Gets whether retry-upon-failure is enabled.
|
protected void |
markProcessingCompleted(AuditEventHandlerContext context,
AuditEvent event,
DispatchedEvent de)
Mark "Processing Completed" on the specified DispatchedEvent and purge
the associated AuditEvent.
|
protected void |
processEvent(AuditEventHandlerContext context,
AuditEvent event)
Process the specified event.
|
protected abstract void |
processEvent(LibrarySession session,
AuditEvent event,
DispatchedEvent de)
Low-level processing of an event.
|
protected void |
processEvents(AuditEventHandlerContext context,
int batchSize)
Handle events by performing the requested operations, using the specified batch size.
|
protected void |
processExistingDispatchedEvent(AuditEventHandlerContext context,
AuditEvent event,
DispatchedEvent de)
Process an event that already has an existing DispatchedEvent
defined, indicating that it was likely requeued by a Worker.
|
protected void |
rebalanceActiveWorkers(AuditEventHandlerContext context,
DispatchingHandlerState state)
Perform rebalancing of all events dispatched by this handler
that are currently assigned to Active Workers.
|
protected void |
rebalanceInactiveWorkers(AuditEventHandlerContext context,
DispatchingHandlerState state)
Perform rebalancing of all events dispatched by this handler
that are currently assigned to Inactive Workers.
|
protected void |
rebalanceWorker(AuditEventHandlerContext context,
DispatchingHandlerState state,
AuditSpecification worker,
boolean force)
Perform rebalancing of all events dispatched by this handler
to the specified Worker..
|
protected void |
refreshDynamicProperties(AuditEventHandlerContext context)
Refresh the member variables for the dynamic handler properties.
|
void |
setForceRetryAllFailuresNextBatch()
Sets indication that all previous failures waiting to retry
should ignore the timer and retry during the next batch.
|
void |
setForceRetryFailuresNextBatch()
Sets indication that the first previous failure waiting to retry
should ignore the timer and retry during the next batch.
|
protected DispatchedEvent |
setProcessingStarted(AuditEventHandlerContext context,
AuditEvent event,
DispatchedEvent de)
Mark the specified DispatchedEvent as "Processing started" if
this event is indeed to be processed.
|
deleteEvents, getAuditHandlerSpecification, getAuditSpecification, getHandlerProperty, handleDispose, markProcessingStarted, processEvents, processEvents, selectEvents, selectEvents, selectMaximumEventId, setHandlerProperty
public static final String PROPERTY_NAME_DISPATCHINGHANDLERSPECIFICATION
Note: this property is only set on the Disptcher (not on Worker template).
public static final String PROPERTY_NAME_BATCHSIZE
public static final String PROPERTY_NAME_PENDING_EVENTSET_NAMES
public static final String PROPERTY_NAME_PROCESS_EVENTS_WITH_TIMER
public static final String PROPERTY_NAME_PROCESS_EVENTS_WHEN_NEW_EVENT_POSTED
public static final String PROPERTY_NAME_REQUEUE_UPON_FAILURE
public static final String PROPERTY_NAME_DYNAMIC_BATCHSIZE_ENABLED
public static final String PROPERTY_NAME_MAXIMUM_WORKER_QUEUE_SIZE
public static final String PROPERTY_NAME_RETRY_UPON_FAILURE
public static final String PROPERTY_NAME_RETRY_PHASE_PERIODS
public static final String PROPERTY_NAME_FORCE_RETRY_OF_FAILURES
public static final String PROPERTY_NAME_CONTINUOUS_WORKER_MODE_ENABLED
public static final int PROPERTY_DEFAULT_BATCHSIZE
public void handleInitialize(AuditEventHandlerContext context) throws Exception
AuditEventHandlerAdapter
Called immediately after construction.
handleInitialize
in interface AuditEventHandler
handleInitialize
in class AuditEventHandlerAdapter
context
- the AuditEventHandlerContext to use for processingException
- if the operation failspublic void handleTimerExpired(AuditEventHandlerContext context) throws Exception
AuditEventHandlerAdapter
handleTimerExpired
in interface AuditEventHandler
handleTimerExpired
in class AuditEventHandlerAdapter
context
- the AuditEventHandlerContext to use for processingException
- if the operation failspublic void handleEventPosted(AuditEventHandlerContext context) throws Exception
AuditEventHandlerAdapter
handleEventPosted
in interface AuditEventHandler
handleEventPosted
in class AuditEventHandlerAdapter
context
- the AuditEventHandlerContext to use for processingException
- if the operation failsprotected void initializeNonDynamicProperties(AuditEventHandlerContext context) throws IfsException
Any updates to these properties are not recognized by the handler while it is running.
context
- the AuditEventHandlerContextIfsException
- if the operation failsprotected void refreshDynamicProperties(AuditEventHandlerContext context) throws IfsException
Any updates to these properties are recognized by the handler at the next timer interval.
context
- the AuditEventHandlerContextIfsException
- if the operation failsprotected String getCommonName()
protected boolean isProcessEventsWithTimerEnabled() throws IfsException
IfsException
- if the operation failsprotected boolean isProcessEventsWhenNewEventPostedEnabled() throws IfsException
IfsException
- if the operation failsprotected boolean isRequeueUponFailureEnabled() throws IfsException
IfsException
- if the operation failsprotected boolean isRetryUponFailureEnabled() throws IfsException
IfsException
- if the operation failsprotected boolean isDynamicBatchSizeEnabled() throws IfsException
IfsException
- if the operation failsprotected boolean isContinuousWorkerModeEnabled() throws IfsException
IfsException
- if the operation failsprotected String[] getRetryPhasePeriods() throws IfsException
IfsException
- if the operation failsprotected boolean isForceRetryFailuresEnabled() throws IfsException
IfsException
- if the operation failsprotected DispatchingHandlerSpecification getDispatchingHandlerSpecification(AuditEventHandlerContext context) throws IfsException
context
- the handler contextIfsException
- if the operation failsprotected boolean hasAuxDispatchingHandlerSpecifications(AuditEventHandlerContext context) throws IfsException
context
- the handler contextIfsException
- if the operation failsprotected DispatchingHandlerSpecification determineDispatchingHandlerSpecification(LibrarySession session, AuditEvent event) throws IfsException
This is called when auxiliary DispatchingHandlerSpecifications are enabled. This is overridfden by subclasses that use auxiliary DispatchingHandlerSpecifications; the default implementation just returns null;
context
- the handler contextIfsException
- if the operation failspublic int getMaximumWorkerQueueSize() throws IfsException
A value of 0 implies no maximum.
IfsException
- if the operation failsprotected int getBatchSize() throws IfsException
IfsException
- if the operation failsprotected int getDynamicBatchSize(LibrarySession session, int baseSize) throws IfsException
session
- the session contextbaseSize
- the base batch size, fromthe handler property settingIfsException
- if the operation failsprotected int deriveDispatcherDynamicBatchSize(LibrarySession session, DispatchingHandlerState state, int baseSize) throws IfsException
session
- the session contextstate
- the DispatchingHandlerStatebaseSize
- base batch size, from the handler property settingIfsException
- if the operation failsprotected int deriveWorkerDynamicBatchSize(LibrarySession session, int baseSize) throws IfsException
session
- the session contextbaseSize
- the base batch size, fromthe handler property settingIfsException
- if the operation failsprotected DispatchingHandlerState constructDispatchingHandlerState() throws IfsException
This is typically overridden by subclasses that wish to add custom dispatching logic.
IfsException
- if the opertation failsprotected DispatchingHandlerState getDispatchingHandlerState() throws IfsException
IfsException
- if the operation failsprotected void checkDispatchingHandlerSpecificationRequests(AuditEventHandlerContext context) throws IfsException
context
- the AuditEventHandlerContextIfsException
- if the operation failsprotected void processEvents(AuditEventHandlerContext context, int batchSize) throws IfsException
AuditEventHandlerAdapter
processEvents
in class AuditEventHandlerAdapter
context
- the AuditEventHandlerContext to use for processingIfsException
- if the operation failsprotected void processEvent(AuditEventHandlerContext context, AuditEvent event) throws IfsException
processEvent
in class AuditEventHandlerAdapter
context
- the AuditEventHandlerContext to use for processingevent
- the event to processIfsException
- if the operation failspublic void incrementSkipCount()
For the dispatcher, this is called by DispatchinghandlerState when it cannot dispatch an event to a Worker.
For a Worker, this is called whenever a failure is encountered, or when an event is skipped because it is dependent on an earlier event that has failed, when in Continuous Worker mode.
protected DispatchedEvent setProcessingStarted(AuditEventHandlerContext context, AuditEvent event, DispatchedEvent de) throws IfsException
This is overridden by the DispatchingHandler if the event is to be skipped for some reason, such as when RetryOnFailure is set and the retry phase timer has not yet expired.
setProcessingStarted
in class AuditEventHandlerAdapter
context
- the AuditEventHandlerContext to use for processingevent
- the event being processedde
- the DispatchedEvent to set "Processing Started"
if appropriateIfsException
- if the operation failsprotected void markProcessingCompleted(AuditEventHandlerContext context, AuditEvent event, DispatchedEvent de) throws IfsException
markProcessingCompleted
in class AuditEventHandlerAdapter
context
- the AuditEventHandlerContext to use for processingevent
- the event to purgede
- the DispatchedEventIfsException
- if the operation failspublic void setForceRetryFailuresNextBatch() throws IfsException
If this first previous failure is successfully processed, subsequent failures will be retried also, until one fails. After any new failure, the retry of previous failures stops.
IfsException
- if the operation failspublic void setForceRetryAllFailuresNextBatch() throws IfsException
IfsException
- if the operation failsprotected void processExistingDispatchedEvent(AuditEventHandlerContext context, AuditEvent event, DispatchedEvent de) throws IfsException
context
- the AuditEventHandlerContext to use for processingevent
- the event to processde
- the existing DispatchedEventIfsException
- if the operation failsprotected void checkForNewPendingEventSetName(AuditEventHandlerContext context, AuditEvent event) throws IfsException
session
- the session contextevent
- the eventIfsException
- if the operation fails.public String getEventSetName(LibrarySession session, AuditEvent event) throws IfsException
session
- the session contextevent
- the eventIfsException
- if the operation fails.public Integer getEstimatedCost(LibrarySession session, AuditEvent event) throws IfsException
session
- the session contextevent
- the eventIfsException
- if the operation fails.protected void completeEventSet(AuditEventHandlerContext context, String setName) throws IfsException
context
- the handler contextsetName
- the Event Set name that has completedIfsException
- if the operation failsprotected abstract void processEvent(LibrarySession session, AuditEvent event, DispatchedEvent de) throws IfsException
session
- the session Context to use for processingevent
- the event to processde
- the associated DispatchedEventIfsException
- if the operation failsprotected void rebalanceActiveWorkers(AuditEventHandlerContext context, DispatchingHandlerState state) throws IfsException
context
- the AuditEventHandlerContextstate
- the DispatchingHandlerStateIfsException
- if the operation failsprotected void rebalanceInactiveWorkers(AuditEventHandlerContext context, DispatchingHandlerState state) throws IfsException
context
- the AuditEventHandlerContextstate
- the DispatchingHandlerStateIfsException
- if the operation failsprotected void rebalanceWorker(AuditEventHandlerContext context, DispatchingHandlerState state, AuditSpecification worker, boolean force) throws IfsException
context
- the AuditEventHandlerContextstate
- the DispatchingHandlerStateworker
- the Worker whose events get requeued to dispatcherforce
- whether to also requeue events whose status is
STATUSCODE_PROCESSING_STARTEDIfsException
- if the operation failspublic void checkForCompletedEventSets(AuditEventHandlerContext context) throws IfsException
Typically called by subclasses as part of their Timer handling, to check if any existing pending Event Sets have all of their events processed by the Workers.
context
- the handler contextIfsException
- if the operation failsprotected String[] getPendingEventSetNames(LibrarySession session) throws IfsException
session
- the session contextIfsException
- if the operation failsprotected void addPendingEventSetName(AuditEventHandlerContext context, String setName) throws IfsException
session
- the session contextsetName
- the new pending Event Set nameIfsException
- if the operation failsCopyright © 2025. All rights reserved.