Ejemplo n.º 1
0
 private VProto.GetResponse handleGet(VProto.GetRequest request, Store<ByteArray, byte[]> store) {
   VProto.GetResponse.Builder response = VProto.GetResponse.newBuilder();
   try {
     List<Versioned<byte[]>> values = store.get(ProtoUtils.decodeBytes(request.getKey()));
     for (Versioned<byte[]> versioned : values)
       response.addVersioned(ProtoUtils.encodeVersioned(versioned));
   } catch (VoldemortException e) {
     response.setError(ProtoUtils.encodeError(getErrorMapper(), e));
   }
   return response.build();
 }
Ejemplo n.º 2
0
 public Message unknownStore(String storeName, RequestType type) {
   VProto.Error error =
       VProto.Error.newBuilder()
           .setErrorCode(getErrorMapper().getCode(VoldemortException.class))
           .setErrorMessage("Unknown store '" + storeName + "'.")
           .build();
   switch (type) {
     case GET:
       return VProto.GetResponse.newBuilder().setError(error).build();
     case GET_ALL:
       return VProto.GetAllResponse.newBuilder().setError(error).build();
     case PUT:
       return VProto.PutResponse.newBuilder().setError(error).build();
     case DELETE:
       return VProto.DeleteResponse.newBuilder().setError(error).setSuccess(false).build();
     default:
       throw new VoldemortException("Unknown operation " + type);
   }
 }