Changed logging to commons-logging, added package documentation, fixes for cyclic dependencies, other bug fixes.
This commit is contained in:
@@ -13,39 +13,6 @@
|
||||
<name>Spring Data Riak Support</name>
|
||||
|
||||
<dependencies>
|
||||
<!-- Spring -->
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-beans</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-tx</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-test</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Spring Data -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.data</groupId>
|
||||
<artifactId>spring-data-keyvalue-core</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Jackson JSON -->
|
||||
<dependency>
|
||||
<groupId>org.codehaus.jackson</groupId>
|
||||
<artifactId>jackson-core-asl</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.codehaus.jackson</groupId>
|
||||
<artifactId>jackson-mapper-asl</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Logging -->
|
||||
<dependency>
|
||||
@@ -87,6 +54,47 @@
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- Spring -->
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-beans</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-tx</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-test</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Groovy -->
|
||||
<dependency>
|
||||
<groupId>org.codehaus.groovy</groupId>
|
||||
<artifactId>groovy-all</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Spring Data -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.data</groupId>
|
||||
<artifactId>spring-data-keyvalue-core</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Jackson JSON -->
|
||||
<dependency>
|
||||
<groupId>org.codehaus.jackson</groupId>
|
||||
<artifactId>jackson-core-asl</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.codehaus.jackson</groupId>
|
||||
<artifactId>jackson-mapper-asl</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- APIs -->
|
||||
<dependency>
|
||||
<groupId>javax.annotation</groupId>
|
||||
<artifactId>jsr250-api</artifactId>
|
||||
@@ -101,18 +109,14 @@
|
||||
<artifactId>activation</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Commons -->
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-all</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- Groovy -->
|
||||
<dependency>
|
||||
<groupId>org.codehaus.groovy</groupId>
|
||||
<artifactId>groovy-all</artifactId>
|
||||
<groupId>commons-cli</groupId>
|
||||
<artifactId>commons-cli</artifactId>
|
||||
<version>1.2</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Testing -->
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
@@ -121,6 +125,11 @@
|
||||
<groupId>org.spockframework</groupId>
|
||||
<artifactId>spock-spring</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-all</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
||||
@@ -18,12 +18,13 @@
|
||||
|
||||
package org.springframework.data.keyvalue.riak.core;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.codehaus.groovy.runtime.GStringImpl;
|
||||
import org.codehaus.jackson.map.ObjectMapper;
|
||||
import org.codehaus.jackson.map.ser.CustomSerializerFactory;
|
||||
import org.codehaus.jackson.map.ser.ToStringSerializer;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.BeanClassLoaderAware;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.core.convert.ConversionService;
|
||||
import org.springframework.core.convert.support.ConversionServiceFactory;
|
||||
@@ -62,7 +63,7 @@ import java.util.regex.Pattern;
|
||||
*
|
||||
* @author J. Brisbin <jon@jbrisbin.com>
|
||||
*/
|
||||
public abstract class AbstractRiakTemplate extends RestGatewaySupport implements InitializingBean {
|
||||
public abstract class AbstractRiakTemplate extends RestGatewaySupport implements InitializingBean, BeanClassLoaderAware {
|
||||
|
||||
protected static final String RIAK_META_CLASSNAME = "X-Riak-Meta-ClassName";
|
||||
protected static final String RIAK_VCLOCK = "X-Riak-Vclock";
|
||||
@@ -75,16 +76,16 @@ public abstract class AbstractRiakTemplate extends RestGatewaySupport implements
|
||||
/**
|
||||
* Do we need to handle Groovy strings in the Jackson JSON processor?
|
||||
*/
|
||||
protected static final boolean groovyPresent = ClassUtils.isPresent(
|
||||
protected final boolean groovyPresent = ClassUtils.isPresent(
|
||||
"org.codehaus.groovy.runtime.GStringImpl",
|
||||
RiakTemplate.class.getClassLoader());
|
||||
getClass().getClassLoader());
|
||||
/**
|
||||
* For getting a <code>java.util.Date</code> from the Last-Modified header.
|
||||
*/
|
||||
protected static SimpleDateFormat httpDate = new SimpleDateFormat(
|
||||
"EEE, d MMM yyyy HH:mm:ss z");
|
||||
|
||||
protected final Logger log = LoggerFactory.getLogger(getClass());
|
||||
protected final Log log = LogFactory.getLog(getClass());
|
||||
|
||||
/**
|
||||
* Client ID used by Riak to correlate updates.
|
||||
@@ -124,8 +125,14 @@ public abstract class AbstractRiakTemplate extends RestGatewaySupport implements
|
||||
* {@link java.util.concurrent.ExecutorService} to use for running asynchronous jobs.
|
||||
*/
|
||||
protected ExecutorService workerPool = Executors.newCachedThreadPool();
|
||||
|
||||
/**
|
||||
* Default type to use when trying to deserialize objects and we can't otherwise tell what to
|
||||
* do.
|
||||
*/
|
||||
protected Class<?> defaultType = String.class;
|
||||
/**
|
||||
* ClassLoader to use for saving/loading objects using the automatic converters.
|
||||
*/
|
||||
protected ClassLoader classLoader = null;
|
||||
|
||||
/**
|
||||
@@ -133,7 +140,6 @@ public abstract class AbstractRiakTemplate extends RestGatewaySupport implements
|
||||
*/
|
||||
public AbstractRiakTemplate() {
|
||||
setRestTemplate(new RestTemplate());
|
||||
bucketKeyResolvers.add(new SimpleBucketKeyResolver());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -144,7 +150,6 @@ public abstract class AbstractRiakTemplate extends RestGatewaySupport implements
|
||||
public AbstractRiakTemplate(ClientHttpRequestFactory requestFactory) {
|
||||
super(requestFactory);
|
||||
setRestTemplate(new RestTemplate());
|
||||
bucketKeyResolvers.add(new SimpleBucketKeyResolver());
|
||||
}
|
||||
|
||||
public ConversionService getConversionService() {
|
||||
@@ -219,21 +224,7 @@ public abstract class AbstractRiakTemplate extends RestGatewaySupport implements
|
||||
this.defaultType = defaultType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the {@link ClassLoader} to use when trying to load objects from the store.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public ClassLoader getClassLoader() {
|
||||
return classLoader;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the {@link ClassLoader} to use when trying to load objects from the store.
|
||||
*
|
||||
* @param classLoader
|
||||
*/
|
||||
public void setClassLoader(ClassLoader classLoader) {
|
||||
public void setBeanClassLoader(ClassLoader classLoader) {
|
||||
this.classLoader = classLoader;
|
||||
}
|
||||
|
||||
@@ -285,6 +276,7 @@ public abstract class AbstractRiakTemplate extends RestGatewaySupport implements
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*----------------- Utilities -----------------*/
|
||||
|
||||
@SuppressWarnings({"unchecked"})
|
||||
@@ -296,26 +288,24 @@ public abstract class AbstractRiakTemplate extends RestGatewaySupport implements
|
||||
break;
|
||||
}
|
||||
}
|
||||
BucketKeyPair bucketKeyPair;
|
||||
if (null != resolver) {
|
||||
bucketKeyPair = resolver.resolve(key);
|
||||
if (null == bucketKeyPair.getBucket() && null != val) {
|
||||
// No bucket specified, check for an annotation that specified bucket name.
|
||||
Annotation meta = (val instanceof Class ? (Class) val : val.getClass()).getAnnotation(
|
||||
org.springframework.data.keyvalue.riak.convert.KeyValueStoreMetaData.class);
|
||||
if (null != meta) {
|
||||
String bucket = ((KeyValueStoreMetaData) meta).bucket();
|
||||
if (null != bucket) {
|
||||
return new SimpleBucketKeyPair<String, Object>(bucket,
|
||||
bucketKeyPair.getKey());
|
||||
}
|
||||
if (null == resolver) {
|
||||
resolver = new SimpleBucketKeyResolver();
|
||||
}
|
||||
|
||||
BucketKeyPair bucketKeyPair = resolver.resolve(key);
|
||||
if (null == bucketKeyPair.getBucket() && null != val) {
|
||||
// No bucket specified, check for an annotation that specified bucket name.
|
||||
Annotation meta = (val instanceof Class ? (Class) val : val.getClass()).getAnnotation(
|
||||
org.springframework.data.keyvalue.riak.convert.KeyValueStoreMetaData.class);
|
||||
if (null != meta) {
|
||||
String bucket = ((KeyValueStoreMetaData) meta).bucket();
|
||||
if (null != bucket) {
|
||||
return new SimpleBucketKeyPair<String, Object>(bucket,
|
||||
bucketKeyPair.getKey());
|
||||
}
|
||||
}
|
||||
return bucketKeyPair;
|
||||
}
|
||||
throw new DataStoreOperationException(String.format(
|
||||
"No resolvers available to resolve bucket/key pair from %s",
|
||||
key));
|
||||
return bucketKeyPair;
|
||||
}
|
||||
|
||||
protected MediaType extractMediaType(Object value) {
|
||||
|
||||
@@ -18,8 +18,6 @@
|
||||
|
||||
package org.springframework.data.keyvalue.riak.core;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.dao.DataAccessResourceFailureException;
|
||||
import org.springframework.data.keyvalue.riak.DataStoreOperationException;
|
||||
import org.springframework.data.keyvalue.riak.mapreduce.AsyncMapReduceOperations;
|
||||
@@ -73,8 +71,6 @@ import java.util.concurrent.Future;
|
||||
*/
|
||||
public class AsyncRiakTemplate extends AbstractRiakTemplate implements AsyncBucketKeyValueStoreOperations, AsyncMapReduceOperations {
|
||||
|
||||
protected final Logger log = LoggerFactory.getLogger(getClass());
|
||||
|
||||
protected AsyncKeyValueStoreOperation<Throwable, Object> defaultErrorHandler = new LoggingErrorHandler();
|
||||
|
||||
public AsyncRiakTemplate() {
|
||||
|
||||
@@ -23,7 +23,6 @@ import org.springframework.dao.DataAccessResourceFailureException;
|
||||
import org.springframework.data.keyvalue.riak.DataStoreOperationException;
|
||||
import org.springframework.data.keyvalue.riak.mapreduce.MapReduceJob;
|
||||
import org.springframework.data.keyvalue.riak.mapreduce.MapReduceOperations;
|
||||
import org.springframework.data.keyvalue.riak.mapreduce.RiakMapReduceJob;
|
||||
import org.springframework.http.*;
|
||||
import org.springframework.http.client.ClientHttpRequest;
|
||||
import org.springframework.http.client.ClientHttpRequestFactory;
|
||||
@@ -510,10 +509,6 @@ public class RiakTemplate extends AbstractRiakTemplate implements BucketKeyValue
|
||||
|
||||
/*----------------- Map/Reduce Operations -----------------*/
|
||||
|
||||
public RiakMapReduceJob createMapReduceJob() {
|
||||
return new RiakMapReduceJob(this);
|
||||
}
|
||||
|
||||
public Object execute(MapReduceJob job) {
|
||||
return execute(job, List.class);
|
||||
}
|
||||
|
||||
@@ -30,9 +30,9 @@ import java.util.regex.Pattern;
|
||||
@SuppressWarnings({"unchecked"})
|
||||
public class SimpleBucketKeyResolver implements BucketKeyResolver {
|
||||
|
||||
private static final boolean groovyPresent = ClassUtils.isPresent(
|
||||
private final boolean groovyPresent = ClassUtils.isPresent(
|
||||
"org.codehaus.groovy.runtime.GStringImpl",
|
||||
RiakTemplate.class.getClassLoader());
|
||||
getClass().getClassLoader());
|
||||
|
||||
protected Pattern bucketColonKey = Pattern.compile("(.+):(.+)");
|
||||
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
|
||||
package org.springframework.data.keyvalue.riak.core.io;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.data.keyvalue.riak.DataStoreOperationException;
|
||||
import org.springframework.data.keyvalue.riak.core.KeyValueStoreMetaData;
|
||||
import org.springframework.data.keyvalue.riak.core.RiakTemplate;
|
||||
@@ -43,7 +43,7 @@ import java.util.Map;
|
||||
public class RiakFile<B, K> extends File {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final Logger log = LoggerFactory.getLogger(RiakFile.class);
|
||||
protected final Log log = LogFactory.getLog(getClass());
|
||||
|
||||
private RiakTemplate riak;
|
||||
private B bucket;
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
|
||||
package org.springframework.data.keyvalue.riak.core.io;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.core.io.UrlResource;
|
||||
import org.springframework.data.keyvalue.riak.core.RiakTemplate;
|
||||
@@ -40,7 +40,7 @@ import java.net.URL;
|
||||
*/
|
||||
public class RiakResource<B, K> extends UrlResource {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(RiakResource.class);
|
||||
protected final Log log = LogFactory.getLog(getClass());
|
||||
|
||||
private RiakTemplate riak;
|
||||
private B bucket;
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
<html>
|
||||
<body>
|
||||
<p>
|
||||
Utilities for working with resources stored in Riak as standard java.io objects. Opening a <a
|
||||
href="RiakInputStream.html">RiakInputStream</a> to a resource will allow code that doesn't
|
||||
know anything about Key/Value datastores to access resources stored within them.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Alternatively, writing data to a <a href="RiakOutputStream.html">RiakOutputStream</a> will
|
||||
create a resources in Riak without exposing any of the underlying data access code to the
|
||||
calling application.
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,7 @@
|
||||
<html>
|
||||
<body>
|
||||
<p>
|
||||
Root package for the core utilities that make up the Riak data access library.
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
||||
@@ -20,8 +20,8 @@ package org.springframework.data.keyvalue.riak.groovy;
|
||||
|
||||
import groovy.lang.Closure;
|
||||
import groovy.util.BuilderSupport;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.keyvalue.riak.DataStoreOperationException;
|
||||
import org.springframework.data.keyvalue.riak.core.AsyncRiakTemplate;
|
||||
@@ -60,7 +60,7 @@ public class RiakBuilder extends BuilderSupport {
|
||||
CALL, FOREACH, MAPREDUCE, QUERY, MAP, REDUCE, INPUTS, LANGUAGE, SOURCE, KEEP, ARG, COMPLETED, FAILED
|
||||
}
|
||||
|
||||
protected final Logger log = LoggerFactory.getLogger(getClass());
|
||||
protected final Log log = LogFactory.getLog(getClass());
|
||||
@Autowired(required = false)
|
||||
protected AsyncRiakTemplate riak;
|
||||
@Autowired(required = false)
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
package org.springframework.data.keyvalue.riak.groovy;
|
||||
|
||||
import groovy.lang.Closure;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.data.keyvalue.riak.core.AsyncKeyValueStoreOperation;
|
||||
import org.springframework.data.keyvalue.riak.core.AsyncRiakTemplate;
|
||||
import org.springframework.data.keyvalue.riak.core.KeyValueStoreMetaData;
|
||||
@@ -36,7 +36,7 @@ import java.util.concurrent.TimeUnit;
|
||||
*/
|
||||
public class RiakMapReduceOperation implements Callable {
|
||||
|
||||
protected final Logger log = LoggerFactory.getLogger(getClass());
|
||||
protected final Log log = LogFactory.getLog(getClass());
|
||||
|
||||
protected AsyncRiakTemplate riak;
|
||||
protected AsyncRiakMapReduceJob job;
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
package org.springframework.data.keyvalue.riak.groovy;
|
||||
|
||||
import groovy.lang.Closure;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.data.keyvalue.riak.DataStoreOperationException;
|
||||
import org.springframework.data.keyvalue.riak.core.AsyncKeyValueStoreOperation;
|
||||
import org.springframework.data.keyvalue.riak.core.AsyncRiakTemplate;
|
||||
@@ -42,7 +42,7 @@ public class RiakOperation<T> implements Callable {
|
||||
static String COMPLETED = "completed";
|
||||
static String FAILED = "failed";
|
||||
|
||||
protected final Logger log = LoggerFactory.getLogger(getClass());
|
||||
protected final Log log = LogFactory.getLog(getClass());
|
||||
|
||||
protected AsyncRiakTemplate riak;
|
||||
protected Type type;
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
<html>
|
||||
<body>
|
||||
<p>
|
||||
Utilities for making Riak data access easier in Groovy. The <a href="RiakBuilder.html">RiakBuilder</a>
|
||||
provides a Groovy DSL for interacting with Riak.
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
||||
@@ -18,11 +18,11 @@
|
||||
|
||||
package org.springframework.data.keyvalue.riak.mapreduce;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.codehaus.jackson.JsonFactory;
|
||||
import org.codehaus.jackson.JsonGenerator;
|
||||
import org.codehaus.jackson.map.ObjectMapper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.data.keyvalue.riak.core.BucketKeyPair;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -40,7 +40,7 @@ import java.util.Map;
|
||||
@SuppressWarnings({"unchecked"})
|
||||
public abstract class AbstractRiakMapReduceJob implements MapReduceJob {
|
||||
|
||||
protected final Logger log = LoggerFactory.getLogger(getClass());
|
||||
protected final Log log = LogFactory.getLog(getClass());
|
||||
protected List<Object> inputs = new LinkedList<Object>();
|
||||
protected List<MapReducePhase> phases = new ArrayList<MapReducePhase>();
|
||||
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
<html>
|
||||
<body>
|
||||
<p>
|
||||
Root package for
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,8 @@
|
||||
<html>
|
||||
<body>
|
||||
<p>
|
||||
Root package for integrating <a href="http://www.basho.com/Riak.html">Riak</a> with Spring
|
||||
concepts.
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright (c) 2011 by J. Brisbin <jon@jbrisbin.com>
|
||||
* Portions (c) 2011 by NPC International, Inc. or the
|
||||
* original author(s).
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.keyvalue.riak.util;
|
||||
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.client.ClientHttpResponse;
|
||||
import org.springframework.web.client.DefaultResponseErrorHandler;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* @author J. Brisbin <jon@jbrisbin.com>
|
||||
*/
|
||||
public class Ignore404sErrorHandler extends DefaultResponseErrorHandler {
|
||||
|
||||
@Override
|
||||
protected boolean hasError(HttpStatus statusCode) {
|
||||
if (statusCode != HttpStatus.NOT_FOUND) {
|
||||
return super.hasError(statusCode);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleError(ClientHttpResponse response) throws IOException {
|
||||
// Ignore 404s entirely
|
||||
if (response.getStatusCode() != HttpStatus.NOT_FOUND) {
|
||||
super.handleError(response);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright (c) 2011 by J. Brisbin <jon@jbrisbin.com>
|
||||
* Portions (c) 2011 by NPC International, Inc. or the
|
||||
* original author(s).
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.keyvalue.riak.core;
|
||||
|
||||
/**
|
||||
* @author J. Brisbin <jon@jbrisbin.com>
|
||||
*/
|
||||
public class ClassLoaderTest {
|
||||
|
||||
String name = "ClassLoaderTest";
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
@@ -17,38 +17,49 @@
|
||||
*/
|
||||
package org.springframework.data.keyvalue.riak.core
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired
|
||||
import org.springframework.context.ApplicationContext
|
||||
import org.springframework.data.keyvalue.riak.mapreduce.JavascriptMapReduceOperation
|
||||
import org.springframework.data.keyvalue.riak.mapreduce.MapReduceJob
|
||||
import org.springframework.data.keyvalue.riak.mapreduce.RiakMapReducePhase
|
||||
import org.springframework.test.context.ContextConfiguration
|
||||
import org.springframework.data.keyvalue.riak.util.Ignore404sErrorHandler
|
||||
import spock.lang.Shared
|
||||
import spock.lang.Specification
|
||||
|
||||
/**
|
||||
* @author J. Brisbin <jon@jbrisbin.com>
|
||||
*/
|
||||
@ContextConfiguration(locations = "/org/springframework/data/RiakKeyValueTemplateTests.xml")
|
||||
class RiakKeyValueTemplateSpec extends Specification {
|
||||
|
||||
@Autowired
|
||||
ApplicationContext appCtx
|
||||
@Autowired
|
||||
RiakKeyValueTemplate riak
|
||||
@Shared RiakKeyValueTemplate riak = new RiakKeyValueTemplate()
|
||||
int run = 1
|
||||
@Shared def riakBin = System.properties["bamboo.RIAK_BIN"] ?: "/usr/sbin/riak"
|
||||
@Shared def p
|
||||
|
||||
def setupSpec() {
|
||||
p = "$riakBin start".execute()
|
||||
p.waitFor()
|
||||
Thread.sleep(2000)
|
||||
RiakQosParameters qos = new RiakQosParameters()
|
||||
qos.setDurableWriteThreshold("all")
|
||||
riak.setDefaultQosParameters(qos)
|
||||
riak.getRestTemplate().setErrorHandler(new Ignore404sErrorHandler())
|
||||
|
||||
if (!riak.get("status", "")) {
|
||||
p = "$riakBin start".execute()
|
||||
p.waitFor()
|
||||
shutdown = true
|
||||
Thread.sleep(2000)
|
||||
}
|
||||
|
||||
riak.getBucketSchema("test", true).keys.each {
|
||||
riak.delete("test", it)
|
||||
}
|
||||
riak.getBucketSchema(TestObject.name, true).keys.each {
|
||||
riak.delete("test", it)
|
||||
}
|
||||
}
|
||||
|
||||
def cleanupSpec() {
|
||||
p = "$riakBin stop".execute()
|
||||
p.waitFor()
|
||||
if (shutdown) {
|
||||
p = "$riakBin stop".execute()
|
||||
p.waitFor()
|
||||
}
|
||||
}
|
||||
|
||||
def "Test Map object"() {
|
||||
|
||||
@@ -17,24 +17,20 @@
|
||||
*/
|
||||
package org.springframework.data.keyvalue.riak.core
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired
|
||||
import org.springframework.context.ApplicationContext
|
||||
import org.springframework.data.keyvalue.riak.core.io.RiakFile
|
||||
import org.springframework.data.keyvalue.riak.mapreduce.JavascriptMapReduceOperation
|
||||
import org.springframework.data.keyvalue.riak.mapreduce.MapReduceJob
|
||||
import org.springframework.data.keyvalue.riak.mapreduce.RiakMapReduceJob
|
||||
import org.springframework.data.keyvalue.riak.mapreduce.RiakMapReducePhase
|
||||
import org.springframework.test.context.ContextConfiguration
|
||||
import org.springframework.data.keyvalue.riak.util.Ignore404sErrorHandler
|
||||
import spock.lang.Shared
|
||||
import spock.lang.Specification
|
||||
|
||||
/**
|
||||
* @author J. Brisbin <jon@jbrisbin.com>
|
||||
*/
|
||||
@ContextConfiguration(locations = "/org/springframework/data/RiakTemplateTests.xml")
|
||||
class RiakTemplateSpec extends Specification {
|
||||
|
||||
@Autowired
|
||||
ApplicationContext appCtx
|
||||
@Shared RiakTemplate riak = new RiakTemplate()
|
||||
int run = 1
|
||||
@Shared def riakBin = System.properties["bamboo.RIAK_BIN"] ?: "/usr/sbin/riak"
|
||||
@@ -46,6 +42,7 @@ class RiakTemplateSpec extends Specification {
|
||||
RiakQosParameters qos = new RiakQosParameters()
|
||||
qos.setDurableWriteThreshold("all")
|
||||
riak.setDefaultQosParameters(qos)
|
||||
riak.getRestTemplate().setErrorHandler(new Ignore404sErrorHandler())
|
||||
|
||||
if (!riak.get("status", "")) {
|
||||
p = "$riakBin start".execute()
|
||||
@@ -242,7 +239,7 @@ class RiakTemplateSpec extends Specification {
|
||||
def "Test Map/Reduce returning Integer"() {
|
||||
|
||||
given:
|
||||
MapReduceJob job = riak.createMapReduceJob()
|
||||
MapReduceJob job = new RiakMapReduceJob(riak)
|
||||
def uuid = UUID.randomUUID().toString()
|
||||
def mapJs = new JavascriptMapReduceOperation("function(v){ var uuid='$uuid'; ejsLog('/tmp/mapred.log', 'map input: '+JSON.stringify(v)); var o=Riak.mapValuesJson(v); return [1]; }")
|
||||
def mapPhase = new RiakMapReducePhase("map", "javascript", mapJs)
|
||||
@@ -266,7 +263,7 @@ class RiakTemplateSpec extends Specification {
|
||||
def "Test Map/Reduce returning List"() {
|
||||
|
||||
given:
|
||||
MapReduceJob job = riak.createMapReduceJob()
|
||||
MapReduceJob job = new RiakMapReduceJob(riak)
|
||||
def uuid = UUID.randomUUID().toString()
|
||||
def mapJs = new JavascriptMapReduceOperation("function(v){ var uuid='$uuid'; ejsLog('/tmp/mapred.log', 'map input: '+JSON.stringify(v)); var o=Riak.mapValuesJson(v); return [1]; }")
|
||||
def mapPhase = new RiakMapReducePhase("map", "javascript", mapJs)
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:p="http://www.springframework.org/schema/p"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
|
||||
|
||||
<import resource="classpath:/META-INF/spring/app-context.xml"/>
|
||||
|
||||
<bean id="qos" class="org.springframework.data.keyvalue.riak.core.RiakQosParameters"
|
||||
p:durableWriteThreshold="all"
|
||||
p:writeThreshold="all"/>
|
||||
<bean id="riakTemplate"
|
||||
class="org.springframework.data.keyvalue.riak.core.RiakKeyValueTemplate"
|
||||
p:defaultQosParameters-ref="qos"/>
|
||||
|
||||
</beans>
|
||||
@@ -1,34 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ Copyright (c) 2010 by J. Brisbin <jon@jbrisbin.com>
|
||||
~ Portions (c) 2010 by NPC International, Inc. or the
|
||||
~ original author(s).
|
||||
~
|
||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||
~ you may not use this file except in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
-->
|
||||
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:p="http://www.springframework.org/schema/p"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
|
||||
|
||||
<import resource="classpath:/META-INF/spring/app-context.xml"/>
|
||||
|
||||
<bean id="qos" class="org.springframework.data.keyvalue.riak.core.RiakQosParameters"
|
||||
p:durableWriteThreshold="all"
|
||||
p:writeThreshold="all"/>
|
||||
<bean id="riakTemplate"
|
||||
class="org.springframework.data.keyvalue.riak.core.RiakTemplate"
|
||||
p:defaultQosParameters-ref="qos"/>
|
||||
|
||||
</beans>
|
||||
Reference in New Issue
Block a user