org.apache.hadoop.hbase.HBaseTestingUtility.waitTableEnabled()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(12.9k)|赞(0)|评价(0)|浏览(91)

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

HBaseTestingUtility.waitTableEnabled介绍

[英]Waits for a table to be 'enabled'. Enabled means that table is set as 'enabled' and the regions have been all assigned. Will timeout after default period (30 seconds) Tolerates nonexistent table.
[中]等待“启用”表。启用意味着表被设置为“启用”,并且所有区域都已分配。将在默认时间段(30秒)后超时,以允许不存在表。

代码示例

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

/**
 * Waits for a table to be 'enabled'.  Enabled means that table is set as 'enabled' and the
 * regions have been all assigned.  Will timeout after default period (30 seconds)
 * Tolerates nonexistent table.
 * @param table Table to wait on.
 * @param table
 * @throws InterruptedException
 * @throws IOException
 */
public void waitTableEnabled(TableName table)
  throws InterruptedException, IOException {
 waitTableEnabled(table, 30000);
}

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

private void waitForTable(TableName name) throws InterruptedException, IOException {
  // First wait until all regions are online
  TEST_UTIL.waitTableEnabled(name);
  // Now wait a bit longer for the coprocessor hosts to load the CPs
  Thread.sleep(1000);
 }
}

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

/**
 * Waits for a table to be 'enabled'.  Enabled means that table is set as 'enabled' and the
 * regions have been all assigned.
 * @see #waitTableEnabled(TableName, long)
 * @param table Table to wait on.
 * @param timeoutMillis Time to wait on it being marked enabled.
 * @throws InterruptedException
 * @throws IOException
 */
public void waitTableEnabled(byte[] table, long timeoutMillis)
throws InterruptedException, IOException {
 waitTableEnabled(TableName.valueOf(table), timeoutMillis);
}

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

@Before
public void setUp() throws Exception {
 // Create the test table (owner added to the _acl_ table)
 Admin admin = TEST_UTIL.getAdmin();
 HTableDescriptor htd = new HTableDescriptor(TEST_TABLE.getTableName());
 HColumnDescriptor hcd = new HColumnDescriptor(TEST_FAMILY);
 hcd.setMaxVersions(4);
 htd.setOwner(USER_OWNER);
 htd.addFamily(hcd);
 admin.createTable(htd, new byte[][] { Bytes.toBytes("s") });
 TEST_UTIL.waitTableEnabled(TEST_TABLE.getTableName());
 LOG.info("Sleeping a second because of HBASE-12581");
 Threads.sleep(1000);
}

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

@BeforeClass
public static void setupBeforeClass() throws Exception {
 // setup configuration
 conf = TEST_UTIL.getConfiguration();
 VisibilityTestUtil.enableVisiblityLabels(conf);
 String classes = SimpleScanLabelGenerator.class.getCanonicalName() + " , "
   + LabelFilteringScanLabelGenerator.class.getCanonicalName();
 conf.setStrings(VisibilityUtils.VISIBILITY_LABEL_GENERATOR_CLASS, classes);
 conf.set("hbase.superuser", "admin");
 TEST_UTIL.startMiniCluster(1);
 SUPERUSER = User.createUserForTesting(conf, "admin", new String[] { "supergroup" });
 // Wait for the labels table to become available
 TEST_UTIL.waitTableEnabled(LABELS_TABLE_NAME.getName(), 50000);
 addLabels();
}

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

@Before
public void setUp() throws Exception {
 admin = TEST_UTIL.getHBaseAdmin();
 HTableDescriptor htd = new HTableDescriptor(TEST_TABLE);
 HColumnDescriptor hcd = new HColumnDescriptor(TEST_FAMILY);
 hcd.setMaxVersions(100);
 htd.addFamily(hcd);
 htd.setOwner(USER_OWNER);
 admin.createTable(htd, new byte[][] { Bytes.toBytes("s") });
 TEST_UTIL.waitTableEnabled(TEST_TABLE);
 grantOnTable(TEST_UTIL, USER_RW.getShortName(), TEST_TABLE, TEST_FAMILY, null,
     Permission.Action.READ, Permission.Action.WRITE);
 grantOnTable(TEST_UTIL, USER_RO.getShortName(), TEST_TABLE, TEST_FAMILY, null,
     Permission.Action.READ);
}

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

