com.oracle.coherence.patterns.command.internal
Class CommandExecutor

java.lang.Object
  extended by com.oracle.coherence.patterns.command.internal.CommandExecutor
All Implemented Interfaces:
CommandExecutorMBean

public class CommandExecutor
extends Object
implements CommandExecutorMBean

An CommandExecutor is responsible for coordinating and executing Commands (represented as CommandExecutionRequests) for a single a Context.

Included in this responsibility is the recovery and potential re-execution of CommandExecutionRequests (in-the-originally-submitted-order). Such recovery may be due to Coherence load-balancing or recovering cache partitions.

Internally CommandExecutors operate as a simple finite-state-machine (see CommandExecutor.State for details on states).

CommandExecutors state transitions are typically controlled via 'events' delivered a ContextBackingMapListener or through the SubmitCommandExecutionRequestProcessor.

All CommandExecutors are monitorable through JMX. They are automatically registered and de-registered when they created and stopped (respectively).

Use a ContextsManager register and manage Contexts.

Copyright (c) 2008. All Rights Reserved. Oracle Corporation.
Oracle is a registered trademark of Oracle Corporation and/or its affiliates.

Author:
Brian Oliver, Simon Bisson
See Also:
CommandExecutionRequest, CommandSubmitter, CommandExecutorMBean, SubmitCommandExecutionRequestProcessor

Nested Class Summary
static class CommandExecutor.State
          The set of possible CommandExecutor.States for a CommandExecutor.
 
Constructor Summary
CommandExecutor(Identifier contextIdentifier, com.tangosol.net.BackingMapManagerContext backingMapManagerContext)
          Internal Constructor.
 
Method Summary
 SubmissionOutcome acceptCommandExecutionRequest(CommandExecutionRequest commandExecutionRequest)
          Accepts the specified CommandExecutionRequest for execution by this CommandExecutor.
 void execute()
          The method is used to asynchronously execute queued CommandExecutionRequests.
 Identifier getContextIdentifier()
          Returns the Identifier of the Context for which this CommandExecutor is coordinating CommandExecutionRequest execution.
 String getContextIdentity()
          Returns the Context Identifier as a string.
 long getContextVersion()
          Returns the version number of the Context that the CommandExecutor is managing.
 double getLocalAverageCommandExecutionDuration()
          Returns the average execution time (in milliseconds) for the Commands executed locally by the current owner of the Context (ie: local CommandExecutor).
 double getLocalCommandExecutionServiceDuration()
          Returns the local command execution service duration (in milliseconds).
 long getLocalCommandsExecuted()
          Returns the number of Commands that have been executed locally by the current owner of the Context (ie: local CommandExecutor).
 long getLocalCommandsSubmitted()
          Returns the number of Commands that have been submitted locally to the current owner of the Context (ie: local CommandExecutor).
 double getLocalLastCommandExecutionDuration()
          Returns the execution time (in milliseconds) for the last Command executed locally by the current owner of the Context (ie: the local CommandExecutor)
 double getLocalMaximumCommandExecutionDuration()
          Returns the maximum time (in milliseconds) that a Command has taken to execute locally by the current owner of the Context (ie: the local CommandExecutor)
 double getLocalMinimumCommandExecutionDuration()
          Returns the minimum time (in milliseconds) that a Command has taken to execute locally by the current owner of the Context (ie: the local CommandExecutor)
 String getMBeanName()
          Returns the cluster-wide uniquely generated JMX bean name for the CommandExecutor.
 CommandExecutor.State getState()
          Returns the current CommandExecutor.State of the CommandExecutor.
 String getStatus()
          Returns the current CommandExecutor.State of the CommandExecutor.
 long getTicketIssuerId()
          Returns the current id that is being used to issue Tickets.
 long getTotalCommandExecutionDuration()
          Returns the total time (in milliseconds) that the Commands executed thus far have taken to execute.
 long getTotalCommandExecutionWaitingDuration()
          Returns the total time (in milliseconds) that the Commands executed thus far have waited to execute (ie: the queuing time).
 long getTotalCommandsExecuted()
          Returns the total number of Commands for the Context that have been executed (regardless of the owner)
 long getTotalCommandsPendingExecution()
          Returns the total number of Commands that are yet to be executed
 void setState(CommandExecutor.State state)
          Sets the CommandExecutor.State of the CommandExecutor.
 void start()
          Starts up, initializes, recovers and schedules the CommandExecutor to start processing CommandExecutionRequests.
 void stop()
          Immediately stops the CommandExecutor from executing any further CommandExecutionRequests.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CommandExecutor

public CommandExecutor(Identifier contextIdentifier,
                       com.tangosol.net.BackingMapManagerContext backingMapManagerContext)
Internal Constructor. NOTE: To construct a CommandExecutor for your application, you should use a ContextsManager.

Parameters:
contextIdentifier -
backingMapManagerContext -
Method Detail

getContextIdentifier

public Identifier getContextIdentifier()
Returns the Identifier of the Context for which this CommandExecutor is coordinating CommandExecutionRequest execution. Context Identifiers are unique across a cluster.


setState

public void setState(CommandExecutor.State state)
Sets the CommandExecutor.State of the CommandExecutor.

Parameters:
state -

getState

public CommandExecutor.State getState()
Returns the current CommandExecutor.State of the CommandExecutor.


