Remove RJC driver due to lack of Redis 2.6 support
DATAREDIS-185
This commit is contained in:
@@ -45,7 +45,6 @@ dependencies {
|
||||
compile "redis.clients:jedis:$jedisVersion"
|
||||
compile("com.github.spullara.redis:client:$srpVersion", optional)
|
||||
compile("org.jredis:jredis-anthonylauzon:$jredisVersion", optional)
|
||||
compile("org.idevlab:rjc:$rjcVersion", optional)
|
||||
compile("com.lambdaworks:lettuce:$lettuceVersion", optional)
|
||||
|
||||
// Mappers
|
||||
@@ -80,7 +79,7 @@ javadoc {
|
||||
]
|
||||
|
||||
links = [
|
||||
"http://static.springframework.org/spring/docs/3.0.x/javadoc-api",
|
||||
"http://static.springframework.org/spring/docs/3.1.x/javadoc-api",
|
||||
"http://download.oracle.com/javase/6/docs/api",
|
||||
"http://jackson.codehaus.org/1.8.2/javadoc"
|
||||
]
|
||||
|
||||
@@ -55,7 +55,7 @@ template.convertAndSend("hello!", "world");]]></programlisting>
|
||||
whether it is listening or not, <interfacename>RedisConnection</interfacename>
|
||||
provides <methodname>getSubscription</methodname> and <methodname>isSubscribed</methodname> method.</para>
|
||||
|
||||
<important>When using Jedis, JRedis or RJC connectors, subscribing commands are synchronous and thus blocking. That is, calling subscribe on a connection will cause
|
||||
<important>When using Jedis or JRedis connectors, subscribing commands are synchronous and thus blocking. That is, calling subscribe on a connection will cause
|
||||
the current thread to block as it will start waiting for messages - the thread will be released only if the subscription
|
||||
is canceled, that is an additional thread invokes <methodname>unsubscribe</methodname> or <methodname>pUnsubscribe</methodname>
|
||||
on the <emphasis>same</emphasis> connection. See <link linkend="redis:pubsub:subscribe:containers">message listener container</link> below
|
||||
|
||||
@@ -18,9 +18,9 @@
|
||||
<title>Redis Requirements</title>
|
||||
<para>Spring Redis requires Redis 2.2 or above and Java SE 6.0 or above .
|
||||
In terms of language bindings (or connectors), Spring Redis integrates with <ulink url="http://github.com/xetorthio/jedis">Jedis</ulink>,
|
||||
<ulink url="http://github.com/alphazero/jredis">JRedis</ulink>, <ulink url="http://github.com/e-mzungu/rjc">RJC</ulink>,
|
||||
<ulink url="http://github.com/alphazero/jredis">JRedis</ulink>,
|
||||
<ulink url="http://github.com/spullara/redis-protocol">SRP</ulink> and
|
||||
<ulink url="http://github.com/wg/lettuce">Lettuce</ulink>, five popular open source Java libraries for Redis.
|
||||
<ulink url="http://github.com/wg/lettuce">Lettuce</ulink>, four popular open source Java libraries for Redis.
|
||||
If you are aware of any other connector that we should be integrating with, please send us feedback.
|
||||
</para>
|
||||
</section>
|
||||
@@ -145,36 +145,6 @@
|
||||
<para>This issue is currently being addressed in the JRedis project and once fixed, will be incorporated by Spring Data Redis.</para>
|
||||
</important>
|
||||
|
||||
</section>
|
||||
|
||||
<section id="redis:connectors:rjc">
|
||||
<title>Configuring RJC connector</title>
|
||||
|
||||
<para><ulink url="http://github.com/e-mzungu/rjc">RJC</ulink> is the third, open-source connector supported by Spring Data Redis through the
|
||||
<literal>org.springframework.data.redis.connection.rjc</literal> package.</para>
|
||||
|
||||
<para>Similar to the other connectors, a typical RJC configuration can look like this:</para>
|
||||
|
||||
<programlisting language="xml"><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:p="http://www.springframework.org/schema/p"
|
||||
xsi:schemaLocation="
|
||||
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
|
||||
|
||||
<bean id="rjcConnectionFactory" class="org.springframework.data.redis.connection.rjc.RjcConnectionFactory"
|
||||
p:host-name="server" p:port="6379"/>
|
||||
</beans>]]></programlisting>
|
||||
|
||||
<para>As one can note, the configuration is quite similar to the Jredis or Jedis one.</para>
|
||||
|
||||
<important><para>Currently, RJC does not have support for binary keys. This forces the <classname>RjcConnection</classname> to perform encoding internally
|
||||
(through <ulink url="http://en.wikipedia.org/wiki/Base64">base64</ulink> schema). In practice, this means it's safe to read/write arbitrary data however
|
||||
the Redis key stored values will differ from the decoded ones, even in the simplest cases, since everything (no matter the format) is encoded. This will not be
|
||||
the case for Redis values.</para>
|
||||
<para>This issue is currently being addressed in the RJC project and once fixed, will be incorporated by Spring Data Redis.</para>
|
||||
</important>
|
||||
|
||||
</section>
|
||||
|
||||
<section id="redis:connectors:srp">
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
rjcVersion=0.6.4
|
||||
slf4jVersion=1.6.6
|
||||
junitVersion=4.8.1
|
||||
jredisVersion=03122010
|
||||
|
||||
@@ -1,117 +0,0 @@
|
||||
/*
|
||||
* Copyright 2011-2013 the original author or authors.
|
||||
*
|
||||
* 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.redis.connection.rjc;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.List;
|
||||
|
||||
import org.idevlab.rjc.ds.RedisConnection;
|
||||
import org.idevlab.rjc.message.RedisNodeSubscriber;
|
||||
import org.idevlab.rjc.protocol.Protocol.Command;
|
||||
|
||||
/**
|
||||
* Basic decorator suppressing close() calls to the underlying connection.
|
||||
* Used for reusing arbitrary connections with {@link RedisNodeSubscriber} without
|
||||
* resorting to connection pooling.
|
||||
*
|
||||
* @author Costin Leau
|
||||
*/
|
||||
class CloseSuppressingRjcConnection implements RedisConnection {
|
||||
|
||||
private final RedisConnection delegate;
|
||||
|
||||
/**
|
||||
* Constructs a new <code>CloseSuppressingRjcConnection</code> instance.
|
||||
*
|
||||
* @param delegate
|
||||
*/
|
||||
CloseSuppressingRjcConnection(RedisConnection delegate) {
|
||||
this.delegate = delegate;
|
||||
}
|
||||
|
||||
public void close() {
|
||||
// no-op
|
||||
}
|
||||
|
||||
public void connect() throws UnknownHostException, IOException {
|
||||
delegate.connect();
|
||||
}
|
||||
|
||||
public List<Object> getAll() {
|
||||
return delegate.getAll();
|
||||
}
|
||||
|
||||
public String getBulkReply() {
|
||||
return delegate.getBulkReply();
|
||||
}
|
||||
|
||||
public String getHost() {
|
||||
return delegate.getHost();
|
||||
}
|
||||
|
||||
public Long getIntegerReply() {
|
||||
return delegate.getIntegerReply();
|
||||
}
|
||||
|
||||
public List<String> getMultiBulkReply() {
|
||||
return delegate.getMultiBulkReply();
|
||||
}
|
||||
|
||||
public List<Object> getObjectMultiBulkReply() {
|
||||
return delegate.getObjectMultiBulkReply();
|
||||
}
|
||||
|
||||
public Object getOne() {
|
||||
return delegate.getOne();
|
||||
}
|
||||
|
||||
public int getPort() {
|
||||
return delegate.getPort();
|
||||
}
|
||||
|
||||
public String getStatusCodeReply() {
|
||||
return delegate.getStatusCodeReply();
|
||||
}
|
||||
|
||||
public int getTimeout() {
|
||||
return delegate.getTimeout();
|
||||
}
|
||||
|
||||
public boolean isConnected() {
|
||||
return delegate.isConnected();
|
||||
}
|
||||
|
||||
public void rollbackTimeout() {
|
||||
delegate.rollbackTimeout();
|
||||
}
|
||||
|
||||
public void sendCommand(Command arg0, byte[]... arg1) {
|
||||
delegate.sendCommand(arg0, arg1);
|
||||
}
|
||||
|
||||
public void sendCommand(Command arg0, String... arg1) {
|
||||
delegate.sendCommand(arg0, arg1);
|
||||
}
|
||||
|
||||
public void sendCommand(Command arg0) {
|
||||
delegate.sendCommand(arg0);
|
||||
}
|
||||
|
||||
public void setTimeoutInfinite() {
|
||||
delegate.setTimeoutInfinite();
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,221 +0,0 @@
|
||||
/*
|
||||
* Copyright 2011-2013 the original author or authors.
|
||||
*
|
||||
* 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.redis.connection.rjc;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.idevlab.rjc.ds.DataSource;
|
||||
import org.idevlab.rjc.ds.PoolableDataSource;
|
||||
import org.idevlab.rjc.ds.SimpleDataSource;
|
||||
import org.idevlab.rjc.message.RedisNodeSubscriber;
|
||||
import org.idevlab.rjc.protocol.Protocol;
|
||||
import org.springframework.beans.factory.DisposableBean;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.dao.DataAccessException;
|
||||
import org.springframework.data.redis.connection.RedisConnection;
|
||||
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* Connection factory creating <a href="http://github.com/e-mzungu/rjc/">rjc</a> based connections.
|
||||
*
|
||||
* @author Costin Leau
|
||||
*/
|
||||
public class RjcConnectionFactory implements InitializingBean, DisposableBean, RedisConnectionFactory {
|
||||
|
||||
private final static Log log = LogFactory.getLog(RjcConnectionFactory.class);
|
||||
|
||||
private String hostName = "localhost";
|
||||
private int port = Protocol.DEFAULT_PORT;
|
||||
private int timeout = Protocol.DEFAULT_TIMEOUT;
|
||||
private String password;
|
||||
|
||||
private boolean usePool = true;
|
||||
private int dbIndex = 0;
|
||||
private DataSource dataSource;
|
||||
private DataSource subscriptionDataSource;
|
||||
|
||||
|
||||
/**
|
||||
* Constructs a new <code>RjcConnectionFactory</code> instance
|
||||
* with default settings (default connection pooling, no shard information).
|
||||
*/
|
||||
public RjcConnectionFactory() {
|
||||
}
|
||||
|
||||
|
||||
public void afterPropertiesSet() {
|
||||
if (usePool) {
|
||||
PoolableDataSource pool = new PoolableDataSource();
|
||||
pool.setHost(hostName);
|
||||
pool.setPort(port);
|
||||
pool.setPassword(password);
|
||||
pool.setTimeout(timeout);
|
||||
|
||||
pool.init();
|
||||
|
||||
dataSource = pool;
|
||||
|
||||
}
|
||||
else {
|
||||
dataSource = new SimpleDataSource(hostName, port, timeout, password);
|
||||
}
|
||||
subscriptionDataSource = new SimpleDataSource(hostName, port, timeout, password);
|
||||
}
|
||||
|
||||
public void destroy() {
|
||||
if (usePool && dataSource != null) {
|
||||
try {
|
||||
((PoolableDataSource) dataSource).close();
|
||||
} catch (Exception ex) {
|
||||
log.warn("Cannot properly close Rjc pool", ex);
|
||||
}
|
||||
dataSource = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public RedisConnection getConnection() {
|
||||
return postProcessConnection(new RjcConnection(dataSource.getConnection(), dbIndex,
|
||||
new RedisNodeSubscriber(subscriptionDataSource)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Post process a newly retrieved connection. Useful for decorating or executing
|
||||
* initialization commands on a new connection.
|
||||
* This implementation simply returns the connection.
|
||||
*
|
||||
* @param connection
|
||||
* @return processed connection
|
||||
*/
|
||||
protected RjcConnection postProcessConnection(RjcConnection connection) {
|
||||
return connection;
|
||||
}
|
||||
|
||||
|
||||
public DataAccessException translateExceptionIfPossible(RuntimeException ex) {
|
||||
return RjcUtils.convertRjcAccessException(ex);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the Redis hostName.
|
||||
*
|
||||
* @return Returns the hostName
|
||||
*/
|
||||
public String getHostName() {
|
||||
return hostName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Redis hostName.
|
||||
*
|
||||
* @param hostName The hostName to set.
|
||||
*/
|
||||
public void setHostName(String hostName) {
|
||||
this.hostName = hostName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the password used for authenticating with the Redis server.
|
||||
*
|
||||
* @return password for authentication
|
||||
*/
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the password used for authenticating with the Redis server.
|
||||
*
|
||||
* @param password the password to set
|
||||
*/
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the port used to connect to the Redis instance.
|
||||
*
|
||||
* @return Redis port.
|
||||
*/
|
||||
public int getPort() {
|
||||
return port;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the port used to connect to the Redis instance.
|
||||
*
|
||||
* @param port Redis port
|
||||
*/
|
||||
public void setPort(int port) {
|
||||
this.port = port;
|
||||
}
|
||||
/**
|
||||
* Returns the timeout.
|
||||
*
|
||||
* @return Returns the timeout
|
||||
*/
|
||||
public int getTimeout() {
|
||||
return timeout;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param timeout The timeout to set.
|
||||
*/
|
||||
public void setTimeout(int timeout) {
|
||||
this.timeout = timeout;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates the use of a connection pool.
|
||||
*
|
||||
* @return Returns the use of connection pooling.
|
||||
*/
|
||||
public boolean getUsePool() {
|
||||
return usePool;
|
||||
}
|
||||
|
||||
/**
|
||||
* Turns on or off the use of connection pooling.
|
||||
*
|
||||
* @param usePool The usePool to set.
|
||||
*/
|
||||
public void setUsePool(boolean usePool) {
|
||||
this.usePool = usePool;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the index of the database.
|
||||
*
|
||||
* @return Returns the database index
|
||||
*/
|
||||
public int getDatabase() {
|
||||
return dbIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the index of the database used by this connection factory.
|
||||
* Can be between 0 (default) and 15.
|
||||
*
|
||||
* @param index database index
|
||||
*/
|
||||
public void setDatabase(int index) {
|
||||
Assert.isTrue(index >= 0, "invalid DB index (a positive index required)");
|
||||
this.dbIndex = index;
|
||||
}
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
/*
|
||||
* Copyright 2011-2013 the original author or authors.
|
||||
*
|
||||
* 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.redis.connection.rjc;
|
||||
|
||||
import org.idevlab.rjc.message.MessageListener;
|
||||
import org.idevlab.rjc.message.PMessageListener;
|
||||
import org.springframework.data.redis.connection.DefaultMessage;
|
||||
|
||||
/**
|
||||
* Message listener adapter for RJC library.
|
||||
*
|
||||
* @author Costin Leau
|
||||
*/
|
||||
class RjcMessageListener implements MessageListener, PMessageListener {
|
||||
|
||||
private final org.springframework.data.redis.connection.MessageListener listener;
|
||||
|
||||
RjcMessageListener(org.springframework.data.redis.connection.MessageListener messageListener) {
|
||||
this.listener = messageListener;
|
||||
}
|
||||
|
||||
|
||||
public void onMessage(String channel, String message) {
|
||||
listener.onMessage(new DefaultMessage(RjcUtils.encode(channel), RjcUtils.encode(message)), null);
|
||||
}
|
||||
|
||||
|
||||
public void onMessage(String pattern, String channel, String message) {
|
||||
listener.onMessage(new DefaultMessage(RjcUtils.encode(channel), RjcUtils.encode(message)),
|
||||
RjcUtils.encode(pattern));
|
||||
}
|
||||
}
|
||||
@@ -1,64 +0,0 @@
|
||||
/*
|
||||
* Copyright 2011-2013 the original author or authors.
|
||||
*
|
||||
* 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.redis.connection.rjc;
|
||||
|
||||
import org.idevlab.rjc.message.RedisNodeSubscriber;
|
||||
import org.springframework.data.redis.connection.MessageListener;
|
||||
import org.springframework.data.redis.connection.util.AbstractSubscription;
|
||||
|
||||
/**
|
||||
* Message subscription on top of RJC.
|
||||
*
|
||||
* @author Costin Leau
|
||||
*/
|
||||
class RjcSubscription extends AbstractSubscription {
|
||||
|
||||
private final RedisNodeSubscriber subscriber;
|
||||
|
||||
RjcSubscription(MessageListener listener, RedisNodeSubscriber subscriber) {
|
||||
super(listener);
|
||||
this.subscriber = subscriber;
|
||||
subscriber.setMessageListener(new RjcMessageListener(listener));
|
||||
subscriber.setPMessageListener(new RjcMessageListener(listener));
|
||||
}
|
||||
|
||||
|
||||
protected void doClose() {
|
||||
if(!getChannels().isEmpty() || !getPatterns().isEmpty()) {
|
||||
subscriber.close();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected void doPsubscribe(byte[]... patterns) {
|
||||
subscriber.psubscribe(RjcUtils.decodeMultiple(patterns));
|
||||
}
|
||||
|
||||
|
||||
protected void doPUnsubscribe(boolean all, byte[]... patterns) {
|
||||
subscriber.punsubscribe(RjcUtils.decodeMultiple(patterns));
|
||||
}
|
||||
|
||||
|
||||
protected void doSubscribe(byte[]... channels) {
|
||||
subscriber.subscribe(RjcUtils.decodeMultiple(channels));
|
||||
}
|
||||
|
||||
|
||||
protected void doUnsubscribe(boolean all, byte[]... channels) {
|
||||
subscriber.unsubscribe(RjcUtils.decodeMultiple(channels));
|
||||
}
|
||||
}
|
||||
@@ -1,249 +0,0 @@
|
||||
/*
|
||||
* Copyright 2011-2013 the original author or authors.
|
||||
*
|
||||
* 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.redis.connection.rjc;
|
||||
|
||||
import java.io.StringReader;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
|
||||
import org.idevlab.rjc.Client.LIST_POSITION;
|
||||
import org.idevlab.rjc.ElementScore;
|
||||
import org.idevlab.rjc.RedisException;
|
||||
import org.idevlab.rjc.SortingParams;
|
||||
import org.idevlab.rjc.ZParams;
|
||||
import org.springframework.dao.DataAccessException;
|
||||
import org.springframework.dao.InvalidDataAccessApiUsageException;
|
||||
import org.springframework.data.redis.RedisSystemException;
|
||||
import org.springframework.data.redis.connection.DataType;
|
||||
import org.springframework.data.redis.connection.DefaultTuple;
|
||||
import org.springframework.data.redis.connection.RedisListCommands.Position;
|
||||
import org.springframework.data.redis.connection.RedisZSetCommands.Aggregate;
|
||||
import org.springframework.data.redis.connection.RedisZSetCommands.Tuple;
|
||||
import org.springframework.data.redis.connection.SortParameters;
|
||||
import org.springframework.data.redis.connection.SortParameters.Order;
|
||||
import org.springframework.data.redis.connection.SortParameters.Range;
|
||||
import org.springframework.data.redis.connection.util.DecodeUtils;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
|
||||
/**
|
||||
* Helper class featuring methods for RJC connection handling, providing support for exception translation.
|
||||
*
|
||||
* @author Costin Leau
|
||||
*/
|
||||
public abstract class RjcUtils {
|
||||
|
||||
private static final String ONE = "1";
|
||||
private static final String ZERO = "0";
|
||||
|
||||
|
||||
public static DataAccessException convertRjcAccessException(RuntimeException ex) {
|
||||
if (ex instanceof RedisException) {
|
||||
return convertRjcAccessException((RedisException) ex);
|
||||
}
|
||||
|
||||
return new RedisSystemException("Unknown exception", ex);
|
||||
}
|
||||
|
||||
public static DataAccessException convertRjcAccessException(RedisException ex) {
|
||||
return new InvalidDataAccessApiUsageException(ex.getMessage(), ex);
|
||||
}
|
||||
|
||||
static DataType convertDataType(String type) {
|
||||
if ("string".equals(type)) {
|
||||
return DataType.STRING;
|
||||
}
|
||||
else if ("list".equals(type)) {
|
||||
return DataType.LIST;
|
||||
}
|
||||
else if ("set".equals(type)) {
|
||||
return DataType.SET;
|
||||
}
|
||||
else if ("zset".equals(type)) {
|
||||
return DataType.ZSET;
|
||||
}
|
||||
else if ("hash".equals(type)) {
|
||||
return DataType.HASH;
|
||||
}
|
||||
else if ("none".equals(type)) {
|
||||
return DataType.NONE;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
static String decode(byte[] bytes) {
|
||||
return DecodeUtils.decode(bytes);
|
||||
}
|
||||
|
||||
static byte[] encode(String string) {
|
||||
return DecodeUtils.encode(string);
|
||||
}
|
||||
|
||||
static String[] decodeMultiple(byte[]... bytes) {
|
||||
return DecodeUtils.decodeMultiple(bytes);
|
||||
}
|
||||
|
||||
static String[] flatten(Map<byte[], byte[]> tuple) {
|
||||
String[] result = new String[tuple.size() * 2];
|
||||
int index = 0;
|
||||
for (Map.Entry<byte[], byte[]> entry : tuple.entrySet()) {
|
||||
result[index++] = decode(entry.getKey());
|
||||
result[index++] = decode(entry.getValue());
|
||||
}
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
static Set<byte[]> convertToSet(Collection<String> keys) {
|
||||
if (keys == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return DecodeUtils.convertToSet(keys);
|
||||
}
|
||||
|
||||
static List<byte[]> convertToList(Collection<String> keys) {
|
||||
if (keys == null) {
|
||||
return null;
|
||||
}
|
||||
return DecodeUtils.convertToList(keys);
|
||||
}
|
||||
|
||||
static SortingParams convertSortParams(SortParameters params) {
|
||||
SortingParams rjcSort = null;
|
||||
|
||||
if (params != null) {
|
||||
rjcSort = new SortingParams();
|
||||
|
||||
byte[] byPattern = params.getByPattern();
|
||||
if (byPattern != null) {
|
||||
rjcSort.by(DecodeUtils.decode(byPattern));
|
||||
}
|
||||
byte[][] getPattern = params.getGetPattern();
|
||||
|
||||
if (getPattern != null && getPattern.length > 0) {
|
||||
for (byte[] bs : getPattern) {
|
||||
rjcSort.get(DecodeUtils.decode(bs));
|
||||
}
|
||||
}
|
||||
Range limit = params.getLimit();
|
||||
if (limit != null) {
|
||||
rjcSort.limit((int) limit.getStart(), (int) limit.getCount());
|
||||
}
|
||||
Order order = params.getOrder();
|
||||
if (order != null && order.equals(Order.DESC)) {
|
||||
rjcSort.desc();
|
||||
}
|
||||
Boolean isAlpha = params.isAlphabetic();
|
||||
if (isAlpha != null && isAlpha) {
|
||||
rjcSort.alpha();
|
||||
}
|
||||
}
|
||||
return rjcSort;
|
||||
}
|
||||
|
||||
static Properties info(String string) {
|
||||
Properties info = new Properties();
|
||||
StringReader stringReader = new StringReader(string);
|
||||
try {
|
||||
info.load(stringReader);
|
||||
} catch (Exception ex) {
|
||||
throw new RedisSystemException("Cannot read Redis info", ex);
|
||||
} finally {
|
||||
stringReader.close();
|
||||
}
|
||||
return info;
|
||||
}
|
||||
|
||||
static String asBit(boolean value) {
|
||||
return (value ? ONE : ZERO);
|
||||
}
|
||||
|
||||
static LIST_POSITION convertPosition(Position where) {
|
||||
switch (where) {
|
||||
case BEFORE:
|
||||
return LIST_POSITION.BEFORE;
|
||||
|
||||
case AFTER:
|
||||
return LIST_POSITION.AFTER;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
static ZParams toZParams(Aggregate aggregate, int[] weights) {
|
||||
return new ZParams().weights(weights).aggregate(ZParams.Aggregate.valueOf(aggregate.name()));
|
||||
}
|
||||
|
||||
static Set<Tuple> convertElementScore(List<ElementScore> tuples) {
|
||||
Set<Tuple> value = new LinkedHashSet<Tuple>(tuples.size());
|
||||
for (ElementScore tuple : tuples) {
|
||||
value.add(new DefaultTuple(encode(tuple.getElement()), Double.valueOf(tuple.getScore())));
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
static Map<byte[], byte[]> encodeMap(Map<String, String> map) {
|
||||
Map<byte[], byte[]> result = new LinkedHashMap<byte[], byte[]>(map.size());
|
||||
for (Map.Entry<String, String> entry : map.entrySet()) {
|
||||
result.put(encode(entry.getKey()), encode(entry.getValue()));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
static Map<String, String> decodeMap(Map<byte[], byte[]> map) {
|
||||
Map<String, String> result = new LinkedHashMap<String, String>(map.size());
|
||||
for (Map.Entry<byte[], byte[]> entry : map.entrySet()) {
|
||||
result.put(decode(entry.getKey()), decode(entry.getValue()));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
static Double convert(String zscore) {
|
||||
return (zscore == null ? null : Double.valueOf(zscore));
|
||||
}
|
||||
|
||||
|
||||
static String[] addArray(String[] one, String[] two) {
|
||||
if (ObjectUtils.isEmpty(one)) {
|
||||
return two;
|
||||
}
|
||||
if (ObjectUtils.isEmpty(two)) {
|
||||
return one;
|
||||
}
|
||||
|
||||
String[] result = Arrays.copyOf(one, one.length + two.length);
|
||||
System.arraycopy(two, 0, result, one.length, two.length);
|
||||
return result;
|
||||
}
|
||||
|
||||
static List<Object> maybeConvert(List<Object> result) {
|
||||
for (int i = 0; i < result.size(); i++) {
|
||||
Object obj = result.get(i);
|
||||
if (obj instanceof String) {
|
||||
result.set(i, encode((String) obj));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
/*
|
||||
* Copyright 2011-2013 the original author or authors.
|
||||
*
|
||||
* 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.redis.connection.rjc;
|
||||
|
||||
import org.idevlab.rjc.ds.DataSource;
|
||||
import org.idevlab.rjc.ds.RedisConnection;
|
||||
|
||||
/**
|
||||
* Basic data source that always returns the same connection.
|
||||
*
|
||||
* @author Costin Leau
|
||||
*/
|
||||
class SingleDataSource implements DataSource {
|
||||
|
||||
private final RedisConnection connection;
|
||||
|
||||
SingleDataSource(RedisConnection connection) {
|
||||
this.connection = connection;
|
||||
}
|
||||
|
||||
|
||||
public RedisConnection getConnection() {
|
||||
return connection;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
/**
|
||||
* Connection package for <a href="https://github.com/e-mzungu/rjc">RJC</a> library.
|
||||
*/
|
||||
package org.springframework.data.redis.connection.rjc;
|
||||
|
||||
@@ -18,7 +18,6 @@ package org.springframework.data.redis.connection;
|
||||
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
|
||||
import org.springframework.data.redis.connection.jredis.JredisConnectionFactory;
|
||||
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
|
||||
import org.springframework.data.redis.connection.rjc.RjcConnectionFactory;
|
||||
import org.springframework.data.redis.connection.srp.SrpConnectionFactory;
|
||||
|
||||
/**
|
||||
@@ -34,10 +33,6 @@ public abstract class ConnectionUtils {
|
||||
|| (connectionFactory instanceof SrpConnectionFactory);
|
||||
}
|
||||
|
||||
public static boolean isRjc(RedisConnectionFactory connectionFactory) {
|
||||
return connectionFactory instanceof RjcConnectionFactory;
|
||||
}
|
||||
|
||||
public static boolean isSrp(RedisConnectionFactory connectionFactory) {
|
||||
return connectionFactory instanceof SrpConnectionFactory;
|
||||
}
|
||||
|
||||
@@ -1,119 +0,0 @@
|
||||
/*
|
||||
* Copyright 2011-2013 the original author or authors.
|
||||
*
|
||||
* 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.redis.connection.rjc;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.data.redis.connection.AbstractConnectionIntegrationTests;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
/**
|
||||
* Integration test of {@link RjcConnection}
|
||||
*
|
||||
* @author Costin Leau
|
||||
* @author Jennifer Hickey
|
||||
*
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration
|
||||
public class RjcConnectionIntegrationTests extends AbstractConnectionIntegrationTests {
|
||||
|
||||
@Ignore("nulls are encoded to empty strings")
|
||||
public void testNullKey() throws Exception {
|
||||
}
|
||||
|
||||
@Ignore("nulls are encoded to empty strings")
|
||||
public void testNullValue() throws Exception {
|
||||
}
|
||||
|
||||
@Ignore("nulls are encoded to empty strings")
|
||||
public void testHashNullKey() throws Exception {
|
||||
}
|
||||
|
||||
@Ignore("nulls are encoded to empty strings")
|
||||
public void testHashNullValue() throws Exception {
|
||||
}
|
||||
|
||||
@Ignore("DATAREDIS-133 Key search does not work with regex")
|
||||
public void testKeys() throws Exception {
|
||||
}
|
||||
|
||||
@Ignore("DATAREDIS-121 incr/decr does not work with encoded values")
|
||||
public void testDecrByIncrBy() {
|
||||
}
|
||||
|
||||
@Ignore("DATAREDIS-121 incr/decr does not work with encoded values")
|
||||
public void testIncDecr() {
|
||||
}
|
||||
|
||||
@Ignore("DATAREDIS-121 incr/decr does not work with encoded values")
|
||||
public void testHIncrBy() {
|
||||
}
|
||||
|
||||
@Ignore("DATAREDIS-134 string ops do not work with encoded values")
|
||||
public void testSort() {
|
||||
}
|
||||
|
||||
@Ignore("DATAREDIS-134 string ops do not work with encoded values")
|
||||
public void testSortStore() {
|
||||
}
|
||||
|
||||
@Ignore("DATAREDIS-134 string ops do not work with encoded values")
|
||||
public void testGetRangeSetRange() {
|
||||
}
|
||||
|
||||
@Ignore("DATAREDIS-134 string ops do not work with encoded values")
|
||||
public void testStrLen() {
|
||||
}
|
||||
|
||||
@Ignore("DATAREDIS-120 Pattern matching currently broken")
|
||||
public void testPubSubWithPatterns() {
|
||||
}
|
||||
|
||||
@Ignore("DATAREDIS-148 Syntax error on RJC zUnionStore")
|
||||
public void testZUnionStoreAggWeights() {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMultiExec() throws Exception {
|
||||
byte[] key = "key".getBytes();
|
||||
byte[] value = "value".getBytes();
|
||||
|
||||
connection.multi();
|
||||
connection.set(key, value);
|
||||
assertNull(connection.get(key));
|
||||
List<Object> results = connection.exec();
|
||||
assertEquals(2, results.size());
|
||||
assertEquals("OK", (String) results.get(0));
|
||||
assertEquals(new String(value), new String(RjcUtils.encode((String) results.get(1))));
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
@Test
|
||||
public void testExecute() {
|
||||
connection.set("foo", "bar");
|
||||
assertEquals(Arrays.asList(new Object[] { RjcUtils.decode("bar".getBytes()) }),
|
||||
(List) connection.execute("GET", RjcUtils.decode("foo".getBytes())));
|
||||
}
|
||||
}
|
||||
@@ -1,272 +0,0 @@
|
||||
/*
|
||||
* Copyright 2011-2013 the original author or authors.
|
||||
*
|
||||
* 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.redis.connection.rjc;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.data.redis.connection.AbstractConnectionPipelineIntegrationTests;
|
||||
import org.springframework.data.redis.connection.DefaultStringRedisConnection;
|
||||
import org.springframework.data.redis.connection.DefaultStringTuple;
|
||||
import org.springframework.data.redis.connection.StringRedisConnection.StringTuple;
|
||||
import org.springframework.data.redis.serializer.SerializationUtils;
|
||||
import org.springframework.test.annotation.IfProfileValue;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
/**
|
||||
* Integration test of {@link RjcConnection} pipeline functionality
|
||||
*
|
||||
* @author Jennifer Hickey
|
||||
*
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration
|
||||
public class RjcConnectionPipelineIntegrationTests extends
|
||||
AbstractConnectionPipelineIntegrationTests {
|
||||
|
||||
@Ignore("DATAREDIS-134 string ops do not work with encoded values")
|
||||
public void testGetRangeSetRange() {
|
||||
}
|
||||
|
||||
@Ignore("DATAREDIS-133 Key search does not work with regex")
|
||||
public void testKeys() throws Exception {
|
||||
}
|
||||
|
||||
@Ignore("DATAREDIS-121 incr/decr does not work with encoded values")
|
||||
public void testDecrByIncrBy() {
|
||||
}
|
||||
|
||||
@Ignore("DATAREDIS-121 incr/decr does not work with encoded values")
|
||||
public void testIncDecr() {
|
||||
}
|
||||
|
||||
@Ignore("DATAREDIS-121 incr/decr does not work with encoded values")
|
||||
public void testHIncrBy() {
|
||||
}
|
||||
|
||||
@Ignore("DATAREDIS-134 string ops do not work with encoded values")
|
||||
public void testSort() {
|
||||
}
|
||||
|
||||
@Ignore("DATAREDIS-134 string ops do not work with encoded values")
|
||||
public void testSortStore() {
|
||||
}
|
||||
|
||||
@Ignore("DATAREDIS-134 string ops do not work with encoded values")
|
||||
public void testStrLen() {
|
||||
}
|
||||
|
||||
@Ignore("DATAREDIS-148 Syntax error on RJC zUnionStore")
|
||||
public void testZUnionStoreAggWeights() {
|
||||
}
|
||||
|
||||
@Ignore("DATAREDIS-149 Wrong number of args on RJC brPop when pipelining")
|
||||
public void testBRPop() {
|
||||
}
|
||||
|
||||
@Ignore("DATAREDIS-149 Wrong number of args on RJC brPop when pipelining")
|
||||
public void testBLPop() {
|
||||
}
|
||||
|
||||
@Ignore("DATAREDIS-149 Wrong number of args on RJC brPop when pipelining")
|
||||
public void testBRPopTimeout() {
|
||||
}
|
||||
|
||||
@Ignore("DATAREDIS-149 Wrong number of args on RJC brPop when pipelining")
|
||||
public void testBLPopTimeout() {
|
||||
}
|
||||
|
||||
@Ignore("DATAREDIS-150 the 6 from zIncrBy improperly decoded")
|
||||
public void testZIncrBy() {
|
||||
}
|
||||
|
||||
@Ignore("DATAREDIS-150 the 3 from zScore improperly decoded")
|
||||
public void testZScore() {
|
||||
}
|
||||
|
||||
@Ignore("DATAREDIS-150 the results of info improperly decoded")
|
||||
public void testInfo() throws Exception {
|
||||
}
|
||||
|
||||
@Ignore("DATAREDIS-150 the results of ping improperly decoded")
|
||||
public void testPingPong() throws Exception {
|
||||
}
|
||||
|
||||
@Ignore("DATAREDIS-150 the results of type improperly decoded")
|
||||
public void testType() {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore("DATAREDIS-161 Syntax error in pipelined RJC op causes SocketTimeouts on subsequent calls")
|
||||
public void exceptionExecuteNative() throws Exception {
|
||||
}
|
||||
|
||||
// Overrides, usually due to return values being Long vs Boolean or Set vs
|
||||
// List
|
||||
|
||||
@Test
|
||||
public void testSIsMember() {
|
||||
convertResultToSet = true;
|
||||
actual.add(connection.sAdd("myset", "foo"));
|
||||
actual.add(connection.sAdd("myset", "bar"));
|
||||
actual.add(connection.sIsMember("myset", "foo"));
|
||||
actual.add(connection.sIsMember("myset", "baz"));
|
||||
verifyResults(Arrays.asList(new Object[] { 1l, 1l, 1l, 0l }), actual);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRename() {
|
||||
connection.set("renametest", "testit");
|
||||
connection.rename("renametest", "newrenametest");
|
||||
actual.add(connection.get("newrenametest"));
|
||||
actual.add(connection.exists("renametest"));
|
||||
verifyResults(Arrays.asList(new Object[] { "testit", 0l }), actual);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExists() {
|
||||
connection.set("existent", "true");
|
||||
actual.add(connection.exists("existent"));
|
||||
actual.add(connection.exists("nonexistent"));
|
||||
verifyResults(Arrays.asList(new Object[] { 1l, 0l }), actual);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMultiExec() throws Exception {
|
||||
connection.multi();
|
||||
connection.set("key", "value");
|
||||
assertNull(connection.get("key"));
|
||||
assertNull(connection.exec());
|
||||
List<Object> convertedResults = convertResults();
|
||||
// "OK" will be decoded to null
|
||||
assertEquals(Arrays.asList(new Object[] { Arrays.asList(new String[] { null, "value" }) }),
|
||||
convertedResults);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWatch() throws Exception {
|
||||
connection.set("testitnow", "willdo");
|
||||
connection.watch("testitnow".getBytes());
|
||||
//Give some time for watch to be asynch executed
|
||||
Thread.sleep(500);
|
||||
DefaultStringRedisConnection conn2 = new DefaultStringRedisConnection(
|
||||
connectionFactory.getConnection());
|
||||
conn2.set("testitnow", "something");
|
||||
conn2.close();
|
||||
connection.multi();
|
||||
connection.set("testitnow", "somethingelse");
|
||||
actual.add(connection.exec());
|
||||
actual.add(connection.get("testitnow"));
|
||||
List<Object> convertedResults = convertResults();
|
||||
// The null returned from exec will be filtered out
|
||||
assertEquals(Arrays.asList(new String[] { "something" }), convertedResults);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUnwatch() throws Exception {
|
||||
connection.set("testitnow", "willdo");
|
||||
connection.watch("testitnow".getBytes());
|
||||
connection.unwatch();
|
||||
//Give some time for unwatch to be asynch executed
|
||||
Thread.sleep(500);
|
||||
connection.multi();
|
||||
DefaultStringRedisConnection conn2 = new DefaultStringRedisConnection(
|
||||
connectionFactory.getConnection());
|
||||
conn2.set("testitnow", "something");
|
||||
connection.set("testitnow", "somethingelse");
|
||||
connection.get("testitnow");
|
||||
connection.exec();
|
||||
List<Object> convertedResults = convertResults();
|
||||
// "OK" will be decoded to null
|
||||
assertEquals(Arrays.asList(new Object[] { Arrays.asList(new String[] { null,
|
||||
"somethingelse" }) }), convertedResults);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExecute() {
|
||||
connection.set("foo", "bar");
|
||||
actual.add(connection.execute("GET", RjcUtils.decode("foo".getBytes())));
|
||||
verifyResults(Arrays.asList(new Object[] { "bar" }), actual);
|
||||
}
|
||||
|
||||
@Test
|
||||
@IfProfileValue(name = "runLongTests", value = "true")
|
||||
public void testBRPopLPushTimeout() throws Exception {
|
||||
connection.bRPopLPush(1, "alist", "foo");
|
||||
Thread.sleep(1500l);
|
||||
List<Object> results = connection.closePipeline();
|
||||
assertEquals(Arrays.asList(new Object[] { null }), results);
|
||||
}
|
||||
|
||||
protected List<Object> convertResults() {
|
||||
List<Object> serializedResults = new ArrayList<Object>();
|
||||
List<Object> pipelinedResults = getResults();
|
||||
for (Object result : pipelinedResults) {
|
||||
Object convertedResult = convertResult(result);
|
||||
// closePipeline attempts to decode "OK" and "QUEUED" which turn
|
||||
// them into null
|
||||
// Filter them out here
|
||||
if (convertedResult != null && !"OK".equals(convertedResult)
|
||||
&& !"QUEUED".equals(convertedResult)) {
|
||||
serializedResults.add(convertedResult);
|
||||
}
|
||||
}
|
||||
return serializedResults;
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
protected Object convertResult(Object result) {
|
||||
if (result instanceof List && !(((List) result).isEmpty())
|
||||
&& ((List) result).get(0) instanceof String) {
|
||||
if (convertResultToSet) {
|
||||
return SerializationUtils.deserialize(RjcUtils.convertToSet((List) result),
|
||||
stringSerializer);
|
||||
} else if (convertResultToTuples) {
|
||||
List resultList = (List) result;
|
||||
List<StringTuple> stringTuples = new ArrayList<StringTuple>();
|
||||
for (int i = 0; i < resultList.size(); i += 2) {
|
||||
String value = stringSerializer.deserialize(RjcUtils.encode((String) resultList
|
||||
.get(i)));
|
||||
stringTuples.add(new DefaultStringTuple(value.getBytes(), value, Double
|
||||
.valueOf((String) resultList.get(i + 1))));
|
||||
}
|
||||
return stringTuples;
|
||||
} else {
|
||||
return SerializationUtils.deserialize(RjcUtils.convertToList((List) result),
|
||||
stringSerializer);
|
||||
}
|
||||
} else if (result instanceof byte[]) {
|
||||
return stringSerializer.deserialize((byte[]) result);
|
||||
} else if (result instanceof Map
|
||||
&& ((Map) result).keySet().iterator().next() instanceof byte[]) {
|
||||
return (SerializationUtils.deserialize((Map) result, stringSerializer));
|
||||
} else if (result instanceof Set && !(((Set) result).isEmpty())
|
||||
&& ((Set) result).iterator().next() instanceof byte[]) {
|
||||
return (SerializationUtils.deserialize((Set) result, stringSerializer));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -1,310 +0,0 @@
|
||||
/*
|
||||
* Copyright 2011-2013 the original author or authors.
|
||||
*
|
||||
* 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.redis.connection.rjc;
|
||||
|
||||
import static org.junit.Assert.assertArrayEquals;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.idevlab.rjc.message.RedisNodeSubscriber;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.mockito.Mockito;
|
||||
import org.springframework.data.redis.connection.MessageListener;
|
||||
import org.springframework.data.redis.connection.RedisInvalidSubscriptionException;
|
||||
|
||||
/**
|
||||
* Unit test of {@link RjcSubscription}
|
||||
*
|
||||
* @author Jennifer Hickey
|
||||
*
|
||||
*/
|
||||
public class RjcSubscriptionTests {
|
||||
|
||||
private RjcSubscription subscription;
|
||||
|
||||
private RedisNodeSubscriber subscriber;
|
||||
|
||||
private MessageListener listener;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
subscriber = Mockito.mock(RedisNodeSubscriber.class);
|
||||
listener = Mockito.mock(MessageListener.class);
|
||||
subscription = new RjcSubscription(listener, subscriber);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUnsubscribeAllAndClose() {
|
||||
byte[][] channel = new byte[][] { "a".getBytes() };
|
||||
subscription.subscribe(channel);
|
||||
subscription.unsubscribe();
|
||||
verify(subscriber, never()).close();
|
||||
verify(subscriber, times(1)).unsubscribe(RjcUtils.decodeMultiple(channel));
|
||||
assertFalse(subscription.isAlive());
|
||||
assertTrue(subscription.getChannels().isEmpty());
|
||||
assertTrue(subscription.getPatterns().isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUnsubscribeAllChannelsWithPatterns() {
|
||||
byte[][] channel = new byte[][] { "a".getBytes() };
|
||||
subscription.subscribe(channel);
|
||||
subscription.pSubscribe(new byte[][] { "s*".getBytes() });
|
||||
subscription.unsubscribe();
|
||||
verify(subscriber, times(1)).unsubscribe(RjcUtils.decodeMultiple(channel));
|
||||
verify(subscriber, never()).close();
|
||||
assertTrue(subscription.isAlive());
|
||||
assertTrue(subscription.getChannels().isEmpty());
|
||||
Collection<byte[]> patterns = subscription.getPatterns();
|
||||
assertEquals(1, patterns.size());
|
||||
assertArrayEquals("s*".getBytes(), patterns.iterator().next());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUnsubscribeChannelAndClose() {
|
||||
byte[][] channel = new byte[][] { "a".getBytes() };
|
||||
subscription.subscribe(channel);
|
||||
subscription.unsubscribe(channel);
|
||||
verify(subscriber, times(1)).unsubscribe(RjcUtils.decodeMultiple(channel));
|
||||
verify(subscriber, never()).close();
|
||||
assertFalse(subscription.isAlive());
|
||||
assertTrue(subscription.getChannels().isEmpty());
|
||||
assertTrue(subscription.getPatterns().isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUnsubscribeChannelSomeLeft() {
|
||||
byte[][] channels = new byte[][] { "a".getBytes(), "b".getBytes() };
|
||||
subscription.subscribe(channels);
|
||||
subscription.unsubscribe(new byte[][] { "a".getBytes() });
|
||||
verify(subscriber, times(1)).unsubscribe(
|
||||
RjcUtils.decodeMultiple(new byte[][] { "a".getBytes() }));
|
||||
verify(subscriber, never()).close();
|
||||
assertTrue(subscription.isAlive());
|
||||
Collection<byte[]> subChannels = subscription.getChannels();
|
||||
assertEquals(1, subChannels.size());
|
||||
assertArrayEquals("b".getBytes(), subChannels.iterator().next());
|
||||
assertTrue(subscription.getPatterns().isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUnsubscribeChannelWithPatterns() {
|
||||
byte[][] channel = new byte[][] { "a".getBytes() };
|
||||
subscription.subscribe(channel);
|
||||
subscription.pSubscribe(new byte[][] { "s*".getBytes() });
|
||||
subscription.unsubscribe(channel);
|
||||
verify(subscriber, times(1)).unsubscribe(RjcUtils.decodeMultiple(channel));
|
||||
verify(subscriber, never()).close();
|
||||
assertTrue(subscription.isAlive());
|
||||
assertTrue(subscription.getChannels().isEmpty());
|
||||
Collection<byte[]> patterns = subscription.getPatterns();
|
||||
assertEquals(1, patterns.size());
|
||||
assertArrayEquals("s*".getBytes(), patterns.iterator().next());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUnsubscribeChannelWithPatternsSomeLeft() {
|
||||
byte[][] channel = new byte[][] { "a".getBytes() };
|
||||
subscription.subscribe(new byte[][] { "a".getBytes(), "b".getBytes() });
|
||||
subscription.pSubscribe(new byte[][] { "s*".getBytes() });
|
||||
subscription.unsubscribe(channel);
|
||||
verify(subscriber, times(1)).unsubscribe(RjcUtils.decodeMultiple(channel));
|
||||
verify(subscriber, never()).close();
|
||||
assertTrue(subscription.isAlive());
|
||||
Collection<byte[]> channels = subscription.getChannels();
|
||||
assertEquals(1, channels.size());
|
||||
assertArrayEquals("b".getBytes(), channels.iterator().next());
|
||||
Collection<byte[]> patterns = subscription.getPatterns();
|
||||
assertEquals(1, patterns.size());
|
||||
assertArrayEquals("s*".getBytes(), patterns.iterator().next());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUnsubscribeAllNoChannels() {
|
||||
subscription.pSubscribe(new byte[][] { "s*".getBytes() });
|
||||
subscription.unsubscribe();
|
||||
verify(subscriber, never()).close();
|
||||
assertTrue(subscription.isAlive());
|
||||
assertTrue(subscription.getChannels().isEmpty());
|
||||
Collection<byte[]> patterns = subscription.getPatterns();
|
||||
assertEquals(1, patterns.size());
|
||||
assertArrayEquals("s*".getBytes(), patterns.iterator().next());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUnsubscribeNotAlive() {
|
||||
byte[][] channel = new byte[][] { "a".getBytes() };
|
||||
subscription.subscribe(channel);
|
||||
subscription.unsubscribe();
|
||||
assertFalse(subscription.isAlive());
|
||||
subscription.unsubscribe();
|
||||
verify(subscriber, times(1)).unsubscribe(RjcUtils.decodeMultiple(channel));
|
||||
verify(subscriber, never()).close();
|
||||
}
|
||||
|
||||
@Test(expected = RedisInvalidSubscriptionException.class)
|
||||
public void testSubscribeNotAlive() {
|
||||
subscription.subscribe(new byte[][] { "a".getBytes() });
|
||||
subscription.unsubscribe();
|
||||
assertFalse(subscription.isAlive());
|
||||
subscription.subscribe(new byte[][] { "s".getBytes() });
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPUnsubscribeAllAndClose() {
|
||||
byte[][] pattern = new byte[][] { "a*".getBytes() };
|
||||
subscription.pSubscribe(pattern);
|
||||
subscription.pUnsubscribe();
|
||||
verify(subscriber, never()).close();
|
||||
verify(subscriber, times(1)).punsubscribe(RjcUtils.decodeMultiple(pattern));
|
||||
assertFalse(subscription.isAlive());
|
||||
assertTrue(subscription.getChannels().isEmpty());
|
||||
assertTrue(subscription.getPatterns().isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPUnsubscribeAllPatternsWithChannels() {
|
||||
subscription.subscribe(new byte[][] { "a".getBytes() });
|
||||
byte[][] patterns = new byte[][] { "s*".getBytes() };
|
||||
subscription.pSubscribe(patterns);
|
||||
subscription.pUnsubscribe();
|
||||
verify(subscriber, never()).close();
|
||||
verify(subscriber, times(1)).punsubscribe(RjcUtils.decodeMultiple(patterns));
|
||||
assertTrue(subscription.isAlive());
|
||||
assertTrue(subscription.getPatterns().isEmpty());
|
||||
Collection<byte[]> channels = subscription.getChannels();
|
||||
assertEquals(1, channels.size());
|
||||
assertArrayEquals("a".getBytes(), channels.iterator().next());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPUnsubscribeAndClose() {
|
||||
byte[][] pattern = new byte[][] { "a*".getBytes() };
|
||||
subscription.pSubscribe(pattern);
|
||||
subscription.pUnsubscribe(pattern);
|
||||
verify(subscriber, never()).close();
|
||||
verify(subscriber, times(1)).punsubscribe(RjcUtils.decodeMultiple(pattern));
|
||||
assertFalse(subscription.isAlive());
|
||||
assertTrue(subscription.getChannels().isEmpty());
|
||||
assertTrue(subscription.getPatterns().isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPUnsubscribePatternSomeLeft() {
|
||||
byte[][] patterns = new byte[][] { "a*".getBytes(), "b*".getBytes() };
|
||||
subscription.pSubscribe(patterns);
|
||||
byte[][] pattern = new byte[][] { "a*".getBytes() };
|
||||
subscription.pUnsubscribe(pattern);
|
||||
verify(subscriber, times(1)).punsubscribe(RjcUtils.decodeMultiple(pattern));
|
||||
verify(subscriber, never()).close();
|
||||
assertTrue(subscription.isAlive());
|
||||
Collection<byte[]> subPatterns = subscription.getPatterns();
|
||||
assertEquals(1, subPatterns.size());
|
||||
assertArrayEquals("b*".getBytes(), subPatterns.iterator().next());
|
||||
assertTrue(subscription.getChannels().isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPUnsubscribePatternWithChannels() {
|
||||
byte[][] pattern = new byte[][] { "s*".getBytes() };
|
||||
subscription.subscribe(new byte[][] { "a".getBytes() });
|
||||
subscription.pSubscribe(pattern);
|
||||
subscription.pUnsubscribe(pattern);
|
||||
verify(subscriber, times(1)).punsubscribe(RjcUtils.decodeMultiple(pattern));
|
||||
verify(subscriber, never()).close();
|
||||
assertTrue(subscription.isAlive());
|
||||
assertTrue(subscription.getPatterns().isEmpty());
|
||||
Collection<byte[]> channels = subscription.getChannels();
|
||||
assertEquals(1, channels.size());
|
||||
assertArrayEquals("a".getBytes(), channels.iterator().next());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUnsubscribePatternWithChannelsSomeLeft() {
|
||||
byte[][] pattern = new byte[][] { "a*".getBytes() };
|
||||
subscription.pSubscribe(new byte[][] { "a*".getBytes(), "b*".getBytes() });
|
||||
subscription.subscribe(new byte[][] { "a".getBytes() });
|
||||
subscription.pUnsubscribe(pattern);
|
||||
verify(subscriber, never()).close();
|
||||
verify(subscriber, times(1)).punsubscribe(RjcUtils.decodeMultiple(pattern));
|
||||
assertTrue(subscription.isAlive());
|
||||
Collection<byte[]> channels = subscription.getChannels();
|
||||
assertEquals(1, channels.size());
|
||||
assertArrayEquals("a".getBytes(), channels.iterator().next());
|
||||
Collection<byte[]> patterns = subscription.getPatterns();
|
||||
assertEquals(1, patterns.size());
|
||||
assertArrayEquals("b*".getBytes(), patterns.iterator().next());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPUnsubscribeAllNoPatterns() {
|
||||
subscription.subscribe(new byte[][] { "s".getBytes() });
|
||||
subscription.pUnsubscribe();
|
||||
verify(subscriber, never()).close();
|
||||
assertTrue(subscription.isAlive());
|
||||
assertTrue(subscription.getPatterns().isEmpty());
|
||||
Collection<byte[]> channels = subscription.getChannels();
|
||||
assertEquals(1, channels.size());
|
||||
assertArrayEquals("s".getBytes(), channels.iterator().next());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPUnsubscribeNotAlive() {
|
||||
byte[][] channels = new byte[][] { "a".getBytes() };
|
||||
subscription.subscribe(channels);
|
||||
subscription.unsubscribe();
|
||||
assertFalse(subscription.isAlive());
|
||||
subscription.pUnsubscribe();
|
||||
verify(subscriber, times(1)).unsubscribe(RjcUtils.decodeMultiple(channels));
|
||||
verify(subscriber, never()).close();
|
||||
}
|
||||
|
||||
@Test(expected = RedisInvalidSubscriptionException.class)
|
||||
public void testPSubscribeNotAlive() {
|
||||
subscription.subscribe(new byte[][] { "a".getBytes() });
|
||||
subscription.unsubscribe();
|
||||
assertFalse(subscription.isAlive());
|
||||
subscription.pSubscribe(new byte[][] { "s*".getBytes() });
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDoCloseNotSubscribed() {
|
||||
subscription.doClose();
|
||||
verify(subscriber, never()).close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDoCloseSubscribedChannels() {
|
||||
subscription.subscribe(new byte[][] { "a".getBytes() });
|
||||
subscription.doClose();
|
||||
verify(subscriber, times(1)).close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDoCloseSubscribedPatterns() {
|
||||
subscription.pSubscribe(new byte[][] { "a*".getBytes() });
|
||||
subscription.doClose();
|
||||
verify(subscriber, times(1)).close();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -71,11 +71,6 @@ public class TemplateTest {
|
||||
|
||||
@Test
|
||||
public void testIncrement() throws Exception {
|
||||
// disable in case of Rjc
|
||||
if (ConnectionUtils.isRjc(template.getConnectionFactory())) {
|
||||
return;
|
||||
}
|
||||
|
||||
StringRedisTemplate sr = new StringRedisTemplate(template.getConnectionFactory());
|
||||
String key = "test.template.inc";
|
||||
ValueOperations<String, String> valueOps = sr.opsForValue();
|
||||
|
||||
@@ -22,7 +22,6 @@ import org.springframework.data.redis.Person;
|
||||
import org.springframework.data.redis.SettingsUtils;
|
||||
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
|
||||
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
|
||||
import org.springframework.data.redis.connection.rjc.RjcConnectionFactory;
|
||||
import org.springframework.data.redis.connection.srp.SrpConnectionFactory;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
@@ -54,18 +53,6 @@ public class PubSubTestParams {
|
||||
personTemplate.setConnectionFactory(jedisConnFactory);
|
||||
personTemplate.afterPropertiesSet();
|
||||
|
||||
// create RJC
|
||||
RjcConnectionFactory rjcConnFactory = new RjcConnectionFactory();
|
||||
rjcConnFactory.setUsePool(true);
|
||||
rjcConnFactory.setPort(SettingsUtils.getPort());
|
||||
rjcConnFactory.setHostName(SettingsUtils.getHost());
|
||||
rjcConnFactory.afterPropertiesSet();
|
||||
|
||||
RedisTemplate<String, String> stringTemplateRJC = new StringRedisTemplate(rjcConnFactory);
|
||||
RedisTemplate<String, Person> personTemplateRJC = new RedisTemplate<String, Person>();
|
||||
personTemplateRJC.setConnectionFactory(rjcConnFactory);
|
||||
personTemplateRJC.afterPropertiesSet();
|
||||
|
||||
// add Lettuce
|
||||
LettuceConnectionFactory lettuceConnFactory = new LettuceConnectionFactory();
|
||||
lettuceConnFactory.setPort(SettingsUtils.getPort());
|
||||
@@ -91,7 +78,6 @@ public class PubSubTestParams {
|
||||
// JRedis does not support pub/sub
|
||||
|
||||
return Arrays.asList(new Object[][] { { stringFactory, stringTemplate }, { personFactory, personTemplate },
|
||||
{ stringFactory, stringTemplateRJC }, { personFactory, personTemplateRJC },
|
||||
{ stringFactory, stringTemplateLtc }, { personFactory, personTemplateLtc },
|
||||
{ stringFactory, stringTemplateSrp }, { personFactory, personTemplateSrp }
|
||||
});
|
||||
|
||||
@@ -35,7 +35,6 @@ import org.springframework.data.redis.connection.RedisConnection;
|
||||
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
|
||||
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
|
||||
import org.springframework.data.redis.connection.rjc.RjcConnectionFactory;
|
||||
import org.springframework.data.redis.connection.srp.SrpConnectionFactory;
|
||||
import org.springframework.data.redis.listener.adapter.MessageListenerAdapter;
|
||||
|
||||
@@ -104,15 +103,8 @@ public class SubscriptionConnectionTests {
|
||||
srpConnFactory.setHostName(SettingsUtils.getHost());
|
||||
srpConnFactory.afterPropertiesSet();
|
||||
|
||||
// RJC
|
||||
RjcConnectionFactory rjcConnFactory = new RjcConnectionFactory();
|
||||
rjcConnFactory.setPort(SettingsUtils.getPort());
|
||||
rjcConnFactory.setHostName(SettingsUtils.getHost());
|
||||
rjcConnFactory.setDatabase(2);
|
||||
rjcConnFactory.afterPropertiesSet();
|
||||
|
||||
return Arrays.asList(new Object[][] { { jedisConnFactory }, { lettuceConnFactory },
|
||||
{ srpConnFactory }, { rjcConnFactory } });
|
||||
{ srpConnFactory } });
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -22,7 +22,6 @@ import org.springframework.data.redis.SettingsUtils;
|
||||
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
|
||||
import org.springframework.data.redis.connection.jredis.JredisConnectionFactory;
|
||||
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
|
||||
import org.springframework.data.redis.connection.rjc.RjcConnectionFactory;
|
||||
import org.springframework.data.redis.connection.srp.SrpConnectionFactory;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.data.redis.support.atomic.RedisAtomicInteger;
|
||||
@@ -84,17 +83,6 @@ public class BoundKeyParams {
|
||||
RedisList listSRP = new DefaultRedisList("bound:key:listSRP", templateSRP);
|
||||
|
||||
|
||||
// RJC
|
||||
RjcConnectionFactory rjcConnFactory = new RjcConnectionFactory();
|
||||
rjcConnFactory.setPort(SettingsUtils.getPort());
|
||||
rjcConnFactory.setHostName(SettingsUtils.getHost());
|
||||
rjcConnFactory.afterPropertiesSet();
|
||||
|
||||
StringRedisTemplate templateRJC = new StringRedisTemplate(rjcConnFactory);
|
||||
DefaultRedisMap mapRJC = new DefaultRedisMap("bound:key:mapRJC", templateRJC);
|
||||
DefaultRedisSet setRJC = new DefaultRedisSet("bound:key:setRJC", templateRJC);
|
||||
RedisList listRJC = new DefaultRedisList("bound:key:listRJC", templateRJC);
|
||||
|
||||
StringObjectFactory sof = new StringObjectFactory();
|
||||
|
||||
return Arrays.asList(new Object[][] {
|
||||
@@ -109,9 +97,6 @@ public class BoundKeyParams {
|
||||
{ listLT, sof, templateLT }, { setLT, sof, templateLT }, { mapLT, sof, templateLT },
|
||||
{ new RedisAtomicInteger("bound:key:intSrp", srpConnFactory), sof, templateSRP },
|
||||
{ new RedisAtomicLong("bound:key:longSrp", srpConnFactory), sof, templateSRP },
|
||||
{ listSRP, sof, templateSRP }, { setSRP, sof, templateSRP }, { mapSRP, sof, templateSRP },
|
||||
{ new RedisAtomicInteger("bound:key:intRjc", rjcConnFactory), sof, templateRJC },
|
||||
{ new RedisAtomicLong("bound:key:longRjc", rjcConnFactory), sof, templateRJC },
|
||||
{ listRJC, sof, templateRJC }, { setRJC, sof, templateRJC }, { mapRJC, sof, templateRJC }});
|
||||
{ listSRP, sof, templateSRP }, { setSRP, sof, templateSRP }, { mapSRP, sof, templateSRP }});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,6 @@ import org.springframework.data.redis.SettingsUtils;
|
||||
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
|
||||
import org.springframework.data.redis.connection.jredis.JredisConnectionFactory;
|
||||
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
|
||||
import org.springframework.data.redis.connection.rjc.RjcConnectionFactory;
|
||||
import org.springframework.data.redis.connection.srp.SrpConnectionFactory;
|
||||
|
||||
/**
|
||||
@@ -58,14 +57,8 @@ public abstract class AtomicCountersParam {
|
||||
srpConnFactory.setHostName(SettingsUtils.getHost());
|
||||
srpConnFactory.afterPropertiesSet();
|
||||
|
||||
// RJC
|
||||
RjcConnectionFactory rjcConnFactory = new RjcConnectionFactory();
|
||||
rjcConnFactory.setPort(SettingsUtils.getPort());
|
||||
rjcConnFactory.setHostName(SettingsUtils.getHost());
|
||||
rjcConnFactory.afterPropertiesSet();
|
||||
|
||||
return Arrays.asList(new Object[][] { { jedisConnFactory },
|
||||
{ jredisConnFactory}, { lettuceConnFactory },
|
||||
{ srpConnFactory}, { rjcConnFactory } });
|
||||
{ srpConnFactory} });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,24 +93,18 @@ public class RedisAtomicTests {
|
||||
|
||||
@Test
|
||||
public void testLongIncrement() throws Exception {
|
||||
// DATAREDIS-121 incr/decr broken in RJC
|
||||
assumeTrue(!ConnectionUtils.isRjc(factory));
|
||||
longCounter.set(0);
|
||||
assertEquals(1, longCounter.incrementAndGet());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIntIncrement() throws Exception {
|
||||
// DATAREDIS-121 incr/decr broken in RJC
|
||||
assumeTrue(!ConnectionUtils.isRjc(factory));
|
||||
intCounter.set(0);
|
||||
assertEquals(1, intCounter.incrementAndGet());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLongCustomIncrement() throws Exception {
|
||||
// DATAREDIS-121 incr/decr broken in RJC
|
||||
assumeTrue(!ConnectionUtils.isRjc(factory));
|
||||
longCounter.set(0);
|
||||
long delta = 5;
|
||||
assertEquals(delta, longCounter.addAndGet(delta));
|
||||
@@ -118,8 +112,6 @@ public class RedisAtomicTests {
|
||||
|
||||
@Test
|
||||
public void testIntCustomIncrement() throws Exception {
|
||||
// DATAREDIS-121 incr/decr broken in RJC
|
||||
assumeTrue(!ConnectionUtils.isRjc(factory));
|
||||
intCounter.set(0);
|
||||
int delta = 5;
|
||||
assertEquals(delta, intCounter.addAndGet(delta));
|
||||
@@ -127,16 +119,12 @@ public class RedisAtomicTests {
|
||||
|
||||
@Test
|
||||
public void testLongDecrement() throws Exception {
|
||||
// DATAREDIS-121 incr/decr broken in RJC
|
||||
assumeTrue(!ConnectionUtils.isRjc(factory));
|
||||
longCounter.set(1);
|
||||
assertEquals(0, longCounter.decrementAndGet());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIntDecrement() throws Exception {
|
||||
// DATAREDIS-121 incr/decr broken in RJC
|
||||
assumeTrue(!ConnectionUtils.isRjc(factory));
|
||||
intCounter.set(1);
|
||||
assertEquals(0, intCounter.decrementAndGet());
|
||||
}
|
||||
|
||||
@@ -23,7 +23,6 @@ import org.springframework.data.redis.SettingsUtils;
|
||||
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
|
||||
import org.springframework.data.redis.connection.jredis.JredisConnectionFactory;
|
||||
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
|
||||
import org.springframework.data.redis.connection.rjc.RjcConnectionFactory;
|
||||
import org.springframework.data.redis.connection.srp.SrpConnectionFactory;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
@@ -109,34 +108,6 @@ public abstract class CollectionTestParams {
|
||||
jsonPersonTemplateJR.setConnectionFactory(jredisConnFactory);
|
||||
jsonPersonTemplateJR.afterPropertiesSet();
|
||||
|
||||
|
||||
// rjc
|
||||
RjcConnectionFactory rjcConnFactory = new RjcConnectionFactory();
|
||||
rjcConnFactory.setUsePool(true);
|
||||
rjcConnFactory.setPort(SettingsUtils.getPort());
|
||||
rjcConnFactory.setHostName(SettingsUtils.getHost());
|
||||
rjcConnFactory.afterPropertiesSet();
|
||||
|
||||
RedisTemplate<String, String> stringTemplateRJC = new StringRedisTemplate(rjcConnFactory);
|
||||
RedisTemplate<String, Person> personTemplateRJC = new RedisTemplate<String, Person>();
|
||||
personTemplateRJC.setConnectionFactory(rjcConnFactory);
|
||||
personTemplateRJC.afterPropertiesSet();
|
||||
|
||||
RedisTemplate<String, Person> xstreamStringTemplateRJC = new RedisTemplate<String, Person>();
|
||||
xstreamStringTemplateRJC.setConnectionFactory(rjcConnFactory);
|
||||
xstreamStringTemplateRJC.setDefaultSerializer(serializer);
|
||||
xstreamStringTemplateRJC.afterPropertiesSet();
|
||||
|
||||
RedisTemplate<String, Person> xstreamPersonTemplateRJC = new RedisTemplate<String, Person>();
|
||||
xstreamPersonTemplateRJC.setValueSerializer(serializer);
|
||||
xstreamPersonTemplateRJC.setConnectionFactory(rjcConnFactory);
|
||||
xstreamPersonTemplateRJC.afterPropertiesSet();
|
||||
|
||||
RedisTemplate<String, Person> jsonPersonTemplateRJC = new RedisTemplate<String, Person>();
|
||||
jsonPersonTemplateRJC.setValueSerializer(jsonSerializer);
|
||||
jsonPersonTemplateRJC.setConnectionFactory(rjcConnFactory);
|
||||
jsonPersonTemplateRJC.afterPropertiesSet();
|
||||
|
||||
// SRP
|
||||
SrpConnectionFactory srConnFactory = new SrpConnectionFactory();
|
||||
srConnFactory.setPort(SettingsUtils.getPort());
|
||||
@@ -189,8 +160,7 @@ public abstract class CollectionTestParams {
|
||||
jsonPersonTemplateLtc.setConnectionFactory(lettuceConnFactory);
|
||||
jsonPersonTemplateLtc.afterPropertiesSet();
|
||||
|
||||
return Arrays.asList(new Object[][] { { stringFactory, stringTemplate }, { stringFactory, stringTemplateRJC },
|
||||
{ personFactory, personTemplateRJC },
|
||||
return Arrays.asList(new Object[][] { { stringFactory, stringTemplate },
|
||||
//{ stringFactory, stringTemplateJR },
|
||||
//{ personFactory, personTemplateJR },
|
||||
{ personFactory, personTemplate },
|
||||
@@ -199,9 +169,6 @@ public abstract class CollectionTestParams {
|
||||
//{ personFactory, xstreamPersonTemplateJR },
|
||||
{ personFactory, jsonPersonTemplate },
|
||||
//{ personFactory, jsonPersonTemplateJR },
|
||||
// rjc
|
||||
{ stringFactory, xstreamStringTemplateRJC }, { personFactory, xstreamPersonTemplateRJC },
|
||||
{ personFactory, jsonPersonTemplateRJC },
|
||||
// srp
|
||||
{ stringFactory, stringTemplateSRP },{ personFactory, personTemplateSRP },
|
||||
{ stringFactory, xstreamStringTemplateSRP }, { personFactory, xstreamPersonTemplateSRP },
|
||||
|
||||
@@ -24,13 +24,10 @@ import org.springframework.data.redis.SettingsUtils;
|
||||
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
|
||||
import org.springframework.data.redis.connection.jredis.JredisConnectionFactory;
|
||||
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
|
||||
import org.springframework.data.redis.connection.rjc.RjcConnectionFactory;
|
||||
import org.springframework.data.redis.connection.srp.SrpConnectionFactory;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.data.redis.serializer.JacksonJsonRedisSerializer;
|
||||
import org.springframework.data.redis.serializer.OxmSerializer;
|
||||
import org.springframework.data.redis.support.collections.DefaultRedisMap;
|
||||
import org.springframework.data.redis.support.collections.RedisMap;
|
||||
import org.springframework.oxm.xstream.XStreamMarshaller;
|
||||
|
||||
/**
|
||||
@@ -113,29 +110,6 @@ public class RedisMapTests extends AbstractRedisMapTests<Object, Object> {
|
||||
jsonPersonTemplateJR.setHashValueSerializer(jsonStringSerializer);
|
||||
jsonPersonTemplateJR.afterPropertiesSet();
|
||||
|
||||
// RJC
|
||||
RjcConnectionFactory rjcConnFactory = new RjcConnectionFactory();
|
||||
rjcConnFactory.setUsePool(true);
|
||||
rjcConnFactory.setPort(SettingsUtils.getPort());
|
||||
rjcConnFactory.setHostName(SettingsUtils.getHost());
|
||||
rjcConnFactory.afterPropertiesSet();
|
||||
|
||||
RedisTemplate genericTemplateRJC = new RedisTemplate();
|
||||
genericTemplateRJC.setConnectionFactory(rjcConnFactory);
|
||||
genericTemplateRJC.afterPropertiesSet();
|
||||
|
||||
RedisTemplate<String, Person> xGenericTemplateRJC = new RedisTemplate<String, Person>();
|
||||
xGenericTemplateRJC.setConnectionFactory(rjcConnFactory);
|
||||
xGenericTemplateRJC.setDefaultSerializer(serializer);
|
||||
xGenericTemplateRJC.afterPropertiesSet();
|
||||
|
||||
RedisTemplate<String, Person> jsonPersonTemplateRJC = new RedisTemplate<String, Person>();
|
||||
jsonPersonTemplateRJC.setConnectionFactory(rjcConnFactory);
|
||||
jsonPersonTemplateRJC.setDefaultSerializer(jsonSerializer);
|
||||
jsonPersonTemplateRJC.setHashKeySerializer(jsonSerializer);
|
||||
jsonPersonTemplateRJC.setHashValueSerializer(jsonStringSerializer);
|
||||
jsonPersonTemplateRJC.afterPropertiesSet();
|
||||
|
||||
// Lettuce
|
||||
LettuceConnectionFactory lettuceConnFactory = new LettuceConnectionFactory();
|
||||
lettuceConnFactory.setPort(SettingsUtils.getPort());
|
||||
@@ -194,12 +168,6 @@ public class RedisMapTests extends AbstractRedisMapTests<Object, Object> {
|
||||
{ personFactory, stringFactory, genericTemplateJR },
|
||||
{ personFactory, stringFactory, xGenericTemplateJR },
|
||||
{ personFactory, stringFactory, jsonPersonTemplateJR },
|
||||
{ stringFactory, stringFactory, genericTemplateRJC },
|
||||
{ personFactory, personFactory, genericTemplateRJC },
|
||||
{ stringFactory, personFactory, genericTemplateRJC },
|
||||
{ personFactory, stringFactory, genericTemplateRJC },
|
||||
{ personFactory, stringFactory, xGenericTemplateRJC },
|
||||
{ personFactory, stringFactory, jsonPersonTemplateRJC },
|
||||
{ stringFactory, stringFactory, genericTemplateLettuce },
|
||||
{ personFactory, personFactory, genericTemplateLettuce },
|
||||
{ stringFactory, personFactory, genericTemplateLettuce },
|
||||
|
||||
@@ -40,7 +40,6 @@ import org.springframework.data.redis.SettingsUtils;
|
||||
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
|
||||
import org.springframework.data.redis.connection.jredis.JredisConnectionFactory;
|
||||
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
|
||||
import org.springframework.data.redis.connection.rjc.RjcConnectionFactory;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.data.redis.serializer.JacksonJsonRedisSerializer;
|
||||
@@ -278,27 +277,6 @@ public class RedisPropertiesTests extends RedisMapTests {
|
||||
jsonPersonTemplateJR.setHashValueSerializer(jsonStringSerializer);
|
||||
jsonPersonTemplateJR.afterPropertiesSet();
|
||||
|
||||
// RJC
|
||||
|
||||
// rjc
|
||||
RjcConnectionFactory rjcConnFactory = new RjcConnectionFactory();
|
||||
rjcConnFactory.setUsePool(true);
|
||||
rjcConnFactory.setPort(SettingsUtils.getPort());
|
||||
rjcConnFactory.setHostName(SettingsUtils.getHost());
|
||||
rjcConnFactory.afterPropertiesSet();
|
||||
|
||||
RedisTemplate<String, String> genericTemplateRJC = new StringRedisTemplate(jredisConnFactory);
|
||||
RedisTemplate<String, Person> xGenericTemplateRJC = new RedisTemplate<String, Person>();
|
||||
xGenericTemplateRJC.setConnectionFactory(rjcConnFactory);
|
||||
xGenericTemplateRJC.setDefaultSerializer(serializer);
|
||||
xGenericTemplateRJC.afterPropertiesSet();
|
||||
|
||||
RedisTemplate<String, Person> jsonPersonTemplateRJC = new RedisTemplate<String, Person>();
|
||||
jsonPersonTemplateRJC.setConnectionFactory(rjcConnFactory);
|
||||
jsonPersonTemplateRJC.setDefaultSerializer(jsonSerializer);
|
||||
jsonPersonTemplateRJC.setHashKeySerializer(jsonSerializer);
|
||||
jsonPersonTemplateRJC.setHashValueSerializer(jsonStringSerializer);
|
||||
jsonPersonTemplateRJC.afterPropertiesSet();
|
||||
|
||||
// Lettuce
|
||||
LettuceConnectionFactory lettuceConnFactory = new LettuceConnectionFactory();
|
||||
@@ -331,12 +309,6 @@ public class RedisPropertiesTests extends RedisMapTests {
|
||||
{ stringFactory, stringFactory, xGenericTemplateJR },
|
||||
{ stringFactory, stringFactory, jsonPersonTemplate },
|
||||
{ stringFactory, stringFactory, jsonPersonTemplateJR },
|
||||
{ stringFactory, stringFactory, genericTemplateRJC },
|
||||
{ stringFactory, stringFactory, genericTemplateRJC },
|
||||
{ stringFactory, stringFactory, genericTemplateRJC },
|
||||
{ stringFactory, stringFactory, genericTemplateRJC },
|
||||
{ stringFactory, stringFactory, xGenericTemplateRJC },
|
||||
{ stringFactory, stringFactory, jsonPersonTemplateRJC },
|
||||
{ stringFactory, stringFactory, genericTemplateLtc },
|
||||
{ stringFactory, stringFactory, genericTemplateLtc },
|
||||
{ stringFactory, stringFactory, genericTemplateLtc },
|
||||
|
||||
Reference in New Issue
Block a user