Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

refactor

  • Loading branch information...
commit bf1f9a4d9e688bbd1d60c017f798ab036ebfdd0b 1 parent e57a5a7
Yamashita Yuu authored
26 jetty-nosql-memcached/src/main/java/org/eclipse/jetty/nosql/memcached/spymemcached/SpyMemcachedClient.java
View
@@ -15,7 +15,7 @@
public class SpyMemcachedClient extends AbstractMemcachedClient {
private static final int FOREVER = 0;
- private MemcachedClient _connection = null;
+ private MemcachedClient _client = null;
private Transcoder<byte[]> _transcoder = null;
public SpyMemcachedClient() {
@@ -28,15 +28,15 @@ public SpyMemcachedClient(String serverString) {
}
public boolean establish() throws KeyValueStoreClientException {
- if (_connection != null) {
+ if (_client != null) {
shutdown();
}
try {
ConnectionFactory cf = getConnectionFactory();
if (cf == null) {
- this._connection = new MemcachedClient(AddrUtil.getAddresses(_serverString));
+ this._client = new MemcachedClient(AddrUtil.getAddresses(_serverString));
} else {
- this._connection = new MemcachedClient(cf, AddrUtil.getAddresses(_serverString));
+ this._client = new MemcachedClient(cf, AddrUtil.getAddresses(_serverString));
}
} catch (IOException error) {
throw(new KeyValueStoreClientException(error));
@@ -54,24 +54,24 @@ protected ConnectionFactory getConnectionFactory() {
}
public boolean shutdown() throws KeyValueStoreClientException {
- if (_connection != null) {
- _connection.shutdown();
- _connection = null;
+ if (_client != null) {
+ _client.shutdown();
+ _client = null;
}
return true;
}
public boolean isAlive() {
- return _connection != null;
+ return _client != null;
}
public byte[] get(String key) throws KeyValueStoreClientException {
if (!isAlive()) {
throw(new KeyValueStoreClientException(new IllegalStateException("client not established")));
}
- byte[] raw;
+ byte[] raw = null;
try {
- Future<byte[]> f = _connection.asyncGet(key, _transcoder);
+ Future<byte[]> f = _client.asyncGet(key, _transcoder);
raw = f.get(_timeoutInMs, TimeUnit.MILLISECONDS);
} catch (Exception error) {
throw(new KeyValueStoreClientException(error));
@@ -89,7 +89,7 @@ public boolean set(String key, byte[] raw, int exp) throws KeyValueStoreClientEx
}
boolean result;
try {
- Future<Boolean> f = _connection.set(key, exp, raw, _transcoder);
+ Future<Boolean> f = _client.set(key, exp, raw, _transcoder);
result = f.get(_timeoutInMs, TimeUnit.MILLISECONDS);
} catch (Exception error) {
throw(new KeyValueStoreClientException(error));
@@ -107,7 +107,7 @@ public boolean add(String key, byte[] raw, int exp) throws KeyValueStoreClientEx
}
boolean result;
try {
- Future<Boolean> f = _connection.add(key, exp, raw, _transcoder);
+ Future<Boolean> f = _client.add(key, exp, raw, _transcoder);
result = f.get(_timeoutInMs, TimeUnit.MILLISECONDS);
} catch (Exception error) {
throw(new KeyValueStoreClientException(error));
@@ -121,7 +121,7 @@ public boolean delete(String key) throws KeyValueStoreClientException {
}
boolean result;
try {
- Future<Boolean> f = _connection.delete(key);
+ Future<Boolean> f = _client.delete(key);
result = f.get(_timeoutInMs, TimeUnit.MILLISECONDS);
} catch (Exception error) {
throw(new KeyValueStoreClientException(error));
24 jetty-nosql-memcached/src/main/java/org/eclipse/jetty/nosql/memcached/xmemcached/XMemcachedClient.java
View
@@ -13,7 +13,7 @@
public class XMemcachedClient extends AbstractMemcachedClient {
private static final int FOREVER = 0;
private XMemcachedClientBuilder _builder = null;
- private MemcachedClient _connection = null;
+ private MemcachedClient _client = null;
private Transcoder<byte[]> _transcoder = null;
public XMemcachedClient() {
@@ -26,8 +26,8 @@ public XMemcachedClient(String serverString) {
}
public boolean establish() throws KeyValueStoreClientException {
- if (_connection != null) {
- if (!_connection.isShutdown()) {
+ if (_client != null) {
+ if (!_client.isShutdown()) {
return true;
} else {
shutdown();
@@ -36,7 +36,7 @@ public boolean establish() throws KeyValueStoreClientException {
this._builder = getClientBuilder(_serverString);
try {
- this._connection = _builder.build();
+ this._client = _builder.build();
} catch (IOException error) {
throw(new KeyValueStoreClientException(error));
}
@@ -50,20 +50,20 @@ protected XMemcachedClientBuilder getClientBuilder(String serverString) {
}
public boolean shutdown() throws KeyValueStoreClientException {
- if (_connection != null) {
+ if (_client != null) {
try {
- _connection.shutdown();
+ _client.shutdown();
} catch (IOException error) {
throw(new KeyValueStoreClientException(error));
} finally {
- _connection = null;
+ _client = null;
}
}
return true;
}
public boolean isAlive() {
- return this._connection != null && !this._connection.isShutdown();
+ return this._client != null && !this._client.isShutdown();
}
public byte[] get(String key) throws KeyValueStoreClientException {
@@ -72,7 +72,7 @@ public boolean isAlive() {
}
byte[] raw = null;
try {
- raw = _connection.get(key);
+ raw = _client.get(key);
} catch (Exception error) {
throw(new KeyValueStoreClientException(error));
}
@@ -89,7 +89,7 @@ public boolean set(String key, byte[] raw, int exp) throws KeyValueStoreClientEx
}
boolean result = false;
try {
- result = _connection.set(key, exp, raw);
+ result = _client.set(key, exp, raw);
} catch (Exception error) {
throw(new KeyValueStoreClientException(error));
}
@@ -106,7 +106,7 @@ public boolean add(String key, byte[] raw, int exp) throws KeyValueStoreClientEx
}
boolean result = false;
try {
- result = _connection.add(key, exp, raw);
+ result = _client.add(key, exp, raw);
} catch (Exception error) {
throw(new KeyValueStoreClientException(error));
}
@@ -119,7 +119,7 @@ public boolean delete(String key) throws KeyValueStoreClientException {
}
boolean result = false;
try {
- result = _connection.delete(key);
+ result = _client.delete(key);
} catch (Exception error) {
throw(new KeyValueStoreClientException(error));
}
Please sign in to comment.
Something went wrong with that request. Please try again.