public static class Consistency.Version extends Consistency
The version of a Key-Value pair represents a point in the serialized
transaction schedule created by the master. In other words, the version
is like a bookmark, representing a particular transaction commit in the
replication stream. The Replica ensures that the commit identified by
Version has been executed before allowing the transaction on
the Replica to proceed.
For example, suppose the application is a web application. Each request to the web server consists of an update operation followed by read operations (say from the same client). The read operations naturally expect to see the data from the updates executed by the same request. However, the read operations might have been routed to a Replica node that did not execute the update.
In such a case, the update request would generate a
which would be resubmitted by the browser, and then passed via a
Consistency.Version object with subsequent read requests to the
KV Store. The read request may be directed by the KV Store's load
balancer to any one of the available Replicas. If the Replica servicing
the request is already current (with respect to the version token), it
will immediately execute the transaction and satisfy the request. If
not, the transaction will stall until the Replica replay has caught up
and the change is available at that node.
This class has a
timeout attribute that controls how
long a Replica may wait for the desired consistency to be
achieved before giving up.
All KVStore read operations support a Consistency specification, as well as a separate operation timeout. The KVStore client driver implements a read operation by choosing a node (usually a Replica) from the proper replication group, and sending it a request. If the Replica cannot guarantee the desired Consistency within the Consistency timeout, it replies to the request with a failure indication. If there is still time remaining within the operation timeout, the client driver picks another node and tries the request again (transparent to the application).
It makes sense to think of the operation timeout as the maximum amount of time the application is willing to wait for the operation to complete. The Consistency timeout is like a performance hint to the implementation, suggesting that it can generally expect that a healthy Replica usually should be able to become consistent within the given amount of time, and that if it doesn't, then it is probably more likely worth the overhead of abandoning the request attempt and retrying with a different replica. Note that for the Consistency timeout to be meaningful it must be smaller than the operation timeout.
Choosing a value for the operation timeout depends on the needs of the application. Finding a good Consistency timeout value is more likely to depend on observations made of real system performance.
|Constructor and Description|
Defines how current a Replica needs to be in terms of a specific write operation that was previously completed.
|Modifier and Type||Method and Description|
Returns the name used to identify the policy.
Return the timeout specified when creating this consistency policy.
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
versionhas been committed on the Replica. The transaction will wait for at most
timeoutfor the Replica to catch up. If the Replica has not caught up in this period, the client method will throw a
version- the token identifying the transaction.
timeout- the maximum amount of time that the transaction start will wait to allow the Replica to catch up.
TimeUnitfor the timeout parameter.
public String getName()
public Version getVersion()
Versionused to create this consistency policy.
public long getTimeout(TimeUnit unit)
TimeUnitof the returned value.
Copyright (c) 2011, 2014 Oracle and/or its affiliates. All rights reserved.