@Before
public void setUp() throws Exception {
 HTableDescriptor htd = new HTableDescriptor(TEST_TABLE.getTableName());
 HColumnDescriptor hcd = new HColumnDescriptor(TEST_FAMILY1);
 hcd.setMaxVersions(4);
 htd.setOwner(USER_OWNER);
 htd.addFamily(hcd);
 hcd = new HColumnDescriptor(TEST_FAMILY2);
 hcd.setMaxVersions(4);
 htd.setOwner(USER_OWNER);
 htd.addFamily(hcd);
 // Create the test table (owner added to the _acl_ table)
 try (Connection connection = ConnectionFactory.createConnection(TEST_UTIL.getConfiguration())) {
  try (Admin admin = connection.getAdmin()) {
   admin.createTable(htd, new byte[][] { Bytes.toBytes("s") });
  }
 }
 TEST_UTIL.waitTableEnabled(TEST_TABLE.getTableName());
 LOG.info("Sleeping a second because of HBASE-12581");
 Threads.sleep(1000);
}

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

@BeforeClass
public static void setUpBeforeClass() throws Exception {
 // set the always on security provider
 UserProvider.setUserProviderForTesting(util.getConfiguration(),
  HadoopSecurityEnabledUserProviderForTesting.class);
 // setup configuration
 SecureTestUtil.enableSecurity(util.getConfiguration());
 util.getConfiguration().setInt(LoadIncrementalHFiles.MAX_FILES_PER_REGION_PER_FAMILY,
  MAX_FILES_PER_REGION_PER_FAMILY);
 // change default behavior so that tag values are returned with normal rpcs
 util.getConfiguration().set(HConstants.RPC_CODEC_CONF_KEY,
  KeyValueCodecWithTags.class.getCanonicalName());
 util.startMiniCluster();
 // Wait for the ACL table to become available
 util.waitTableEnabled(AccessControlLists.ACL_TABLE_NAME);
 setupNamespace();
}

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

@BeforeClass
public static void setupBeforeClass() throws Exception {
 // setup configuration
 conf = TEST_UTIL.getConfiguration();
 VisibilityTestUtil.enableVisiblityLabels(conf);
 conf.setBoolean(VisibilityConstants.CHECK_AUTHS_FOR_MUTATION, true);
 conf.setClass(VisibilityUtils.VISIBILITY_LABEL_GENERATOR_CLASS, SimpleScanLabelGenerator.class,
   ScanLabelGenerator.class);
 conf.set("hbase.superuser", "admin");
 TEST_UTIL.startMiniCluster(2);
 SUPERUSER = User.createUserForTesting(conf, "admin", new String[] { "supergroup" });
 USER = User.createUserForTesting(conf, "user", new String[]{});
 // Wait for the labels table to become available
 TEST_UTIL.waitTableEnabled(LABELS_TABLE_NAME.getName(), 50000);
 addLabels();
}

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

@Before
public void setUp() throws Exception {
 createNamespace(TEST_UTIL, NamespaceDescriptor.create(namespace).build());
 try (Table table = createTable(TEST_UTIL, tableName,
    new byte[][] { TEST_FAMILY, TEST_FAMILY_2 })) {
  TEST_UTIL.waitTableEnabled(tableName);
  // Ingesting test data.
  table.put(Arrays.asList(new Put(TEST_ROW).addColumn(TEST_FAMILY, Q1, value1),
    new Put(TEST_ROW_2).addColumn(TEST_FAMILY, Q2, value2),
    new Put(TEST_ROW_3).addColumn(TEST_FAMILY_2, Q1, value1)));
 }
 assertEquals(1, AccessControlLists.getTablePermissions(conf, tableName).size());
 try {
  assertEquals(1, AccessControlClient.getUserPermissions(systemUserConnection,
    tableName.toString()).size());
 } catch (Throwable e) {
  LOG.error("Error during call of AccessControlClient.getUserPermissions. ", e);
 }
}

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

