public class GHNReservation extends SortableElement<java.lang.Long,PlanBuilderIdentifier>
PlanBuilderWorkflow session, to each workflow is
associated, in a persistent way, a GHNReservation.
The reservation essentially consists of an expiration time
and a list of GHNDescriptor elements that have
been reserved for that session.
Once the reservation time expires, or a feedback is received
from the caller, all the reserved GHNDescriptor are
restored and made available for further reuse.
This solution ensures that until the Reservation is alive all
the GHNs assigned to it are not available to other
PlanBuilderWorkflow sessions.
A reservation is supposed to be sorted on the expiration time
(a Long) and identified by the unique PlanBuilderIdentifier
of the PlanBuilderWorkflow it is involved in.
Two GHNReservation assigned to the same PlanBuilderIdentifier
are assumed to be equals, namely for each PlanBuilderWorkflow a single
reservation can be done.
Once created a reservation, the GHNDescriptor can be inserted inside it.
To each PlanBuilderElem of a PlanBuilderWorkflow a GHNReservation
is automatically assigned.| Constructor and Description |
|---|
GHNReservation(PlanBuilderIdentifier wfID,
long ttl)
Builds a
GHNReservation to assign to a
PlanBuilderWorkflow session uniquely identified by
its PlanBuilderIdentifier. |
| Modifier and Type | Method and Description |
|---|---|
void |
addGHN(GHNDescriptor ghn)
Stores a new
GHNDescriptor in the list of
reserved GHNs in this reservation context. |
boolean |
equals(java.lang.Object obj)
|
java.util.List<GHNDescriptor> |
getGHNsForScope(GCUBEScope scope) |
int |
hashCode() |
boolean |
isExpired() |
void |
lock()
Deprecated.
This method should be only accessed by feedback handling function.
|
void |
revoke() |
void |
unlock()
Deprecated.
This method should be only accessed by feedback handling function.
|
compareTo, getElement, getSortIndex, toStringpublic GHNReservation(PlanBuilderIdentifier wfID,
long ttl)
GHNReservation to assign to a
PlanBuilderWorkflow session uniquely identified by
its PlanBuilderIdentifier.
The SortableElement.getElement() will return the
PlanBuilderIdentifier passed at construction phase
and is the key element to use for equals.
Once created the reservation stores the creation timestamp
that can be acceded through SortableElement.getSortIndex()
method.ttl - the time to live for the reservation expressed in mills.wfID - the PlanBuilderIdentifier workflow session.public final boolean isExpired()
public final boolean equals(java.lang.Object obj)
GHNReservation with both another
GHNReservation or a GHNDescriptor.
The comparison is done on the GHN unique ID.
This method is used to discover GHNDescriptor
that have been moved inside a private queue of reserved
GHNDescriptor owned by a workflow.equals in class java.lang.Objectpublic final int hashCode()
hashCode in class java.lang.Objectpublic final void addGHN(GHNDescriptor ghn) throws GCUBEFault
GHNDescriptor in the list of
reserved GHNs in this reservation context.ghn - GCUBEFaultpublic final void revoke()
public final java.util.List<GHNDescriptor> getGHNsForScope(GCUBEScope scope) throws GCUBEFault
GCUBEFaultpublic final void lock()
throws java.lang.InterruptedException
java.lang.InterruptedExceptionpublic final void unlock()