HBASE-26002 MultiRowMutationEndpoint should return the result of the conditional update (#3384)
This commit is contained in:
parent
ba6995e083
commit
ec31818574
|
@ -41,6 +41,7 @@ message MutateRowsRequest {
|
|||
}
|
||||
|
||||
message MutateRowsResponse {
|
||||
optional bool processed = 1;
|
||||
}
|
||||
|
||||
service MultiRowMutationService {
|
||||
|
|
|
@ -109,8 +109,7 @@ public class MultiRowMutationEndpoint extends MultiRowMutationService implements
|
|||
@Override
|
||||
public void mutateRows(RpcController controller, MutateRowsRequest request,
|
||||
RpcCallback<MutateRowsResponse> done) {
|
||||
MutateRowsResponse response = MutateRowsResponse.getDefaultInstance();
|
||||
|
||||
boolean matches = true;
|
||||
List<Region.RowLock> rowLocks = null;
|
||||
try {
|
||||
// set of rows to lock, sorted to avoid deadlocks
|
||||
|
@ -141,7 +140,6 @@ public class MultiRowMutationEndpoint extends MultiRowMutationService implements
|
|||
rowsToLock.add(m.getRow());
|
||||
}
|
||||
|
||||
boolean matches = true;
|
||||
if (request.getConditionCount() > 0) {
|
||||
// Get row locks for the mutations and the conditions
|
||||
rowLocks = new ArrayList<>();
|
||||
|
@ -184,7 +182,7 @@ public class MultiRowMutationEndpoint extends MultiRowMutationService implements
|
|||
}
|
||||
}
|
||||
}
|
||||
done.run(response);
|
||||
done.run(MutateRowsResponse.newBuilder().setProcessed(matches).build());
|
||||
}
|
||||
|
||||
private boolean matches(Region region, ClientProtos.Condition condition) throws IOException {
|
||||
|
|
|
@ -76,6 +76,7 @@ import org.apache.hadoop.hbase.regionserver.HRegion;
|
|||
import org.apache.hadoop.hbase.regionserver.HRegionServer;
|
||||
import org.apache.hadoop.hbase.regionserver.HStore;
|
||||
import org.apache.hadoop.hbase.regionserver.NoSuchColumnFamilyException;
|
||||
import org.apache.hadoop.hbase.shaded.protobuf.generated.MultiRowMutationProtos;
|
||||
import org.apache.hadoop.hbase.testclassification.ClientTests;
|
||||
import org.apache.hadoop.hbase.testclassification.LargeTests;
|
||||
import org.apache.hadoop.hbase.util.Bytes;
|
||||
|
@ -301,9 +302,12 @@ public class TestFromClientSide5 extends FromClientSideBase {
|
|||
CoprocessorRpcChannel channel = t.coprocessorService(ROW);
|
||||
MultiRowMutationService.BlockingInterface service =
|
||||
MultiRowMutationService.newBlockingStub(channel);
|
||||
service.mutateRows(null, mrmBuilder.build());
|
||||
MultiRowMutationProtos.MutateRowsResponse response =
|
||||
service.mutateRows(null, mrmBuilder.build());
|
||||
|
||||
// Assert
|
||||
assertTrue(response.getProcessed());
|
||||
|
||||
Result r = t.get(new Get(ROW));
|
||||
assertEquals(Bytes.toString(VALUE), Bytes.toString(r.getValue(FAMILY, QUALIFIER)));
|
||||
|
||||
|
@ -349,9 +353,12 @@ public class TestFromClientSide5 extends FromClientSideBase {
|
|||
CoprocessorRpcChannel channel = t.coprocessorService(ROW);
|
||||
MultiRowMutationService.BlockingInterface service =
|
||||
MultiRowMutationService.newBlockingStub(channel);
|
||||
service.mutateRows(null, mrmBuilder.build());
|
||||
MultiRowMutationProtos.MutateRowsResponse response =
|
||||
service.mutateRows(null, mrmBuilder.build());
|
||||
|
||||
// Assert
|
||||
assertTrue(response.getProcessed());
|
||||
|
||||
Result r = t.get(new Get(ROW));
|
||||
assertEquals(Bytes.toString(VALUE), Bytes.toString(r.getValue(FAMILY, QUALIFIER)));
|
||||
|
||||
|
@ -393,9 +400,12 @@ public class TestFromClientSide5 extends FromClientSideBase {
|
|||
CoprocessorRpcChannel channel = t.coprocessorService(ROW);
|
||||
MultiRowMutationService.BlockingInterface service =
|
||||
MultiRowMutationService.newBlockingStub(channel);
|
||||
service.mutateRows(null, mrmBuilder.build());
|
||||
MultiRowMutationProtos.MutateRowsResponse response =
|
||||
service.mutateRows(null, mrmBuilder.build());
|
||||
|
||||
// Assert
|
||||
assertFalse(response.getProcessed());
|
||||
|
||||
Result r = t.get(new Get(ROW));
|
||||
assertTrue(r.isEmpty());
|
||||
|
||||
|
@ -439,9 +449,12 @@ public class TestFromClientSide5 extends FromClientSideBase {
|
|||
CoprocessorRpcChannel channel = t.coprocessorService(ROW);
|
||||
MultiRowMutationService.BlockingInterface service =
|
||||
MultiRowMutationService.newBlockingStub(channel);
|
||||
service.mutateRows(null, mrmBuilder.build());
|
||||
MultiRowMutationProtos.MutateRowsResponse response =
|
||||
service.mutateRows(null, mrmBuilder.build());
|
||||
|
||||
// Assert
|
||||
assertTrue(response.getProcessed());
|
||||
|
||||
Result r = t.get(new Get(ROW));
|
||||
assertEquals(Bytes.toString(VALUE), Bytes.toString(r.getValue(FAMILY, QUALIFIER)));
|
||||
|
||||
|
@ -485,9 +498,12 @@ public class TestFromClientSide5 extends FromClientSideBase {
|
|||
CoprocessorRpcChannel channel = t.coprocessorService(ROW);
|
||||
MultiRowMutationService.BlockingInterface service =
|
||||
MultiRowMutationService.newBlockingStub(channel);
|
||||
service.mutateRows(null, mrmBuilder.build());
|
||||
MultiRowMutationProtos.MutateRowsResponse response =
|
||||
service.mutateRows(null, mrmBuilder.build());
|
||||
|
||||
// Assert
|
||||
assertFalse(response.getProcessed());
|
||||
|
||||
Result r = t.get(new Get(ROW));
|
||||
assertTrue(r.isEmpty());
|
||||
|
||||
|
@ -533,9 +549,12 @@ public class TestFromClientSide5 extends FromClientSideBase {
|
|||
CoprocessorRpcChannel channel = t.coprocessorService(ROW);
|
||||
MultiRowMutationService.BlockingInterface service =
|
||||
MultiRowMutationService.newBlockingStub(channel);
|
||||
service.mutateRows(null, mrmBuilder.build());
|
||||
MultiRowMutationProtos.MutateRowsResponse response =
|
||||
service.mutateRows(null, mrmBuilder.build());
|
||||
|
||||
// Assert
|
||||
assertTrue(response.getProcessed());
|
||||
|
||||
Result r = t.get(new Get(ROW));
|
||||
assertEquals(Bytes.toString(VALUE), Bytes.toString(r.getValue(FAMILY, QUALIFIER)));
|
||||
|
||||
|
@ -581,9 +600,12 @@ public class TestFromClientSide5 extends FromClientSideBase {
|
|||
CoprocessorRpcChannel channel = t.coprocessorService(ROW);
|
||||
MultiRowMutationService.BlockingInterface service =
|
||||
MultiRowMutationService.newBlockingStub(channel);
|
||||
service.mutateRows(null, mrmBuilder.build());
|
||||
MultiRowMutationProtos.MutateRowsResponse response =
|
||||
service.mutateRows(null, mrmBuilder.build());
|
||||
|
||||
// Assert
|
||||
assertFalse(response.getProcessed());
|
||||
|
||||
Result r = t.get(new Get(ROW));
|
||||
assertTrue(r.isEmpty());
|
||||
|
||||
|
|
Loading…
Reference in New Issue