@Test
  public void testRowMutation() throws IOException {
    TableName tableName = TableName.valueOf(TEST_TABLE.getNameAsString() + ".testRowMutation");
    HTable table = util.createTable(tableName, new byte[][] {A, B, C});
    try {
      verifyMethodResult(
          SimpleRegionObserver.class,
          new String[] {"hadPreGet", "hadPostGet", "hadPrePut", "hadPostPut", "hadDeleted"},
          tableName,
          new Boolean[] {false, false, false, false, false});
      Put put = new Put(ROW);
      put.add(A, A, A);
      put.add(B, B, B);
      put.add(C, C, C);

      Delete delete = new Delete(ROW);
      delete.deleteColumn(A, A);
      delete.deleteColumn(B, B);
      delete.deleteColumn(C, C);

      RowMutations arm = new RowMutations(ROW);
      arm.add(put);
      arm.add(delete);
      table.mutateRow(arm);

      verifyMethodResult(
          SimpleRegionObserver.class,
          new String[] {"hadPreGet", "hadPostGet", "hadPrePut", "hadPostPut", "hadDeleted"},
          tableName,
          new Boolean[] {false, false, true, true, true});
    } finally {
      util.deleteTable(tableName);
      table.close();
    }
  }
 /**
  * Attempt to claim the given queue with a checkAndPut on the OWNER column. We check that the
  * recently killed server is still the OWNER before we claim it.
  *
  * @param queue The queue that we are trying to claim
  * @param originalServer The server that originally owned the queue
  * @return Whether we successfully claimed the queue
  * @throws IOException
  */
 private boolean attemptToClaimQueue(Result queue, String originalServer) throws IOException {
   Put putQueueNameAndHistory = new Put(queue.getRow());
   putQueueNameAndHistory.addColumn(CF_QUEUE, COL_QUEUE_OWNER, Bytes.toBytes(serverName));
   String newOwnerHistory =
       buildClaimedQueueHistory(
           Bytes.toString(queue.getValue(CF_QUEUE, COL_QUEUE_OWNER_HISTORY)), originalServer);
   putQueueNameAndHistory.addColumn(
       CF_QUEUE, COL_QUEUE_OWNER_HISTORY, Bytes.toBytes(newOwnerHistory));
   RowMutations claimAndRenameQueue = new RowMutations(queue.getRow());
   claimAndRenameQueue.add(putQueueNameAndHistory);
   // Attempt to claim ownership for this queue by checking if the current OWNER is the original
   // server. If it is not then another RS has already claimed it. If it is we set ourselves as the
   // new owner and update the queue's history
   boolean success =
       replicationTable.checkAndMutate(
           queue.getRow(),
           CF_QUEUE,
           COL_QUEUE_OWNER,
           CompareFilter.CompareOp.EQUAL,
           Bytes.toBytes(originalServer),
           claimAndRenameQueue);
   return success;
 }
 /**
  * Attempt to mutate a given queue in the Replication Table with a checkAndPut on the OWNER column
  * of the queue. Abort the server if this checkAndPut fails: which means we have somehow lost
  * ownership of the column or an IO Exception has occurred during the transaction.
  *
  * @param mutate Mutation to perform on a given queue
  */
 private void safeQueueUpdate(RowMutations mutate) throws ReplicationException, IOException {
   boolean updateSuccess =
       replicationTable.checkAndMutate(
           mutate.getRow(),
           CF_QUEUE,
           COL_QUEUE_OWNER,
           CompareFilter.CompareOp.EQUAL,
           serverNameBytes,
           mutate);
   if (!updateSuccess) {
     throw new ReplicationException(
         "Failed to update Replication Table because we lost queue " + " ownership");
   }
 }
 /**
  * See safeQueueUpdate(RowMutations mutate)
  *
  * @param delete Row mutation to perform on the queue
  */
 private void safeQueueUpdate(Delete delete) throws ReplicationException, IOException {
   RowMutations mutations = new RowMutations(delete.getRow());
   mutations.add(delete);
   safeQueueUpdate(mutations);
 }
 /**
  * See safeQueueUpdate(RowMutations mutate)
  *
  * @param put Row mutation to perform on the queue
  */
 private void safeQueueUpdate(Put put) throws ReplicationException, IOException {
   RowMutations mutations = new RowMutations(put.getRow());
   mutations.add(put);
   safeQueueUpdate(mutations);
 }