Permalink
Browse files

Fairly substantial update. Current with latest Redis server commands …

…(SUNION, SUNIONSTORE, etc.)

and a completely re-written and comprehensive tests using TestNG.
  • Loading branch information...
1 parent 2c08577 commit f094c0302f79745669ecc09ecfdad689f1315d6d @alphazero committed Apr 21, 2009
Showing with 3,815 additions and 1,137 deletions.
  1. +5 −25 README
  2. +9 −6 RELEASE-NOTES.txt
  3. +6 −0 core/api/pom.xml
  4. +1 −1 core/api/src/main/java/org/jredis/Command.java
  5. +12 −8 core/api/src/main/java/org/jredis/JRedis.java
  6. +1 −1 core/api/src/main/java/org/jredis/ProviderException.java
  7. +28 −27 core/api/src/main/java/org/jredis/connector/ConnectionSpec.java
  8. +0 −1 core/api/src/main/java/org/jredis/connector/FaultedConnection.java
  9. +24 −0 core/api/src/main/java/org/jredis/resource/Context.java
  10. +54 −0 core/api/src/main/java/org/jredis/resource/Resource.java
  11. +41 −0 core/api/src/main/java/org/jredis/resource/ResourceException.java
  12. +37 −0 core/api/src/main/java/org/jredis/resource/_specification.java
  13. +23 −0 core/api/src/main/java/org/jredis/resource/package-info.java
  14. +40 −6 core/pom.xml
  15. +7 −0 core/ri/pom.xml
  16. +464 −0 core/ri/src/main/java/org/jredis/ri/alphazero/ConnectionBase.java
  17. +22 −18 ...rg/jredis/JavaSemantics.java → ri/src/main/java/org/jredis/ri/alphazero/ConnectionException.java}
  18. +43 −0 core/ri/src/main/java/org/jredis/ri/alphazero/ConnectionResetException.java
  19. +45 −37 core/ri/src/main/java/org/jredis/ri/alphazero/JRedisClient.java
  20. +175 −90 core/ri/src/main/java/org/jredis/ri/alphazero/JRedisSupport.java
  21. +15 −3 core/ri/src/main/java/org/jredis/ri/alphazero/ProtocolBase.java
  22. +4 −21 core/ri/src/main/java/org/jredis/ri/alphazero/SocketConnection.java
  23. +154 −62 core/ri/src/main/java/org/jredis/ri/alphazero/SynchConnection.java
  24. +134 −0 core/ri/src/main/java/org/jredis/ri/alphazero/SynchJRedisBase.java
  25. +24 −4 core/ri/src/main/java/org/jredis/ri/alphazero/SynchProtocol.java
  26. +41 −0 core/ri/src/main/java/org/jredis/ri/alphazero/UnexpectedEOFException.java
  27. +36 −0 core/ri/src/main/java/org/jredis/ri/alphazero/_specification.java
  28. +16 −13 core/ri/src/main/java/org/jredis/ri/alphazero/support/Convert.java
  29. +23 −3 core/ri/src/main/java/org/jredis/ri/alphazero/support/DefaultCodec.java
  30. +85 −0 core/ri/src/test/java/org/jredis/ri/JRedisTestSuiteNGBase.java
  31. +80 −0 core/ri/src/test/java/org/jredis/ri/alphazero/JRedisClientNGTest.java
  32. +0 −806 core/ri/src/test/java/org/jredis/ri/alphazero/JRedisClientTest.java
  33. +2,134 −0 core/ri/src/test/java/org/jredis/ri/alphazero/JRedisProviderTestNGBase.java
  34. BIN documentation/design/diagrams/connector-design/connector-design-a0.1.png
  35. BIN documentation/design/diagrams/{ → connector-design}/connector-design-a0.png
  36. +2 −2 examples/src/main/java/org/jredis/examples/HelloAgain.java
  37. +30 −3 pom.xml
