@Override protected void readAndCheck(AsyncTable<?> table, int replicaId) throws Exception { Get get = new Get(ROW).setConsistency(Consistency.TIMELINE); if (replicaId >= 0) { get.setReplicaId(replicaId); } assertArrayEquals(VALUE, table.get(get).get().getValue(FAMILY, QUALIFIER)); } }
this.setReplicaId(get.getReplicaId()); this.setConsistency(get.getConsistency());
protected Get createGet(long keyToRead) throws IOException { Get get = new Get(dataGenerator.getDeterministicUniqueKey(keyToRead)); String cfsString = ""; byte[][] columnFamilies = dataGenerator.getColumnFamilies(); for (byte[] cf : columnFamilies) { get.addFamily(cf); if (verbose) { if (cfsString.length() > 0) { cfsString += ", "; } cfsString += "[" + Bytes.toStringBinary(cf) + "]"; } } get = dataGenerator.beforeGet(keyToRead, get); if (regionReplicaId > 0) { get.setReplicaId(regionReplicaId); get.setConsistency(Consistency.TIMELINE); } if (verbose) { LOG.info("[" + readerId + "] " + "Querying key " + keyToRead + ", cfs " + cfsString); } return get; }
public void verifyNumericRows(Table table, final byte[] f, int startRow, int endRow, int replicaId) throws IOException { for (int i = startRow; i < endRow; i++) { String failMsg = "Failed verification of row :" + i; byte[] data = Bytes.toBytes(String.valueOf(i)); Get get = new Get(data); get.setReplicaId(replicaId); get.setConsistency(Consistency.TIMELINE); Result result = table.get(get); assertTrue(failMsg, result.containsColumn(f, null)); assertEquals(failMsg, 1, result.getColumnCells(f, null).size()); Cell cell = result.getColumnLatestCell(f, null); assertTrue(failMsg, Bytes.equals(data, 0, data.length, cell.getValueArray(), cell.getValueOffset(), cell.getValueLength())); } }
/** * Tests the case where a newly created table with region replicas and no data, the secondary * region replicas are available to read immediately. */ @Test public void testSecondaryRegionWithEmptyRegion() throws IOException { // Create a new table with region replication, don't put any data. Test that the secondary // region replica is available to read. try (Connection connection = ConnectionFactory.createConnection(HTU.getConfiguration()); Table table = connection.getTable(htd.getTableName())) { Get get = new Get(row); get.setConsistency(Consistency.TIMELINE); get.setReplicaId(1); table.get(get); // this should not block } }
@Test public void testGetOnTargetRegionReplica() throws Exception { try { //load some data to primary HTU.loadNumericRows(table, f, 0, 1000); // assert that we can read back from primary Assert.assertEquals(1000, HTU.countRows(table)); // flush so that region replica can read HRegion region = getRS().getRegionByEncodedName(hriPrimary.getEncodedName()); region.flush(true); openRegion(HTU, getRS(), hriSecondary); // try directly Get against region replica byte[] row = Bytes.toBytes(String.valueOf(42)); Get get = new Get(row); get.setConsistency(Consistency.TIMELINE); get.setReplicaId(1); Result result = table.get(get); Assert.assertArrayEquals(row, result.getValue(f, null)); } finally { HTU.deleteNumericRows(table, HConstants.CATALOG_FAMILY, 0, 1000); closeRegion(HTU, getRS(), hriSecondary); } }
Get get = new Get(splits[i]); get.setConsistency(Consistency.TIMELINE); get.setReplicaId(j);
.setAttribute("att_v0", Bytes.toBytes("att_v0")) .setColumnFamilyTimeRange(Bytes.toBytes("cf"), 0, 123) .setReplicaId(3) .setACL("test_user", new Permission(Permission.Action.READ)) .setAuthorizations(new Authorizations("test_label"))
out.setReplicaId(in.getTargetReplicaId());
get.setACL("u", new Permission(Permission.Action.READ)); get.setConsistency(Consistency.TIMELINE); get.setReplicaId(2); get.setIsolationLevel(IsolationLevel.READ_UNCOMMITTED); get.setCheckExistenceOnly(true);
this.setReplicaId(get.getReplicaId()); this.setConsistency(get.getConsistency());
.setAttribute("att_v0", Bytes.toBytes("att_v0")) .setColumnFamilyTimeRange(Bytes.toBytes("cf"), 0, 123) .setReplicaId(3) .setACL("test_user", new Permission(Permission.Action.READ)) .setAuthorizations(new Authorizations("test_label"))
get.setACL("u", new Permission(Permission.Action.READ)); get.setConsistency(Consistency.TIMELINE); get.setReplicaId(2); get.setIsolationLevel(IsolationLevel.READ_UNCOMMITTED); get.setCheckExistenceOnly(true);
this.setReplicaId(get.getReplicaId()); this.setConsistency(get.getConsistency());
this.setReplicaId(get.getReplicaId()); this.setConsistency(get.getConsistency());
protected Get createGet(long keyToRead) throws IOException { Get get = new Get(dataGenerator.getDeterministicUniqueKey(keyToRead)); String cfsString = ""; byte[][] columnFamilies = dataGenerator.getColumnFamilies(); for (byte[] cf : columnFamilies) { get.addFamily(cf); if (verbose) { if (cfsString.length() > 0) { cfsString += ", "; } cfsString += "[" + Bytes.toStringBinary(cf) + "]"; } } get = dataGenerator.beforeGet(keyToRead, get); if (regionReplicaId > 0) { get.setReplicaId(regionReplicaId); get.setConsistency(Consistency.TIMELINE); } if (verbose) { LOG.info("[" + readerId + "] " + "Querying key " + keyToRead + ", cfs " + cfsString); } return get; }
public void verifyNumericRows(Table table, final byte[] f, int startRow, int endRow, int replicaId) throws IOException { for (int i = startRow; i < endRow; i++) { String failMsg = "Failed verification of row :" + i; byte[] data = Bytes.toBytes(String.valueOf(i)); Get get = new Get(data); get.setReplicaId(replicaId); get.setConsistency(Consistency.TIMELINE); Result result = table.get(get); assertTrue(failMsg, result.containsColumn(f, null)); assertEquals(failMsg, 1, result.getColumnCells(f, null).size()); Cell cell = result.getColumnLatestCell(f, null); assertTrue(failMsg, Bytes.equals(data, 0, data.length, cell.getValueArray(), cell.getValueOffset(), cell.getValueLength())); } }
/** * Tests the case where a newly created table with region replicas and no data, the secondary * region replicas are available to read immediately. */ @Test public void testSecondaryRegionWithEmptyRegion() throws IOException { // Create a new table with region replication, don't put any data. Test that the secondary // region replica is available to read. try (Connection connection = ConnectionFactory.createConnection(HTU.getConfiguration()); Table table = connection.getTable(htd.getTableName())) { Get get = new Get(row); get.setConsistency(Consistency.TIMELINE); get.setReplicaId(1); table.get(get); // this should not block } }
@Test public void testGetOnTargetRegionReplica() throws Exception { try { //load some data to primary HTU.loadNumericRows(table, f, 0, 1000); // assert that we can read back from primary Assert.assertEquals(1000, HTU.countRows(table)); // flush so that region replica can read HRegion region = getRS().getRegionByEncodedName(hriPrimary.getEncodedName()); region.flush(true); openRegion(HTU, getRS(), hriSecondary); // try directly Get against region replica byte[] row = Bytes.toBytes(String.valueOf(42)); Get get = new Get(row); get.setConsistency(Consistency.TIMELINE); get.setReplicaId(1); Result result = table.get(get); Assert.assertArrayEquals(row, result.getValue(f, null)); } finally { HTU.deleteNumericRows(table, HConstants.CATALOG_FAMILY, 0, 1000); closeRegion(HTU, getRS(), hriSecondary); } }
Get get = new Get(splits[i]); get.setConsistency(Consistency.TIMELINE); get.setReplicaId(j);