Package org.apache.hadoop.hbase.executor
Class EventHandler
java.lang.Object
org.apache.hadoop.hbase.executor.EventHandler
- All Implemented Interfaces:
Comparable<EventHandler>
,Runnable
- Direct Known Subclasses:
AssignRegionHandler
,CloseRegionHandler
,CompactedHFilesDischargeHandler
,OpenRegionHandler
,ParallelSeekHandler
,RegionReplicaFlushHandler
,RSProcedureHandler
,TakeSnapshotHandler
,UnassignRegionHandler
,WALSplitterHandler
@Private
public abstract class EventHandler
extends Object
implements Runnable, Comparable<EventHandler>
Abstract base class for all HBase event handlers. Subclasses should implement the
process()
and prepare()
methods. Subclasses should also do all necessary checks
up in their prepare() if possible -- check table exists, is disabled, etc. -- so they fail fast
rather than later when process is running. Do it this way because process be invoked directly but
event handlers are also run in an executor context -- i.e. asynchronously -- and in this case,
exceptions thrown at process time will not be seen by the invoker, not till we implement a
call-back mechanism so the client can pick them up later.
Event handlers have an EventType
. EventType
is a list of ALL handler event types.
We need to keep a full list in one place -- and as enums is a good shorthand for an
implemenations -- because event handlers can be passed to executors when they are to be run
asynchronously. The hbase executor, see ExecutorService, has a switch for passing event type to
executor.
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionprotected EventType
private static final org.slf4j.Logger
private final io.opentelemetry.api.trace.Span
private final long
protected static final AtomicLong
protected Server
protected int
-
Constructor Summary
ConstructorDescriptionEventHandler
(Server server, EventType eventType) Default base class constructor. -
Method Summary
Modifier and TypeMethodDescriptionint
Default prioritized runnable comparator which implements a FIFO ordering.Return the event typeEvent implementations should override thie class to provide an informative name about what event they are handling.int
Get the priority level for this handler instance.long
getSeqid()
Returns This events' sequence id.protected void
Event exception handler, may be overriddenprepare()
Event handlers should do all the necessary checks in this method (rather than in the constructor, or in process()) so that the caller, which is mostly executed in the ipc context can fail fast.abstract void
process()
This method is the main processing loop to be implemented by the various subclasses.void
run()
toString()
-
Field Details
-
LOG
-
eventType
-
server
-
seqids
-
seqid
-
waitingTimeForEvents
-
parent
-
-
Constructor Details
-
EventHandler
Default base class constructor.
-
-
Method Details
-
prepare
Event handlers should do all the necessary checks in this method (rather than in the constructor, or in process()) so that the caller, which is mostly executed in the ipc context can fail fast. Process is executed async from the client ipc, so this method gives a quick chance to do some basic checks. Should be called after constructing the EventHandler, and before process().- Returns:
- the instance of this class
- Throws:
Exception
- when something goes wrong
-
run
-
process
This method is the main processing loop to be implemented by the various subclasses.- Throws:
IOException
-
getEventType
Return the event type- Returns:
- The event type.
-
getPriority
Get the priority level for this handler instance. This uses natural ordering so lower numbers are higher priority.Lowest priority is Integer.MAX_VALUE. Highest priority is 0.
Subclasses should override this method to allow prioritizing handlers.
Handlers with the same priority are handled in FIFO order.
- Returns:
- Integer.MAX_VALUE by default, override to set higher priorities
-
getSeqid
Returns This events' sequence id. -
compareTo
Default prioritized runnable comparator which implements a FIFO ordering.Subclasses should not override this. Instead, if they want to implement priority beyond FIFO, they should override
getPriority()
.- Specified by:
compareTo
in interfaceComparable<EventHandler>
-
toString
-
getInformativeName
Event implementations should override thie class to provide an informative name about what event they are handling. For example, event-specific information such as which region or server is being processed should be included if possible. -
handleException
Event exception handler, may be overridden- Parameters:
t
- Throwable object
-