@Override
public boolean delete(ByteArray key, Version version) throws VoldemortException {
try {
// Create the REST request with this byte array
String base64Key = RestUtils.encodeVoldemortKey(key.get());
RestRequestBuilder rb = new RestRequestBuilder(new URI(this.restBootstrapURL + "/"
+ getName() + "/" + base64Key));
// Create a HTTP POST request
rb.setMethod(DELETE);
rb.setHeader(CONTENT_LENGTH, "0");
String timeoutStr = Long.toString(this.config.getTimeoutConfig()
.getOperationTimeout(VoldemortOpCode.DELETE_OP_CODE));
rb.setHeader(RestMessageHeaders.X_VOLD_REQUEST_TIMEOUT_MS, timeoutStr);
rb.setHeader(RestMessageHeaders.X_VOLD_REQUEST_ORIGIN_TIME_MS,
String.valueOf(System.currentTimeMillis()));
if(this.routingTypeCode != null) {
rb.setHeader(RestMessageHeaders.X_VOLD_ROUTING_TYPE_CODE, this.routingTypeCode);
}
if(this.zoneId != INVALID_ZONE_ID) {
rb.setHeader(RestMessageHeaders.X_VOLD_ZONE_ID, String.valueOf(this.zoneId));
}
// Serialize the Vector clock
VectorClock vc = (VectorClock) version;
// If the given Vector clock is empty, we'll let the receiver of
// this request fetch the existing vector clock and increment
// before
// doing the put.
if(vc != null && vc.getEntries().size() != 0) {
String serializedVC = null;
if(!vc.getEntries().isEmpty()) {
serializedVC = RestUtils.getSerializedVectorClock(vc);
}
if(serializedVC != null && serializedVC.length() > 0) {
rb.setHeader(RestMessageHeaders.X_VOLD_VECTOR_CLOCK, serializedVC);
}
}
RestRequest request = rb.build();
Future<RestResponse> f = client.restRequest(request);
// This will block
RestResponse response = f.get();
final ByteString entity = response.getEntity();