@Override public void call(Admin admin) throws Exception { admin.listTables(); } @Override
private void setupMockTables() throws IOException { HTableDescriptor tables[] = new HTableDescriptor[] { new HTableDescriptor(TableName.valueOf("foo")), new HTableDescriptor(TableName.valueOf("bar")) }; Mockito.doReturn(tables).when(admin).listTables(); }
@Override public Set<String> getTableNames() { try(Admin admin = plugin.getConnection().getAdmin()) { HTableDescriptor[] tables = admin.listTables(); Set<String> tableNames = Sets.newHashSet(); for (HTableDescriptor table : tables) { tableNames.add(new String(table.getTableName().getNameAsString())); } return tableNames; } catch (Exception e) { logger.warn("Failure while loading table names for database '{}'.", getName(), e.getCause()); return Collections.emptySet(); } }
public void waitTableDeleted(TableName name, long timeoutInMillis) throws Exception { long start = System.currentTimeMillis(); while (true) { HTableDescriptor[] tables = admin.listTables(); for (HTableDescriptor htd : tables) { if (htd.getNameAsString() == name.getNameAsString()) return; } if (System.currentTimeMillis() - start > timeoutInMillis) return; Thread.sleep(1000); } }
private void clean() throws IOException { Connection conn = HBaseConnection.get(KylinConfig.getInstanceFromEnv().getStorageUrl()); Admin hbaseAdmin = conn.getAdmin(); for (HTableDescriptor descriptor : hbaseAdmin.listTables()) { String name = descriptor.getNameAsString().toLowerCase(Locale.ROOT); if (name.startsWith("kylin") || name.startsWith("_kylin")) { String x = descriptor.getValue(IRealizationConstants.HTableTag); System.out.println("table name " + descriptor.getNameAsString() + " host: " + x); System.out.println(descriptor); System.out.println(); descriptor.setValue(IRealizationConstants.HTableOwner, "whoami@kylin.apache.org"); hbaseAdmin.modifyTable(TableName.valueOf(descriptor.getNameAsString()), descriptor); } } hbaseAdmin.close(); }
protected HTableDescriptor[] getTables(final Configuration configuration) throws IOException { HTableDescriptor[] htbls = null; try (Connection connection = ConnectionFactory.createConnection(configuration)) { try (Admin admin = connection.getAdmin()) { htbls = admin.listTables(); } } return htbls; } }
@Override public Object run() throws Exception { try (Connection conn = ConnectionFactory.createConnection(TEST_UTIL.getConfiguration()); Admin admin = conn.getAdmin()) { return Arrays.asList(admin.listTables()); } } };
@After public void tearDown() throws Exception { for (HTableDescriptor htd : this.admin.listTables()) { TEST_UTIL.deleteTable(htd.getTableName()); } }
@After public void tearDown() throws Exception { for (HTableDescriptor htd : this.admin.listTables()) { TEST_UTIL.deleteTable(htd.getTableName()); } }
@Test public void createTableInDefaultNamespace() throws Exception { HTableDescriptor desc = new HTableDescriptor(TableName.valueOf(name.getMethodName())); HColumnDescriptor colDesc = new HColumnDescriptor("cf1"); desc.addFamily(colDesc); admin.createTable(desc); assertTrue(admin.listTables().length == 1); admin.disableTable(desc.getTableName()); admin.deleteTable(desc.getTableName()); }
/** * @throws java.lang.Exception */ @After public void tearDown() throws Exception { for (HTableDescriptor htd: TEST_UTIL.getAdmin().listTables()) { LOG.info("Tear down, remove table=" + htd.getTableName()); TEST_UTIL.deleteTable(htd.getTableName()); } }
/** * @throws java.lang.Exception */ @After public void tearDown() throws Exception { for (HTableDescriptor htd : TEST_UTIL.getAdmin().listTables()) { LOG.info("Tear down, remove table=" + htd.getTableName()); TEST_UTIL.deleteTable(htd.getTableName()); } }
@Test public void createTableInSystemNamespace() throws Exception { final TableName tableName = TableName.valueOf("hbase:" + name.getMethodName()); HTableDescriptor desc = new HTableDescriptor(tableName); HColumnDescriptor colDesc = new HColumnDescriptor("cf1"); desc.addFamily(colDesc); admin.createTable(desc); assertEquals(0, admin.listTables().length); assertTrue(admin.tableExists(tableName)); admin.disableTable(desc.getTableName()); admin.deleteTable(desc.getTableName()); }
@After public void tearDown() throws Exception { resetProcExecutorTestingKillFlag(); for (HTableDescriptor htd: UTIL.getAdmin().listTables()) { LOG.info("Tear down, remove table=" + htd.getTableName()); UTIL.deleteTable(htd.getTableName()); } }
@Test public void testCreateTable() throws IOException { HTableDescriptor [] tables = admin.listTables(); int numTables = tables.length; final TableName tableName = TableName.valueOf(name.getMethodName()); TEST_UTIL.createTable(tableName, HConstants.CATALOG_FAMILY).close(); tables = this.admin.listTables(); assertEquals(numTables + 1, tables.length); assertTrue("Table must be enabled.", TEST_UTIL.getHBaseCluster().getMaster().getTableStateManager() .isTableState(tableName, TableState.State.ENABLED)); assertEquals(TableState.State.ENABLED, getStateFromMeta(tableName)); }
@Before public void setup() throws IOException { try (Connection connection = ConnectionFactory.createConnection(UTIL.getConfiguration()); Admin admin = connection.getAdmin()) { for (HTableDescriptor htd : admin.listTables()) { UTIL.deleteTable(htd.getTableName()); } } }
@Before public void beforeMethod() throws IOException { for (HTableDescriptor desc : admin.listTables(prefix+".*")) { admin.disableTable(desc.getTableName()); admin.deleteTable(desc.getTableName()); } for (NamespaceDescriptor ns : admin.listNamespaceDescriptors()) { if (ns.getName().startsWith(prefix)) { admin.deleteNamespace(ns.getName()); } } }
@After public void tearDown() throws Exception { assertTrue("expected executor to be running", getMasterProcedureExecutor().isRunning()); ProcedureTestingUtility.setKillAndToggleBeforeStoreUpdate(getMasterProcedureExecutor(), false); for (HTableDescriptor htd: UTIL.getAdmin().listTables()) { LOG.info("Tear down, remove table=" + htd.getTableName()); UTIL.deleteTable(htd.getTableName()); } }
@Before public void setUpBefore() throws Exception { TEST_UTIL = new HBaseTestingUtility(); TEST_UTIL.getConfiguration().setInt("dfs.datanode.max.xceivers", 9192); TEST_UTIL.startMiniCluster(3); conf = TEST_UTIL.getConfiguration(); this.connection = ConnectionFactory.createConnection(conf); assertEquals(0, TEST_UTIL.getAdmin().listTables().length); // setup the table table = TableName.valueOf(TABLE_BASE + "-" + tableIdx); tableIdx++; htbl = setupTable(table); populateTable(htbl); assertEquals(5, scanMeta()); LOG.info("Table " + table + " has " + tableRowCount(conf, table) + " entries."); assertEquals(16, tableRowCount(conf, table)); TEST_UTIL.getAdmin().disableTable(table); assertEquals(1, TEST_UTIL.getAdmin().listTables().length); }
@After public void cleanup() throws Exception, KeeperException { for (HTableDescriptor table : ADMIN.listTables()) { ADMIN.disableTable(table.getTableName()); deleteTable(table.getTableName()); } for (NamespaceDescriptor ns : ADMIN.listNamespaceDescriptors()) { if (ns.getName().startsWith(prefix)) { ADMIN.deleteNamespace(ns.getName()); } } assertTrue("Quota manager not initialized", UTIL.getHBaseCluster().getMaster() .getMasterQuotaManager().isQuotaInitialized()); }