try (Table table = con.getTable(tableName)) { MultiRowMutationProtos.MutateRowsRequest request = MultiRowMutationProtos.MutateRowsRequest.newBuilder() .addMutationRequest(org.apache.hadoop.hbase.protobuf.ProtobufUtil.toMutation( org.apache.hadoop.hbase.protobuf.generated.ClientProtos.MutationProto.MutationType.PUT, put1))
List<MutationProto> mutateRequestList = request.getMutationRequestList(); List<Mutation> mutations = new ArrayList<>(mutateRequestList.size()); for (MutationProto m : mutateRequestList) { long nonceGroup = request.hasNonceGroup() ? request.getNonceGroup() : HConstants.NO_NONCE; long nonce = request.hasNonce() ? request.getNonce() : HConstants.NO_NONCE; env.getRegion().mutateRowsWithLocks(mutations, rowsToLock, nonceGroup, nonce); } catch (IOException e) {
public org.apache.hadoop.hbase.protobuf.generated.MultiRowMutationProtos.MutateRowsRequest buildPartial() { org.apache.hadoop.hbase.protobuf.generated.MultiRowMutationProtos.MutateRowsRequest result = new org.apache.hadoop.hbase.protobuf.generated.MultiRowMutationProtos.MutateRowsRequest(this); int from_bitField0_ = bitField0_; int to_bitField0_ = 0;
try (Table table = con.getTable(tableName)) { MultiRowMutationProtos.MutateRowsRequest request = MultiRowMutationProtos.MutateRowsRequest.newBuilder() .addMutationRequest(org.apache.hadoop.hbase.protobuf.ProtobufUtil.toMutation( org.apache.hadoop.hbase.protobuf.generated.ClientProtos.MutationProto.MutationType.PUT, put1))
public Builder mergeFrom(org.apache.hadoop.hbase.protobuf.generated.MultiRowMutationProtos.MutateRowsRequest other) { if (other == org.apache.hadoop.hbase.protobuf.generated.MultiRowMutationProtos.MutateRowsRequest.getDefaultInstance()) return this; if (mutationRequestBuilder_ == null) { if (!other.mutationRequest_.isEmpty()) { if (other.hasNonceGroup()) { setNonceGroup(other.getNonceGroup()); if (other.hasNonce()) { setNonce(other.getNonce()); if (other.hasRegion()) { mergeRegion(other.getRegion()); this.mergeUnknownFields(other.getUnknownFields()); return this;
public Builder mergeFrom(org.apache.hadoop.hbase.protobuf.generated.MultiRowMutationProtos.MutateRowsRequest other) { if (other == org.apache.hadoop.hbase.protobuf.generated.MultiRowMutationProtos.MutateRowsRequest.getDefaultInstance()) return this; if (mutationRequestBuilder_ == null) { if (!other.mutationRequest_.isEmpty()) { if (other.hasNonceGroup()) { setNonceGroup(other.getNonceGroup()); if (other.hasNonce()) { setNonce(other.getNonce()); this.mergeUnknownFields(other.getUnknownFields()); return this;
public Builder mergeFrom(org.apache.hadoop.hbase.protobuf.generated.MultiRowMutationProtos.MutateRowsRequest other) { if (other == org.apache.hadoop.hbase.protobuf.generated.MultiRowMutationProtos.MutateRowsRequest.getDefaultInstance()) return this; if (mutationRequestBuilder_ == null) { if (!other.mutationRequest_.isEmpty()) { if (other.hasNonceGroup()) { setNonceGroup(other.getNonceGroup()); if (other.hasNonce()) { setNonce(other.getNonce()); if (other.hasRegion()) { mergeRegion(other.getRegion()); this.mergeUnknownFields(other.getUnknownFields()); return this;
public org.apache.hadoop.hbase.protobuf.generated.MultiRowMutationProtos.MutateRowsRequest buildPartial() { org.apache.hadoop.hbase.protobuf.generated.MultiRowMutationProtos.MutateRowsRequest result = new org.apache.hadoop.hbase.protobuf.generated.MultiRowMutationProtos.MutateRowsRequest(this); int from_bitField0_ = bitField0_; int to_bitField0_ = 0;
List<MutationProto> mutateRequestList = request.getMutationRequestList(); List<Mutation> mutations = new ArrayList<Mutation>(mutateRequestList.size()); for (MutationProto m : mutateRequestList) { long nonceGroup = request.hasNonceGroup() ? request.getNonceGroup() : HConstants.NO_NONCE; long nonce = request.hasNonce() ? request.getNonce() : HConstants.NO_NONCE; env.getRegion().mutateRowsWithLocks(mutations, rowsToLock, nonceGroup, nonce); } catch (IOException e) {
MutateRowsRequest.Builder mrmBuilder = MutateRowsRequest.newBuilder();
/** * Performs an atomic multi-Mutate operation against the given table. */ private static void multiMutate(Table table, byte[] row, Mutation... mutations) throws IOException { CoprocessorRpcChannel channel = table.coprocessorService(row); MultiRowMutationProtos.MutateRowsRequest.Builder mmrBuilder = MultiRowMutationProtos.MutateRowsRequest.newBuilder(); for (Mutation mutation : mutations) { if (mutation instanceof Put) { mmrBuilder.addMutationRequest(ProtobufUtil.toMutation( ClientProtos.MutationProto.MutationType.PUT, mutation)); } else if (mutation instanceof Delete) { mmrBuilder.addMutationRequest(ProtobufUtil.toMutation( ClientProtos.MutationProto.MutationType.DELETE, mutation)); } else { throw new DoNotRetryIOException("multi in MetaEditor doesn't support " + mutation.getClass().getName()); } } MultiRowMutationProtos.MultiRowMutationService.BlockingInterface service = MultiRowMutationProtos.MultiRowMutationService.newBlockingStub(channel); try { service.mutateRows(null, mmrBuilder.build()); } catch (ServiceException ex) { ProtobufUtil.toIOException(ex); } }
public org.apache.hadoop.hbase.protobuf.generated.MultiRowMutationProtos.MutateRowsRequest buildPartial() { org.apache.hadoop.hbase.protobuf.generated.MultiRowMutationProtos.MutateRowsRequest result = new org.apache.hadoop.hbase.protobuf.generated.MultiRowMutationProtos.MutateRowsRequest(this); int from_bitField0_ = bitField0_; int to_bitField0_ = 0;
@Override protected MutateRowsResponse rpcCall() throws Exception { final MutateRowsRequest.Builder builder = MutateRowsRequest.newBuilder(); for (Mutation mutation : mutations) { if (mutation instanceof Put) { builder.addMutationRequest(ProtobufUtil.toMutation( ClientProtos.MutationProto.MutationType.PUT, mutation)); } else if (mutation instanceof Delete) { builder.addMutationRequest(ProtobufUtil.toMutation( ClientProtos.MutationProto.MutationType.DELETE, mutation)); } else { throw new DoNotRetryIOException("multi in MetaEditor doesn't support " + mutation.getClass().getName()); } } // The call to #prepare that ran before this invocation will have populated HRegionLocation. HRegionLocation hrl = getLocation(); RegionSpecifier region = ProtobufUtil.buildRegionSpecifier( RegionSpecifierType.REGION_NAME, hrl.getRegion().getRegionName()); builder.setRegion(region); // The rpcController here is awkward. The Coprocessor Endpoint wants an instance of a // com.google.protobuf but we are going over an rpc that is all shaded protobuf so it // wants a org.apache.h.h.shaded.com.google.protobuf.RpcController. Set up a factory // that makes com.google.protobuf.RpcController and then copy into it configs. return getStub().mutateRows(null, builder.build()); }
result = result && getMutationRequestList() .equals(other.getMutationRequestList()); result = result && (hasNonceGroup() == other.hasNonceGroup()); if (hasNonceGroup()) { result = result && (getNonceGroup() == other.getNonceGroup()); result = result && (hasNonce() == other.hasNonce()); if (hasNonce()) { result = result && (getNonce() == other.getNonce()); result = result && (hasRegion() == other.hasRegion()); if (hasRegion()) { result = result && getRegion() .equals(other.getRegion()); getUnknownFields().equals(other.getUnknownFields()); return result;
private void multiMutate(List<Mutation> mutations) throws IOException { CoprocessorRpcChannel channel = rsGroupTable.coprocessorService(ROW_KEY); MultiRowMutationProtos.MutateRowsRequest.Builder mmrBuilder = MultiRowMutationProtos.MutateRowsRequest.newBuilder(); for (Mutation mutation : mutations) { if (mutation instanceof Put) { mmrBuilder.addMutationRequest(org.apache.hadoop.hbase.protobuf.ProtobufUtil.toMutation( org.apache.hadoop.hbase.protobuf.generated.ClientProtos.MutationProto.MutationType.PUT, mutation)); } else if (mutation instanceof Delete) { mmrBuilder.addMutationRequest( org.apache.hadoop.hbase.protobuf.ProtobufUtil.toMutation( org.apache.hadoop.hbase.protobuf.generated.ClientProtos.MutationProto. MutationType.DELETE, mutation)); } else { throw new DoNotRetryIOException("multiMutate doesn't support " + mutation.getClass().getName()); } } MultiRowMutationProtos.MultiRowMutationService.BlockingInterface service = MultiRowMutationProtos.MultiRowMutationService.newBlockingStub(channel); try { service.mutateRows(null, mmrBuilder.build()); } catch (ServiceException ex) { ProtobufUtil.toIOException(ex); } }
private void multiMutate(List<Mutation> mutations) throws IOException { CoprocessorRpcChannel channel = rsGroupTable.coprocessorService(ROW_KEY); MultiRowMutationProtos.MutateRowsRequest.Builder mmrBuilder = MultiRowMutationProtos.MutateRowsRequest.newBuilder(); for (Mutation mutation : mutations) { if (mutation instanceof Put) { mmrBuilder.addMutationRequest(org.apache.hadoop.hbase.protobuf.ProtobufUtil.toMutation( org.apache.hadoop.hbase.protobuf.generated.ClientProtos.MutationProto.MutationType.PUT, mutation)); } else if (mutation instanceof Delete) { mmrBuilder.addMutationRequest( org.apache.hadoop.hbase.protobuf.ProtobufUtil.toMutation( org.apache.hadoop.hbase.protobuf.generated.ClientProtos.MutationProto. MutationType.DELETE, mutation)); } else { throw new DoNotRetryIOException("multiMutate doesn't support " + mutation.getClass().getName()); } } MultiRowMutationProtos.MultiRowMutationService.BlockingInterface service = MultiRowMutationProtos.MultiRowMutationService.newBlockingStub(channel); try { service.mutateRows(null, mmrBuilder.build()); } catch (ServiceException ex) { ProtobufUtil.toIOException(ex); } }
public org.apache.hadoop.hbase.protobuf.generated.MultiRowMutationProtos.MutateRowsRequest buildPartial() { org.apache.hadoop.hbase.protobuf.generated.MultiRowMutationProtos.MutateRowsRequest result = new org.apache.hadoop.hbase.protobuf.generated.MultiRowMutationProtos.MutateRowsRequest(this); int from_bitField0_ = bitField0_; int to_bitField0_ = 0; if (mutationRequestBuilder_ == null) { if (((bitField0_ & 0x00000001) == 0x00000001)) { mutationRequest_ = java.util.Collections.unmodifiableList(mutationRequest_); bitField0_ = (bitField0_ & ~0x00000001); } result.mutationRequest_ = mutationRequest_; } else { result.mutationRequest_ = mutationRequestBuilder_.build(); } if (((from_bitField0_ & 0x00000002) == 0x00000002)) { to_bitField0_ |= 0x00000001; } result.nonceGroup_ = nonceGroup_; if (((from_bitField0_ & 0x00000004) == 0x00000004)) { to_bitField0_ |= 0x00000002; } result.nonce_ = nonce_; result.bitField0_ = to_bitField0_; onBuilt(); return result; }
result = result && getMutationRequestList() .equals(other.getMutationRequestList()); result = result && (hasNonceGroup() == other.hasNonceGroup()); if (hasNonceGroup()) { result = result && (getNonceGroup() == other.getNonceGroup()); result = result && (hasNonce() == other.hasNonce()); if (hasNonce()) { result = result && (getNonce() == other.getNonce()); result = result && (hasRegion() == other.hasRegion()); if (hasRegion()) { result = result && getRegion() .equals(other.getRegion()); getUnknownFields().equals(other.getUnknownFields()); return result;
@java.lang.Override public boolean equals(final java.lang.Object obj) { if (obj == this) { return true; } if (!(obj instanceof org.apache.hadoop.hbase.protobuf.generated.MultiRowMutationProtos.MutateRowsRequest)) { return super.equals(obj); } org.apache.hadoop.hbase.protobuf.generated.MultiRowMutationProtos.MutateRowsRequest other = (org.apache.hadoop.hbase.protobuf.generated.MultiRowMutationProtos.MutateRowsRequest) obj; boolean result = true; result = result && getMutationRequestList() .equals(other.getMutationRequestList()); result = result && (hasNonceGroup() == other.hasNonceGroup()); if (hasNonceGroup()) { result = result && (getNonceGroup() == other.getNonceGroup()); } result = result && (hasNonce() == other.hasNonce()); if (hasNonce()) { result = result && (getNonce() == other.getNonce()); } result = result && getUnknownFields().equals(other.getUnknownFields()); return result; }
@Test public void testMultiRowMutation() throws Exception { LOG.info("Starting testMultiRowMutation"); final TableName tableName = TableName.valueOf(name.getMethodName()); final byte [] ROW1 = Bytes.toBytes("testRow1"); Table t = TEST_UTIL.createTable(tableName, FAMILY); Put p = new Put(ROW); p.addColumn(FAMILY, QUALIFIER, VALUE); MutationProto m1 = ProtobufUtil.toMutation(MutationType.PUT, p); p = new Put(ROW1); p.addColumn(FAMILY, QUALIFIER, VALUE); MutationProto m2 = ProtobufUtil.toMutation(MutationType.PUT, p); MutateRowsRequest.Builder mrmBuilder = MutateRowsRequest.newBuilder(); mrmBuilder.addMutationRequest(m1); mrmBuilder.addMutationRequest(m2); MutateRowsRequest mrm = mrmBuilder.build(); CoprocessorRpcChannel channel = t.coprocessorService(ROW); MultiRowMutationService.BlockingInterface service = MultiRowMutationService.newBlockingStub(channel); service.mutateRows(null, mrm); Get g = new Get(ROW); Result r = t.get(g); assertEquals(0, Bytes.compareTo(VALUE, r.getValue(FAMILY, QUALIFIER))); g = new Get(ROW1); r = t.get(g); assertEquals(0, Bytes.compareTo(VALUE, r.getValue(FAMILY, QUALIFIER))); }