HBASE-17816 HRegion#mutateRowWithLocks should update writeRequestCount metric (Weizhan Zeng)

This commit is contained in:
Jerry He 2017-04-06 16:45:45 -07:00
parent af604f0c0c
commit 48b2502a5f
2 changed files with 25 additions and 0 deletions

View File

@ -6966,6 +6966,7 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver, Regi
@Override @Override
public void mutateRowsWithLocks(Collection<Mutation> mutations, public void mutateRowsWithLocks(Collection<Mutation> mutations,
Collection<byte[]> rowsToLock, long nonceGroup, long nonce) throws IOException { Collection<byte[]> rowsToLock, long nonceGroup, long nonce) throws IOException {
writeRequestsCount.add(mutations.size());
MultiRowMutationProcessor proc = new MultiRowMutationProcessor(mutations, rowsToLock); MultiRowMutationProcessor proc = new MultiRowMutationProcessor(mutations, rowsToLock);
processRowsWithLocks(proc, -1, nonceGroup, nonce); processRowsWithLocks(proc, -1, nonceGroup, nonce);
} }

View File

@ -6391,4 +6391,28 @@ public class TestHRegion {
this.region = null; this.region = null;
} }
} }
@Test
public void testMutateRow_WriteRequestCount() throws Exception {
byte[] row1 = Bytes.toBytes("row1");
byte[] fam1 = Bytes.toBytes("fam1");
byte[] qf1 = Bytes.toBytes("qualifier");
byte[] val1 = Bytes.toBytes("value1");
RowMutations rm = new RowMutations(row1);
Put put = new Put(row1);
put.addColumn(fam1, qf1, val1);
rm.add(put);
this.region = initHRegion(tableName, method, CONF, fam1);
try {
long wrcBeforeMutate = this.region.writeRequestsCount.longValue();
this.region.mutateRow(rm);
long wrcAfterMutate = this.region.writeRequestsCount.longValue();
Assert.assertEquals(wrcBeforeMutate + rm.getMutations().size(), wrcAfterMutate);
} finally {
HBaseTestingUtility.closeRegionAndWAL(this.region);
this.region = null;
}
}
} }