voldemort.client
Interface StoreClient<K,V>

Type Parameters:
K - The type of the key being stored
V - The type of the value being stored
All Known Implementing Classes:
DefaultStoreClient, DynamicTimeoutStoreClient, LazyStoreClient, ZenStoreClient

public interface StoreClient<K,V>

The user-facing interface to a Voldemort store. Gives basic put/get/delete plus helper functions.


Method Summary
 boolean applyUpdate(UpdateAction<K,V> action)
          Apply the given action repeatedly until no ObsoleteVersionException is thrown.
 boolean applyUpdate(UpdateAction<K,V> action, int maxTries)
          Apply the given action repeatedly until no ObsoleteVersionException is thrown or maxTries unsuccessful attempts have been made.
 boolean delete(K key)
          Delete any version of the given key which equal to or less than the current versions
 boolean delete(K key, Version version)
          Delete the specified version and any prior versions of the given key
 Versioned<V> get(K key)
          Get the versioned value associated with the given key or null if no value is associated with the key.
 Versioned<V> get(K key, java.lang.Object transforms)
          Get the versioned value associated with the given key and apply the given transforms to it before returning the value.
 Versioned<V> get(K key, Versioned<V> defaultValue)
          Get the versioned value associated with the given key or the defaultValue if no value is associated with the key.
 java.util.Map<K,Versioned<V>> getAll(java.lang.Iterable<K> keys)
          Gets the versioned values associated with the given keys and returns them in a Map of keys to versioned values.
 java.util.Map<K,Versioned<V>> getAll(java.lang.Iterable<K> keys, java.util.Map<K,java.lang.Object> transforms)
          Like getAll, except that the transforms are applied on the value associated with each key before returning the results
 java.util.List<Node> getResponsibleNodes(K key)
          Returns the list of nodes which should have this key.
 V getValue(K key)
          Get the value associated with the given key or null if there is no value associated with this key.
 V getValue(K key, V defaultValue)
          Get the value associated with the given key or defaultValue if there is no value associated with the key.
 Version put(K key, V value)
          Associated the given value to the key, clobbering any existing values stored for the key.
 Version put(K key, Versioned<V> versioned)
          Put the given Versioned value into the store for the given key if the version is greater to or concurrent with existing values.
 Version put(K key, V value, java.lang.Object transforms)
          Like #put(Object, Object), except that the given transforms are applied on the value before writing it to the store
 boolean putIfNotObsolete(K key, Versioned<V> versioned)
          Put the versioned value to the key, ignoring any ObsoleteVersionException that may be thrown
 

Method Detail

getValue

V getValue(K key)
Get the value associated with the given key or null if there is no value associated with this key. This method strips off all version information and is only useful when no further storage operations will be done on this key.

Parameters:
key - The key

getValue

V getValue(K key,
           V defaultValue)
Get the value associated with the given key or defaultValue if there is no value associated with the key. This method strips off all version information and is only useful when no further storage operations will be done on this key.

Parameters:
key - The key for which to fetch the associated value
defaultValue - A value to return if there is no value associated with this key
Returns:
Either the value stored for the key or the default value.

get

Versioned<V> get(K key)
Get the versioned value associated with the given key or null if no value is associated with the key.

Parameters:
key - The key for which to fetch the value.
Returns:
The versioned value, or null if no value is stored for this key.

get

Versioned<V> get(K key,
                 java.lang.Object transforms)
Get the versioned value associated with the given key and apply the given transforms to it before returning the value. Returns null if no value is associated with the key

Parameters:
key - the key for which the value is fetched
transforms - the transforms to be applied on the value fetched from the store
Returns:
the transformed versioned value, or null if no value is stored for this key

getAll

java.util.Map<K,Versioned<V>> getAll(java.lang.Iterable<K> keys)
Gets the versioned values associated with the given keys and returns them in a Map of keys to versioned values. Note that the returned map will only contain entries for the keys which have a value associated with them.

Parameters:
keys - The keys for which to fetch the values.
Returns:
A Map of keys to versioned values.

getAll

java.util.Map<K,Versioned<V>> getAll(java.lang.Iterable<K> keys,
                                     java.util.Map<K,java.lang.Object> transforms)
Like getAll, except that the transforms are applied on the value associated with each key before returning the results

Parameters:
keys - the keys for which the values are fetched
transforms - the map of transforms, describing the transform to be applied to the value for each key
Returns:
A map of keys to transformed versioned values

get

Versioned<V> get(K key,
                 Versioned<V> defaultValue)
Get the versioned value associated with the given key or the defaultValue if no value is associated with the key.

Parameters:
key - The key for which to fetch the value.
Returns:
The versioned value, or the defaultValue if no value is stored for this key.

put

Version put(K key,
            V value)
Associated the given value to the key, clobbering any existing values stored for the key.

Parameters:
key - The key
value - The value
Returns:
version The version of the object

put

Version put(K key,
            V value,
            java.lang.Object transforms)
Like #put(Object, Object), except that the given transforms are applied on the value before writing it to the store

Parameters:
key - the key
value - the value
transforms - the transforms to be applied on the value
Returns:
version The version of the object

put

Version put(K key,
            Versioned<V> versioned)
            throws ObsoleteVersionException
Put the given Versioned value into the store for the given key if the version is greater to or concurrent with existing values. Throw an ObsoleteVersionException otherwise.

Parameters:
key - The key
versioned - The value and its versioned
Throws:
ObsoleteVersionException

putIfNotObsolete

boolean putIfNotObsolete(K key,
                         Versioned<V> versioned)
Put the versioned value to the key, ignoring any ObsoleteVersionException that may be thrown

Parameters:
key - The key
versioned - The versioned value
Returns:
true if the put succeeded

applyUpdate

boolean applyUpdate(UpdateAction<K,V> action)
Apply the given action repeatedly until no ObsoleteVersionException is thrown. This is useful for implementing a read-modify-store loop that could be pre-empted by another concurrent update, and should be repeated until it succeeds.

Parameters:
action - The action to apply. This is meant as a callback for the user to extend to provide their own logic.
Returns:
true if the action is successfully applied, false if the 3 attempts all result in ObsoleteVersionException

applyUpdate

boolean applyUpdate(UpdateAction<K,V> action,
                    int maxTries)
Apply the given action repeatedly until no ObsoleteVersionException is thrown or maxTries unsuccessful attempts have been made. This is useful for implementing a read-modify-store loop.

Parameters:
action - The action to apply
Returns:
true if the action is successfully applied, false if maxTries failed attempts have been made

delete

boolean delete(K key)
Delete any version of the given key which equal to or less than the current versions

Parameters:
key - The key
Returns:
true if anything is deleted

delete

boolean delete(K key,
               Version version)
Delete the specified version and any prior versions of the given key

Parameters:
key - The key to delete
version - The version of the key
Returns:
true if anything is deleted

getResponsibleNodes

java.util.List<Node> getResponsibleNodes(K key)
Returns the list of nodes which should have this key.

Parameters:
key -
Returns:
a list of Nodes which should hold this key


Jay Kreps, Roshan Sumbaly, Alex Feinberg, Bhupesh Bansal, Lei Gao, Chinmay Soman, Vinoth Chandar, Zhongjie Wu