Skip to content

Commit 28b8b41

Browse files
committed
1) Fix bug in perf test
2) Modify log level in delete method Change-Id: I7fc1a00b389ed02068482cd4495a629d06c7c5f1
1 parent 3d26db2 commit 28b8b41

File tree

3 files changed

+24
-31
lines changed

3 files changed

+24
-31
lines changed

src/main/com/schooner/MemCached/AscIIClient.java

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -184,21 +184,17 @@ public boolean delete(String key, Integer hashCode, Date expiry) {
184184
// get result code
185185
String line = new SockInputStream(sock, Integer.MAX_VALUE).getLine();
186186
if (DELETED.equals(line)) { // successful
187-
if (log.isInfoEnabled())
188-
// log.info(new
189-
// StringBuffer().append("++++ deletion of key: ").append(key)
190-
// .append(" from cache was a success").toString());
191-
return true;
187+
if (log.isDebugEnabled())
188+
log.debug(new StringBuffer().append("++++ deletion of key: ").append(key)
189+
.append(" from cache was a success").toString());
190+
return true;
192191
} else if (NOTFOUND.equals(line)) { // key not found
193-
// if (log.isInfoEnabled())
194-
// log.info(new
195-
// StringBuffer().append("++++ deletion of key: ").append(key)
196-
// .append(" from cache failed as the key was not found").toString());
192+
if (log.isDebugEnabled())
193+
log.debug(new StringBuffer().append("++++ deletion of key: ").append(key)
194+
.append(" from cache failed as the key was not found").toString());
197195
} else { // other error information
198-
// log.error(new
199-
// StringBuffer().append("++++ error deleting key: ").append(key).toString());
200-
// log.error(new
201-
// StringBuffer().append("++++ server response: ").append(line).toString());
196+
log.error(new StringBuffer().append("++++ error deleting key: ").append(key).toString());
197+
log.error(new StringBuffer().append("++++ server response: ").append(line).toString());
202198
}
203199
} catch (IOException e) {
204200

src/main/com/schooner/MemCached/SchoonerSockIOPool.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,8 @@ protected final MessageDigest initialValue() {
150150

151151
boolean initialized = false;
152152

153-
private int initConn = 1;
153+
private int minConn = 8;
154+
private int maxConn = 32;
154155
private long maxBusyTime = 1000 * 30; // max idle time for avail sockets
155156
private long maintSleep = 1000 * 30; // maintenance thread sleep time
156157
private int socketTO = 1000 * 30; // default timeout of socket reads
@@ -159,7 +160,7 @@ protected final MessageDigest initialValue() {
159160
@SuppressWarnings("unused")
160161
private static int recBufferSize = 128;// bufsize
161162

162-
private long maxIdle = 1000 * 60 * 5; // max idle time for avail sockets
163+
private long maxIdle = 1000; // max idle time for avail sockets
163164

164165
private boolean aliveCheck = false; // default to not check each connection
165166
// for being alive
@@ -193,8 +194,6 @@ protected final MessageDigest initialValue() {
193194

194195
ConcurrentMap<String, Long> hostDeadDur;
195196

196-
private int maxConn = 32;
197-
198197
private boolean isTcp;
199198

200199
private int bufferSize = 1024 * 1025;
@@ -311,7 +310,7 @@ private void populateBuckets() {
311310
GenericObjectPool gop;
312311
SchoonerSockIOFactory factory = new SchoonerSockIOFactory(servers[i], isTcp, bufferSize, socketTO,
313312
socketConnectTO, nagle);
314-
gop = new GenericObjectPool(factory, maxConn, GenericObjectPool.WHEN_EXHAUSTED_BLOCK, 1000, maxConn);
313+
gop = new GenericObjectPool(factory, maxConn, GenericObjectPool.WHEN_EXHAUSTED_BLOCK, maxIdle, maxConn);
315314
factory.setSockets(gop);
316315
socketPool.put(servers[i], gop);
317316
}
@@ -351,7 +350,7 @@ private void populateConsistentBuckets() {
351350
GenericObjectPool gop;
352351
SchoonerSockIOFactory factory = new SchoonerSockIOFactory(servers[i], isTcp, bufferSize, socketTO,
353352
socketConnectTO, nagle);
354-
gop = new GenericObjectPool(factory, maxConn, GenericObjectPool.WHEN_EXHAUSTED_BLOCK, 1000, maxConn);
353+
gop = new GenericObjectPool(factory, maxConn, GenericObjectPool.WHEN_EXHAUSTED_BLOCK, maxIdle, maxConn);
355354
factory.setSockets(gop);
356355
socketPool.put(servers[i], gop);
357356
}
@@ -558,6 +557,7 @@ protected final void closeSocketPool() {
558557
try {
559558
sockets.close();
560559
} catch (Exception e) {
560+
log.error("++++ failed to close socket pool.");
561561
}
562562
}
563563
}
@@ -577,7 +577,6 @@ public void shutDown() {
577577
buckets = null;
578578
consistentBuckets = null;
579579
initialized = false;
580-
581580
}
582581

583582
/**
@@ -637,7 +636,8 @@ public final Integer[] getWeights() {
637636
* int number of connections
638637
*/
639638
public final void setInitConn(int initConn) {
640-
this.initConn = initConn;
639+
if (initConn < minConn)
640+
minConn = initConn;
641641
}
642642

643643
/**
@@ -647,7 +647,7 @@ public final void setInitConn(int initConn) {
647647
* @return number of connections
648648
*/
649649
public final int getInitConn() {
650-
return this.initConn;
650+
return this.minConn;
651651
}
652652

653653
/**
@@ -994,11 +994,11 @@ public int getMaxConn() {
994994
}
995995

996996
public void setMinConn(int minConn) {
997-
this.initConn = minConn;
997+
this.minConn = minConn;
998998
}
999999

10001000
public int getMinConn() {
1001-
return initConn;
1001+
return minConn;
10021002
}
10031003

10041004
public void setBufferSize(int bufferSize) {

src/test/com/schooner/MemCached/MemcachedPerfTest.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,18 +48,15 @@ public static void main(String[] args) {
4848
// initialize the pool for memcache servers
4949
SchoonerSockIOPool pool = SchoonerSockIOPool.getInstance("test");
5050
pool.setServers(serverlist);
51-
52-
// pool.setInitConn(5);
53-
// pool.setMinConn(5);
54-
pool.setMaxConn(50);
55-
// pool.setMaintSleep(30);
56-
51+
pool.setMaxConn(Integer.parseInt(args[5]));
52+
pool.setMinConn(Integer.parseInt(args[4]));
53+
pool.setMaxIdle(Integer.parseInt(args[6]));
5754
pool.setNagle(false);
5855
pool.initialize();
5956

6057
int threads = Integer.parseInt(args[1]);
6158
int runs = Integer.parseInt(args[2]);
62-
int size = 1024 * Integer.parseInt(args[3]); // how many kilobytes
59+
int size = 1024 * Integer.parseInt(args[3]) / 4; // how many kilobytes
6360

6461
// get object to store
6562
int[] obj = new int[size];

0 commit comments

Comments
 (0)