Search in sources :

Example 1 with MutateResponse

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

the class HTable method incrementColumnValue.

/**
   * {@inheritDoc}
   */
@Override
public long incrementColumnValue(final byte[] row, final byte[] family, final byte[] qualifier, final long amount, final Durability durability) throws IOException {
    NullPointerException npe = null;
    if (row == null) {
        npe = new NullPointerException("row is null");
    } else if (family == null) {
        npe = new NullPointerException("family is null");
    } else if (qualifier == null) {
        npe = new NullPointerException("qualifier is null");
    }
    if (npe != null) {
        throw new IOException("Invalid arguments to incrementColumnValue", npe);
    }
    NoncedRegionServerCallable<Long> callable = new NoncedRegionServerCallable<Long>(this.connection, getName(), row, this.rpcControllerFactory.newController()) {

        @Override
        protected Long rpcCall() throws Exception {
            MutateRequest request = RequestConverter.buildIncrementRequest(getLocation().getRegionInfo().getRegionName(), row, family, qualifier, amount, durability, getNonceGroup(), getNonce());
            MutateResponse response = doMutate(request);
            Result result = ProtobufUtil.toResult(response.getResult(), getRpcControllerCellScanner());
            return Long.valueOf(Bytes.toLong(result.getValue(family, qualifier)));
        }
    };
    return rpcCallerFactory.<Long>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) InterruptedIOException(java.io.InterruptedIOException) IOException(java.io.IOException)

Example 2 with MutateResponse

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

the class HTable method delete.

/**
   * {@inheritDoc}
   */
@Override
public void delete(final Delete delete) throws IOException {
    CancellableRegionServerCallable<SingleResponse> callable = new CancellableRegionServerCallable<SingleResponse>(connection, getName(), delete.getRow(), this.rpcControllerFactory.newController(), writeRpcTimeout, new RetryingTimeTracker().start()) {

        @Override
        protected SingleResponse rpcCall() throws Exception {
            MutateRequest request = RequestConverter.buildMutateRequest(getLocation().getRegionInfo().getRegionName(), delete);
            MutateResponse response = doMutate(request);
            return ResponseConverter.getResult(request, response, getRpcControllerCellScanner());
        }
    };
    List<Delete> rows = Collections.singletonList(delete);
    AsyncProcessTask task = AsyncProcessTask.newBuilder().setPool(pool).setTableName(tableName).setRowAccess(rows).setCallable(callable).setRpcTimeout(writeRpcTimeout).setOperationTimeout(operationTimeout).setSubmittedRows(AsyncProcessTask.SubmittedRows.ALL).build();
    AsyncRequestFuture ars = multiAp.submit(task);
    ars.waitUntilDone();
    if (ars.hasError()) {
        throw ars.getErrors();
    }
}
Also used : MutateResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.MutateResponse) MutateRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.MutateRequest)

Example 3 with MutateResponse

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

the class HTable method checkAndDelete.

/**
   * {@inheritDoc}
   */
@Override
public boolean checkAndDelete(final byte[] row, final byte[] family, final byte[] qualifier, final CompareOp compareOp, final byte[] value, final Delete delete) throws IOException {
    CancellableRegionServerCallable<SingleResponse> callable = new CancellableRegionServerCallable<SingleResponse>(this.connection, getName(), row, this.rpcControllerFactory.newController(), writeRpcTimeout, new RetryingTimeTracker().start()) {

        @Override
        protected SingleResponse rpcCall() throws Exception {
            CompareType compareType = CompareType.valueOf(compareOp.name());
            MutateRequest request = RequestConverter.buildMutateRequest(getLocation().getRegionInfo().getRegionName(), row, family, qualifier, new BinaryComparator(value), compareType, delete);
            MutateResponse response = doMutate(request);
            return ResponseConverter.getResult(request, response, getRpcControllerCellScanner());
        }
    };
    List<Delete> rows = Collections.singletonList(delete);
    Object[] results = new Object[1];
    AsyncProcessTask task = AsyncProcessTask.newBuilder().setPool(pool).setTableName(tableName).setRowAccess(rows).setCallable(callable).setRpcTimeout(Math.max(readRpcTimeout, writeRpcTimeout)).setOperationTimeout(operationTimeout).setSubmittedRows(AsyncProcessTask.SubmittedRows.ALL).setResults(results).build();
    AsyncRequestFuture ars = multiAp.submit(task);
    ars.waitUntilDone();
    if (ars.hasError()) {
        throw ars.getErrors();
    }
    return ((SingleResponse.Entry) results[0]).isProcessed();
}
Also used : MutateRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.MutateRequest) CompareType(org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.CompareType) BinaryComparator(org.apache.hadoop.hbase.filter.BinaryComparator) MutateResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.MutateResponse)

Example 4 with MutateResponse

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

the class HTable method increment.

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

        @Override
        protected Result rpcCall() throws Exception {
            MutateRequest request = RequestConverter.buildMutateRequest(getLocation().getRegionInfo().getRegionName(), increment, getNonceGroup(), getNonce());
            MutateResponse response = doMutate(request);
            // Should this check for null like append does?
            return ProtobufUtil.toResult(response.getResult(), getRpcControllerCellScanner());
        }
    };
    return rpcCallerFactory.<Result>newCaller(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 5 with MutateResponse

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

the class HTable method checkAndPut.

/**
   * {@inheritDoc}
   */
@Override
public boolean checkAndPut(final byte[] row, final byte[] family, final byte[] qualifier, final CompareOp compareOp, final byte[] value, final Put put) throws IOException {
    ClientServiceCallable<Boolean> callable = new ClientServiceCallable<Boolean>(this.connection, getName(), row, this.rpcControllerFactory.newController()) {

        @Override
        protected Boolean rpcCall() throws Exception {
            CompareType compareType = CompareType.valueOf(compareOp.name());
            MutateRequest request = RequestConverter.buildMutateRequest(getLocation().getRegionInfo().getRegionName(), row, family, qualifier, new BinaryComparator(value), compareType, put);
            MutateResponse response = doMutate(request);
            return Boolean.valueOf(response.getProcessed());
        }
    };
    return rpcCallerFactory.<Boolean>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) CompareType(org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.CompareType) BinaryComparator(org.apache.hadoop.hbase.filter.BinaryComparator)

Aggregations

MutateResponse (org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.MutateResponse)10 MutateRequest (org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.MutateRequest)9 IOException (java.io.IOException)4 BinaryComparator (org.apache.hadoop.hbase.filter.BinaryComparator)3 HBaseRpcController (org.apache.hadoop.hbase.ipc.HBaseRpcController)3 MutationProto (org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.MutationProto)3 RegionActionResult (org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.RegionActionResult)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 ClientProtos (org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos)2 GetRequest (org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.GetRequest)2 ColumnValue (org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.MutationProto.ColumnValue)2 QualifierValue (org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.MutationProto.ColumnValue.QualifierValue)2 ScanRequest (org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.ScanRequest)2 CompareType (org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.CompareType)2 RpcCallback (org.apache.hbase.thirdparty.com.google.protobuf.RpcCallback)2