@BeforeClass
public static void setupBeforeClass() throws Exception {
 // setup configuration
 conf = TEST_UTIL.getConfiguration();
 VisibilityTestUtil.enableVisiblityLabels(conf);
 conf.setClass(VisibilityUtils.VISIBILITY_LABEL_GENERATOR_CLASS, SimpleScanLabelGenerator.class,
  ScanLabelGenerator.class);
 conf.set("hbase.superuser", "admin");
 TEST_UTIL.startMiniCluster(2);
 SUPERUSER = User.createUserForTesting(conf, "admin", new String[] { "supergroup" });
 // Wait for the labels table to become available
 TEST_UTIL.waitTableEnabled(LABELS_TABLE_NAME.getName(), 50000);
 addLabels();
}

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

@BeforeClass
public static void setupBeforeClass() throws Exception {
 TEST_UTIL = new HBaseTestingUtility();
 Configuration conf = TEST_UTIL.getConfiguration();
 // Up the handlers; this test needs more than usual.
 conf.setInt(HConstants.REGION_SERVER_HIGH_PRIORITY_HANDLER_COUNT, 10);
 enableSecurity(conf);
 verifyConfiguration(conf);
 // We expect 0.98 scanning semantics
 conf.setBoolean(AccessControlConstants.CF_ATTRIBUTE_EARLY_OUT, false);
 TEST_UTIL.startMiniCluster();
 TEST_UTIL.waitTableEnabled(AccessControlLists.ACL_TABLE_NAME.getName(), 50000);
 READER = User.createUserForTesting(conf, "reader", new String[0]);
 LIMITED = User.createUserForTesting(conf, "limited", new String[0]);
 DENIED = User.createUserForTesting(conf, "denied", new String[0]);
}

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

@BeforeClass
public static void setupCluster() throws Exception {
 util = new HBaseTestingUtility();
 // set the always on security provider
 UserProvider.setUserProviderForTesting(util.getConfiguration(),
  HadoopSecurityEnabledUserProviderForTesting.class);
 // setup configuration
 SecureTestUtil.enableSecurity(util.getConfiguration());
 util.startMiniCluster();
 // Wait for the ACL table to become available
 util.waitTableEnabled(AccessControlLists.ACL_TABLE_NAME);
}

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

@BeforeClass
public static void setupBeforeClass() throws Exception {
 // setup configuration
 conf = TEST_UTIL.getConfiguration();
 VisibilityTestUtil.enableVisiblityLabels(conf);
 conf.setClass(VisibilityUtils.VISIBILITY_LABEL_GENERATOR_CLASS, SimpleScanLabelGenerator.class,
   ScanLabelGenerator.class);
 conf.set("hbase.superuser", "admin");
 TEST_UTIL.startMiniCluster(2);
 SUPERUSER = User.createUserForTesting(conf, "admin", new String[] { "supergroup" });
 USER1 = User.createUserForTesting(conf, "user1", new String[] {});
 // Wait for the labels table to become available
 TEST_UTIL.waitTableEnabled(LABELS_TABLE_NAME.getName(), 50000);
 addLabels();
}

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

@BeforeClass
public static void setupBeforeClass() throws Exception {
 // setup configuration
 conf = TEST_UTIL.getConfiguration();
 VisibilityTestUtil.enableVisiblityLabels(conf);
 conf.setClass(VisibilityUtils.VISIBILITY_LABEL_GENERATOR_CLASS, SimpleScanLabelGenerator.class,
   ScanLabelGenerator.class);
 conf.setClass(VisibilityLabelServiceManager.VISIBILITY_LABEL_SERVICE_CLASS,
   ExpAsStringVisibilityLabelServiceImpl.class, VisibilityLabelService.class);
 conf.set("hbase.superuser", "admin");
 TEST_UTIL.startMiniCluster(2);
 SUPERUSER = User.createUserForTesting(conf, "admin", new String[] { "supergroup" });
 // Wait for the labels table to become available
 TEST_UTIL.waitTableEnabled(LABELS_TABLE_NAME.getName(), 50000);
 addLabels();
}

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

