public static void addCoprocessorOnHTable(HTableDescriptor desc, Path hdfsCoprocessorJar) throws IOException { logger.info("Add coprocessor on " + desc.getNameAsString()); desc.addCoprocessor(CubeEndpointClass, hdfsCoprocessorJar, 1001, null); }
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(); }
private static void show() throws IOException { Map<String, List<String>> envs = Maps.newHashMap(); // get all kylin hbase tables KylinConfig kylinConfig = KylinConfig.getInstanceFromEnv(); Connection conn = HBaseConnection.get(kylinConfig.getStorageUrl()); Admin hbaseAdmin = conn.getAdmin(); String tableNamePrefix = kylinConfig.getHBaseTableNamePrefix(); HTableDescriptor[] tableDescriptors = hbaseAdmin.listTables(tableNamePrefix + ".*"); for (HTableDescriptor desc : tableDescriptors) { String host = desc.getValue(IRealizationConstants.HTableTag); if (StringUtils.isEmpty(host)) { add("unknown", desc.getNameAsString(), envs); } else { add(host, desc.getNameAsString(), envs); } } for (Map.Entry<String, List<String>> entry : envs.entrySet()) { System.out.println(entry.getKey() + " has htable count: " + entry.getValue().size()); } hbaseAdmin.close(); }
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); } }
/** * Verify the presence of a column family in the schema path of the hbase table or whether the schema path is * the row key column. * * @param columns List of the selected columns * @param hTableDesc HTableDescriptor of HBase/MapR-DB_binary table (consists the details about that table) * @throws DrillRuntimeException if column family does not exist, or is not row_key column. */ public static void verifyColumns(List<SchemaPath> columns, HTableDescriptor hTableDesc) { if (Utilities.isStarQuery(columns)) { return; } for (SchemaPath column : columns) { if (!(column.equals(DrillHBaseConstants.ROW_KEY_PATH) || hTableDesc.hasFamily(HBaseUtils.getBytes(column.getRootSegment().getPath())))) { DrillRuntimeException.format("The column family '%s' does not exist in HBase table: %s .", column.getRootSegment().getPath(), hTableDesc.getNameAsString()); } } }
String tableNameStr = singleTableInfo.getHTableDescriptor().getNameAsString(); LOG.info("Running LoadIncrementalHFiles on table" + tableNameStr); if (writeMultipleTables) {
private void clean() throws IOException { Configuration conf = HBaseConfiguration.create(); HBaseAdmin hbaseAdmin = new HBaseAdmin(conf); for (HTableDescriptor descriptor : hbaseAdmin.listTables()) { String name = descriptor.getNameAsString().toLowerCase(); if (name.startsWith("kylin") || name.startsWith("_kylin")) { String x = descriptor.getValue("KYLIN_HOST"); System.out.println("table name " + descriptor.getNameAsString() + " host: " + x); System.out.println(descriptor); System.out.println(); } } hbaseAdmin.close(); }
Path basedir = new Path(hbaseRootDir, htd.getNameAsString()); List<Pair<byte[], String>> hfiles = new ArrayList<>(1); for (int i = 0; i < compactionThreshold; i++) {
public static void addCoprocessorOnHTable(HTableDescriptor desc, Path hdfsCoprocessorJar) throws IOException { logger.info("Add coprocessor on " + desc.getNameAsString()); desc.addCoprocessor(ENDPOINT_CLS_NAMAE, hdfsCoprocessorJar, 1000, null); desc.addCoprocessor(OBSERVER_CLS_NAME, hdfsCoprocessorJar, 1001, null); }
private static IndexBuilder getIndexBuilder(RegionCoprocessorEnvironment e) throws IOException { Configuration conf = e.getConfiguration(); Class<? extends IndexBuilder> builderClass = conf.getClass(Indexer.INDEX_BUILDER_CONF_KEY, null, IndexBuilder.class); try { IndexBuilder builder = builderClass.newInstance(); builder.setup(e); return builder; } catch (InstantiationException e1) { throw new IOException("Couldn't instantiate index builder:" + builderClass + ", disabling indexing on table " + e.getRegion().getTableDesc().getNameAsString()); } catch (IllegalAccessException e1) { throw new IOException("Couldn't instantiate index builder:" + builderClass + ", disabling indexing on table " + e.getRegion().getTableDesc().getNameAsString()); } }
/** * Adds the column family and set properties. * * @param tableDescriptor * the table descriptor * @param colFamilyName * the sec table */ private void addColumnFamilyAndSetProperties(HTableDescriptor tableDescriptor, String colFamilyName) { if (!tableDescriptor.hasFamily(colFamilyName.getBytes())) { HColumnDescriptor hColumnDescriptor = getColumnDescriptor(colFamilyName); tableDescriptor.addFamily(hColumnDescriptor); setExternalProperties(tableDescriptor.getNameAsString(), hColumnDescriptor); } }
public void exportTables() throws IOException { cli.execute("mkdir -p " + exportFolder); for (HTableDescriptor table : allTables) { String tName = table.getNameAsString(); if (!tName.equals(tableNameBase) && !tName.startsWith(HBaseMiniclusterHelper.SHARED_STORAGE_PREFIX)) continue; cli.execute("hbase org.apache.hadoop.hbase.mapreduce.Export " + tName + " " + exportFolder + tName); } cli.execute("hadoop fs -copyToLocal " + exportFolder + " " + exportFolder); cli.execute("tar -zcvf " + backupArchive + " --directory=" + exportFolder + " ."); downloadToLocal(); }
public void listCollections(HttpServletResponse resp) throws IOException { HTableDescriptor[] htableDescriptors = null; htableDescriptors = hbaseAdmin.listTables(); resp.setContentType("text/plain"); resp.setStatus(HttpServletResponse.SC_OK); PrintWriter out = resp.getWriter(); for (HTableDescriptor htableDescriptor : htableDescriptors) { String tableNameTmp = htableDescriptor.getNameAsString(); out.println(tableNameTmp); } }
public static void main(String[] args) throws Exception { Configuration conf = HBaseConfiguration.create(); HBaseAdmin admin = new HBaseAdmin(conf); HTableDescriptor[] tables = admin.listTables(); System.out.printf("Found %d table(s)\n", tables.length); for (HTableDescriptor table : tables) { System.out.printf("%s\n", table.getNameAsString()); } } }
@Override public List<String> listTableNames() throws Exception { checkConfiguration(); HTableDescriptor[] tables = m_admin.listTables(); List<String> tableNames = new ArrayList<String>(); for ( HTableDescriptor h : tables ) { tableNames.add( h.getNameAsString() ); } return tableNames; }
@Override public void deleteStorageTables(List<HTableDescriptor> deleteEntityTables) throws MetaException { for (HTableDescriptor htable : deleteEntityTables) { try { hbaseActionManager.deleteStorageTable(htable.getName()); } catch (IOException e) { LOG.error("deleteStorageTables " + htable.getNameAsString(), e); } } }
@Override public void process() { String tableName = this.hTableDescriptor.getNameAsString(); try { LOG.info("Attempting to create the table " + tableName); handleCreateTable(tableName); completed(null); } catch (Throwable e) { LOG.error("Error trying to create the table " + tableName, e); completed(e); } }
@Override protected Supplier<TransactionStateCache> getTransactionStateCacheSupplier(RegionCoprocessorEnvironment env) { String tableName = env.getRegion().getTableDesc().getNameAsString(); String[] parts = tableName.split("\\.", 2); String tableNamespace = ""; if (parts.length > 0) { tableNamespace = parts[0]; } return new DefaultTransactionStateCacheSupplier(tableNamespace, env.getConfiguration()); }
protected Supplier<TransactionStateCache> getTransactionStateCacheSupplier(RegionCoprocessorEnvironment env) { String tableName = env.getRegion().getTableDesc().getNameAsString(); String[] parts = tableName.split("\\.", 2); String tableNamespace = ""; if (parts.length > 0) { tableNamespace = parts[0]; } return new DefaultTransactionStateCacheSupplier(tableNamespace, env.getConfiguration()); }
@Override public void preDeleteTable(ObserverContext<MasterCoprocessorEnvironment> ctx, byte[] tableName) throws IOException { HTableDescriptor tableDesc = ctx.getEnvironment().getMasterServices().getTableDescriptors() .get(tableName); if (isSecondaryIndexEnableTable(tableDesc)) { LOG.info("keep table desc for secondary index enable table, tableName=" + tableDesc.getNameAsString()); deletedTableDesc.set(tableDesc); } }