Java 类org.apache.hadoop.hbase.client.RegionCoprocessorServiceExec 实例源码

项目:ditb    文件:RequestConverter.java   
/**
 * Create a protocol buffer multi request for a list of actions.
 * Propagates Actions original index.
 *
 * @param regionName
 * @param actions
 * @return a multi request
 * @throws IOException
 */
public static <R> RegionAction.Builder buildRegionAction(final byte[] regionName,
    final List<Action<R>> actions, final RegionAction.Builder regionActionBuilder,
    final ClientProtos.Action.Builder actionBuilder,
    final MutationProto.Builder mutationBuilder) throws IOException {
  for (Action<R> action: actions) {
    Row row = action.getAction();
    actionBuilder.clear();
    actionBuilder.setIndex(action.getOriginalIndex());
    mutationBuilder.clear();
    if (row instanceof Get) {
      Get g = (Get)row;
      regionActionBuilder.addAction(actionBuilder.setGet(ProtobufUtil.toGet(g)));
    } else if (row instanceof Put) {
      regionActionBuilder.addAction(actionBuilder.
        setMutation(ProtobufUtil.toMutation(MutationType.PUT, (Put)row, mutationBuilder)));
    } else if (row instanceof Delete) {
      regionActionBuilder.addAction(actionBuilder.
        setMutation(ProtobufUtil.toMutation(MutationType.DELETE, (Delete)row, mutationBuilder)));
    } else if (row instanceof Append) {
      regionActionBuilder.addAction(actionBuilder.setMutation(ProtobufUtil.toMutation(
          MutationType.APPEND, (Append)row, mutationBuilder, action.getNonce())));
    } else if (row instanceof Increment) {
      regionActionBuilder.addAction(actionBuilder.setMutation(
          ProtobufUtil.toMutation((Increment)row, mutationBuilder, action.getNonce())));
    } else if (row instanceof RegionCoprocessorServiceExec) {
      RegionCoprocessorServiceExec exec = (RegionCoprocessorServiceExec) row;
      regionActionBuilder.addAction(actionBuilder.setServiceCall(
          ClientProtos.CoprocessorServiceCall.newBuilder()
            .setRow(ByteStringer.wrap(exec.getRow()))
            .setServiceName(exec.getMethod().getService().getFullName())
            .setMethodName(exec.getMethod().getName())
            .setRequest(exec.getRequest().toByteString())));
    } else if (row instanceof RowMutations) {
      throw new UnsupportedOperationException("No RowMutations in multi calls; use mutateRow");
    } else {
      throw new DoNotRetryIOException("Multi doesn't support " + row.getClass().getName());
    }
  }
  return regionActionBuilder;
}
项目:ditb    文件:RequestConverter.java   
/**
 * Create a protocol buffer multirequest with NO data for a list of actions (data is carried
 * otherwise than via protobuf).  This means it just notes attributes, whether to write the
 * WAL, etc., and the presence in protobuf serves as place holder for the data which is
 * coming along otherwise.  Note that Get is different.  It does not contain 'data' and is always
 * carried by protobuf.  We return references to the data by adding them to the passed in
 * <code>data</code> param.
 *
 * <p>Propagates Actions original index.
 *
 * @param regionName
 * @param actions
 * @param cells Place to stuff references to actual data.
 * @return a multi request that does not carry any data.
 * @throws IOException
 */
