public
Description: A simple, asynchronous, single-threaded memcached client written in java.
Homepage: http://code.google.com/p/spymemcached/
Clone URL: git://github.com/dustin/java-memcached-client.git
Read before writes and expect IllegalStateException.

These are two measures that are helping with the queue overflow
problems.

Firstly, the IllegalStateException is thrown whenever you attempted to
add to a queue that's full.  If that happens internally, I don't want
the IO thread to crash, so I add it to the normal ``expected
exceptions'' list.

Secondly, reading before writing helps keep the read buffer ready for
new data.  When writing first, the write will have to transition to a
read and may cause the read buffer to overflow.  It still may happen,
but by servicing the reads first I can at least get the complete ones
popped out before piling new ones in (since writes are almost always
smaller and likely to transition).
dustin (author)
Tue May 13 22:18:58 -0700 2008
commit  0be1844a79e2d9ecd635e770faf479f3a221be87
tree    f17bbf319e48839119dfef8e39f58803338dbb87
parent  6a38bf7b3b190035e35133e8b08056ceb86d2eaf
...
1253
1254
1255
 
 
1256
1257
1258
...
1253
1254
1255
1256
1257
1258
1259
1260
0
@@ -1253,6 +1253,8 @@ public final class MemcachedClient extends SpyThread {
0
         logRunException(e);
0
       } catch(ClosedSelectorException e) {
0
         logRunException(e);
0
+      } catch(IllegalStateException e) {
0
+        logRunException(e);
0
       }
0
     }
0
     getLogger().info("Shut down memcached client");
...
258
259
260
261
262
263
264
265
266
 
 
 
267
268
269
...
258
259
260
 
 
 
261
262
263
264
265
266
267
268
269
0
@@ -258,12 +258,12 @@ public final class MemcachedConnection extends SpyObject {
0
           assert !channel.isConnected() : "connected";
0
         }
0
       } else {
0
-        if(sk.isWritable()) {
0
-          handleWrites(sk, qa);
0
-        }
0
         if(sk.isReadable()) {
0
           handleReads(sk, qa);
0
         }
0
+        if(sk.isWritable()) {
0
+          handleWrites(sk, qa);
0
+        }
0
       }
0
     } catch(Exception e) {
0
       // Various errors occur on Linux that wind up here.  However, any

Comments