Permalink
Browse files

Release 03-12-2010 - Redis 1.2.n compliance.

See Release/RELEASE-NOTES-Update-03122010.txt for details.
  • Loading branch information...
1 parent d7a775c commit a46ff1cae7a6000be297052a6fa1dc43ae3bab76 @alphazero committed Mar 12, 2010
@@ -0,0 +1,36 @@
+Final release for Redis 1.2.n compliant clients.
+
+REQUIREMENTS CHANGES:
+
+Requires Redis server 1.2.n. This release is NOT compatible with either Redis 1.000 or 2.n (development edge).
+
+See:
+http://code.google.com/p/redis/downloads/list
+
+NEW FEATURES:
+
+* Heartbeat
+
+Connectors will launch a heartbeat thread to maintain connections. Frequency can be set using ConnectionSpec, with default of 1/sec.
+
+* Synchronous semantics for Pipeline
+
+See JRedisPipeline.sync(). In a nutshell, allows for mixing in synchronous semantics when using the asynchronous pipelines. For example, you may issue a set of asynchronous commands (per JRedisFuture interface) and then use pipeline.sync() to obtain a JRedis (synchronous) interface to issue a blocking command. See UsingJredisPipeline.exampleUseofSyncInPipeline() (in /Examples)
+
+
+BUG FIX:
+
+A few bugs were reported and have been addressed. (Thanks to all who provided feedback.)
+
+See:
+http://github.com/alphazero/jredis/issues/closed
+
+ROAD MAP:
+
+Development focus will be on Redis 2.n compliance in tandem with Redis edge (http://github.com/antirez/redis), and maintenance for (this) 1.2.n compliant clients.
+
+/enjoy
+
+03-12-2010
+NoVA
+
@@ -1 +1 @@
-Sun Nov 8 16:53:59 EST 2009
+Fri Mar 12 11:19:49 EST 2010
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,357 @@
+/*
+ * 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.examples;
+
+import static org.jredis.ri.alphazero.support.DefaultCodec.toLong;
+import static org.jredis.ri.alphazero.support.DefaultCodec.toStr;
+import java.util.Random;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Future;
+import org.jredis.JRedisFuture;
+import org.jredis.ProviderException;
+import org.jredis.RedisException;
+import org.jredis.bench.Util;
+import org.jredis.bench.Util.Timer;
+import org.jredis.connector.ConnectionSpec;
+import org.jredis.connector.ConnectionSpec.SocketProperty;
+import org.jredis.protocol.ResponseStatus;
+import org.jredis.ri.alphazero.JRedisPipeline;
+import org.jredis.ri.alphazero.connection.DefaultConnectionSpec;
+import org.jredis.ri.alphazero.support.Log;
+
+/**
+ * Pipelines are an order of magnitude faster than the request/reply connectors.
+ * Get a sense of how much faster it is.
+ *
+ * <p>use JVM flags -server -Xms512m -Xmx2560m for better results (adjust your
+ * mem settings per your box's limits.)
+ *
+ * @author Joubin Houshyar (alphazero@sensesay.net)
+ * @version alpha.0, Nov 5, 2009
+ * @since alpha.0
+ *
+ */
+
+public class PipelineInAction {
+ public static void main (String[] args) {
+ final ConnectionSpec spec = DefaultConnectionSpec.newSpec();
+ spec.setCredentials("jredis".getBytes());
+ spec.setDatabase(13);
+ spec.setSocketProperty(SocketProperty.SO_RCVBUF, 1024 * 512);
+ spec.setSocketProperty(SocketProperty.SO_SNDBUF, 1024 * 512);
+
+ usingSynchSemantics(spec);
+ final boolean forever = true;
+
+ runJRedisPipelineSET (spec, 10000, 3, forever);
+ }
+ /**
+ * @param spec
+ */
+ private static void usingSynchSemantics (ConnectionSpec spec) {
+ JRedisPipeline pipeline = new JRedisPipeline(spec);
+ try {
+ long start = System.currentTimeMillis();
+ pipeline.ping();
+ pipeline.flushall();
+ String cntrKey = "my-cntr";
+
+ Random rand = new Random();
+ byte[] data = new byte[8];
+ for(int i=0; i<100000; i++)
+ pipeline.incr(cntrKey);
+
+ long cntr = toLong (pipeline.sync().get(cntrKey));
+
+ for(int i=0; i<100000; i++){
+ rand.nextBytes(data);
+ pipeline.set("random:"+i, "value:" + rand.nextInt());
+ }
+ String randomVal = toStr (pipeline.sync().get("random:"+999));
+ System.out.format ("end using sync() = %d msec\n", System.currentTimeMillis() - start);
+
+ System.out.format("%s => %d\n", cntrKey, cntr);
+ System.out.format("%s => %s\n", "random:"+999, randomVal);
+
+ }
+ catch (RedisException e) {
+ Log.problem("RedisException: " + e);
+ }
+ finally{
+ pipeline.sync().quit();
+ }
+
+ }
+ /**
+ * pipelines SET reqCnt times and then waits on response of the last INCR.
+ * If foverever flag is true, will do so forever. Each cycle prints out timing stats.
+ * @param spec
+ * @param reqCnt
+ * @param forever
+ */
+ @SuppressWarnings("unused")
+ private static void runJRedisPipelineGET (ConnectionSpec spec, int reqCnt, int size, boolean forever) {
+ long totTime = 0;
+ long avgRespTime = 0;
+ float avgThroughput = (float)0;
+ long iters = 0;
+ JRedisFuture pipeline = new JRedisPipeline(spec);
+ try {
+ String key = "pipeKey";
+ byte[] data = new byte[size];
+ (new Random()).nextBytes(data);
+ pipeline.del(key);
+ pipeline.set(key, data);
+
+ do {
+ int cnt = 0;
+ Util.Timer timer = Timer.startNewTimer();
+ Future<byte[]> futureBytes = null;
+ while(cnt < reqCnt){
+ futureBytes = pipeline.get(key);
+ cnt++;
+ }
+ long reqDoneTime = timer.mark();
+ byte[] value = futureBytes.get();
+ long respDoneTime = timer.mark();
+// System.out.format("JRedisPipeline: %d GETs invoked @ %5d (%.2f ops/s)\n", cnt, reqDoneTime, timer.opsPerSecAtDelta(cnt, reqDoneTime));
+ float throughput = timer.opsPerSecAtMark(cnt);
+// System.out.format("JRedisPipeline: %d GETs completed @ %5d (%.2f ops/s) [%d msecs to comp] \n", cnt, timer.deltaAtMark(), throughput, respDoneTime-reqDoneTime);
+ if(iters > 0){
+ totTime += respDoneTime;
+ avgRespTime = (totTime) / (long)iters;
+ avgThroughput =(float)( reqCnt * 1000) / (float) avgRespTime;
+ System.out.format("JRedisPipeline: %d GETs [%d bytes/GET] average response time @ %dms (%.2f ops/s) last: %dms\n", cnt, data.length, avgRespTime, avgThroughput, respDoneTime);
+// Assert.isEquivalent(data, value);
+ }
+ iters ++;
+// System.out.println ();
+ } while(forever);
+
+ pipeline.quit();
+ }
+ catch (ProviderException e) {
+ e.printStackTrace();
+ }
+ catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ catch (ExecutionException e) {
+ e.printStackTrace();
+ }
+ }
+ @SuppressWarnings("unused")
+ private static void runJRedisPipelinePING (ConnectionSpec spec, int reqCnt, int size, boolean forever) {
+ long totTime = 0;
+ long avgRespTime = 0;
+ float avgThroughput = (float)0;
+ long iters = 0;
+ JRedisFuture pipeline = new JRedisPipeline(spec);
+ try {
+ do {
+ int cnt = 0;
+ Util.Timer timer = Timer.startNewTimer();
+ Future<ResponseStatus> futureStat = null;
+ while(cnt < reqCnt){
+ futureStat = pipeline.ping();
+ cnt++;
+ }
+ long reqDoneTime = timer.mark();
+ futureStat.get();
+ long respDoneTime = timer.mark();
+// System.out.format("JRedisPipeline: %d PINGs invoked @ %5d (%.2f ops/s)\n", cnt, reqDoneTime, timer.opsPerSecAtDelta(cnt, reqDoneTime));
+ float throughput = timer.opsPerSecAtMark(cnt);
+// System.out.format("JRedisPipeline: %d PINGs completed @ %5d (%.2f ops/s) [%d msecs to comp] \n", cnt, timer.deltaAtMark(), throughput, respDoneTime-reqDoneTime);
+ if(iters > 0){
+ totTime += reqDoneTime;
+ avgRespTime = (totTime) / (long)iters;
+ avgThroughput =(float)( reqCnt * 1000) / (float) avgRespTime;
+ System.out.print("\r");
+ System.out.format("JRedisPipeline: %d PINGs average response time @ %dms (%.2f ops/s)", cnt, avgRespTime, avgThroughput);
+ }
+ iters ++;
+// System.out.println ();
+ } while(forever);
+
+ pipeline.quit();
+ }
+ catch (ProviderException e) {
+ e.printStackTrace();
+ }
+ catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ catch (ExecutionException e) {
+ e.printStackTrace();
+ }
+ }
+ private static void runJRedisPipelineLPUSH (ConnectionSpec spec, int reqCnt, int size, boolean forever) {
+ JRedisFuture pipeline = new JRedisPipeline(spec);
+ long totTime = 0;
+ long avgRespTime = 0;
+ float avgThroughput = (float)0;
+ long iters = 0;
+ try {
+ String key = "pipeKey";
+ byte[] data = new byte[size];
+ (new Random()).nextBytes(data);
+ Future<Boolean> futureBool = pipeline.del(key);
+ futureBool.get();
+ do {
+ int cnt = 0;
+ Util.Timer timer = Timer.startNewTimer();
+ Future<ResponseStatus> futureStat = null;
+ while(cnt < reqCnt){
+ futureStat = pipeline.lpush(key, data);
+ cnt++;
+ }
+ long reqDoneTime = timer.mark();
+ futureStat.get();
+ long respDoneTime = timer.mark();
+ System.out.format("JRedisPipeline: %d LPUSHs invoked @ %5d (%.2f ops/s)\n", cnt, reqDoneTime, timer.opsPerSecAtDelta(cnt, reqDoneTime));
+ System.out.format("JRedisPipeline: %d LPUSHs completed @ %5d (%.2f ops/s) [%d msecs to comp] \n", cnt, timer.deltaAtMark(), timer.opsPerSecAtMark(cnt), respDoneTime-reqDoneTime);
+ if(iters > 0){
+ totTime += reqDoneTime;
+ avgRespTime = (totTime) / (long)iters;
+ avgThroughput =(float)( reqCnt * 1000) / (float) avgRespTime;
+ System.out.format("JRedisPipeline: %d LPUSHs average response time @ %dms (%.2f ops/s) \n", cnt, avgRespTime, avgThroughput);
+ }
+ iters ++;
+ System.out.println ();
+ } while(forever);
+
+ pipeline.quit();
+ }
+ catch (ProviderException e) {
+ e.printStackTrace();
+ }
+ catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ catch (ExecutionException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * pipelines SET reqCnt times and then waits on response of the last INCR.
+ * If foverever flag is true, will do so forever. Each cycle prints out timing stats.
+ * @param spec
+ * @param reqCnt
+ * @param forever
+ */
+ private static void runJRedisPipelineSET (ConnectionSpec spec, int reqCnt, int size, boolean forever) {
+ JRedisFuture pipeline = new JRedisPipeline(spec);
+ long totTime = 0;
+ long avgRespTime = 0;
+ float avgThroughput = (float)0;
+ long iters = 0;
+ try {
+ String key = "pipeKey";
+ byte[] data = new byte[size];
+ (new Random()).nextBytes(data);
+ Future<Boolean> futureBool = pipeline.del(key);
+ futureBool.get();
+ do {
+ int cnt = 0;
+ Util.Timer timer = Timer.startNewTimer();
+ Future<ResponseStatus> futureStat = null;
+ while(cnt < reqCnt){
+ futureStat = pipeline.set(key, data);
+ cnt++;
+ }
+ long reqDoneTime = timer.mark();
+ futureStat.get();
+ long respDoneTime = timer.mark();
+// System.out.format("JRedisPipeline: %d SETs invoked @ %5d (%.2f ops/s)\n", cnt, reqDoneTime, timer.opsPerSecAtDelta(cnt, reqDoneTime));
+// System.out.format("JRedisPipeline: %d SETs completed @ %5d (%.2f ops/s) [%d msecs to comp] \n", cnt, timer.deltaAtMark(), timer.opsPerSecAtMark(cnt), respDoneTime-reqDoneTime);
+ if(iters > 0){
+ totTime += respDoneTime;
+ avgRespTime = (totTime) / (long)iters;
+ avgThroughput =(float)( reqCnt * 1000) / (float) avgRespTime;
+ System.out.format("JRedisPipeline: %d SETs [%d bytes/GET] average response time @ %dms (%.2f ops/s) \n", cnt, data.length, avgRespTime, avgThroughput);
+ }
+ iters ++;
+// System.out.println ();
+ } while(forever);
+
+ pipeline.quit();
+ }
+ catch (ProviderException e) {
+ e.printStackTrace();
+ }
+ catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ catch (ExecutionException e) {
+ e.printStackTrace();
+ }
+ }
+ /**
+ * pipelines INCRs reqCnt times and then waits on response of the last INCR.
+ * If foverever flag is true, will do so forever. Each cycle prints out timing stats.
+ * @param spec
+ * @param reqCnt
+ * @param forever
+ */
+ private static void runJRedisPipelineINCR (ConnectionSpec spec, int reqCnt, int size, boolean forever) {
+ JRedisFuture pipeline = new JRedisPipeline(spec);
+ long totTime = 0;
+ long avgRespTime = 0;
+ float avgThroughput = (float)0;
+ long iters = 0;
+ try {
+ String key = "pipeCounter";
+ Future<Boolean> futureBool = pipeline.del(key);
+ futureBool.get();
+ do {
+ int cnt = 0;
+ Util.Timer timer = Timer.startNewTimer();
+ Future<Long> futureLong = null;
+ while(cnt < reqCnt){
+ futureLong = pipeline.incr(key);
+ cnt++;
+ }
+ long reqDoneTime = timer.mark();
+ long counter = futureLong.get();
+ long respDoneTime = timer.mark();
+ System.out.format("JRedisPipeline: %d INCRs invoked @ %5d (%.2f ops/s)\n", cnt, reqDoneTime, timer.opsPerSecAtDelta(cnt, reqDoneTime));
+ System.out.format("JRedisPipeline: %d INCRs completed @ %5d (%.2f ops/s) [%d msecs to comp] \n", cnt, timer.deltaAtMark(), timer.opsPerSecAtMark(cnt), respDoneTime-reqDoneTime);
+ System.out.format ("counter is now: %d\n\n", counter);
+ if(iters > 0){
+ totTime += reqDoneTime;
+ avgRespTime = (totTime) / (long)iters;
+ avgThroughput =(float)( reqCnt * 1000) / (float) avgRespTime;
+ System.out.format("JRedisPipeline: %d INCRs average response time @ %dms (%.2f ops/s) \n", cnt, avgRespTime, avgThroughput);
+ }
+ iters ++;
+ System.out.println ();
+ } while(forever);
+
+ pipeline.quit();
+ }
+ catch (ProviderException e) {
+ e.printStackTrace();
+ }
+ catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ catch (ExecutionException e) {
+ e.printStackTrace();
+ }
+ }
+}
Oops, something went wrong.

0 comments on commit a46ff1c

Please sign in to comment.