public static <R> RegionAction.Builder buildNoDataRegionAction(final byte[] regionName,
    final List<Action<R>> actions, final List<CellScannable> cells,
    final RegionAction.Builder regionActionBuilder,
    final ClientProtos.Action.Builder actionBuilder,
    final MutationProto.Builder mutationBuilder) throws IOException {
  RegionAction.Builder builder = getRegionActionBuilderWithRegion(
    RegionAction.newBuilder(), regionName);
  for (Action<R> action: actions) {
    Row row = action.getAction();
    actionBuilder.clear();
    actionBuilder.setIndex(action.getOriginalIndex());
    mutationBuilder.clear();
    if (row instanceof Get) {
      Get g = (Get)row;
      builder.addAction(actionBuilder.setGet(ProtobufUtil.toGet(g)));
    } else if (row instanceof Put) {
      Put p = (Put)row;
      cells.add(p);
      builder.addAction(actionBuilder.
        setMutation(ProtobufUtil.toMutationNoData(MutationType.PUT, p, mutationBuilder)));
    } else if (row instanceof Delete) {
      Delete d = (Delete)row;
      int size = d.size();
      // Note that a legitimate Delete may have a size of zero; i.e. a Delete that has nothing
      // in it but the row to delete.  In this case, the current implementation does not make
      // a KeyValue to represent a delete-of-all-the-row until we serialize... For such cases
      // where the size returned is zero, we will send the Delete fully pb'd rather than have
      // metadata only in the pb and then send the kv along the side in cells.
      if (size > 0) {
        cells.add(d);
        builder.addAction(actionBuilder.
          setMutation(ProtobufUtil.toMutationNoData(MutationType.DELETE, d, mutationBuilder)));
      } else {
        builder.addAction(actionBuilder.
          setMutation(ProtobufUtil.toMutation(MutationType.DELETE, d, mutationBuilder)));
      }
    } else if (row instanceof Append) {
      Append a = (Append)row;
      cells.add(a);
      builder.addAction(actionBuilder.setMutation(ProtobufUtil.toMutationNoData(
        MutationType.APPEND, a, mutationBuilder, action.getNonce())));
    } else if (row instanceof Increment) {
      Increment i = (Increment)row;
      cells.add(i);
      builder.addAction(actionBuilder.setMutation(ProtobufUtil.toMutationNoData(
        MutationType.INCREMENT, i, mutationBuilder, action.getNonce())));
    } else if (row instanceof RegionCoprocessorServiceExec) {
      RegionCoprocessorServiceExec exec = (RegionCoprocessorServiceExec) row;
      builder.addAction(actionBuilder.setServiceCall(ClientProtos.CoprocessorServiceCall
          .newBuilder().setRow(ByteStringer.wrap(exec.getRow()))
          .setServiceName(exec.getMethod().getService().getFullName())
          .setMethodName(exec.getMethod().getName())
          .setRequest(exec.getRequest().toByteString())));
    } else if (row instanceof RowMutations) {
      throw new UnsupportedOperationException("No RowMutations in multi calls; use mutateRow");
    } else {
      throw new DoNotRetryIOException("Multi doesn't support " + row.getClass().getName());
    }
  }
  return builder;
}
项目:pbase    文件:RequestConverter.java   
/**
 * Create a protocol buffer multi request for a list of actions.
 * Propagates Actions original index.
 *
 * @param regionName
 * @param actions
 * @return a multi request
 * @throws IOException
 */
public static <R> RegionAction.Builder buildRegionAction(final byte[] regionName,
    final List<Action<R>> actions, final RegionAction.Builder regionActionBuilder,
    final ClientProtos.Action.Builder actionBuilder,
    final MutationProto.Builder mutationBuilder) throws IOException {
  for (Action<R> action: actions) {
    Row row = action.getAction();
    actionBuilder.clear();
    actionBuilder.setIndex(action.getOriginalIndex());
    mutationBuilder.clear();
    if (row instanceof Get) {
      Get g = (Get)row;
      regionActionBuilder.addAction(actionBuilder.setGet(ProtobufUtil.toGet(g)));
    } else if (row instanceof Put) {
      regionActionBuilder.addAction(actionBuilder.
        setMutation(ProtobufUtil.toMutation(MutationType.PUT, (Put)row, mutationBuilder)));
    } else if (row instanceof Delete) {
      regionActionBuilder.addAction(actionBuilder.
        setMutation(ProtobufUtil.toMutation(MutationType.DELETE, (Delete)row, mutationBuilder)));
    } else if (row instanceof Append) {
      regionActionBuilder.addAction(actionBuilder.setMutation(ProtobufUtil.toMutation(
          MutationType.APPEND, (Append)row, mutationBuilder, action.getNonce())));
    } else if (row instanceof Increment) {
      regionActionBuilder.addAction(actionBuilder.setMutation(
          ProtobufUtil.toMutation((Increment)row, mutationBuilder, action.getNonce())));
    } else if (row instanceof RegionCoprocessorServiceExec) {
      RegionCoprocessorServiceExec exec = (RegionCoprocessorServiceExec) row;
      regionActionBuilder.addAction(actionBuilder.setServiceCall(
          ClientProtos.CoprocessorServiceCall.newBuilder()
            .setRow(ByteStringer.wrap(exec.getRow()))
            .setServiceName(exec.getMethod().getService().getFullName())
            .setMethodName(exec.getMethod().getName())
            .setRequest(exec.getRequest().toByteString())));
    } else if (row instanceof RowMutations) {
      throw new UnsupportedOperationException("No RowMutations in multi calls; use mutateRow");
    } else {
      throw new DoNotRetryIOException("Multi doesn't support " + row.getClass().getName());
    }
  }
  return regionActionBuilder;
}
项目:HIndex    文件:RequestConverter.java   
/**
 * Create a protocol buffer multi request for a list of actions.
 * Propagates Actions original index.
 *
 * @param regionName
 * @param actions
 * @return a multi request
 * @throws IOException
 */
