static VoldemortFilter getFilterFromRequest(
      VAdminProto.VoldemortFilter request,
      VoldemortConfig voldemortConfig,
      NetworkClassLoader networkClassLoader) {
    VoldemortFilter filter = null;

    byte[] classBytes = ProtoUtils.decodeBytes(request.getData()).get();
    String className = request.getName();
    logger.debug("Attempt to load VoldemortFilter class:" + className);

    try {
      if (voldemortConfig.isNetworkClassLoaderEnabled()) {
        // TODO: network class loader was throwing NoClassDefFound for
        // voldemort.server package classes, Need testing and fixes
        logger.warn("NetworkLoader is experimental and should not be used for now.");

        Class<?> cl = networkClassLoader.loadClass(className, classBytes, 0, classBytes.length);
        filter = (VoldemortFilter) cl.newInstance();
      } else {
        Class<?> cl = Thread.currentThread().getContextClassLoader().loadClass(className);
        filter = (VoldemortFilter) cl.newInstance();
      }
    } catch (Exception e) {
      throw new VoldemortException("Failed to load and instantiate the filter class", e);
    }

    return filter;
  }
  public VAdminProto.GetMetadataResponse handleGetMetadata(VAdminProto.GetMetadataRequest request) {
    VAdminProto.GetMetadataResponse.Builder response = VAdminProto.GetMetadataResponse.newBuilder();

    try {
      ByteArray key = ProtoUtils.decodeBytes(request.getKey());
      String keyString = ByteUtils.getString(key.get(), "UTF-8");
      if (MetadataStore.METADATA_KEYS.contains(keyString)) {
        List<Versioned<byte[]>> versionedList = metadataStore.get(key);
        int size = (versionedList.size() > 0) ? 1 : 0;

        if (size > 0) {
          Versioned<byte[]> versioned = versionedList.get(0);
          response.setVersion(ProtoUtils.encodeVersioned(versioned));
        }
      } else {
        throw new VoldemortException(
            "Metadata Key passed " + keyString + " is not handled yet ...");
      }
    } catch (VoldemortException e) {
      response.setError(ProtoUtils.encodeError(errorCodeMapper, e));
      logger.error("handleGetMetadata failed for request(" + request.toString() + ")", e);
    }

    return response.build();
  }
 private Message handleGetVersion(GetRequest request, Store<ByteArray, byte[]> store) {
   VProto.GetVersionResponse.Builder response = VProto.GetVersionResponse.newBuilder();
   try {
     List<Version> versions = store.getVersions(ProtoUtils.decodeBytes(request.getKey()));
     for (Version version : versions) response.addVersions(ProtoUtils.encodeClock(version));
   } catch (VoldemortException e) {
     response.setError(ProtoUtils.encodeError(getErrorMapper(), e));
   }
   return response.build();
 }
 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();
 }
 private VProto.PutResponse handlePut(VProto.PutRequest request, Store<ByteArray, byte[]> store) {
   VProto.PutResponse.Builder response = VProto.PutResponse.newBuilder();
   try {
     ByteArray key = ProtoUtils.decodeBytes(request.getKey());
     Versioned<byte[]> value = ProtoUtils.decodeVersioned(request.getVersioned());
     store.put(key, value);
   } catch (VoldemortException e) {
     response.setError(ProtoUtils.encodeError(getErrorMapper(), e));
   }
   return response.build();
 }
 private VProto.DeleteResponse handleDelete(
     VProto.DeleteRequest request, Store<ByteArray, byte[]> store) {
   VProto.DeleteResponse.Builder response = VProto.DeleteResponse.newBuilder();
   try {
     boolean success =
         store.delete(
             ProtoUtils.decodeBytes(request.getKey()),
             ProtoUtils.decodeClock(request.getVersion()));
     response.setSuccess(success);
   } catch (VoldemortException e) {
     response.setSuccess(false);
     response.setError(ProtoUtils.encodeError(getErrorMapper(), e));
   }
   return response.build();
 }
 private VProto.GetAllResponse handleGetAll(
     VProto.GetAllRequest request, Store<ByteArray, byte[]> store) {
   VProto.GetAllResponse.Builder response = VProto.GetAllResponse.newBuilder();
   try {
     List<ByteArray> keys = new ArrayList<ByteArray>(request.getKeysCount());
     for (ByteString string : request.getKeysList()) keys.add(ProtoUtils.decodeBytes(string));
     Map<ByteArray, List<Versioned<byte[]>>> values = store.getAll(keys);
     for (Map.Entry<ByteArray, List<Versioned<byte[]>>> entry : values.entrySet()) {
       VProto.KeyedVersions.Builder keyedVersion =
           VProto.KeyedVersions.newBuilder().setKey(ProtoUtils.encodeBytes(entry.getKey()));
       for (Versioned<byte[]> version : entry.getValue())
         keyedVersion.addVersions(ProtoUtils.encodeVersioned(version));
       response.addValues(keyedVersion);
     }
   } catch (VoldemortException e) {
     response.setError(ProtoUtils.encodeError(getErrorMapper(), e));
   }
   return response.build();
 }
  public VAdminProto.UpdateMetadataResponse handleUpdateMetadata(
      VAdminProto.UpdateMetadataRequest request) {
    VAdminProto.UpdateMetadataResponse.Builder response =
        VAdminProto.UpdateMetadataResponse.newBuilder();

    try {
      ByteArray key = ProtoUtils.decodeBytes(request.getKey());
      String keyString = ByteUtils.getString(key.get(), "UTF-8");

      if (MetadataStore.METADATA_KEYS.contains(keyString)) {
        Versioned<byte[]> versionedValue = ProtoUtils.decodeVersioned(request.getVersioned());
        metadataStore.put(new ByteArray(ByteUtils.getBytes(keyString, "UTF-8")), versionedValue);
      }
    } catch (VoldemortException e) {
      response.setError(ProtoUtils.encodeError(errorCodeMapper, e));
      logger.error("handleUpdateMetadata failed for request(" + request.toString() + ")", e);
    }

    return response.build();
  }