Permalink
Browse files

Support delete

  • Loading branch information...
justinsb committed Dec 9, 2013
1 parent ccb1941 commit 398299ab41a4983f02dbd126b4e51bdeef9de470
@@ -47,7 +47,7 @@ public void put(long storeId, ByteString key, ByteString value) throws Exception
break;
default:
throw new IllegalStateException();
throw new IllegalStateException("Unexpected status: " + status);
}
} finally {
response.close();
@@ -71,6 +71,12 @@ public ByteString getKey() {
public ByteString getValue() {
return value;
}
@Override
public String toString() {
return "KeyValueEntry [key=" + Hex.forDebug(key) + ", value=" + Hex.forDebug(value) + "]";
}
}
public KeyValueEntry read(long storeId, ByteString key) throws IOException {
@@ -87,7 +93,7 @@ public KeyValueEntry read(long storeId, ByteString key) throws IOException {
return null;
default:
throw new IllegalStateException();
throw new IllegalStateException("Unexpected status: " + status);
}
InputStream is = response.getEntityInputStream();
@@ -102,4 +108,23 @@ public KeyValueEntry read(long storeId, ByteString key) throws IOException {
private String toUrlPath(long storeId, ByteString key) {
return Long.toString(storeId) + "/" + Hex.toHex(key);
}
public void delete(long storeId, ByteString key) {
ClientResponse response = CLIENT.resource(url).path(toUrlPath(storeId, key)).delete(ClientResponse.class);
try {
int status = response.getStatus();
switch (status) {
case 200:
case 204:
break;
default:
throw new IllegalStateException("Unexpected status: " + status);
}
} finally {
response.close();
}
}
}
Oops, something went wrong.

0 comments on commit 398299a

Please sign in to comment.