コード例 #1
0
  @Test(timeout = 300000)
  public void testReplicationWithCellTags() throws Exception {
    LOG.info("testSimplePutDelete");
    Put put = new Put(ROW);
    put.setAttribute("visibility", Bytes.toBytes("myTag3"));
    put.add(FAMILY, ROW, ROW);

    htable1 = utility1.getConnection().getTable(TABLE_NAME);
    htable1.put(put);

    Get get = new Get(ROW);
    try {
      for (int i = 0; i < NB_RETRIES; i++) {
        if (i == NB_RETRIES - 1) {
          fail("Waited too much time for put replication");
        }
        Result res = htable2.get(get);
        if (res.size() == 0) {
          LOG.info("Row not available");
          Thread.sleep(SLEEP_TIME);
        } else {
          assertArrayEquals(res.value(), ROW);
          assertEquals(1, TestCoprocessorForTagsAtSink.tags.size());
          Tag tag = TestCoprocessorForTagsAtSink.tags.get(0);
          assertEquals(TAG_TYPE, tag.getType());
          break;
        }
      }
    } finally {
      TestCoprocessorForTagsAtSink.tags = null;
    }
  }
コード例 #2
0
 @Override
 public void postGetOp(
     ObserverContext<RegionCoprocessorEnvironment> e, Get get, List<Cell> results)
     throws IOException {
   if (results.size() > 0) {
     // Check tag presence in the 1st cell in 1st Result
     if (!results.isEmpty()) {
       Cell cell = results.get(0);
       tags = Tag.asList(cell.getTagsArray(), cell.getTagsOffset(), cell.getTagsLength());
     }
   }
 }