org.apache.hadoop.hbase.client.Get.setConsistency()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(7.5k)|赞(0)|评价(0)|浏览(114)

本文整理了Java中org.apache.hadoop.hbase.client.Get.setConsistency()方法的一些代码示例,展示了Get.setConsistency()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Get.setConsistency()方法的具体详情如下:
包路径:org.apache.hadoop.hbase.client.Get
类名称:Get
方法名:setConsistency

Get.setConsistency介绍

暂无

代码示例

代码示例来源:origin: apache/hbase

private static List<Get> makeTimelineGets(byte[]... rows) {
 List<Get> result = new ArrayList<>(rows.length);
 for (byte[] row : rows) {
  Get get = new Get(row);
  get.setConsistency(Consistency.TIMELINE);
  result.add(get);
 }
 return result;
}

代码示例来源:origin: apache/hbase

@Override
protected Get createGet(long keyToRead) throws IOException {
 Get get = super.createGet(keyToRead);
 get.setConsistency(Consistency.TIMELINE);
 return get;
}

代码示例来源:origin: apache/hbase

@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));
 }
}

代码示例来源:origin: apache/hbase

@Test
public void testGetNoResultStaleRegionWithReplica() throws Exception {
 byte[] b1 = "testGetNoResultStaleRegionWithReplica".getBytes();
 openRegion(hriSecondary);
 SlowMeCopro.getPrimaryCdl().set(new CountDownLatch(1));
 try {
  Get g = new Get(b1);
  g.setConsistency(Consistency.TIMELINE);
  Result r = table.get(g);
  Assert.assertTrue(r.isStale());
 } finally {
  SlowMeCopro.getPrimaryCdl().get().countDown();
  closeRegion(hriSecondary);
 }
}

代码示例来源:origin: apache/hbase

this.setConsistency(get.getConsistency());

代码示例来源:origin: apache/hbase

get.setFilter(new FilterAllFilter());
get.setConsistency(consistency);
if (LOG.isTraceEnabled()) LOG.trace(get.toString());
try {

代码示例来源:origin: apache/hbase

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;
}

代码示例来源:origin: apache/hbase

get.setFilter(new FilterAllFilter());
get.setConsistency(consistency);
if (LOG.isTraceEnabled()) LOG.trace(get.toString());
if (opts.multiGet > 0) {

代码示例来源:origin: apache/hbase

@Test
public void testCreateDeleteTable() throws IOException {
 // Create table then get the single region for our new table.
 HTableDescriptor hdt = HTU.createTableDescriptor("testCreateDeleteTable");
 hdt.setRegionReplication(NB_SERVERS);
 hdt.addCoprocessor(SlowMeCopro.class.getName());
 Table table = HTU.createTable(hdt, new byte[][]{f}, null);
 Put p = new Put(row);
 p.addColumn(f, row, row);
 table.put(p);
 Get g = new Get(row);
 Result r = table.get(g);
 Assert.assertFalse(r.isStale());
 try {
  // But if we ask for stale we will get it
  SlowMeCopro.cdl.set(new CountDownLatch(1));
  g = new Get(row);
  g.setConsistency(Consistency.TIMELINE);
  r = table.get(g);
  Assert.assertTrue(r.isStale());
  SlowMeCopro.cdl.get().countDown();
 } finally {
  SlowMeCopro.cdl.get().countDown();
  SlowMeCopro.sleepTime.set(0);
 }
 HTU.getAdmin().disableTable(hdt.getTableName());
 HTU.deleteTable(hdt.getTableName());
}

代码示例来源:origin: apache/hbase

SlowMeCopro.getSecondaryCdl().set(new CountDownLatch(1));
g = new Get(b1);
g.setConsistency(Consistency.TIMELINE);
r = table.get(g);
Assert.assertFalse(r.isStale());
g.setConsistency(Consistency.TIMELINE);
r = table.get(g);
Assert.assertTrue(r.isStale());

代码示例来源:origin: apache/hbase

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()));
 }
}

代码示例来源:origin: apache/hbase

/**
 * 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
 }
}

代码示例来源:origin: apache/hbase

g.setConsistency(Consistency.TIMELINE);
Result r = t.get(g);
Assert.assertTrue(r.isStale());

代码示例来源:origin: apache/hbase

@Test
public void testReplicaGetWithPrimaryDown() throws IOException {
 // Create table then get the single region for our new table.
 HTableDescriptor hdt = HTU.createTableDescriptor("testCreateDeleteTable");
 hdt.setRegionReplication(NB_SERVERS);
 hdt.addCoprocessor(RegionServerStoppedCopro.class.getName());
 try {
  Table table = HTU.createTable(hdt, new byte[][] { f }, null);
  Put p = new Put(row);
  p.addColumn(f, row, row);
  table.put(p);
  // Flush so it can be picked by the replica refresher thread
  HTU.flush(table.getName());
  // Sleep for some time until data is picked up by replicas
  try {
   Thread.sleep(2 * REFRESH_PERIOD);
  } catch (InterruptedException e1) {
   LOG.error(e1.toString(), e1);
  }
  // But if we ask for stale we will get it
  Get g = new Get(row);
  g.setConsistency(Consistency.TIMELINE);
  Result r = table.get(g);
  Assert.assertTrue(r.isStale());
 } finally {
  HTU.getAdmin().disableTable(hdt.getTableName());
  HTU.deleteTable(hdt.getTableName());
 }
}

代码示例来源:origin: apache/hbase

@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);
 }
}

代码示例来源:origin: apache/hbase

get.setCheckExistenceOnly(checkExistenceOnly);
if (get.getConsistency() == null){
 get.setConsistency(DEFAULT_CONSISTENCY);

代码示例来源:origin: apache/hbase

for (int j = 0; j < regionReplication; j++) {
 Get get = new Get(splits[i]);
 get.setConsistency(Consistency.TIMELINE);
 get.setReplicaId(j);

代码示例来源:origin: apache/hbase

SlowMeCopro.cdl.set(new CountDownLatch(1));
g = new Get(row);
g.setConsistency(Consistency.TIMELINE);
r = table.get(g);
Assert.assertTrue(r.isStale());

代码示例来源:origin: apache/hbase

Get get = new Get(Bytes.toBytes(1));
get.setCacheBlocks(true)
    .setConsistency(Consistency.TIMELINE)
    .setFilter(new FilterList())
    .setId("get")

代码示例来源:origin: apache/hbase

get.setAuthorizations(new Authorizations("foo"));
get.setACL("u", new Permission(Permission.Action.READ));
get.setConsistency(Consistency.TIMELINE);
get.setReplicaId(2);
get.setIsolationLevel(IsolationLevel.READ_UNCOMMITTED);

相关文章