/** * @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0. * Use {@link Row#COMPARATOR} instead */ @Deprecated @Override public int compareTo(Row i) { return Bytes.compareTo(this.getRow(), i.getRow()); }
@Override public void run(MultiResponse resp) { if (controller.failed()) { future.completeExceptionally(controller.getFailed()); } else { try { org.apache.hadoop.hbase.client.MultiResponse multiResp = ResponseConverter.getResults(req, resp, controller.cellScanner()); Throwable ex = multiResp.getException(regionName); if (ex != null) { future.completeExceptionally(ex instanceof IOException ? ex : new IOException( "Failed to mutate row: " + Bytes.toStringBinary(mutation.getRow()), ex)); } else { future.complete(respConverter .apply((Result) multiResp.getResults().get(regionName).result.get(0))); } } catch (IOException e) { future.completeExceptionally(e); } } } });
public static TRowMutations rowMutationsFromHBase(RowMutations in) { TRowMutations tRowMutations = new TRowMutations(); tRowMutations.setRow(in.getRow()); for (Mutation mutation : in.getMutations()) { TMutation tMutation = new TMutation(); if (mutation instanceof Put) { tMutation.setPut(ThriftUtilities.putFromHBase((Put)mutation)); } else if (mutation instanceof Delete) { tMutation.setDeleteSingle(ThriftUtilities.deleteFromHBase((Delete)mutation)); } else { throw new IllegalArgumentException( "Only Put and Delete is supported in mutateRow, but muation=" + mutation); } tRowMutations.addToMutations(tMutation); } return tRowMutations; }
@Override protected MultiResponse rpcCall() throws Exception { CompareType compareType = CompareType.valueOf(opName); MultiRequest request = RequestConverter .buildMutateRequest(getLocation().getRegionInfo().getRegionName(), row, family, qualifier, new BinaryComparator(value), compareType, timeRange, rm); ClientProtos.MultiResponse response = doMulti(request); ClientProtos.RegionActionResult res = response.getRegionActionResultList().get(0); if (res.hasException()) { Throwable ex = ProtobufUtil.toException(res.getException()); if (ex instanceof IOException) { throw (IOException) ex; } throw new IOException( "Failed to checkAndMutate row: " + Bytes.toStringBinary(rm.getRow()), ex); } return ResponseConverter.getResults(request, response, getRpcControllerCellScanner()); } };
@Override protected MultiResponse rpcCall() throws Exception { RegionAction.Builder regionMutationBuilder = RequestConverter.buildRegionAction( getLocation().getRegionInfo().getRegionName(), rm); regionMutationBuilder.setAtomic(true); MultiRequest request = MultiRequest.newBuilder().addRegionAction(regionMutationBuilder.build()).build(); ClientProtos.MultiResponse response = doMulti(request); ClientProtos.RegionActionResult res = response.getRegionActionResultList().get(0); if (res.hasException()) { Throwable ex = ProtobufUtil.toException(res.getException()); if (ex instanceof IOException) { throw (IOException) ex; } throw new IOException("Failed to mutate row: " + Bytes.toStringBinary(rm.getRow()), ex); } return ResponseConverter.getResults(request, response, getRpcControllerCellScanner()); } };
rm.add(new Put(rm.getRow()).addColumn(FAMILY, null, new byte[CELL_SIZE])); batches.add(rm); try (AsyncConnection asyncConnection = ConnectionFactory
rm.add(new Put(rm.getRow()).addColumn(FAMILY, null, new byte[CELL_SIZE])); batches.add(rm); Object[] results = new Object[batches.size()];
throws IOException { CancellableRegionServerCallable<MultiResponse> callable = new CancellableRegionServerCallable<MultiResponse>(connection, getName(), rm.getRow(), rpcControllerFactory.newController(), writeRpcTimeoutMs, new RetryingTimeTracker().start(), rm.getMaxPriority()) {
public void testAtomicOperations() throws Exception { RowMutations rm = new RowMutations(Bytes.toBytes("fail")); rm.add(new Put(rm.getRow()).addColumn(FAMILY, null, new byte[CELL_SIZE])); rm.add(new Put(rm.getRow()).addColumn(FAMILY, null, new byte[10])); Put put = new Put(Bytes.toBytes("good")).addColumn(FAMILY, null, new byte[10]);
@Override public void mutateRow(final RowMutations rm) throws IOException { CancellableRegionServerCallable<MultiResponse> callable = new CancellableRegionServerCallable<MultiResponse>(this.connection, getName(), rm.getRow(), rpcControllerFactory.newController(), writeRpcTimeoutMs, new RetryingTimeTracker().start(), rm.getMaxPriority()) {
/** * @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0. * Use {@link Row#COMPARATOR} instead */ @Deprecated @Override public int compareTo(Row i) { return Bytes.compareTo(this.getRow(), i.getRow()); }
ClientProtos.MutationProto.Builder mutationBuilder = ClientProtos.MutationProto.newBuilder(); ClientProtos.Condition condition = RequestConverter .buildCondition(rm.getRow(), FAMILY, null, new BinaryComparator(new byte[10]), HBaseProtos.CompareType.EQUAL, null); for (Mutation mutation : rm.getMutations()) {
@Override public void run(MultiResponse resp) { if (controller.failed()) { future.completeExceptionally(controller.getFailed()); } else { try { org.apache.hadoop.hbase.client.MultiResponse multiResp = ResponseConverter.getResults(req, resp, controller.cellScanner()); Throwable ex = multiResp.getException(regionName); if (ex != null) { future.completeExceptionally(ex instanceof IOException ? ex : new IOException( "Failed to mutate row: " + Bytes.toStringBinary(mutation.getRow()), ex)); } else { future.complete(respConverter .apply((Result) multiResp.getResults().get(regionName).result.get(0))); } } catch (IOException e) { future.completeExceptionally(e); } } } });
@Override protected MultiResponse rpcCall() throws Exception { CompareType compareType = CompareType.valueOf(opName); MultiRequest request = RequestConverter .buildMutateRequest(getLocation().getRegionInfo().getRegionName(), row, family, qualifier, new BinaryComparator(value), compareType, timeRange, rm); ClientProtos.MultiResponse response = doMulti(request); ClientProtos.RegionActionResult res = response.getRegionActionResultList().get(0); if (res.hasException()) { Throwable ex = ProtobufUtil.toException(res.getException()); if (ex instanceof IOException) { throw (IOException) ex; } throw new IOException( "Failed to checkAndMutate row: " + Bytes.toStringBinary(rm.getRow()), ex); } return ResponseConverter.getResults(request, response, getRpcControllerCellScanner()); } };
@Override protected MultiResponse rpcCall() throws Exception { RegionAction.Builder regionMutationBuilder = RequestConverter.buildRegionAction( getLocation().getRegionInfo().getRegionName(), rm); regionMutationBuilder.setAtomic(true); MultiRequest request = MultiRequest.newBuilder().addRegionAction(regionMutationBuilder.build()).build(); ClientProtos.MultiResponse response = doMulti(request); ClientProtos.RegionActionResult res = response.getRegionActionResultList().get(0); if (res.hasException()) { Throwable ex = ProtobufUtil.toException(res.getException()); if (ex instanceof IOException) { throw (IOException) ex; } throw new IOException("Failed to mutate row: " + Bytes.toStringBinary(rm.getRow()), ex); } return ResponseConverter.getResults(request, response, getRpcControllerCellScanner()); } };
throws IOException { CancellableRegionServerCallable<MultiResponse> callable = new CancellableRegionServerCallable<MultiResponse>(connection, getName(), rm.getRow(), rpcControllerFactory.newController(), writeRpcTimeoutMs, new RetryingTimeTracker().start(), rm.getMaxPriority()) {
@Override public void mutateRow(final RowMutations rm) throws IOException { CancellableRegionServerCallable<MultiResponse> callable = new CancellableRegionServerCallable<MultiResponse>(this.connection, getName(), rm.getRow(), rpcControllerFactory.newController(), writeRpcTimeoutMs, new RetryingTimeTracker().start(), rm.getMaxPriority()) {
@Override public void mutateRow(RowMutations rm) throws IOException { // Don't need nonces here - RowMutations only supports puts and deletes mutateRowsWithLocks(rm.getMutations(), Collections.singleton(rm.getRow())); }
/** * <p>adapt.</p> * * @param mutations a {@link org.apache.hadoop.hbase.client.RowMutations} object. * @return a {@link RowMutation} object. */ public RowMutation adapt(RowMutations mutations) { RowMutation rowMutation = newRowMutationModel(mutations.getRow()); adapt(mutations, rowMutation); return rowMutation; }
/** * <p>adaptEntry.</p> * * @param mutations a {@link org.apache.hadoop.hbase.client.RowMutations} object. * @return a {@link com.google.bigtable.v2.MutateRowsRequest.Entry} object. */ public MutateRowsRequest.Entry adaptEntry(RowMutations mutations) { RowMutation rowMutation = newRowMutationModel(mutations.getRow()); adapt(mutations, rowMutation); return toEntry(rowMutation); }