org.jgroups.protocols

## Class Executing

- java.lang.Object
- - org.jgroups.stack.Protocol
  - - org.jgroups.protocols.Executing

Direct Known Subclasses:
  CENTRAL_EXECUTOR

    public abstract class Executing
    extends Protocol

This is the base protocol used for executions.

Author:
  wburns
See Also:
  `CENTRAL_EXECUTOR`

### Nested Class Summary

Nested Classes
`static class` `Executing.ExecutorHeader`
`static class` `Executing.Owner`
`protected static class` `Executing.Request`
`protected static class` `Executing.Type`

### Field Summary

Fields
`protected java.util.Queue<java.lang.Runnable>` `_awaitingConsumer` This is a queue on the client side that holds all of the tasks that are awaiting a consumer to pick them up
`protected java.util.Map<Executing.Owner,java.lang.Runnable>` `_awaitingReturn` This is a map on the client side that shows for which owner(consumer, request) the runnable they are currently using.
`protected java.util.concurrent.locks.Lock` `_consumerLock` This lock is to protect the incoming run requests and the incoming consumer queues
`protected java.util.Queue<Address>` `_consumersAvailable` This is stored on the coordinator side.
`protected java.util.concurrent.ConcurrentMap<java.lang.Runnable,java.lang.Thread>` `_runnableThreads` This is a server side map to show which threads are running for a given runnable.
`protected java.util.Map<java.lang.Runnable,Executing.Owner>` `_running` This is a map on the server side that shows which owner is currently tied to the runnable so we can return to them the results
`protected java.util.Queue<Address>` `_runRequests` This is stored on the coordinator side.
`protected java.util.concurrent.BlockingQueue<java.lang.Runnable>` `_tasks` This is a server side queue of all the tasks to pass off.
`protected boolean` `bypass_bundling`
`protected static java.util.concurrent.atomic.AtomicInteger` `counter` This keeps track of all the requests we send.
`protected Address` `local_addr`
`protected java.util.concurrent.ConcurrentMap<java.util.concurrent.Future<?>,ExecutorNotification>` `notifiers`
`protected View` `view`

### Fields inherited from class org.jgroups.stack.Protocol

`down_prot, ergonomics, id, log, name, stack, stats, up_prot`

### Constructor Summary

Constructors
Constructor and Description
`Executing()`

### Method Summary

Methods
`void` `addExecutorListener(java.util.concurrent.Future<?> future, ExecutorNotification listener)`
`java.lang.Object` `down(Event evt)` An event is to be sent down the stack.
`java.lang.String` `getAddress()`
`boolean` `getBypassBundling()`
`java.lang.String` `getView()`
`protected void` `handleConsumerFoundResponse(Address consumer)`
`protected void` `handleConsumerReadyRequest(Address source)`
`protected void` `handleExceptionResponse(Address source, Executing.Request req)`
`protected void` `handleInterruptRequest(Address source, short requestId)`
`protected void` `handleNewConsumer(Address sender)`
`protected void` `handleNewRunRequest(Address sender)`
`protected void` `handleRemoveConsumer(Address sender)`
`protected void` `handleRemoveRunRequest(Address sender)`
`protected void` `handleTaskRejectedResponse(Address source, short requestId)`
`protected void` `handleTaskRequest(Address source)`
`protected void` `handleTaskSubmittedRequest(java.lang.Runnable runnable, Address source, short requestId)`
`protected void` `handleValueResponse(Address source, Executing.Request req)`
`protected void` `handleView(View view)`
`protected abstract void` `sendNewConsumerRequest(Address source)`
`protected abstract void` `sendNewRunRequest(Address source)`
`protected abstract void` `sendRemoveConsumerRequest(Address source)`
`protected abstract void` `sendRemoveRunRequest(Address source)`
`protected void` `sendRequest(Address dest, Executing.Type type, short requestId, java.lang.Object object)`
`protected abstract void` `sendToCoordinator(Executing.Type type, java.lang.Object obj)`
`void` `setBypassBundling(boolean bypass_bundling)`
`java.lang.Object` `up(Event evt)` An event was received from the layer below.

### Methods inherited from class org.jgroups.stack.Protocol

`destroy, downThreadEnabled, dumpStats, enableStats, getConfigurableObjects, getDownProtocol, getId, getLevel, getName, getProperties, getProtocolStack, getSocketFactory, getThreadFactory, getTransport, getUpProtocol, getValue, init, isErgonomics, printStats, providedDownServices, providedUpServices, requiredDownServices, requiredUpServices, resetStats, setDownProtocol, setErgonomics, setId, setLevel, setProperties, setPropertiesInternal, setProperty, setProtocolStack, setSocketFactory, setUpProtocol, setValue, setValues, start, statsEnabled, stop, upThreadEnabled`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### bypass_bundling

    protected boolean bypass_bundling

#### local_addr

    protected Address local_addr

#### view

    protected View view

#### _awaitingConsumer

    protected final java.util.Queue<java.lang.Runnable> _awaitingConsumer

This is a queue on the client side that holds all of the tasks that are awaiting a consumer to pick them up