getMBeanName

public String getMBeanName()
Returns the cluster-wide uniquely generated JMX bean name for the CommandExecutor.


getContextIdentity

public String getContextIdentity()
Returns the Context Identifier as a string.

Specified by:
getContextIdentity in interface CommandExecutorMBean

getContextVersion

public long getContextVersion()
Returns the version number of the Context that the CommandExecutor is managing.

Specified by:
getContextVersion in interface CommandExecutorMBean

getStatus

public String getStatus()
Returns the current CommandExecutor.State of the CommandExecutor.

Specified by:
getStatus in interface CommandExecutorMBean

getTicketIssuerId

public long getTicketIssuerId()
Returns the current id that is being used to issue Tickets.

NOTE: If another CommandExecutor is created for same Context with the same Identifier in the cluster (due to recovery / load-balancing of Contexts), a new Ticket issuer id will be allocated to the new CommandExecutor. This ensures that for each instance of a CommandExecutor, the Ticket issuer id will be different, thus allowing us to "order" Commands send to particular CommandExecutors.

Specified by:
getTicketIssuerId in interface CommandExecutorMBean

getTotalCommandsPendingExecution

public long getTotalCommandsPendingExecution()
Returns the total number of Commands that are yet to be executed

Specified by:
getTotalCommandsPendingExecution in interface CommandExecutorMBean

getLocalCommandsSubmitted

public long getLocalCommandsSubmitted()
Returns the number of Commands that have been submitted locally to the current owner of the Context (ie: local CommandExecutor).

Specified by:
getLocalCommandsSubmitted in interface CommandExecutorMBean

getLocalCommandsExecuted

public long getLocalCommandsExecuted()
Returns the number of Commands that have been executed locally by the current owner of the Context (ie: local CommandExecutor).

Specified by:
getLocalCommandsExecuted in interface CommandExecutorMBean

getLocalAverageCommandExecutionDuration

public double getLocalAverageCommandExecutionDuration()
Returns the average execution time (in milliseconds) for the Commands executed locally by the current owner of the Context (ie: local CommandExecutor).

Specified by:
getLocalAverageCommandExecutionDuration in interface CommandExecutorMBean

getLocalLastCommandExecutionDuration

public double getLocalLastCommandExecutionDuration()
Returns the execution time (in milliseconds) for the last Command executed locally by the current owner of the Context (ie: the local CommandExecutor)

Specified by:
getLocalLastCommandExecutionDuration in interface CommandExecutorMBean

getLocalCommandExecutionServiceDuration

public double getLocalCommandExecutionServiceDuration()
Returns the local command execution service duration (in milliseconds). This includes the time to get the command as well as the time to execute the command.

Specified by:
getLocalCommandExecutionServiceDuration in interface CommandExecutorMBean

getLocalMinimumCommandExecutionDuration

public double getLocalMinimumCommandExecutionDuration()
Returns the minimum time (in milliseconds) that a Command has taken to execute locally by the current owner of the Context (ie: the local CommandExecutor)

Specified by:
getLocalMinimumCommandExecutionDuration in interface CommandExecutorMBean

getLocalMaximumCommandExecutionDuration

public double getLocalMaximumCommandExecutionDuration()
Returns the maximum time (in milliseconds) that a Command has taken to execute locally by the current owner of the Context (ie: the local CommandExecutor)

Specified by:
getLocalMaximumCommandExecutionDuration in interface CommandExecutorMBean

getTotalCommandsExecuted

public long getTotalCommandsExecuted()
Returns the total number of Commands for the Context that have been executed (regardless of the owner)

Specified by:
getTotalCommandsExecuted in interface CommandExecutorMBean

getTotalCommandExecutionDuration

public long getTotalCommandExecutionDuration()
Returns the total time (in milliseconds) that the Commands executed thus far have taken to execute.

Specified by:
getTotalCommandExecutionDuration in interface CommandExecutorMBean

getTotalCommandExecutionWaitingDuration

public long getTotalCommandExecutionWaitingDuration()
Returns the total time (in milliseconds) that the Commands executed thus far have waited to execute (ie: the queuing time).

Specified by:
getTotalCommandExecutionWaitingDuration in interface CommandExecutorMBean

start

public void start()
Starts up, initializes, recovers and schedules the CommandExecutor to start processing CommandExecutionRequests.


stop

public void stop()
Immediately stops the CommandExecutor from executing any further CommandExecutionRequests.


acceptCommandExecutionRequest

public SubmissionOutcome acceptCommandExecutionRequest(CommandExecutionRequest commandExecutionRequest)
Accepts the specified CommandExecutionRequest for execution by this CommandExecutor.

As part of this process, the CommandExecutionRequest is issued with a Ticket, has the instant in time the CommandExecutionRequest was accepted (queued), places the CommandExecutionRequest into the CommandExecutionRequests cache and queues the CommandExecutionRequest for execution.

If the Member in which this CommandExecutor is running no longer owns the Context to which the CommandExecutionRequest has been submitted (or ownership is in doubt), a Ticket.NONE is returned.

Parameters:
commandExecutionRequest - The CommandExecutionRequest to be accepted

execute

public void execute()
The method is used to asynchronously execute queued CommandExecutionRequests.



Copyright © 2016. All Rights Reserved.