HBASE-26002 MultiRowMutationEndpoint should return the result of the conditional update (#3386)
Signed-off-by: Duo Zhang <zhangduo@apache.org>
This commit is contained in:
parent
5159eaec12
commit
b061d477a8
|
@ -41,6 +41,7 @@ message MutateRowsRequest {
|
|||
}
|
||||
|
||||
message MutateRowsResponse {
|
||||
optional bool processed = 1;
|
||||
}
|
||||
|
||||
service MultiRowMutationService {
|
||||
|
|
|
@ -96,7 +96,10 @@ import com.google.protobuf.Service;
|
|||
* MultiRowMutationService.BlockingInterface service =
|
||||
* MultiRowMutationService.newBlockingStub(channel);
|
||||
* MutateRowsRequest mrm = mrmBuilder.build();
|
||||
* service.mutateRows(null, mrm);
|
||||
* MutateRowsResponse response = service.mutateRows(null, mrm);
|
||||
*
|
||||
* // We can get the result of the conditional update
|
||||
* boolean processed = response.getProcessed();
|
||||
* </code>
|
||||
*/
|
||||
@InterfaceAudience.LimitedPrivate(HBaseInterfaceAudience.COPROC)
|
||||
|
@ -109,8 +112,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 +143,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 +185,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.protobuf.generated.ClientProtos.MutationProto;
|
|||
import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.MutationProto.MutationType;
|
||||
import org.apache.hadoop.hbase.protobuf.generated.MultiRowMutationProtos.MultiRowMutationService;
|
||||
import org.apache.hadoop.hbase.protobuf.generated.MultiRowMutationProtos.MutateRowsRequest;
|
||||
import org.apache.hadoop.hbase.protobuf.generated.MultiRowMutationProtos.MutateRowsResponse;
|
||||
import org.apache.hadoop.hbase.regionserver.HRegion;
|
||||
import org.apache.hadoop.hbase.regionserver.HRegionServer;
|
||||
import org.apache.hadoop.hbase.regionserver.HStore;
|
||||
|
@ -299,9 +300,11 @@ public class TestFromClientSide5 extends FromClientSideBase {
|
|||
CoprocessorRpcChannel channel = t.coprocessorService(ROW);
|
||||
MultiRowMutationService.BlockingInterface service =
|
||||
MultiRowMutationService.newBlockingStub(channel);
|
||||
service.mutateRows(null, mrmBuilder.build());
|
||||
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)));
|
||||
|
||||
|
@ -347,9 +350,11 @@ public class TestFromClientSide5 extends FromClientSideBase {
|
|||
CoprocessorRpcChannel channel = t.coprocessorService(ROW);
|
||||
MultiRowMutationService.BlockingInterface service =
|
||||
MultiRowMutationService.newBlockingStub(channel);
|
||||
service.mutateRows(null, mrmBuilder.build());
|
||||
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)));
|
||||
|
||||
|
@ -391,9 +396,11 @@ public class TestFromClientSide5 extends FromClientSideBase {
|
|||
CoprocessorRpcChannel channel = t.coprocessorService(ROW);
|
||||
MultiRowMutationService.BlockingInterface service =
|
||||
MultiRowMutationService.newBlockingStub(channel);
|
||||
service.mutateRows(null, mrmBuilder.build());
|
||||
MutateRowsResponse response = service.mutateRows(null, mrmBuilder.build());
|
||||
|
||||
// Assert
|
||||
assertFalse(response.getProcessed());
|
||||
|
||||
Result r = t.get(new Get(ROW));
|
||||
assertTrue(r.isEmpty());
|
||||
|
||||
|
@ -437,9 +444,11 @@ public class TestFromClientSide5 extends FromClientSideBase {
|
|||
CoprocessorRpcChannel channel = t.coprocessorService(ROW);
|
||||
MultiRowMutationService.BlockingInterface service =
|
||||
MultiRowMutationService.newBlockingStub(channel);
|
||||
service.mutateRows(null, mrmBuilder.build());
|
||||
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)));
|
||||
|
||||
|
@ -483,9 +492,11 @@ public class TestFromClientSide5 extends FromClientSideBase {
|
|||
CoprocessorRpcChannel channel = t.coprocessorService(ROW);
|
||||
MultiRowMutationService.BlockingInterface service =
|
||||
MultiRowMutationService.newBlockingStub(channel);
|
||||
service.mutateRows(null, mrmBuilder.build());
|
||||
MutateRowsResponse response = service.mutateRows(null, mrmBuilder.build());
|
||||
|
||||
// Assert
|
||||
assertFalse(response.getProcessed());
|
||||
|
||||
Result r = t.get(new Get(ROW));
|
||||
assertTrue(r.isEmpty());
|
||||
|
||||
|
@ -531,9 +542,11 @@ public class TestFromClientSide5 extends FromClientSideBase {
|
|||
CoprocessorRpcChannel channel = t.coprocessorService(ROW);
|
||||
MultiRowMutationService.BlockingInterface service =
|
||||
MultiRowMutationService.newBlockingStub(channel);
|
||||
service.mutateRows(null, mrmBuilder.build());
|
||||
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)));
|
||||
|
||||
|
@ -579,9 +592,11 @@ public class TestFromClientSide5 extends FromClientSideBase {
|
|||
CoprocessorRpcChannel channel = t.coprocessorService(ROW);
|
||||
MultiRowMutationService.BlockingInterface service =
|
||||
MultiRowMutationService.newBlockingStub(channel);
|
||||
service.mutateRows(null, mrmBuilder.build());
|
||||
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