|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--one.world.util.IOUtilities
Implementation of I/O utilities. This class provides supporting
functionality for binding resources, managing leases, and
performing structured I/O. It includes several synchronous helper
methods, which should be used with caution: They are intended for
utilities, but should only see limited use in applications. All
synchronous invocations performed by the methods in this class time
out after Constants.SYNCHRONOUS_TIMEOUT.
Note that this class will be removed in a future release.
Warning: Synchronous invocations may result in deadlock. In particular, performing n concurrent synchronous invocations in an environment with n threads results in deadlock. As a result, components that are not thread-safe must not perform synchronous invocations.
Instead of using a synchronous invocation for a
request/response interaction consider using an Operation.
Operations do not capture the executing thread and are more
flexible since they support retries for timed out request/response
interactions. To use an operation, you need to write an additional
event handler, called the continuation, that handles the result of
the request/response interaction.
| Method Summary | |
static BindingResponse |
bind(EventHandler handler,
Tuple descriptor)
Bind the specified resource. |
static BindingResponse |
bind(EventHandler handler,
Tuple descriptor,
long duration)
Bind the specified resource. |
static void |
delete(EventHandler handler,
Guid id)
Delete the tuple with the specified ID. |
static IteratorElement |
next(EventHandler iterator)
Get the next element from the specified iterator. |
static void |
put(EventHandler handler,
Tuple t,
boolean simple)
Put the specified tuple. |
static QueryResponse |
query(EventHandler handler,
Query q)
Query for all tuples matching the specified query. |
static QueryResponse |
query(EventHandler handler,
Query q,
long duration)
Query for all tuples matching the specified query. |
static QueryResponse |
query(EventHandler handler,
Query q,
long duration,
boolean idOnly)
Query for all tuples matching the specified query. |
static Tuple |
read(EventHandler handler,
Query q)
Read a tuple matching the specified query. |
static Tuple |
read(EventHandler handler,
Query q,
long timeout,
boolean simple)
Read a tuple matching the specified query. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
public static BindingResponse bind(EventHandler handler,
Tuple descriptor)
throws UnknownResourceException,
LeaseDeniedException
lease default duration.handler - The request handler.descriptor - The resource descriptor.IllegalArgumentException - Signals that descriptor is not
a valid tuple, that handler
does not accept binding requests, or that
handler responds to binding
requests with an unrecognized event.TimeOutException - Signals that the synchronous invocation of
handler has timed out.UnknownResourceException - Signals that the specified resource is not
recognized by the specified request handler.LeaseDeniedException - Signals that the lease for the specified
resource has been denied.
public static BindingResponse bind(EventHandler handler,
Tuple descriptor,
long duration)
throws UnknownResourceException,
LeaseDeniedException
handler - The request handler.descriptor - The resource descriptor.duration - The initial lease duration.IllegalArgumentException - Signals that descriptor is not
a valid tuple, that duration is
an invalid lease duration, that
handler does not accept binding
requests, or that handler
responds to binding requests with an
unrecognized event.TimeOutException - Signals that the synchronous invocation of
handler has timed out.UnknownResourceException - Signals that the specified resource is not
recognized by the specified request handler.LeaseDeniedException - Signals that the lease for the specified
resource has been denied.
public static void put(EventHandler handler,
Tuple t,
boolean simple)
throws ResourceRevokedException
handler - The event handler for the structured I/O
resource.t - The tuple to put.simple - true if a simple output request
should be used.IllegalArgumentException - Signals that t is invalid,
that handler does not accept
(simple) output requests, or that
handler responds with an
unrecognized event.TimeOutException - Signals that the synchronous invocation of
handler has timed out.ResourceRevokedException - Signals that the resource managed by the
specified event handler has been revoked.
public static void delete(EventHandler handler,
Guid id)
throws ResourceRevokedException,
NoSuchTupleException
handler - The event handler for the tuple store.id - The ID of the tuple to delete.IllegalArgumentException - Signals that handler does not
accept delete requests or that
handler responds with an
unrecognized event.TimeOutException - Signals that the synchronous invocation of
handler has timed out.ResourceRevokedException - Signals that the resource managed by the
specified event handler has been revoked.NoSuchTupleException - Signals that no tuple with the specified
ID exists.
public static Tuple read(EventHandler handler,
Query q)
throws ResourceRevokedException
handler - The event handler for the structured I/O
resource.q - The query to match.null
if no tuple matches the query.IllegalArgumentException - Signals that q is invalid,
that handler does not accept
input requests, or that handler
responds with an unrecognized event.TimeOutException - Signals that the synchronous invocation of
handler has timed out.ResourceRevokedException - Signals that the resource managed by the
specified event handler has been revoked.
public static Tuple read(EventHandler handler,
Query q,
long timeout,
boolean simple)
throws ResourceRevokedException
Note that the specified time-out is not the time-out of the synchronous invocation, but rather the time-out of the structured I/O read operation.
handler - The event handler for the structured I/O
resource.q - The query to match.timeout - The time-out for the read operation.simple - true if a simple input request
should be used.null
if no tuple matches the query.IllegalArgumentException - Signals that q is invalid,
that handler does not accept
(simple) input requests, or that
handler responds with an
unrecognized event.TimeOutException - Signals that the synchronous invocation of
handler has timed out.ResourceRevokedException - Signals that the resource managed by the
specified event handler has been revoked.
public static QueryResponse query(EventHandler handler,
Query q)
throws ResourceRevokedException,
LeaseDeniedException
handler - The event handler for the tuple store.q - The query to match.IllegalArgumentException - Signals that q is invalid,
that handler does not accept
input requests, or that handler
responds with an unrecognized event.TimeOutException - Signals that the synchronous invocation of
handler has timed out.ResourceRevokedException - Signals that the resource managed by the
specified event handler has been revoked.LeaseDeniedException - Signals that the lease for the iterator over
the query's results has been denied.
public static QueryResponse query(EventHandler handler,
Query q,
long duration)
throws ResourceRevokedException,
LeaseDeniedException
handler - The event handler for the tuple store.q - The query to match.duration - The requested duration for the query iterator.IllegalArgumentException - Signals that q is invalid,
that duration is invalid,
that handler does not accept
input requests, or that handler
responds with an unrecognized event.TimeOutException - Signals that the synchronous invocation of
handler has timed out.ResourceRevokedException - Signals that the resource managed by the
specified event handler has been revoked.LeaseDeniedException - Signals that the lease for the iterator over
the query's results has been denied.
public static QueryResponse query(EventHandler handler,
Query q,
long duration,
boolean idOnly)
throws ResourceRevokedException,
LeaseDeniedException
handler - The event handler for the tuple store.q - The query to match.duration - The requested duration for the query iterator.idOnly - The flag for whether to only query for the
tuple IDs.IllegalArgumentException - Signals that q is invalid,
that duration is invalid,
that handler does not accept
input requests, or that handler
responds with an unrecognized event.TimeOutException - Signals that the synchronous invocation of
handler has timed out.ResourceRevokedException - Signals that the resource managed by the
specified event handler has been revoked.LeaseDeniedException - Signals that the lease for the iterator over
the query's results has been denied.public static IteratorElement next(EventHandler iterator)
iterator - The event handler for the iterator.IllegalArgumentException - Signals that handler does not
accept iterator requests, or that
iterator responds to iterator
requests with an unrecognized event.TimeOutException - Signals that the synchronous invocation of
iterator has timed out.NoSuchElementException - Signals that the iterator has no elements
left.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||