hbaseAdmin.disableTable(tableName); desc.setValue(IRealizationConstants.HTableTag, srcConfig.getMetadataUrlPrefix()); hbaseAdmin.modifyTable(tableName, desc); hbaseAdmin.enableTable(tableName); break;
public void fixInconsistent() throws IOException { if (ifFix == true) { for (String segFullName : inconsistentHTables) { String[] sepNameList = StringUtil.splitByComma(segFullName); HTableDescriptor desc = hbaseAdmin.getTableDescriptor(TableName.valueOf(sepNameList[0])); logger.info("Change the host of htable " + sepNameList[0] + "belonging to cube " + sepNameList[1] + " from " + desc.getValue(IRealizationConstants.HTableTag) + " to " + dstCfg.getMetadataUrlPrefix()); hbaseAdmin.disableTable(sepNameList[0]); desc.setValue(IRealizationConstants.HTableTag, dstCfg.getMetadataUrlPrefix()); hbaseAdmin.modifyTable(sepNameList[0], desc); hbaseAdmin.enableTable(sepNameList[0]); } } else { logger.info("------ Inconsistent HTables Needed To Be Fixed ------"); for (String hTable : inconsistentHTables) { String[] sepNameList = StringUtil.splitByComma(hTable); logger.info(sepNameList[0] + " belonging to cube " + sepNameList[1]); } logger.info("----------------------------------------------------"); } }
/** * Set the table's replication switch if the table's replication switch is already not set. * @param tableName name of the table * @param enableRep is replication switch enable or disable * @throws IOException if a remote or network exception occurs */ private void setTableRep(final TableName tableName, boolean enableRep) throws IOException { TableDescriptor tableDesc = getDescriptor(tableName); if (!tableDesc.matchReplicationScope(enableRep)) { int scope = enableRep ? HConstants.REPLICATION_SCOPE_GLOBAL : HConstants.REPLICATION_SCOPE_LOCAL; modifyTable(TableDescriptorBuilder.newBuilder(tableDesc).setReplicationScope(scope).build()); } }
hbaseAdmin.disableTable(tableName); desc.setValue(IRealizationConstants.HTableTag, dstConfig.getMetadataUrlPrefix()); hbaseAdmin.modifyTable(tableName, desc); hbaseAdmin.enableTable(tableName); logger.info("CHANGE_HTABLE_HOST is completed");
hbaseAdmin.disableTable(tableName); desc.setValue(IRealizationConstants.HTableTag, srcConfig.getMetadataUrlPrefix()); hbaseAdmin.modifyTable(tableName, desc); hbaseAdmin.enableTable(tableName); break;
/** * Creates the or update table. * * @param tablename * the tablename * @param hTableDescriptor * the h table descriptor */ private void createOrUpdateTable(String tablename, HTableDescriptor hTableDescriptor) { try { if (admin.isTableAvailable(tablename)) { admin.modifyTable(tablename, hTableDescriptor); } else { admin.createTable(hTableDescriptor); } } catch (IOException ioex) { logger.error("Either table isn't in enabled state or some network problem, Caused by: ", ioex); throw new SchemaGenerationException(ioex, "Either table isn't in enabled state or some network problem."); } }
public static void resetCoprocessor(String tableName, HBaseAdmin hbaseAdmin, Path hdfsCoprocessorJar) throws IOException { logger.info("Disable " + tableName); hbaseAdmin.disableTable(tableName); logger.info("Unset coprocessor on " + tableName); HTableDescriptor desc = hbaseAdmin.getTableDescriptor(TableName.valueOf(tableName)); while (desc.hasCoprocessor(OBSERVER_CLS_NAME)) { desc.removeCoprocessor(OBSERVER_CLS_NAME); } while (desc.hasCoprocessor(ENDPOINT_CLS_NAMAE)) { desc.removeCoprocessor(ENDPOINT_CLS_NAMAE); } addCoprocessorOnHTable(desc, hdfsCoprocessorJar); hbaseAdmin.modifyTable(tableName, desc); logger.info("Enable " + tableName); hbaseAdmin.enableTable(tableName); }
private void alter() throws IOException { Configuration conf = HBaseConfiguration.create(); HBaseAdmin hbaseAdmin = new HBaseAdmin(conf); HTableDescriptor table = hbaseAdmin.getTableDescriptor(TableName.valueOf(tableName)); hbaseAdmin.disableTable(table.getTableName()); table.setValue(metadataKey, metadataValue); hbaseAdmin.modifyTable(table.getTableName(), table); hbaseAdmin.enableTable(table.getTableName()); hbaseAdmin.close(); }
/** * Set the table's replication switch if the table's replication switch is already not set. * @param tableName name of the table * @param enableRep is replication switch enable or disable * @throws IOException if a remote or network exception occurs */ private void setTableRep(final TableName tableName, boolean enableRep) throws IOException { TableDescriptor tableDesc = getDescriptor(tableName); if (!tableDesc.matchReplicationScope(enableRep)) { int scope = enableRep ? HConstants.REPLICATION_SCOPE_GLOBAL : HConstants.REPLICATION_SCOPE_LOCAL; modifyTable(TableDescriptorBuilder.newBuilder(tableDesc).setReplicationScope(scope).build()); } }
hbaseAdmin.disableTable(tableName); desc.setValue(IRealizationConstants.HTableTag, dstConfig.getMetadataUrlPrefix()); hbaseAdmin.modifyTable(tableName, desc); hbaseAdmin.enableTable(tableName); logger.info("CHANGE_HTABLE_HOST is completed");
public void modifyTable(final byte[] tableName, final HTableDescriptor htd) throws IOException { modifyTable(TableName.valueOf(tableName), htd); }
public void modifyTable(final String tableName, final HTableDescriptor htd) throws IOException { modifyTable(TableName.valueOf(tableName), htd); }
@Test public void testRetriveHtableHost() throws IOException { Configuration conf = HBaseConfiguration.create(); HBaseAdmin hbaseAdmin = new HBaseAdmin(conf); HTableDescriptor[] tableDescriptors = hbaseAdmin.listTables(); for (HTableDescriptor table : tableDescriptors) { String value = table.getValue("KYLIN_HOST"); if (value != null) { System.out.println(table.getTableName()); System.out.println("host is " + value); hbaseAdmin.disableTable(table.getTableName()); table.setValue("KYLIN_HOST_ANOTHER", "dev02"); hbaseAdmin.modifyTable(table.getTableName(), table); hbaseAdmin.enableTable(table.getTableName()); } } hbaseAdmin.close(); } }
admin.modifyTable(tableName, newDesc); admin.enableTable(tableName); admin.modifyTable(tableName, newDesc); admin.enableTable(tableName); return false;
HConnection connection = HBaseConnection.createConnection("localhost", "2181"); HBaseAdmin hBaseAdmin = new HBaseAdmin(connection); HTableDescriptor hTableDescriptor = new HTableDescriptor("TTLDemo".getBytes()); HColumnDescriptor hColumnDescriptor = new HColumnDescriptor("C".getBytes()); hColumnDescriptor.setTimeToLive(2); hTableDescriptor.addFamily(hColumnDescriptor); hBaseAdmin.modifyTable("TTLDemo", hTableDescriptor);
@Override public void modifyTable(String namespace, String name, TableDescriptor descriptor) throws IOException { Preconditions.checkArgument(namespace != null, "Namespace should not be null"); Preconditions.checkArgument(name != null, "Table name should not be null."); Preconditions.checkArgument(descriptor != null, "Descriptor should not be null."); HTableDescriptor htd = getHTableDescriptor(descriptor); admin.modifyTable(htd.getTableName(), htd); }
@Override public void modifyTable(String namespace, String name, TableDescriptor descriptor) throws IOException { Preconditions.checkArgument(namespace != null, "Namespace should not be null"); Preconditions.checkArgument(name != null, "Table name should not be null."); Preconditions.checkArgument(descriptor != null, "Descriptor should not be null."); HTableDescriptor htd = getHTableDescriptor(descriptor); admin.modifyTable(htd.getTableName(), htd); }
public Void modifyTable(ByteBuffer tableName, ATableDescriptor tableDescriptor) throws AIOError { try { admin.modifyTable(Bytes.toBytes(tableName), AvroUtil.atdToHTD(tableDescriptor)); return null; } catch (IOException e) { AIOError ioe = new AIOError(); ioe.message = new Utf8(e.getMessage()); throw ioe; } }
private void updateHtable(String tableName) throws IOException { HTableDescriptor desc = hbaseAdmin.getTableDescriptor(TableName.valueOf(tableName)); if (oldHostValue.equals(desc.getValue(IRealizationConstants.HTableTag))) { desc.setValue(IRealizationConstants.HTableTag, kylinConfig.getMetadataUrlPrefix()); hbaseAdmin.disableTable(tableName); hbaseAdmin.modifyTable(tableName, desc); hbaseAdmin.enableTable(tableName); updatedResources.add(tableName); } }
private void alter() throws IOException { Configuration conf = HBaseConfiguration.create(); HBaseAdmin hbaseAdmin = new HBaseAdmin(conf); HTableDescriptor table = hbaseAdmin.getTableDescriptor(TableName.valueOf(tableName)); hbaseAdmin.disableTable(table.getTableName()); table.setValue(metadataKey, metadataValue); hbaseAdmin.modifyTable(table.getTableName(), table); hbaseAdmin.enableTable(table.getTableName()); hbaseAdmin.close(); }