public static <R> RegionAction.Builder buildRegionAction(final byte[] regionName,
    final List<Action<R>> actions, final RegionAction.Builder regionActionBuilder,
    final ClientProtos.Action.Builder actionBuilder,
    final MutationProto.Builder mutationBuilder) throws IOException {
  for (Action<R> action: actions) {
    Row row = action.getAction();
    actionBuilder.clear();
    actionBuilder.setIndex(action.getOriginalIndex());
    mutationBuilder.clear();
    if (row instanceof Get) {
      Get g = (Get)row;
      regionActionBuilder.addAction(actionBuilder.setGet(ProtobufUtil.toGet(g)));
    } else if (row instanceof Put) {
      regionActionBuilder.addAction(actionBuilder.
        setMutation(ProtobufUtil.toMutation(MutationType.PUT, (Put)row, mutationBuilder)));
    } else if (row instanceof Delete) {
      regionActionBuilder.addAction(actionBuilder.
        setMutation(ProtobufUtil.toMutation(MutationType.DELETE, (Delete)row, mutationBuilder)));
    } else if (row instanceof Append) {
      regionActionBuilder.addAction(actionBuilder.setMutation(ProtobufUtil.toMutation(
          MutationType.APPEND, (Append)row, mutationBuilder, action.getNonce())));
    } else if (row instanceof Increment) {
      regionActionBuilder.addAction(actionBuilder.setMutation(
          ProtobufUtil.toMutation((Increment)row, mutationBuilder, action.getNonce())));
    } else if (row instanceof RegionCoprocessorServiceExec) {
      RegionCoprocessorServiceExec exec = (RegionCoprocessorServiceExec) row;
      regionActionBuilder.addAction(actionBuilder.setServiceCall(
          ClientProtos.CoprocessorServiceCall.newBuilder()
            .setRow(HBaseZeroCopyByteString.wrap(exec.getRow()))
            .setServiceName(exec.getMethod().getService().getFullName())
            .setMethodName(exec.getMethod().getName())
            .setRequest(exec.getRequest().toByteString())));
    } else if (row instanceof RowMutations) {
      throw new UnsupportedOperationException("No RowMutations in multi calls; use mutateRow");
    } else {
      throw new DoNotRetryIOException("Multi doesn't support " + row.getClass().getName());
    }
  }
  return regionActionBuilder;
}
项目:PyroDB    文件:RequestConverter.java   
/**
 * Create a protocol buffer multi request for a list of actions.
 * Propagates Actions original index.
 *
 * @param regionName
 * @param actions
 * @return a multi request
 * @throws IOException
 */
public static <R> RegionAction.Builder buildRegionAction(final byte[] regionName,
    final List<Action<R>> actions, final RegionAction.Builder regionActionBuilder,
    final ClientProtos.Action.Builder actionBuilder,
    final MutationProto.Builder mutationBuilder) throws IOException {
  for (Action<R> action: actions) {
    Row row = action.getAction();
    actionBuilder.clear();
    actionBuilder.setIndex(action.getOriginalIndex());
    mutationBuilder.clear();
    if (row instanceof Get) {
      Get g = (Get)row;
      regionActionBuilder.addAction(actionBuilder.setGet(ProtobufUtil.toGet(g)));
    } else if (row instanceof Put) {
      regionActionBuilder.addAction(actionBuilder.
        setMutation(ProtobufUtil.toMutation(MutationType.PUT, (Put)row, mutationBuilder)));
    } else if (row instanceof Delete) {
      regionActionBuilder.addAction(actionBuilder.
        setMutation(ProtobufUtil.toMutation(MutationType.DELETE, (Delete)row, mutationBuilder)));
    } else if (row instanceof Append) {
      regionActionBuilder.addAction(actionBuilder.setMutation(ProtobufUtil.toMutation(
          MutationType.APPEND, (Append)row, mutationBuilder, action.getNonce())));
    } else if (row instanceof Increment) {
      regionActionBuilder.addAction(actionBuilder.setMutation(
          ProtobufUtil.toMutation((Increment)row, mutationBuilder, action.getNonce())));
    } else if (row instanceof RegionCoprocessorServiceExec) {
      RegionCoprocessorServiceExec exec = (RegionCoprocessorServiceExec) row;
      regionActionBuilder.addAction(actionBuilder.setServiceCall(
          ClientProtos.CoprocessorServiceCall.newBuilder()
            .setRow(HBaseZeroCopyByteString.wrap(exec.getRow()))
            .setServiceName(exec.getMethod().getService().getFullName())
            .setMethodName(exec.getMethod().getName())
            .setRequest(exec.getRequest().toByteString())));
    } else if (row instanceof RowMutations) {
      throw new UnsupportedOperationException("No RowMutations in multi calls; use mutateRow");
    } else {
      throw new DoNotRetryIOException("Multi doesn't support " + row.getClass().getName());
    }
  }
  return regionActionBuilder;
}