private V value(Result result) { try { return config.getSerializer().deserialize(result.value()); } catch (IOException e) { throw UserException.dataReadError(e).build(logger); } }
/** Use get to retrieve the HRegionInfo and validate it */ private void getRegionInfo(Table table) throws IOException { Get get = new Get(ROW_KEY); get.addColumn(HConstants.CATALOG_FAMILY, HConstants.REGIONINFO_QUALIFIER); Result result = table.get(get); byte [] bytes = result.value(); validateRegionInfo(bytes); }
private void wait(byte[] row, Table target, boolean isDeleted) throws Exception { Get get = new Get(row); for (int i = 0; i < NB_RETRIES; i++) { if (i == NB_RETRIES - 1) { fail("Waited too much time for replication. Row:" + Bytes.toString(row) + ". IsDeleteReplication:" + isDeleted); } Result res = target.get(get); boolean sleep = isDeleted ? res.size() > 0 : res.isEmpty(); if (sleep) { LOG.info("Waiting for more time for replication. Row:" + Bytes.toString(row) + ". IsDeleteReplication:" + isDeleted); Thread.sleep(SLEEP_TIME); } else { if (!isDeleted) { assertArrayEquals(res.value(), row); } LOG.info("Obtained row:" + Bytes.toString(row) + ". IsDeleteReplication:" + isDeleted); break; } } }
private void putAndWait(byte[] row, byte[] fam, Table source, Table... targets) throws Exception { Put put = new Put(row); put.addColumn(fam, row, row); source.put(put); Get get = new Get(row); for (int i = 0; i < NB_RETRIES; i++) { if (i==NB_RETRIES-1) { fail("Waited too much time for put replication"); } boolean replicatedToAll = true; for (Table target : targets) { Result res = target.get(get); if (res.isEmpty()) { LOG.info("Row not available"); replicatedToAll = false; break; } else { assertArrayEquals(res.value(), row); } } if (replicatedToAll) { break; } else { Thread.sleep(SLEEP_TIME); } } }
private void ensureRowExisted(Table target, byte[] row, byte[]... families) throws Exception { for (byte[] fam : families) { Get get = new Get(row); get.addFamily(fam); for (int i = 0; i < NB_RETRIES; i++) { if (i == NB_RETRIES - 1) { fail("Waited too much time for put replication"); } Result res = target.get(get); if (res.isEmpty()) { LOG.info("Row not available"); } else { assertEquals(1, res.size()); assertArrayEquals(val, res.value()); break; } Thread.sleep(10 * SLEEP_TIME); } } }
private void doPutTest(byte[] row) throws IOException, InterruptedException { Put put = new Put(row); put.addColumn(famName, row, row); if (htable1 == null) { htable1 = utility1.getConnection().getTable(tableName); } htable1.put(put); Get get = new Get(row); 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.isEmpty()) { LOG.info("Row not available"); Thread.sleep(SLEEP_TIME); } else { assertArrayEquals(res.value(), row); break; } } } }
@Test public void testReplicationWithCellTags() throws Exception { LOG.info("testSimplePutDelete"); Put put = new Put(ROW); put.setAttribute("visibility", Bytes.toBytes("myTag3")); put.addColumn(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.isEmpty()) { LOG.info("Row not available"); Thread.sleep(SLEEP_TIME); } else { assertArrayEquals(ROW, res.value()); assertEquals(1, TestCoprocessorForTagsAtSink.tags.size()); Tag tag = TestCoprocessorForTagsAtSink.tags.get(0); assertEquals(TAG_TYPE, tag.getType()); break; } } } finally { TestCoprocessorForTagsAtSink.tags = null; } }
Thread.sleep(SLEEP_TIME); } else { assertArrayEquals(row, res.value()); break;
} else { assertEquals(1, res.size()); assertArrayEquals(val, res.value());
Thread.sleep(SLEEP_TIME); } else { assertArrayEquals(row, res.value()); return;
Thread.sleep(SLEEP_TIME * i); } else { assertArrayEquals(row, res.value()); break;
Thread.sleep(SLEEP_TIME * NB_RETRIES); } else { assertArrayEquals(row, res.value()); return;
Thread.sleep(SLEEP_TIME); } else { assertArrayEquals(res.value(), row); break;
put.addColumn(FAMILY, QUALIFIER, data); table.put(put); assertTrue(Bytes.equals(table.get(new Get(ROW)).value(), data));
put.addColumn(FAMILY, QUALIFIER, data); table.put(put); assertTrue(Bytes.equals(table.get(new Get(ROW)).value(), data));
put.addColumn(FAMILY, QUALIFIER, data); table.put(put); assertTrue(Bytes.equals(table.get(new Get(ROW)).value(), data)); assertEquals(expectedBlockMiss, cache.getStats().getMissCount()); assertTrue(Bytes.equals(table.get(new Get(ROW)).value(), data)); assertEquals(expectedBlockCount, cache.getBlockCount()); assertEquals(++expectedBlockHits, cache.getStats().getHitCount());
@Override protected byte[] fetch(byte[] row, byte[] column) throws IOException { Get get = new Get(row); get.addColumn(QueueEntryRow.COLUMN_FAMILY, column); get.setMaxVersions(1); Result result = hTable.get(get); return result.isEmpty() ? null : result.value(); }
/** * Fetches a schema entry from the tables given a schema ID. * * @param schemaId schema ID * @return Avro schema entry, or null if the schema ID does not exist in the table * @throws IOException on I/O error. */ private SchemaTableEntry loadFromIdTable(long schemaId) throws IOException { final Get get = new Get(longToVarInt64(schemaId)); final Result result = mSchemaIdTable.get(get); return result.isEmpty() ? null : decodeSchemaEntry(result.value()); }
/** Use get to retrieve the HRegionInfo and validate it */ private void getRegionInfo(Table table) throws IOException { Get get = new Get(ROW_KEY); get.addColumn(HConstants.CATALOG_FAMILY, HConstants.REGIONINFO_QUALIFIER); Result result = table.get(get); byte [] bytes = result.value(); validateRegionInfo(bytes); }