Search in sources :

Example 11 with MutateRequest

use of org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.MutateRequest in project hbase by apache.

the class HTable method append.

/**
   * {@inheritDoc}
   */
@Override
public Result append(final Append append) throws IOException {
    checkHasFamilies(append);
    NoncedRegionServerCallable<Result> callable = new NoncedRegionServerCallable<Result>(this.connection, getName(), append.getRow(), this.rpcControllerFactory.newController()) {

        @Override
        protected Result rpcCall() throws Exception {
            MutateRequest request = RequestConverter.buildMutateRequest(getLocation().getRegionInfo().getRegionName(), append, getNonceGroup(), getNonce());
            MutateResponse response = doMutate(request);
            if (!response.hasResult())
                return null;
            return ProtobufUtil.toResult(response.getResult(), getRpcControllerCellScanner());
        }
    };
    return rpcCallerFactory.<Result>newCaller(this.writeRpcTimeout).callWithRetries(callable, this.operationTimeout);
}
Also used : MutateResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.MutateResponse) MutateRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.MutateRequest)

Example 12 with MutateRequest

use of org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.MutateRequest in project hbase by apache.

the class RequestConverter method buildIncrementRequest.

/**
   * Create a protocol buffer MutateRequest for a client increment
   *
   * @param regionName
   * @param row
   * @param family
   * @param qualifier
   * @param amount
   * @param durability
   * @return a mutate request
   */
public static MutateRequest buildIncrementRequest(final byte[] regionName, final byte[] row, final byte[] family, final byte[] qualifier, final long amount, final Durability durability, long nonceGroup, long nonce) {
    MutateRequest.Builder builder = MutateRequest.newBuilder();
    RegionSpecifier region = buildRegionSpecifier(RegionSpecifierType.REGION_NAME, regionName);
    builder.setRegion(region);
    MutationProto.Builder mutateBuilder = MutationProto.newBuilder();
    mutateBuilder.setRow(UnsafeByteOperations.unsafeWrap(row));
    mutateBuilder.setMutateType(MutationType.INCREMENT);
    mutateBuilder.setDurability(ProtobufUtil.toDurability(durability));
    ColumnValue.Builder columnBuilder = ColumnValue.newBuilder();
    columnBuilder.setFamily(UnsafeByteOperations.unsafeWrap(family));
    QualifierValue.Builder valueBuilder = QualifierValue.newBuilder();
    valueBuilder.setValue(UnsafeByteOperations.unsafeWrap(Bytes.toBytes(amount)));
    valueBuilder.setQualifier(UnsafeByteOperations.unsafeWrap(qualifier));
    columnBuilder.addQualifierValue(valueBuilder.build());
    mutateBuilder.addColumnValue(columnBuilder.build());
    if (nonce != HConstants.NO_NONCE) {
        mutateBuilder.setNonce(nonce);
    }
    builder.setMutation(mutateBuilder.build());
    if (nonceGroup != HConstants.NO_NONCE) {
        builder.setNonceGroup(nonceGroup);
    }
    return builder.build();
}
Also used : MutateRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.MutateRequest) QualifierValue(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.MutationProto.ColumnValue.QualifierValue) ColumnValue(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.MutationProto.ColumnValue) MutationProto(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.MutationProto) RegionSpecifier(org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.RegionSpecifier)

Example 13 with MutateRequest

use of org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.MutateRequest in project hbase by apache.

the class RequestConverter method buildMutateRequest.

/**
 * Create a protocol buffer MutateRequest for an append
 *
 * @param regionName
 * @param append
 * @return a mutate request
 * @throws IOException
 */
public static MutateRequest buildMutateRequest(final byte[] regionName, final Append append, long nonceGroup, long nonce) throws IOException {
    MutateRequest.Builder builder = MutateRequest.newBuilder();
    RegionSpecifier region = buildRegionSpecifier(RegionSpecifierType.REGION_NAME, regionName);
    builder.setRegion(region);
    if (nonce != HConstants.NO_NONCE && nonceGroup != HConstants.NO_NONCE) {
        builder.setNonceGroup(nonceGroup);
    }
    builder.setMutation(ProtobufUtil.toMutation(MutationType.APPEND, append, MutationProto.newBuilder(), nonce));
    return builder.build();
}
Also used : MutateRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.MutateRequest) RegionSpecifier(org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.RegionSpecifier)

Example 14 with MutateRequest

use of org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.MutateRequest in project hbase by apache.

the class RequestConverter method buildMutateRequest.

/**
 * Create a protocol buffer MutateRequest for a delete
 *
 * @param regionName
 * @param delete
 * @return a mutate request
 * @throws IOException
 */
public static MutateRequest buildMutateRequest(final byte[] regionName, final Delete delete) throws IOException {
    MutateRequest.Builder builder = MutateRequest.newBuilder();
    RegionSpecifier region = buildRegionSpecifier(RegionSpecifierType.REGION_NAME, regionName);
    builder.setRegion(region);
    builder.setMutation(ProtobufUtil.toMutation(MutationType.DELETE, delete, MutationProto.newBuilder()));
    return builder.build();
}
Also used : MutateRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.MutateRequest) RegionSpecifier(org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.RegionSpecifier)

Example 15 with MutateRequest

use of org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.MutateRequest in project hbase by apache.

the class RequestConverter method buildMutateRequest.

/**
 * Create a protocol buffer MutateRequest for a client increment
 *
 * @param regionName
 * @param increment
 * @return a mutate request
 */
public static MutateRequest buildMutateRequest(final byte[] regionName, final Increment increment, final long nonceGroup, final long nonce) throws IOException {
    MutateRequest.Builder builder = MutateRequest.newBuilder();
    RegionSpecifier region = buildRegionSpecifier(RegionSpecifierType.REGION_NAME, regionName);
    builder.setRegion(region);
    if (nonce != HConstants.NO_NONCE && nonceGroup != HConstants.NO_NONCE) {
        builder.setNonceGroup(nonceGroup);
    }
    builder.setMutation(ProtobufUtil.toMutation(MutationType.INCREMENT, increment, MutationProto.newBuilder(), nonce));
    return builder.build();
}
Also used : MutateRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.MutateRequest) RegionSpecifier(org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.RegionSpecifier)

Aggregations

MutateRequest (org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.MutateRequest)18 MutateResponse (org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.MutateResponse)9 RegionSpecifier (org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.RegionSpecifier)7 MutationProto (org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.MutationProto)4 IOException (java.io.IOException)3 BinaryComparator (org.apache.hadoop.hbase.filter.BinaryComparator)3 GetRequest (org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.GetRequest)3 ColumnValue (org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.MutationProto.ColumnValue)3 QualifierValue (org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.MutationProto.ColumnValue.QualifierValue)3 ScanRequest (org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.ScanRequest)3 CompletableFuture (java.util.concurrent.CompletableFuture)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 Cell (org.apache.hadoop.hbase.Cell)2 HRegionLocation (org.apache.hadoop.hbase.HRegionLocation)2 ServerName (org.apache.hadoop.hbase.ServerName)2 TableName (org.apache.hadoop.hbase.TableName)2 HBaseRpcController (org.apache.hadoop.hbase.ipc.HBaseRpcController)2 ClientProtos (org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos)2 Condition (org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.Condition)2 RegionActionResult (org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.RegionActionResult)2