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

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, 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.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.
 void put(K key, V value)
          Associated the given value to the key, clobbering any existing values stored for the key.
 void 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.
 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.

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.

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

void 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

put

void 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