org.springframework.data.keyvalue.riak.core
Class AsyncRiakTemplate
java.lang.Object
org.springframework.web.client.support.RestGatewaySupport
org.springframework.data.keyvalue.riak.core.AbstractRiakTemplate
org.springframework.data.keyvalue.riak.core.AsyncRiakTemplate
- All Implemented Interfaces:
- BeanClassLoaderAware, InitializingBean, AsyncBucketKeyValueStoreOperations, AsyncMapReduceOperations
public class AsyncRiakTemplate
- extends AbstractRiakTemplate
- implements AsyncBucketKeyValueStoreOperations, AsyncMapReduceOperations
An implementation of AsyncBucketKeyValueStoreOperations
and AsyncMapReduceOperations
for the Riak datastore.
To use the AsyncRiakTemplate, create a singleton in your Spring application-context.xml:
<bean id="riak" class="org.springframework.data.keyvalue.riak.core.AsyncRiakTemplate"
p:defaultUri="http://localhost:8098/riak/{bucket}/{key}"
p:mapReduceUri="http://localhost:8098/mapred"/>
To store and retrieve objects in Riak, use the setXXX and getXXX methods (example in
Groovy):
def callback = [
completed: { v, meta ->
... do something with results ...
},
failed: { err ->
}
] as AsyncKeyValueStoreOperation
def obj = new TestObject(name: "My Name", age: 40)
def future = riak.set("mybucket", "mykey", obj, callback)
... this runs asynchronously, so do other work ...
def name = future.get().name
println "Hello $name!"
- Author:
- J. Brisbin
Fields inherited from class org.springframework.data.keyvalue.riak.core.AbstractRiakTemplate |
bucketKeyResolvers, cache, classLoader, conversionService, defaultQosParameters, defaultType, defaultUri, groovyPresent, httpDate, log, mapReduceUri, prefix, RIAK_CLIENT_ID, RIAK_META_CLASSNAME, RIAK_VCLOCK, useCache, workerPool |
Method Summary |
|
containsKey(B bucket,
K key,
AsyncKeyValueStoreOperation<Boolean,R> callback)
|
|
delete(B bucket,
K key,
AsyncKeyValueStoreOperation<Boolean,R> callback)
Delete a specific entry from this data store. |
|
execute(MapReduceJob job,
AsyncKeyValueStoreOperation<List<?>,R> callback)
Execute a MapReduceJob synchronously. |
|
get(B bucket,
K key,
AsyncKeyValueStoreOperation<V,R> callback)
|
|
getAndSet(B bucket,
K key,
V value,
AsyncKeyValueStoreOperation<V,R> callback)
|
|
getAndSetAsBytes(B bucket,
K key,
byte[] value,
AsyncKeyValueStoreOperation<byte[],R> callback)
|
|
getAndSetAsType(B bucket,
K key,
V value,
Class<T> requiredType,
AsyncKeyValueStoreOperation<T,R> callback)
|
|
getAsBytes(B bucket,
K key,
AsyncKeyValueStoreOperation<byte[],R> callback)
|
|
getAsType(B bucket,
K key,
Class<T> requiredType,
AsyncKeyValueStoreOperation<T,R> callback)
|
|
getBucketSchema(B bucket,
QosParameters qosParams,
AsyncKeyValueStoreOperation<Map<String,Object>,R> callback)
|
AsyncKeyValueStoreOperation<Throwable,Object> |
getDefaultErrorHandler()
|
|
getMetaData(B bucket,
K key)
|
|
getWithMetaData(B bucket,
K key,
Class<T> requiredType,
AsyncKeyValueStoreOperation<T,R> callback)
|
|
put(B bucket,
V value,
AsyncKeyValueStoreOperation<V,R> callback)
|
|
put(B bucket,
V value,
Map<String,String> metaData,
AsyncKeyValueStoreOperation<V,R> callback)
|
|
put(B bucket,
V value,
Map<String,String> metaData,
QosParameters qosParams,
AsyncKeyValueStoreOperation<V,R> callback)
|
|
set(B bucket,
K key,
V value,
AsyncKeyValueStoreOperation<V,R> callback)
Put an object in Riak at a specific bucket and key and invoke callback with the value
pulled back out of Riak after the update, which contains full headers and metadata. |
|
set(B bucket,
K key,
V value,
QosParameters qosParams,
AsyncKeyValueStoreOperation<V,R> callback)
|
|
setAsBytes(B bucket,
K key,
byte[] value,
AsyncKeyValueStoreOperation<byte[],R> callback)
|
|
setAsBytes(B bucket,
K key,
byte[] value,
QosParameters qosParams,
AsyncKeyValueStoreOperation<byte[],R> callback)
|
void |
setDefaultErrorHandler(AsyncKeyValueStoreOperation<Throwable,Object> defaultErrorHandler)
|
|
setIfKeyNonExistent(B bucket,
K key,
V value,
AsyncKeyValueStoreOperation<V,R> callback)
|
|
setIfKeyNonExistentAsBytes(B bucket,
K key,
byte[] value,
AsyncKeyValueStoreOperation<byte[],R> callback)
|
|
setWithMetaData(B bucket,
K key,
V value,
Map<String,String> metaData,
AsyncKeyValueStoreOperation<V,R> callback)
|
|
setWithMetaData(B bucket,
K key,
V value,
Map<String,String> metaData,
QosParameters qosParams,
AsyncKeyValueStoreOperation<V,R> callback)
|
Methods inherited from class org.springframework.data.keyvalue.riak.core.AbstractRiakTemplate |
afterPropertiesSet, checkCache, defaultHeaders, extractMediaType, extractMetaData, extractQosParameters, extractValue, getConversionService, getDefaultQosParameters, getDefaultType, getDefaultUri, getHost, getIgnoreNotFound, getMapReduceUri, getPort, getPrefix, getType, getType, getWorkerPool, isUseCache, resolveBucketKeyPair, setBeanClassLoader, setConversionService, setDefaultQosParameters, setDefaultType, setDefaultUri, setIgnoreNotFound, setMapReduceUri, setUseCache, setWorkerPool |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
defaultErrorHandler
protected AsyncKeyValueStoreOperation<Throwable,Object> defaultErrorHandler
AsyncRiakTemplate
public AsyncRiakTemplate()
AsyncRiakTemplate
public AsyncRiakTemplate(ClientHttpRequestFactory requestFactory)
getDefaultErrorHandler
public AsyncKeyValueStoreOperation<Throwable,Object> getDefaultErrorHandler()
setDefaultErrorHandler
public void setDefaultErrorHandler(AsyncKeyValueStoreOperation<Throwable,Object> defaultErrorHandler)
set
public <B,K,V,R> Future<?> set(B bucket,
K key,
V value,
AsyncKeyValueStoreOperation<V,R> callback)
- Description copied from interface:
AsyncBucketKeyValueStoreOperations
- Put an object in Riak at a specific bucket and key and invoke callback with the value
pulled back out of Riak after the update, which contains full headers and metadata.
- Specified by:
set
in interface AsyncBucketKeyValueStoreOperations
callback
- Called with the update value pulled from Riak
set
public <B,K,V,R> Future<?> set(B bucket,
K key,
V value,
QosParameters qosParams,
AsyncKeyValueStoreOperation<V,R> callback)
- Specified by:
set
in interface AsyncBucketKeyValueStoreOperations
- Returns:
setAsBytes
public <B,K,R> Future<?> setAsBytes(B bucket,
K key,
byte[] value,
AsyncKeyValueStoreOperation<byte[],R> callback)
- Specified by:
setAsBytes
in interface AsyncBucketKeyValueStoreOperations
- Returns:
setWithMetaData
public <B,K,V,R> Future<V> setWithMetaData(B bucket,
K key,
V value,
Map<String,String> metaData,
QosParameters qosParams,
AsyncKeyValueStoreOperation<V,R> callback)
- Specified by:
setWithMetaData
in interface AsyncBucketKeyValueStoreOperations
- Returns:
put
public <B,V,R> Future<V> put(B bucket,
V value,
AsyncKeyValueStoreOperation<V,R> callback)
put
public <B,V,R> Future<V> put(B bucket,
V value,
Map<String,String> metaData,
AsyncKeyValueStoreOperation<V,R> callback)
put
public <B,V,R> Future<V> put(B bucket,
V value,
Map<String,String> metaData,
QosParameters qosParams,
AsyncKeyValueStoreOperation<V,R> callback)
get
public <B,K,V,R> Future<?> get(B bucket,
K key,
AsyncKeyValueStoreOperation<V,R> callback)
- Specified by:
get
in interface AsyncBucketKeyValueStoreOperations
- Returns:
getMetaData
public <B,K> RiakMetaData getMetaData(B bucket,
K key)
getBucketSchema
public <B,R> Future<?> getBucketSchema(B bucket,
QosParameters qosParams,
AsyncKeyValueStoreOperation<Map<String,Object>,R> callback)
getWithMetaData
public <B,K,T,R> Future<?> getWithMetaData(B bucket,
K key,
Class<T> requiredType,
AsyncKeyValueStoreOperation<T,R> callback)
getAsBytes
public <B,K,R> Future<?> getAsBytes(B bucket,
K key,
AsyncKeyValueStoreOperation<byte[],R> callback)
- Specified by:
getAsBytes
in interface AsyncBucketKeyValueStoreOperations
- Returns:
getAsType
public <B,K,T,R> Future<?> getAsType(B bucket,
K key,
Class<T> requiredType,
AsyncKeyValueStoreOperation<T,R> callback)
- Specified by:
getAsType
in interface AsyncBucketKeyValueStoreOperations
- Returns:
getAndSet
public <B,K,V,R> Future<?> getAndSet(B bucket,
K key,
V value,
AsyncKeyValueStoreOperation<V,R> callback)
- Specified by:
getAndSet
in interface AsyncBucketKeyValueStoreOperations
- Returns:
getAndSetAsBytes
public <B,K,R> Future<?> getAndSetAsBytes(B bucket,
K key,
byte[] value,
AsyncKeyValueStoreOperation<byte[],R> callback)
- Specified by:
getAndSetAsBytes
in interface AsyncBucketKeyValueStoreOperations
- Returns:
getAndSetAsType
public <B,K,V,T,R> Future<?> getAndSetAsType(B bucket,
K key,
V value,
Class<T> requiredType,
AsyncKeyValueStoreOperation<T,R> callback)
- Specified by:
getAndSetAsType
in interface AsyncBucketKeyValueStoreOperations
- Returns:
setIfKeyNonExistent
public <B,K,V,R> Future<?> setIfKeyNonExistent(B bucket,
K key,
V value,
AsyncKeyValueStoreOperation<V,R> callback)
- Specified by:
setIfKeyNonExistent
in interface AsyncBucketKeyValueStoreOperations
- Returns:
setIfKeyNonExistentAsBytes
public <B,K,R> Future<?> setIfKeyNonExistentAsBytes(B bucket,
K key,
byte[] value,
AsyncKeyValueStoreOperation<byte[],R> callback)
- Specified by:
setIfKeyNonExistentAsBytes
in interface AsyncBucketKeyValueStoreOperations
- Returns:
containsKey
public <B,K,R> Future<?> containsKey(B bucket,
K key,
AsyncKeyValueStoreOperation<Boolean,R> callback)
- Specified by:
containsKey
in interface AsyncBucketKeyValueStoreOperations
- Returns:
delete
public <B,K,R> Future<?> delete(B bucket,
K key,
AsyncKeyValueStoreOperation<Boolean,R> callback)
- Description copied from interface:
AsyncBucketKeyValueStoreOperations
- Delete a specific entry from this data store.
- Specified by:
delete
in interface AsyncBucketKeyValueStoreOperations
- Returns:
setAsBytes
public <B,K,R> Future<?> setAsBytes(B bucket,
K key,
byte[] value,
QosParameters qosParams,
AsyncKeyValueStoreOperation<byte[],R> callback)
- Specified by:
setAsBytes
in interface AsyncBucketKeyValueStoreOperations
- Returns:
setWithMetaData
public <B,K,V,R> Future<?> setWithMetaData(B bucket,
K key,
V value,
Map<String,String> metaData,
AsyncKeyValueStoreOperation<V,R> callback)
- Specified by:
setWithMetaData
in interface AsyncBucketKeyValueStoreOperations
- Returns:
execute
public <R> Future<?> execute(MapReduceJob job,
AsyncKeyValueStoreOperation<List<?>,R> callback)
- Description copied from interface:
AsyncMapReduceOperations
- Execute a
MapReduceJob
synchronously.
- Specified by:
execute
in interface AsyncMapReduceOperations
- Returns:
Copyright © 2010-2011 SpringSource. All Rights Reserved.