View
30 README
@@ -101,39 +101,19 @@ worries.
If you do, the build will fail, unless you do one
of the following:
-1) If you are a maven guru (i am not) then simply
-make the appropriate configuration settings and pass
-your password to the unit tests in Core-RI test classes
-that use the password.
+1) Change the password in core/pom.xml to match your
+password in redis.conf
-(this will also require changes necessary to the unit
-test to obtain the config info from the test harness during
-test phase of build.)
+2) Alternatively tell maven to skip tests:
-2) Alternatively (still being a maven guru) change the
-surefire settings to allow build on test fail.
+ mvn -Dmaven.test.skip=true install
-[1 or 2 gurus: I'd appreciate your sending me the how to
-for the same.]
-
-3) Hack the unit test case code for Core-RI and BENCH.
-Change the default password setting to reflect your own.
-
-4) If you trust that the code is good (<G>), or, you
-don't care, AND, it is simply not possible for you to
-change/disable password requirement on your localhost Redis
-server, you can always simply delete the test source folders
-for each of the modules.
-
-5) you'll change your redis.conf for the build phase or
-even better, create a redis.conf called redis-testing.conf
-and use 'jredis' as password.
**** REMEMBER: TESTS WILL FLUSH DBS 13 AND 10 *****
-
-
+04-21-09
View
@@ -8,6 +8,7 @@
JREDIS SPECIFICATION AND REFERENCE IMPLEMENTATION
+[updated on 04-21-09]
* About
@@ -20,7 +21,7 @@ else.
* Redis compliance
The specification and the implementation in this release comply with the
-the latest redis development release specification as of 04-12-09 and
+the latest redis development release specification as of 04-21-09 and
tested against the build of the REDIS server from the github repository.
@@ -56,6 +57,10 @@ on the drawing board. (If you can not wait for this, you may hack your
own by placing a JRedis facade in front of a combination of classes from
java.util.concurrent and using a pool of JRedisClients behind the scenes.)
+If you elect to do this, do note that connections to Redis are effectively
+stateful and you can not trivially use a connection to serve the requests
+of multiple requesters (threads) IFF you use commands such as SELECT.
+
Beyond that, JREDIS as of now supports basic Java serialization and you
can use your Java objects as 'values' for String, Set, and List keys in
REDIS. And of course, the JRedis interface has been designed to provide
@@ -88,18 +93,16 @@ earlier version of Java, as that would adversely constrain the options
in both the expression of JRedis semantics and an effective implementation.
TESTS:
-Test source files and classes clearly require the JUnit 3 library files,
+Test source files and classes clearly require TestNG library ,
but these test artifacts are not included in the drop-in jar so JUnit is
not a requirement for using JRedis.
BUILD:
JREDIS was built on Eclipse 3.4, on Apple's Mac OS X 10.5 running JVM1.6.
The JREDIS core software itself can be built simply using jacav and jar
-and this initial distribution does not include either ant or maven build
-files. Once the decision between one of these two build systems has been
-reached, and that becomes a requirement, it will be included in an update
-release.
+That said, the current release uses structured Maven 2 poms to build
+the project and execute the tests.
* Status
View
@@ -16,10 +16,16 @@
<version>a.0-SNAPSHOT</version>
<packaging>jar</packaging>
+ <!--
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.testng</groupId>
+ <artifactId>testng</artifactId>
+ </dependency>
</dependencies>
+ -->
</project>
@@ -47,7 +47,7 @@
RPUSH, LPUSH, LLEN, LRANGE, LTRIM, LINDEX, LSET, LREM, LPOP, RPOP,
// keys operating on sets
- SADD, SREM, SCARD, SISMEMBER, SINTER, SINTERSTORE, SMEMBERS,
+ SADD, SREM, SCARD, SISMEMBER, SINTER, SINTERSTORE, SUNION, SUNIONSTORE, SMEMBERS,
// "Multiple databases handling commands"
SELECT, FLUSHDB, FLUSHALL, MOVE,
@@ -131,7 +131,7 @@
public String randomkey() throws RedisException;
- public String rename (String oldkey, String newkey) throws RedisException;
+ public void rename (String oldkey, String newkey) throws RedisException;
public boolean renamenx (String oldkey, String brandnewkey) throws RedisException;
@@ -155,11 +155,11 @@
public <T extends Serializable>
void lpush (String listkey, T object) throws RedisException;
- public void lset (String key, int index, byte[] value) throws RedisException;
- public void lset (String key, int index, String stringValue) throws RedisException;
- public void lset (String key, int index, Number numberValue) throws RedisException;
+ public void lset (String key, long index, byte[] value) throws RedisException;
+ public void lset (String key, long index, String stringValue) throws RedisException;
+ public void lset (String key, long index, Number numberValue) throws RedisException;
public <T extends Serializable>
- void lset (String key, int index, T object) throws RedisException;
+ void lset (String key, long index, T object) throws RedisException;
public long lrem (String listKey, byte[] value, int count) throws RedisException;
@@ -170,11 +170,11 @@
public long llen (String listkey) throws RedisException;
- public List<byte[]> lrange (String listkey, int from, int to) throws RedisException;
+ public List<byte[]> lrange (String listkey, long from, long to) throws RedisException;
- public void ltrim (String listkey, int keepFrom, int keepTo) throws RedisException;
+ public void ltrim (String listkey, long keepFrom, long keepTo) throws RedisException;
- public byte[] lindex (String listkey, int index) throws RedisException;
+ public byte[] lindex (String listkey, long index) throws RedisException;
public byte[] lpop (String listKey) throws RedisException;
@@ -208,6 +208,10 @@
public void sinterstore (String destSetKey, String...sets) throws RedisException;
+ public List<byte[]> sunion (String set1, String...sets) throws RedisException;
+
+ public void sunionstore (String destSetKey, String...sets) throws RedisException;
+
public List<byte[]> smembers (String setkey) throws RedisException;
// ------------------------------------------------------------------------
@@ -21,7 +21,7 @@
/**
* Used by JRedis implementation providers to indicate an exception related to the
* implementation of the specification. Effectively, this exception and its extensions
- * should only be thrown when a fault has occured that is neither a {@link SystemException},
+ * should only be thrown when a fault has occurred that is neither a {@link SystemException},
* nor a Redis prompted server side error.
*
* @author Joubin Houshyar (alphazero@sensesay.net)
@@ -18,7 +18,6 @@
import java.net.InetAddress;
import java.net.Socket;
-import java.util.Map;
/**
@@ -31,6 +30,7 @@
*/
public interface ConnectionSpec {
+ public int getReconnectCnt ();
public InetAddress getAddress();
public int getPort ();
public boolean getSocketFlag (ConnectionSpec.SocketFlag flag);
@@ -43,6 +43,7 @@
*
*/
public enum SocketFlag {
+ /** Corresponds to SO_KEEP_ALIVE flag of {@link Socket}. @see {@link Socket#setSoTimeout(int)} */
SO_KEEP_ALIVE
}
@@ -57,17 +58,17 @@
* Corresponds to <code><b>SO_SNDBUF</b></code> flag. see {@link Socket#setSendBufferSize(int)}
* <p>expected value is an <b><code>int</code></b> or an {@link Integer}.
*/
- send_buffer_size,
+ SO_SNDBUF,
/**
* corresponds to SO_RCVBUF flag. see {@link Socket#setReceiveBufferSize(int)}
*/
- receive_buffer_size,
+ SO_RCVBUF,
/**
* corresponds to SO_TIMEOUT flag. see {@link Socket#setSoTimeout(int)}
*/
- timeout,
+ SO_TIMEOUT,
/**
* Socket performance preferences.
@@ -76,7 +77,7 @@
* @See {@link SocketProperty#bandwidth}
* @See {@link Socket#setPerformancePreferences(int, int, int)} for details.
*/
- connection_time,
+ SO_PREF_CONN_TIME,
/**
* Socket performance preferences.
@@ -85,7 +86,7 @@
* @See {@link SocketProperty#connection_time}
* @See {@link Socket#setPerformancePreferences(int, int, int)} for details.
*/
- latency,
+ SO_PREF_LATENCY,
/**
* Socket performance preferences.
@@ -94,27 +95,27 @@
* @See {@link SocketProperty#connection_time}
* @See {@link Socket#setPerformancePreferences(int, int, int)} for details.
*/
- bandwidth,
+ SO_PREF_BANDWIDTH,
}
-
- /**
- * @see SocketFlag
- * @see ConnectionSpec#getSocketFlag(SocketFlag)
- *
- * @return the socket flag map. Whether this is a copy or the reference to underlying references
- * is un-Specified. What is specified is that changes to this set after connection has been established are
- * of no effect.
- */
- public Map<SocketFlag, Boolean> getSocketFlags();
-
- /**
- * @see SocketProperty
- * @see ConnectionSpec#getSocketProperty(SocketProperty)
- *
- * @return the socket property map. Whether this is a copy or the reference to underlying references
- * is un-Specified. What is specified is that changes to this set after connection has been established are
- * of no effect.
- */
- public Map<SocketProperty, Integer> getSocketProperties();
+// 2much - keep it simple: the getters above are sufficient - this serves not additional purpose.
+// /**
+// * @see SocketFlag
+// * @see ConnectionSpec#getSocketFlag(SocketFlag)
+// *
+// * @return the socket flag map. Whether this is a copy or the reference to underlying references
+// * is un-Specified. What is specified is that changes to this set after connection has been established are
+// * of no effect.
+// */
+// public Map<SocketFlag, Boolean> getSocketFlags();
+//
+// /**
+// * @see SocketProperty
+// * @see ConnectionSpec#getSocketProperty(SocketProperty)
+// *
+// * @return the socket property map. Whether this is a copy or the reference to underlying references
+// * is un-Specified. What is specified is that changes to this set after connection has been established are
+// * of no effect.
+// */
+// public Map<SocketProperty, Integer> getSocketProperties();
}
@@ -55,5 +55,4 @@ public Response serviceRequest(RequestListener requestListener, Command cmd, byt
{
throw new ClientRuntimeException (errorMsg);
}
-
}
@@ -0,0 +1,24 @@
+package org.jredis.resource;
+
+import java.util.Set;
+
+/**
+ * {@link Context<T>} provides basic context support for {@link Resource}s,
+ * by providing methods for {@link String} parameter name/values and basic
+ * namespace operations for generic {@link Object} types.
+ *
+ * @author Joubin Houshyar (alphazero@sensesay.net)
+ * @version alpha.0, Apr 16, 2009
+ * @since alpha.0
+ *
+ */
+
+public interface Context {
+ public String getParam (String key);
+ public void setParam (String key, String value);
+ Set<String> getParamsKeys();
+
+ public Object get (String name);
+ public void bind (String name, Object value);
+ public void rebind (String name, Object value);
+}
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2009 Joubin Houshyar
+ *
+ * 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.jredis.resource;
+
+
+
+/**
+ *
+ * @author Joubin Houshyar (alphazero@sensesay.net)
+ * @version alpha.0, Apr 16, 2009
+ * @since alpha.0
+ *
+ */
+
+public interface Resource <T> {
+
+ /**
+ * @return the resource type specific interface.
+ */
+ public T getInterface();
+
+ /**
+ * Sets the resource context.
+ *
+ * @see Context<T>
+ * @param context the context for this resource.
+ * @throws ResourceException if the resource context provided is either insufficient, or,
+ * if the new context (regardless of its utility) can not be used. (For example, it already
+ * has a context and re-setting of contexts is not supported or permissible.)
+ */
+ public void setContext (Context context) throws ResourceException;
+
+ /**
+ * @see Context<T>
+ * @return the context for this resource.
+ * @throws ResourceException if the resource for whatever reason can not (or will not)
+ * return a reference to its context. (Security considerations, for example.)
+ */
+ public Context getContext () throws ResourceException;
+}
Oops, something went wrong.

0 comments on commit f094c03

Please sign in to comment.