[infinispan-commits] Infinispan SVN: r1411 - in trunk/server/memcached: src/main/java/org/infinispan/server/memcached and 1 other directories.

infinispan-commits at lists.jboss.org infinispan-commits at lists.jboss.org
Fri Jan 22 12:30:04 EST 2010


Author: galder.zamarreno at jboss.com
Date: 2010-01-22 12:30:03 -0500 (Fri, 22 Jan 2010)
New Revision: 1411

Modified:
   trunk/server/memcached/
   trunk/server/memcached/src/main/java/org/infinispan/server/memcached/TextServer.java
   trunk/server/memcached/src/main/java/org/infinispan/server/memcached/commands/CommandFactory.java
Log:
[ISPN-300] (Demo memcached being accessed from a non-Java client) Fixed issue with old specification delayed delete time parameter. We now ignore it since it's no longer honored.


Property changes on: trunk/server/memcached
___________________________________________________________________
Name: svn:ignore
   - .classpath
.settings
.project
target
eclipse-output
test-output
output
temp-testng-customsuite.xml

   + .classpath
.settings
.project
target
eclipse-output
test-output
output
temp-testng-customsuite.xml
.pydevproject


Modified: trunk/server/memcached/src/main/java/org/infinispan/server/memcached/TextServer.java
===================================================================
--- trunk/server/memcached/src/main/java/org/infinispan/server/memcached/TextServer.java	2010-01-22 17:26:01 UTC (rev 1410)
+++ trunk/server/memcached/src/main/java/org/infinispan/server/memcached/TextServer.java	2010-01-22 17:30:03 UTC (rev 1411)
@@ -24,10 +24,8 @@
 
 import java.io.IOException;
 import java.net.InetSocketAddress;
-import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.atomic.AtomicInteger;
 
 import org.infinispan.Cache;
 import org.infinispan.manager.DefaultCacheManager;

Modified: trunk/server/memcached/src/main/java/org/infinispan/server/memcached/commands/CommandFactory.java
===================================================================
--- trunk/server/memcached/src/main/java/org/infinispan/server/memcached/commands/CommandFactory.java	2010-01-22 17:26:01 UTC (rev 1410)
+++ trunk/server/memcached/src/main/java/org/infinispan/server/memcached/commands/CommandFactory.java	2010-01-22 17:30:03 UTC (rev 1411)
@@ -87,7 +87,16 @@
             return RetrievalCommand.newRetrievalCommand(cache, type, new RetrievalParameters(keys));
          case DELETE:
             String delKey = getKey(args[1]);
-            return DeleteCommand.newDeleteCommand(cache, delKey, parseNoReply(2, args));
+            int time = parseDelayedDeleteTime(2, args);
+            boolean noReply = false;
+            if (time == -1) {
+               // Try parsing noreply just in case
+               noReply = parseNoReply(2, args);
+            } else {
+               // 0 or positive numbers are ignored; We immediately delete since this is no longer in the spec:
+               // http://github.com/trondn/memcached/blob/master/doc/protocol.txt
+            }
+            return DeleteCommand.newDeleteCommand(cache, delKey, noReply);
          case INCR:
          case DECR:
             String key = getKey(args[1]);
@@ -114,22 +123,22 @@
    }
 
    private String getKey(String key) throws IOException {
-      if (key == null) throw new EOFException();
+      if (key == null) throw new EOFException("No key passed");
       return key;
    }
 
    private int getFlags(String flags) throws IOException {
-      if (flags == null) throw new EOFException();
+      if (flags == null) throw new EOFException("No flags passed");
       return Integer.parseInt(flags);
    }
 
    private long getExpiry(String expiry) throws IOException {
-      if (expiry == null) throw new EOFException();
+      if (expiry == null) throw new EOFException("No expiry passed");
       return Long.parseLong(expiry); // seconds
    }
 
    private int getBytes(String bytes) throws IOException {
-      if (bytes == null) throw new EOFException();
+      if (bytes == null) throw new EOFException("No bytes for storage command passed");
       return Integer.parseInt(bytes);
    }
 
@@ -143,4 +152,16 @@
       }
       return false;
    }
+
+   private int parseDelayedDeleteTime(int expectedIndex, String[] args) {
+      if (args.length > expectedIndex) {
+         try {
+            return Integer.parseInt(args[expectedIndex]);
+         } catch (NumberFormatException e) {
+            // Either unformatted number, or noreply found
+            return -1;
+         }
+      }
+      return 0;
+   }
 }



More information about the infinispan-commits mailing list