@Test
 public void testCheckAndPutHooks() throws IOException {
   TableName tableName = TableName.valueOf(TEST_TABLE.getNameAsString() + ".testCheckAndPutHooks");
   HTable table = util.createTable(tableName, new byte[][] {A, B, C});
   try {
     Put p = new Put(Bytes.toBytes(0));
     p.add(A, A, A);
     table.put(p);
     table.flushCommits();
     p = new Put(Bytes.toBytes(0));
     p.add(A, A, A);
     verifyMethodResult(
         SimpleRegionObserver.class,
         new String[] {"hadPreCheckAndPut", "hadPreCheckAndPutAfterRowLock", "hadPostCheckAndPut"},
         tableName,
         new Boolean[] {false, false, false});
     table.checkAndPut(Bytes.toBytes(0), A, A, A, p);
     verifyMethodResult(
         SimpleRegionObserver.class,
         new String[] {"hadPreCheckAndPut", "hadPreCheckAndPutAfterRowLock", "hadPostCheckAndPut"},
         tableName,
         new Boolean[] {true, true, true});
   } finally {
     util.deleteTable(tableName);
     table.close();
   }
 }
Esempio n. 2
0
 @Override
 protected boolean claimFifoEntry(byte[] row, byte[] value, byte[] oldValue) throws IOException {
   Put put = new Put(keyDistributor.getDistributedKey(row));
   put.add(QueueEntryRow.COLUMN_FAMILY, stateColumnName, value);
   return hTable.checkAndPut(
       put.getRow(), QueueEntryRow.COLUMN_FAMILY, stateColumnName, oldValue, put);
 }