Skip to content

Commit 33f2f3e

Browse files
Mike WiederholdMichael Wiederhold
authored andcommitted
SPY-47: Client object should have toString().
The toString() method in MemcachedClient now prints out it's configuration eg. the information of the ConnectionFactory it is using. Change-Id: Ic8f3741bdcdc97d5bb46b2c4a68caec998903fde Reviewed-on: http://review.couchbase.org/9473 Tested-by: Michael Wiederhold <[email protected]> Reviewed-by: Michael Wiederhold <[email protected]>
1 parent 6d9c441 commit 33f2f3e

File tree

1 file changed

+17
-10
lines changed

1 file changed

+17
-10
lines changed

src/main/java/net/spy/memcached/MemcachedClient.java

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,8 @@ public class MemcachedClient extends SpyThread
128128

129129
final AuthDescriptor authDescriptor;
130130

131+
private final ConnectionFactory connFactory;
132+
131133
private final AuthThreadMonitor authMonitor = new AuthThreadMonitor();
132134
private volatile boolean reconfiguring = false;
133135
private ConfigurationProvider configurationProvider;
@@ -176,6 +178,7 @@ public MemcachedClient(ConnectionFactory cf, List<InetSocketAddress> addrs)
176178
throw new IllegalArgumentException(
177179
"Operation timeout must be positive.");
178180
}
181+
connFactory = cf;
179182
tcService = new TranscodeService(cf.isDaemon());
180183
transcoder=cf.getDefaultTranscoder();
181184
opFact=cf.getOperationFactory();
@@ -281,10 +284,10 @@ public MemcachedClient(ConnectionFactory cf, final List<URI> baseList,
281284
cfb.setAuthDescriptor(ad);
282285
}
283286

284-
cf = cfb.build();
287+
connFactory = cfb.build();
285288

286289
List<InetSocketAddress> addrs = AddrUtil.getAddresses(bucket.getConfig().getServers());
287-
if(cf == null) {
290+
if(connFactory == null) {
288291
throw new NullPointerException("Connection factory required");
289292
}
290293
if(addrs == null) {
@@ -294,23 +297,23 @@ public MemcachedClient(ConnectionFactory cf, final List<URI> baseList,
294297
throw new IllegalArgumentException(
295298
"You must have at least one server to connect to");
296299
}
297-
if(cf.getOperationTimeout() <= 0) {
300+
if(connFactory.getOperationTimeout() <= 0) {
298301
throw new IllegalArgumentException(
299302
"Operation timeout must be positive.");
300303
}
301-
tcService = new TranscodeService(cf.isDaemon());
302-
transcoder=cf.getDefaultTranscoder();
303-
opFact=cf.getOperationFactory();
304+
tcService = new TranscodeService(connFactory.isDaemon());
305+
transcoder=connFactory.getDefaultTranscoder();
306+
opFact=connFactory.getOperationFactory();
304307
assert opFact != null : "Connection factory failed to make op factory";
305-
conn=cf.createConnection(addrs);
308+
conn=connFactory.createConnection(addrs);
306309
assert conn != null : "Connection factory failed to make a connection";
307-
operationTimeout = cf.getOperationTimeout();
308-
authDescriptor = cf.getAuthDescriptor();
310+
operationTimeout = connFactory.getOperationTimeout();
311+
authDescriptor = connFactory.getAuthDescriptor();
309312
if(authDescriptor != null) {
310313
addObserver(this);
311314
}
312315
setName("Memcached IO over " + conn);
313-
setDaemon(cf.isDaemon());
316+
setDaemon(connFactory.isDaemon());
314317
this.configurationProvider.subscribe(bucketName, this);
315318
start();
316319
}
@@ -2178,4 +2181,8 @@ public void connectionLost(SocketAddress sa) {
21782181
// Don't care.
21792182
}
21802183

2184+
@Override
2185+
public String toString() {
2186+
return connFactory.toString();
2187+
}
21812188
}

0 commit comments

Comments
 (0)