|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.rhq.core.pc.operation.OperationThreadPoolGateway
public class OperationThreadPoolGateway
This provides a queue-like structure that will submit operations to a thread pool for execution, or will store the operations until a time when they are allowed to be invoked. This class is used to enforce the rule that no two operations that are to be invoked on the same resource can run concurrently. This gateway will pass through all operations to its internal thread pool, unless an operation is already queued or running in the thread pool that is executing on a resource that the newly submitted operation needs to execute on. In this case, the second operation will be queued in this gateway until such time when the first operation is finished with the resource.
An analogy of this is shopping in a department store. Assume for this example a store has two departments - a jewelry department and a shoe department. There is one sales person per department. Two shoppers can concurrently buy different types of products - one shopper can be buying from the sales person in the jewelry department while, at the exact same time, the other shopper can be buying from the sales person in the shoe department. However, if both shoppers want to buy something from the shoe department, the second one has to wait until the first is finished with the shoe department's sales person. They cannot both buy something in the shoe department at the same time. In this analogy, a resource is a sales person, and a shopper's purchasing interaction is an operation invocation.
| Constructor Summary | |
|---|---|
OperationThreadPoolGateway(ThreadPoolExecutor threadPool)
Constructor for OperationThreadPoolGateway. |
|
| Method Summary | |
|---|---|
OperationInvocation |
getOperationInvocation(String jobId)
Returns the operation invocation that is responsible for executing the operation identified with the given job ID. |
void |
operationCompleted(OperationInvocation operation)
This is called by the OperationInvocation when it finished to notify this gateway that if there are any
other pending operations for the resource, that the next one is allowed to be executed. |
void |
shutdown()
Follows the same semantics as ExecutorService.shutdownNow(). |
void |
submit(OperationInvocation operation)
Submits the given operation to the gateway for execution within the thread pool. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public OperationThreadPoolGateway(ThreadPoolExecutor threadPool)
OperationThreadPoolGateway. When an OperationInvocation passes through this
gateway, it will be submitted for execution in the given thread pool.
threadPool - | Method Detail |
|---|
public void shutdown()
ExecutorService.shutdownNow(). All operations previously submitted to the
thread pool (that is, those operations that passed the gateway into the thread pool) will be canceled (or, at
least, a best attempt will be made to cancel them). No additional operations will be allowed to be submitted to
the gateway or the internal thread pool (including those that are queued in this gateway but not yet submitted to
the thread pool). Any queued operations sitting in this gateway will be immediately canceled.
public OperationInvocation getOperationInvocation(String jobId)
jobId - identifies the specific operation invocation to return
null if not foundpublic void submit(OperationInvocation operation)
operation -
IllegalStateException - if the gateway has been shutdownpublic void operationCompleted(OperationInvocation operation)
OperationInvocation when it finished to notify this gateway that if there are any
other pending operations for the resource, that the next one is allowed to be executed.
operation - the operation that has just completed
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||