#### notifiers

    protected final java.util.concurrent.ConcurrentMap<java.util.concurrent.Future<?>,ExecutorNotification> notifiers

#### _running

    protected final java.util.Map<java.lang.Runnable,Executing.Owner> _running

This is a map on the server side that shows which owner is currently tied to the runnable so we can return to them the results

#### _awaitingReturn

    protected final java.util.Map<Executing.Owner,java.lang.Runnable> _awaitingReturn

This is a map on the client side that shows for which owner(consumer, request) the runnable they are currently using. This also allows us to set the values on a future when finished.

#### _tasks

    protected java.util.concurrent.BlockingQueue<java.lang.Runnable> _tasks

This is a server side queue of all the tasks to pass off. Currently there will never be tasks waiting to put in. If a task is put in and doesn't have a respective take at the same time that task is rejected.

#### _runnableThreads

    protected final java.util.concurrent.ConcurrentMap<java.lang.Runnable,java.lang.Thread> _runnableThreads

This is a server side map to show which threads are running for a given runnable. This is used to interrupt those threads if needed.

#### _consumerLock

    protected java.util.concurrent.locks.Lock _consumerLock

This lock is to protect the incoming run requests and the incoming consumer queues

#### _runRequests

    protected java.util.Queue<Address> _runRequests

This is stored on the coordinator side. This queue holds all of the addresses that currently want to run something. If this queue has elements the consumer queue must be empty.

#### _consumersAvailable

    protected java.util.Queue<Address> _consumersAvailable

This is stored on the coordinator side. This queue holds all of the addresses that currently are able to run something. If this queue has elements the run request queue must be empty.

#### counter

    protected static final java.util.concurrent.atomic.AtomicInteger counter

This keeps track of all the requests we send. This is used so that the response doesn't have to send back the future but instead the counter We just let this roll over

### Constructor Detail

#### Executing

    public Executing()

### Method Detail

#### getBypassBundling

    public boolean getBypassBundling()

#### setBypassBundling

    public void setBypassBundling(boolean bypass_bundling)

#### addExecutorListener

    public void addExecutorListener(java.util.concurrent.Future<?> future,
                           ExecutorNotification listener)

#### getAddress

    public java.lang.String getAddress()

#### getView

    public java.lang.String getView()

#### down

    public java.lang.Object down(Event evt)

Description copied from class: `Protocol`
An event is to be sent down the stack. The layer may want to examine its type and perform some action on it, depending on the event's type. If the event is a message MSG, then the layer may need to add a header to it (or do nothing at all) before sending it down the stack using `down_prot.down()`. In case of a GET_ADDRESS event (which tries to retrieve the stack's address from one of the bottom layers), the layer may need to send a new response event back up the stack using `up_prot.up()`.

Overrides:
  `down` in class `Protocol`

#### up

    public java.lang.Object up(Event evt)

Description copied from class: `Protocol`
An event was received from the layer below. Usually the current layer will want to examine the event type and - depending on its type - perform some computation (e.g. removing headers from a MSG event type, or updating the internal membership list when receiving a VIEW_CHANGE event). Finally the event is either a) discarded, or b) an event is sent down the stack using `down_prot.down()` or c) the event (or another event) is sent up the stack using `up_prot.up()`.

Overrides:
  `up` in class `Protocol`

#### handleView

    protected void handleView(View view)

#### sendToCoordinator

    protected abstract void sendToCoordinator(Executing.Type type,
                         java.lang.Object obj)

#### sendNewRunRequest

    protected abstract void sendNewRunRequest(Address source)

#### sendRemoveRunRequest

    protected abstract void sendRemoveRunRequest(Address source)

#### sendNewConsumerRequest

    protected abstract void sendNewConsumerRequest(Address source)

#### sendRemoveConsumerRequest

    protected abstract void sendRemoveConsumerRequest(Address source)

#### handleTaskRequest

    protected void handleTaskRequest(Address source)

#### handleConsumerReadyRequest

    protected void handleConsumerReadyRequest(Address source)

#### handleConsumerFoundResponse

    protected void handleConsumerFoundResponse(Address consumer)

#### handleTaskSubmittedRequest

    protected void handleTaskSubmittedRequest(java.lang.Runnable runnable,
                                  Address source,
                                  short requestId)

#### handleTaskRejectedResponse

    protected void handleTaskRejectedResponse(Address source,
                                  short requestId)

#### handleValueResponse

    protected void handleValueResponse(Address source,
                           Executing.Request req)

#### handleExceptionResponse

    protected void handleExceptionResponse(Address source,
                               Executing.Request req)

#### handleInterruptRequest

    protected void handleInterruptRequest(Address source,
                              short requestId)

#### handleNewRunRequest

    protected void handleNewRunRequest(Address sender)

#### handleRemoveRunRequest

    protected void handleRemoveRunRequest(Address sender)

#### handleNewConsumer

    protected void handleNewConsumer(Address sender)

#### handleRemoveConsumer

    protected void handleRemoveConsumer(Address sender)

#### sendRequest

    protected void sendRequest(Address dest,
                   Executing.Type type,
                   short requestId,
                   java.lang.Object object)