|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.tenduke.command.CommandScheduler
public class CommandScheduler
Top level command scheduler that acts as the main provider for scheduling and executing commands. This class is intended for use from client facing end points and business logical application code that wish to execute and schedule commands.
CommandScheduler takes care of managing resource allocation for
invoking and executing Commands. This class also manages the
distribution of Commands based on Command execution CommandResult
objects.
Distribution is based on using DistributionRequestFactory
by calling getDistributionRequestFactory(),
AbstractDistributionRequest objects and submitting requests
to ExecutionManagers.getConcurrentExecutionManager()'s
implementation of
ConcurrentExecutionManager.submit(java.util.concurrent.Callable, java.lang.String).
Submitting requests for asynchronous calling for ConcurrentExecutionManager is done using
getClass().getSimpleName() for the caller name (study configuration of ConcurrentExecutionManager
thread pooling).
It is key that Batch (or similar implementation) is used to execute
a set of Command objects where execution order must remain same on all nodes in a distributed
system. If commands are executed separately there is no guarantee that execution order
remains the same for what was a ordered sequence on one node.
| Constructor Summary | |
|---|---|
protected |
CommandScheduler()
Prevents a new instance of the CommandScheduler class from being created. |
| Method Summary | |
|---|---|
protected void |
addCommandDistributionResponseFutureHandler(java.util.concurrent.Future<? extends AbstractDistributionRequestResult> commandDistributionResponseFuture)
Creates a handler for dealing with a future that gives access to a command distribution response once it is available. |
protected void |
distribute(Command command,
CommandExecutionContext commandContext,
CommandResult commandResult)
Distributes a command. |
protected DistributionRequestFactory |
getDistributionRequestFactory()
Gets DistributionRequestFactory to use for creating distribution requests. |
protected javax.security.auth.Subject |
impersonate(javax.security.auth.Subject authenticatedActor,
java.lang.String commandsRequiredActorId)
Impersonate an other Subject if command requires to be executed by an other actor. |
static CommandScheduler |
instance()
Get singleton instance of CommandScheduler. |
OperationResult |
invoke(Command command,
CommandExecutionContext commandContext)
Invoke execute for one command. |
OperationResult |
invoke(java.lang.String commandXml,
CommandExecutionContext commandContext)
Invoke execute for one command. |
java.util.List<OperationResult> |
invokeAll(java.util.List<Command> commands,
CommandExecutionContext commandContext)
Invoke execution on list of commands. |
java.util.concurrent.Future<OperationResult> |
invokeAsync(Command command,
CommandExecutionContext commandContext)
Asynchronously invoke execute for one command. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
protected CommandScheduler()
| Method Detail |
|---|
protected void addCommandDistributionResponseFutureHandler(java.util.concurrent.Future<? extends AbstractDistributionRequestResult> commandDistributionResponseFuture)
Creates a handler for dealing with a future that gives access to a command distribution response once it is available. This method is called for every command instance that is distributed.
commandDistributionResponseFuture - The response future to handle.
protected void distribute(Command command,
CommandExecutionContext commandContext,
CommandResult commandResult)
command - Command to distribute.commandContext - The context object from Command execution.commandResult - CommandResult object.protected DistributionRequestFactory getDistributionRequestFactory()
Gets DistributionRequestFactory to use for creating distribution requests.
Implementation is a call through to DistributionRequestFactories.getDistributionRequestFactory().
protected javax.security.auth.Subject impersonate(javax.security.auth.Subject authenticatedActor,
java.lang.String commandsRequiredActorId)
throws java.lang.SecurityException
authenticatedActor - The authenticated actor requesting to impersonate an other actor.commandsRequiredActorId - Actor's id for the actor to impersonate.
java.lang.SecurityException - Thrown if impersonation fails.public static CommandScheduler instance()
public OperationResult invoke(Command command,
CommandExecutionContext commandContext)
throws java.lang.SecurityException
command - Command to invoke.commandContext - The context object for Command execution.
java.lang.SecurityException - Thrown if failed to execute the command as the actor required by the command because impersonation fails.
public OperationResult invoke(java.lang.String commandXml,
CommandExecutionContext commandContext)
commandXml - Command as XML in XmlSerializer format.commandContext - The context object for Command execution.
public java.util.List<OperationResult> invokeAll(java.util.List<Command> commands,
CommandExecutionContext commandContext)
Batch command for cases where execution order needs to remain constant on all nodes in distribution.
commands - The list of Commands to execute.commandContext - The context object for Command execution.
public java.util.concurrent.Future<OperationResult> invokeAsync(Command command,
CommandExecutionContext commandContext)
throws java.lang.SecurityException
command - Command to invoke.commandContext - The context object for Command execution.
java.lang.SecurityException - Thrown if failed to execute the command as the actor required by the command because impersonation fails.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||