public abstract class EventHandler extends Object
TwillRunnable
lifecycle events.Modifier and Type | Class and Description |
---|---|
static class |
EventHandler.TimeoutAction
Represents action to act upon runnable launch timeout.
|
static class |
EventHandler.TimeoutEvent
This class holds information about a launch timeout event.
|
Modifier and Type | Field and Description |
---|---|
protected EventHandlerContext |
context |
Constructor and Description |
---|
EventHandler() |
Modifier and Type | Method and Description |
---|---|
void |
aborted()
Invoked by the application when the application is aborted because of timeout.
|
void |
completed()
Invoked by the application when all containers complete.
|
EventHandlerSpecification |
configure()
Returns an
EventHandlerSpecification for configuring this handler class. |
void |
containerLaunched(String runnableName,
int instanceId,
String containerId)
Invoked by the application when new container is launched for a
TwillRunnable . |
void |
containerStopped(String runnableName,
int instanceId,
String containerId,
int exitStatus)
Invoked by the application when the container allocated for a
TwillRunnable is stopped. |
void |
destroy()
Invoked by the application when shutting down.
|
protected Map<String,String> |
getConfigs()
Returns set of configurations available at runtime for access.
|
void |
initialize(EventHandlerContext context)
Invoked by the application to initialize this EventHandler instance.
|
void |
killed()
Invoked by the application when stop command is received to kill the current application.
|
EventHandler.TimeoutAction |
launchTimeout(Iterable<EventHandler.TimeoutEvent> timeoutEvents)
Invoked when the number of expected instances doesn't match with number of actual instances.
|
void |
started()
Invoked by the application when it starts.
|
protected EventHandlerContext context
public EventHandlerSpecification configure()
EventHandlerSpecification
for configuring this handler class.public void initialize(EventHandlerContext context)
context
- context object for accessing the event handler execution context.public void started()
public void containerLaunched(String runnableName, int instanceId, String containerId)
TwillRunnable
.runnableName
- name of the runnable to be run in the new containerinstanceId
- the instance ID of the runnable instance to be run in the new containercontainerId
- the ID of the newly launched containerpublic void containerStopped(String runnableName, int instanceId, String containerId, int exitStatus)
TwillRunnable
is stopped.runnableName
- name of the runnable in the stopped containerinstanceId
- the instance ID of the runnable instance run in the stopped containercontainerId
- the ID of the stopped containerexitStatus
- the exit status of the containerpublic void completed()
public void killed()
public void aborted()
public void destroy()
public EventHandler.TimeoutAction launchTimeout(Iterable<EventHandler.TimeoutEvent> timeoutEvents)
timeoutEvents
- An Iterable of EventHandler.TimeoutEvent
that contains information about runnable launch timeout.EventHandler.TimeoutAction
to govern action to act. By default it is to recheck after 60 seconds.Copyright © 2013-2016 The Apache Software Foundation. All rights reserved.