public class DispatchingHandlerState extends Object
Modifier and Type | Class and Description |
---|---|
static class |
DispatchingHandlerState.WorkerState
WorkerState holds info about a Worker,
to be used for dispatching and other management.
|
Modifier and Type | Field and Description |
---|---|
static String |
DE_SETTING_EFFECTIVE_TARGETOBJECT
DispatchedEvent setting that holds the effective target object
of the event.
|
static String |
DISPATCHING_POLICY_LEAST_LOADED_FASTLANE
The dispatching Policy name used for a "least loaded" dispatching strategy
where the first N Workers are used as a fast lane as compared to the
other Workers.
|
static String |
DISPATCHING_POLICY_LEASTLOADED
Dispatching policy for choosing the handler that is least loaded
from a processing cost perspective.
|
static String |
DISPATCHING_POLICY_ROUNDROBIN
Dispatching policy for simple round robin.
|
static String |
SETTING_CONTINUOUS_WORKER_ENABLED
DispatchingHandlerSpecification setting that indicates whether
the same Worker should be used for processing events for the
same effective target object referenced in the AuditEvent -
also known as "Continuous Worker" mode.
|
static String |
SETTING_NAME_DISPATCHING_POLICY
DispatchingHandlerSpecification setting that specifies the
dispatching policy.
|
static String |
SETTING_NAME_DISPATCHING_POLICY_DEFAULT
Default policy if not specified in the DispatchingHandlerSpecification.
|
static String |
SETTING_NAME_DISPATCHING_POLICY_FAST_LANE_COUNT
DispatchingHandlerSpecification setting that specifies the
the number of "Fast Lanes" to use for certain
dispatching policies.
|
Constructor and Description |
---|
DispatchingHandlerState()
Constructs a DispatchingHandlerState.
|
Modifier and Type | Method and Description |
---|---|
protected void |
addDispatchedEvent(DispatchedEvent de)
Adds a new DispatchedEvent to the Worker and to the list of
DispatchedEvents issued by the dispatcher.
|
protected void |
addDispatchedEvent(DispatchedEvent de,
boolean addToList)
Adds a new DispatchedEvent to the Worker and conditionally to the list of
DispatchedEvents issued by the dispatcher.
|
protected void |
addToEffectiveTargetObjectMap(DispatchedEvent de)
Adds a DispatchedEvent to the "ContinuousWorkerEnabled" map
if that option is enabled.
|
protected void |
alertHandlers(LibrarySession session)
Notify any handlers that we dispatched to
|
protected void |
applyDispatchedEventSettings(DispatchedEvent de,
AttributeValueTable deTable)
Apply any DispatchedEvent settings that are present in the specified
settings table.
|
void |
beginEventBatch(LibrarySession session)
Mark the beginning of processing a batch of events.
|
boolean |
canDispatch()
Gets whether the state reflects the ability to dispatch new events.
|
protected void |
checkActiveWorkers(LibrarySession session)
Checks to see if there are any changes to Active workers.
|
protected void |
checkInactiveWorkers(LibrarySession session)
Checks to see if any Inactive workers should have
their handler deactivated.
|
protected DispatchingHandlerState.WorkerState |
constructWorkerState(AuditSpecification worker)
Constructs a WorkerState.
|
protected AuditSpecification |
determineWorker(LibrarySession session,
AuditEvent event,
AttributeValueTable deTable)
Determine the Worker to use for the next AuditEvent.
|
void |
dispatchEvent(LibrarySession session,
AuditEvent event)
Dispatch a single event from a batch that selected.
|
void |
endEventBatch(LibrarySession session)
Mark the end of processing a batch of events.
|
protected void |
finalizeDispatchedEventSettings(LibrarySession session,
AuditEvent event,
AttributeValueTable deTable)
Finalize any DispatchedEvent settings that will eventually get stored
on the newly created (or updated) DispatchedEvent.
|
protected AuditSpecification |
getActiveWorkerForNextEvent(LibrarySession session,
AuditEvent event,
AttributeValueTable deTable)
Gets the Worker that should receive the next event.
|
protected AuditSpecification |
getActiveWorkerForNextEventLeastLoaded(LibrarySession session)
Gets the Workers that should receive the next event,
using "least loaded worker" policy.
|
protected AuditSpecification |
getActiveWorkerForNextEventLeastLoaded(LibrarySession session,
AuditSpecification[] workers)
Gets the Worker that should receive the next event,
using "least loaded worker" policy, using the specified set of Workers
as possible candidates.
|
protected AuditSpecification |
getActiveWorkerForNextEventRoundRobin(LibrarySession session)
Gets the Worker that should receive the next event,
using "round robin" policy.
|
AuditSpecification[] |
getActiveWorkers(LibrarySession session)
Gets the set of active Workers defined.
|
AuditSpecification[] |
getAllWorkers(LibrarySession session)
Gets the complete set of Workers defined.
|
DispatchedEvent[] |
getDispatchedEvents(LibrarySession session)
Gets the array of dispatched events.
|
AuditSpecification |
getDispatchingAuditSpecification(LibrarySession session)
Gets the Dispatching AuditSpecification.
|
DispatchingHandler |
getDispatchingHandler()
Gets the DispatchingHandler.
|
DispatchingHandlerSpecification |
getDispatchingHandlerSpecification(LibrarySession session)
Gets the DispatchingHandlerSpecification.
|
String |
getDispatchingPolicy()
Gets the dispatching policy in effect.
|
protected LibraryObject |
getEffectiveTargetObjectForEvent(LibrarySession session,
AuditEvent event)
Get the effective target object for the specified event,
used when "ContinuousWorkerEnabled" is enabled.
|
protected Long |
getEffectiveTargetObjectIdForEvent(LibrarySession session,
AuditEvent event)
Get the effective target object ID for the specified event,
used when "ContinuousWorkerEnabled" is enabled.
|
protected AuditSpecification |
getLeastLoadedWorker(LibrarySession session,
AuditSpecification[] workers)
Gets the Worker that currently is least loaded, using the specified
set of Workers as possible candidates.
|
protected AuditSpecification |
getLeastLoadedWorkerWithFastLane(LibrarySession session,
AuditEvent event,
int fastlaneCount)
Gets the Worker that should receive the next event,
using "least loaded worker" policy, taking into account
the number of "Fast Lanes" specified..
|
int |
getMaximumWorkerQueueSize()
Gets the maximum size of a Worker's event queue.
|
protected DispatchingHandlerState.WorkerState |
getWorkerState(AuditSpecification worker)
Get a WorkerState for the specified Worker's AuditSpecification.
|
Map<Long,DispatchingHandlerState.WorkerState> |
getWorkerStateMap()
Gets the map that holds Worker state, keyed by the worker's
AuditSpecification ID.
|
void |
handleTimerExpired(LibrarySession session)
Handle tasks to be performed at the dispatcher's timer interval.
|
void |
initialize(DispatchingHandler handler,
AuditSpecification dispatcher,
DispatchingHandlerSpecification dhSpec)
Initializes a newly constructed DispatchingHandlerState instance.
|
protected void |
initializeDispatchedEventSettings(LibrarySession session,
AuditEvent event,
AttributeValueTable deTable)
Initialize any DispatchedEvent settings that will eventually get stored
on the newly created (or updated) DispatchedEvent.
|
boolean |
isContinuousWorkerEnabled()
Gets indication as to whether the same Worker should be used for
processing events for the same effective target object referenced
in the AuditEvent - also known as "Continuous Worker" mode.
|
protected boolean |
isFastLaneEvent(LibrarySession session,
AuditEvent event)
Checks the specified event to see if it should be considered a
"fast lane" event.
|
protected void |
markDispatchedWorker(AuditSpecification worker)
Save indication that the specified worker has had at least one event
dispatched to it during the processing of the current batch.
|
void |
redispatchEvent(LibrarySession session,
AuditEvent event,
DispatchedEvent de)
Re-Dispatch a single event from a batch that selected,
forthe case where the event was requeued..
|
protected void |
refreshDispatchedEventList(LibrarySession session)
Refresh the list of dispatched events.
|
protected void |
refreshDispatchingPolicy(LibrarySession session)
Refresh the dispatching policy.
|
public static final String SETTING_CONTINUOUS_WORKER_ENABLED
public static final String SETTING_NAME_DISPATCHING_POLICY
public static final String SETTING_NAME_DISPATCHING_POLICY_FAST_LANE_COUNT
public static final String DE_SETTING_EFFECTIVE_TARGETOBJECT
public static final String DISPATCHING_POLICY_ROUNDROBIN
public static final String DISPATCHING_POLICY_LEASTLOADED
public static final String DISPATCHING_POLICY_LEAST_LOADED_FASTLANE
public static final String SETTING_NAME_DISPATCHING_POLICY_DEFAULT
public DispatchingHandlerState()
public void initialize(DispatchingHandler handler, AuditSpecification dispatcher, DispatchingHandlerSpecification dhSpec) throws IfsException
handler
- the DispatchingHandlerdispatcher
- the AuditSpecification for the dispatching handlerdhSpec
- the DispatchingHandlerSpecification used by
the dispatching handlerIfsException
- if the operation fails.protected DispatchingHandlerState.WorkerState constructWorkerState(AuditSpecification worker) throws IfsException
Can be overridden by subclasses to construct a custom subclass of WorkerState.
worker
- the WorkerIfsException
- if the opertation failsprotected DispatchingHandlerState.WorkerState getWorkerState(AuditSpecification worker) throws IfsException
worker
- the WorkerIfsException
- if the opertation failsprotected void refreshDispatchingPolicy(LibrarySession session) throws IfsException
session
- the session contextIfsException
- if the operation failspublic boolean canDispatch() throws IfsException
IfsException
- if the operation failspublic DispatchingHandler getDispatchingHandler() throws IfsException
IfsException
- if the operation fails.public AuditSpecification getDispatchingAuditSpecification(LibrarySession session) throws IfsException
session
- the session contextIfsException
- if the operation fails.public DispatchingHandlerSpecification getDispatchingHandlerSpecification(LibrarySession session) throws IfsException
session
- the session contextIfsException
- if the operation fails.public AuditSpecification[] getAllWorkers(LibrarySession session) throws IfsException
session
- the session contextIfsException
- if the operation failspublic AuditSpecification[] getActiveWorkers(LibrarySession session) throws IfsException
This refers to the Workers that can receive new Dispatched events, effectively the "active working AuditSpecifications". Note that the actual handlers may be active when the parent AuditSpecification is not active, in order to drain the queue.
session
- the session contextIfsException
- if the operation failspublic Map<Long,DispatchingHandlerState.WorkerState> getWorkerStateMap() throws IfsException
IfsException
- if the operation failspublic String getDispatchingPolicy() throws IfsException
Values supported intrinsically are: "RoundRobin", "LeastLoaded", and "LeastLoaded_FastLane". Subclasses can extend and add custom policies.
IfsException
- if the operation failspublic boolean isContinuousWorkerEnabled() throws IfsException
IfsException
- if the operation failspublic int getMaximumWorkerQueueSize() throws IfsException
A value of 0 implies no maximum.
IfsException
- if the operation failspublic void handleTimerExpired(LibrarySession session) throws IfsException
session
- the session stateIfsException
- if the operation fails.protected void checkActiveWorkers(LibrarySession session) throws IfsException
session
- the session stateIfsException
- if the operation fails.protected void checkInactiveWorkers(LibrarySession session) throws IfsException
session
- the session stateIfsException
- if the operation fails.public void dispatchEvent(LibrarySession session, AuditEvent event) throws IfsException
session
- the session stateevent
- the event to dispatchIfsException
- if the operation fails.public void redispatchEvent(LibrarySession session, AuditEvent event, DispatchedEvent de) throws IfsException
session
- the session stateevent
- the event to dispatchde
- the existing DispatchedEventIfsException
- if the operation fails.protected void markDispatchedWorker(AuditSpecification worker) throws IfsException
worker
- the Worker that has been dispatched toIfsException
- if the operation failsprotected AuditSpecification determineWorker(LibrarySession session, AuditEvent event, AttributeValueTable deTable) throws IfsException
session
- the session contextevent
- the AuditEvent that is being considered for dispatchdeTable
- the DispatchedEvent settings tableIfsException
- if the operation failsprotected AuditSpecification getActiveWorkerForNextEvent(LibrarySession session, AuditEvent event, AttributeValueTable deTable) throws IfsException
session
- the session contextevent
- the AuditEvent that is being considered for dispatchdeTable
- the DispatchedEvent settings tableIfsException
- if the operation failsprotected void initializeDispatchedEventSettings(LibrarySession session, AuditEvent event, AttributeValueTable deTable) throws IfsException
session
- the session contextevent
- the AuditEvent that is being considered for dispatchdeTable
- the DispatchedEvent settings tableIfsException
- if the operation failsprotected void finalizeDispatchedEventSettings(LibrarySession session, AuditEvent event, AttributeValueTable deTable) throws IfsException
session
- the session contextevent
- the AuditEvent that is being dispatcheddeTable
- the DispatchedEvent settings tableIfsException
- if the operation failsprotected void applyDispatchedEventSettings(DispatchedEvent de, AttributeValueTable deTable) throws IfsException
de
- the DispatchedEvent to updatedeTable
- the DispatchedEvent settings tableIfsException
- if the operation failsprotected Long getEffectiveTargetObjectIdForEvent(LibrarySession session, AuditEvent event) throws IfsException
session
- the session contextdeTable
- the DispatchedEvent settings tableIfsException
- if the operation failsprotected LibraryObject getEffectiveTargetObjectForEvent(LibrarySession session, AuditEvent event) throws IfsException
session
- the session contextdeTable
- the DispatchedEvent settings tableIfsException
- if the operation failsprotected AuditSpecification getActiveWorkerForNextEventRoundRobin(LibrarySession session) throws IfsException
session
- the session contextIfsException
- if the operation failsprotected AuditSpecification getActiveWorkerForNextEventLeastLoaded(LibrarySession session) throws IfsException
session
- the session contextIfsException
- if the operation failsprotected AuditSpecification getActiveWorkerForNextEventLeastLoaded(LibrarySession session, AuditSpecification[] workers) throws IfsException
session
- the session contextworkers
- the Worker pool to useIfsException
- if the operation failsprotected AuditSpecification getLeastLoadedWorker(LibrarySession session, AuditSpecification[] workers) throws IfsException
session
- the session contextworkers
- the Worker pool to useIfsException
- if the operation fails.protected AuditSpecification getLeastLoadedWorkerWithFastLane(LibrarySession session, AuditEvent event, int fastlaneCount) throws IfsException
session
- the session contextevent
- the event to be dispatchedfastlaneCount
- how many Workers are reserved for "fast lane"IfsException
- if the operation failsprotected boolean isFastLaneEvent(LibrarySession session, AuditEvent event) throws IfsException
session
- the session contextevent
- the event to be dispatchedIfsException
- if the operation failspublic void beginEventBatch(LibrarySession session) throws IfsException
session
- the session contextIfsException
- if the operation failspublic void endEventBatch(LibrarySession session) throws IfsException
session
- the session contextIfsException
- if the operation failsprotected void alertHandlers(LibrarySession session) throws IfsException
session
- the session contextIfsException
- if the operation failsprotected void addDispatchedEvent(DispatchedEvent de) throws IfsException
de
- the DispatchedEventIfsException
- if the operation fails.protected void addDispatchedEvent(DispatchedEvent de, boolean addToList) throws IfsException
de
- the DispatchedEventaddToList
- whether to add the event to the listIfsException
- if the operation fails.protected void refreshDispatchedEventList(LibrarySession session) throws IfsException
session
- the session contextIfsException
- if the operation fails.public DispatchedEvent[] getDispatchedEvents(LibrarySession session) throws IfsException
session
- the session contextIfsException
- if the operation fails.protected void addToEffectiveTargetObjectMap(DispatchedEvent de) throws IfsException
de
- the DispatchedEventIfsException
- if the operation fails.Copyright © 2025. All rights reserved.