@BeforeClass
public static void provisionCluster() throws Exception {
 conf = util.getConfiguration();
 SUPERUSER = User.createUserForTesting(conf, "admin", new String[] { "supergroup" });
 conf.set("hbase.superuser", "admin,"+User.getCurrent().getName());
 VisibilityTestUtil.enableVisiblityLabels(conf);
 conf.setClass(VisibilityUtils.VISIBILITY_LABEL_GENERATOR_CLASS, SimpleScanLabelGenerator.class,
   ScanLabelGenerator.class);
 util.startMiniCluster();
 // Wait for the labels table to become available
 util.waitTableEnabled(VisibilityConstants.LABELS_TABLE_NAME.getName(), 50000);
 createLabels();
}

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

@BeforeClass
public static void beforeClass() throws Exception {
 // setup configuration
 Configuration conf = UTIL.getConfiguration();
 SecureTestUtil.enableSecurity(conf);
 UTIL.startMiniCluster();
 // Wait for the ACL table to become available
 UTIL.waitTableEnabled(AccessControlLists.ACL_TABLE_NAME);
 ZKW = new ZKWatcher(UTIL.getConfiguration(),
  "TestTablePermissions", ABORTABLE);
 UTIL.createTable(TEST_TABLE, TEST_FAMILY);
 UTIL.createTable(TEST_TABLE2, TEST_FAMILY);
}

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

@BeforeClass
public static void setupBeforeClass() throws Exception {
 // setup configuration
 conf = TEST_UTIL.getConfiguration();
 VisibilityTestUtil.enableVisiblityLabels(conf);
 String currentUser = User.getCurrent().getName();
 conf.set("hbase.superuser", "admin,"+currentUser);
 TEST_UTIL.startMiniCluster(2);
 // Wait for the labels table to become available
 TEST_UTIL.waitTableEnabled(LABELS_TABLE_NAME.getName(), 50000);
 SUPERUSER = User.createUserForTesting(conf, "admin", new String[] { "supergroup" });
 NORMAL_USER = User.createUserForTesting(conf, "user1", new String[] {});
 NORMAL_USER1 = User.createUserForTesting(conf, "user2", new String[] {});
 addLabels();
}

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

@BeforeClass
 public static void setUpBeforeClass() throws Exception {
  setUpBaseConf(TEST_UTIL.getConfiguration());
  // Setup separate test-data directory for MR cluster and set corresponding configurations.
  // Otherwise, different test classes running MR cluster can step on each other.
  TEST_UTIL.getDataTestDir();

  // set the always on security provider
  UserProvider.setUserProviderForTesting(TEST_UTIL.getConfiguration(),
   HadoopSecurityEnabledUserProviderForTesting.class);

  // setup configuration
  SecureTestUtil.enableSecurity(TEST_UTIL.getConfiguration());

  TEST_UTIL.startMiniCluster(3);
  TEST_UTIL.startMiniMapReduceCluster();

  // Wait for the ACL table to become available
  TEST_UTIL.waitTableEnabled(AccessControlLists.ACL_TABLE_NAME);
 }
}

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

@BeforeClass
 public static void setUpBeforeClass() throws Exception {
  setUpBaseConf(TEST_UTIL.getConfiguration());
  // Setup separate test-data directory for MR cluster and set corresponding configurations.
  // Otherwise, different test classes running MR cluster can step on each other.
  TEST_UTIL.getDataTestDir();

  // set the always on security provider
  UserProvider.setUserProviderForTesting(TEST_UTIL.getConfiguration(),
   HadoopSecurityEnabledUserProviderForTesting.class);

  // setup configuration
  SecureTestUtil.enableSecurity(TEST_UTIL.getConfiguration());

  TEST_UTIL.startMiniCluster(3);
  TEST_UTIL.startMiniMapReduceCluster();

  // Wait for the ACL table to become available
  TEST_UTIL.waitTableEnabled(AccessControlLists.ACL_TABLE_NAME);
 }
}

相关文章

HBaseTestingUtility类方法