public abstract class AbstractTwillController extends AbstractZKServiceController implements TwillController
TwillController
implementation that uses Zookeeper to controller a
running twill application.ServiceController.TerminationStatus
zkClient
Constructor and Description |
---|
AbstractTwillController(String appName,
RunId runId,
ZKClient zkClient,
boolean logCollectionEnabled,
Iterable<LogHandler> logHandlers) |
Modifier and Type | Method and Description |
---|---|
void |
addLogHandler(LogHandler handler)
Adds a
LogHandler for receiving application log. |
com.google.common.util.concurrent.ListenableFuture<Integer> |
changeInstances(String runnable,
int newCount)
Changes the number of running instances of a given runnable.
|
ServiceDiscovered |
discoverService(String serviceName)
Discovers the set of
Discoverable endpoints that provides service for the given service name. |
protected void |
doShutDown()
Called during shutdown.
|
protected void |
doStartUp()
Called during startup.
|
protected void |
resetLogHandler()
Reset the log handler to poll from the beginning of Kafka.
|
Future<String[]> |
resetLogLevels(String... loggerNames)
Reset the log levels of all runnables.
|
Future<String[]> |
resetRunnableLogLevels(String runnableName,
String... loggerNames)
Reset the log levels of the given runnable.
|
com.google.common.util.concurrent.ListenableFuture<String> |
restartAllInstances(String runnableName)
Restart all instances of a particular
TwillRunnable . |
com.google.common.util.concurrent.ListenableFuture<Set<String>> |
restartInstances(Map<String,? extends Set<Integer>> runnableToInstanceIds)
Restart instances of some
TwillRunnable . |
com.google.common.util.concurrent.ListenableFuture<String> |
restartInstances(String runnable,
int instanceId,
int... moreInstanceIds)
Restart instances of some
TwillRunnable . |
com.google.common.util.concurrent.ListenableFuture<String> |
restartInstances(String runnable,
Set<Integer> instanceIds)
Restart instances of some
TwillRunnable . |
Future<Map<String,LogEntry.Level>> |
updateLogLevels(Map<String,LogEntry.Level> logLevels)
Update the log levels for requested logger names for Twill applications running in a container.
|
Future<Map<String,LogEntry.Level>> |
updateLogLevels(String runnableName,
Map<String,LogEntry.Level> runnableLogLevels)
Update the log levels for requested logger names for a
TwillRunnable . |
forceShutDown, getInstancePath, getStopMessageFuture, instanceNodeFailed, instanceNodeUpdated, sendCommand, sendCommand, sendMessage, shutDown, startUp, watchInstanceNode
addListener, awaitTerminated, awaitTerminated, executor, getRunId, getTerminationStatus, isRunning, onRunning, onTerminated, setTerminationStatus, start, startAndWait, state, stop, stopAndWait, terminate
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getResourceReport
awaitTerminated, awaitTerminated, getRunId, getTerminationStatus, kill, onRunning, onTerminated, sendCommand, sendCommand, terminate
public AbstractTwillController(String appName, RunId runId, ZKClient zkClient, boolean logCollectionEnabled, Iterable<LogHandler> logHandlers)
protected void doStartUp()
AbstractZKServiceController
doStartUp
in class AbstractZKServiceController
protected void doShutDown()
AbstractZKServiceController
doShutDown
in class AbstractZKServiceController
public final void addLogHandler(LogHandler handler)
TwillController
LogHandler
for receiving application log.addLogHandler
in interface TwillController
handler
- The handler to add.public final ServiceDiscovered discoverService(String serviceName)
TwillController
Discoverable
endpoints that provides service for the given service name.discoverService
in interface TwillController
serviceName
- Name of the service to discovery.ServiceDiscovered
object representing the result.public final com.google.common.util.concurrent.ListenableFuture<Integer> changeInstances(String runnable, int newCount)
TwillController
changeInstances
in interface TwillController
runnable
- The name of the runnable.newCount
- Number of instances for the given runnable.Future
that will be completed when the number running instances has been
successfully changed. The future will carry the new count as the result. If there is any error
while changing instances, it'll be reflected in the future.public final com.google.common.util.concurrent.ListenableFuture<String> restartAllInstances(String runnableName)
TwillController
TwillRunnable
.restartAllInstances
in interface TwillController
runnableName
- The name of the runnable to restart.Future
that will be completed when the restart operation has been done.public final com.google.common.util.concurrent.ListenableFuture<Set<String>> restartInstances(Map<String,? extends Set<Integer>> runnableToInstanceIds)
TwillController
TwillRunnable
.restartInstances
in interface TwillController
runnableToInstanceIds
- A map of runnable ID to list of instance IDs to be restarted.Future
that will be completed when the restart operation has been done.public com.google.common.util.concurrent.ListenableFuture<String> restartInstances(String runnable, int instanceId, int... moreInstanceIds)
TwillController
TwillRunnable
.restartInstances
in interface TwillController
runnable
- The name of the runnable to restart.instanceId
- The main instance id to be restarted.moreInstanceIds
- The optional instance ids.Future
that will be completed when the restart operation has been done.public com.google.common.util.concurrent.ListenableFuture<String> restartInstances(String runnable, Set<Integer> instanceIds)
TwillController
TwillRunnable
.restartInstances
in interface TwillController
runnable
- The name of the runnable to restart.instanceIds
- Instances to be restartedFuture
that will be completed when the restart operation has been done.public Future<Map<String,LogEntry.Level>> updateLogLevels(Map<String,LogEntry.Level> logLevels)
TwillController
null
except for the root logger, which will reset the log level for
the specified logger.updateLogLevels
in interface TwillController
logLevels
- The Map
contains the requested logger names and log levels that need to be updated.Future
that will be completed when the log level update has been done. It will carry the
Map
of log levels as the result.public Future<Map<String,LogEntry.Level>> updateLogLevels(String runnableName, Map<String,LogEntry.Level> runnableLogLevels)
TwillController
TwillRunnable
.
The log level for a logger name can be null
except for the root logger,
which will reset the log level for
the specified logger.updateLogLevels
in interface TwillController
runnableName
- The name of the runnable to update the log level.runnableLogLevels
- The Map
contains the requested logger name and log level that
need to be updated.Future
that will be completed when the log level update has been done. It will carry the
Map
of log levels as the result.public Future<String[]> resetLogLevels(String... loggerNames)
TwillController
resetLogLevels
in interface TwillController
loggerNames
- The optional logger names to be reset for all runnables, if not provided, all log levels will
be reset.Future
that will be completed when the set log level operation has been done. The future result
is the logger names provided in the parameter.public Future<String[]> resetRunnableLogLevels(String runnableName, String... loggerNames)
TwillController
resetRunnableLogLevels
in interface TwillController
loggerNames
- The optional logger names to be reset for the runnable, if not provided, all log levels will
be reset.Future
that will be completed when the set log level operation has been done. The future result
is the logger names provided in the parameter.protected final void resetLogHandler()
Copyright © 2013-2020 The Apache Software Foundation. All rights reserved.