Table of Contents
There are several ways to retrieve records from the store. You can:
Retrieve a single record at a time using
KVStore.get()
.
Retrieve records that share a complete set of major
components using either
KVStore.multiGet()
or
KVStore.multiGetIterator()
.
Retrieve records that share a partial set of major
components using KVStore.storeIterator()
.
Each of these are described in the following sections.
One of three exceptions can occur when you attempt a read operation
in the store. The first of these is
ConsistencyException
.
This exception indicates that the operation cannot be completed
because the consistency policy cannot be met. For more
information, see
Consistency Guarantees.
The second exception is
RequestTimeoutException
. This means that
the operation could not be completed within the amount of time
provided by the store's timeout property. This probably
indicates a store that is attempting to service too many read
requests all at once. Remember that your data is partitioned
across the replication groups in your store, with the
partitioning occurring based on the major path components in
your keys. If you designed your keys such that a large number
of read requests are occurring against a single key, you could
see request timeouts even if some of the replication groups in
your store are idle.
A request timeout could also be indicative of a network problem that is causing the network to be slow or even completely unresponsive.
To handle a RequestTimeoutException
,
you could simply log the error and move on, or you could pause for
a short period of time and then retry the operation. You could
also retry the operation, but use a longer timeout value.
(There is a version of the KVStore.get()
method that allows you to specify a timeout value for that
specific operation.)
Finally, you can receive a general
FaultException
, which indicates that
some exception occurred which is neither a problem with
consistency or a problem with the request timeout. Your only
recourse here is to either log the error and move along, or
retry the operation.