当前位置: 首页>>代码示例>>Java>>正文


Java HBaseAdmin.modifyTable方法代码示例

本文整理汇总了Java中org.apache.hadoop.hbase.client.HBaseAdmin.modifyTable方法的典型用法代码示例。如果您正苦于以下问题:Java HBaseAdmin.modifyTable方法的具体用法?Java HBaseAdmin.modifyTable怎么用?Java HBaseAdmin.modifyTable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.hadoop.hbase.client.HBaseAdmin的用法示例。


在下文中一共展示了HBaseAdmin.modifyTable方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testModifyTable

import org.apache.hadoop.hbase.client.HBaseAdmin; //导入方法依赖的package包/类
@Test
public void testModifyTable() throws IOException {
  HBaseAdmin admin = TEST_UTIL.getHBaseAdmin();
  // Create a table with one family
  HTableDescriptor baseHtd = new HTableDescriptor(TABLE_NAME);
  baseHtd.addFamily(new HColumnDescriptor(FAMILY_0));
  admin.createTable(baseHtd);
  admin.disableTable(TABLE_NAME);
  try {
    // Verify the table descriptor
    verifyTableDescriptor(TABLE_NAME, FAMILY_0);

    // Modify the table adding another family and verify the descriptor
    HTableDescriptor modifiedHtd = new HTableDescriptor(TABLE_NAME);
    modifiedHtd.addFamily(new HColumnDescriptor(FAMILY_0));
    modifiedHtd.addFamily(new HColumnDescriptor(FAMILY_1));
    admin.modifyTable(TABLE_NAME, modifiedHtd);
    verifyTableDescriptor(TABLE_NAME, FAMILY_0, FAMILY_1);
  } finally {
    admin.deleteTable(TABLE_NAME);
  }
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:23,代码来源:TestTableDescriptorModification.java

示例2: updateTableAttribute

import org.apache.hadoop.hbase.client.HBaseAdmin; //导入方法依赖的package包/类
/**
    @param rawAttributeName is the attribute name viewed by applications, it allows multiple values. For example, secondaryIndex in secondaryIndex$1 and coprocessor in corpcessor$2
    @param indexOfAttribute is of the same raw attribute name, for example 2 in secondary$2
    */
    static void updateTableAttribute(Configuration conf, byte[] tableName, String rawAttributeName, int indexOfAttribute, boolean ifUpdateorRemove, String value) throws IOException{
        HBaseAdmin admin = new HBaseAdmin(conf);
        HTableDescriptor desc = admin.getTableDescriptor(tableName);
        admin.disableTable(tableName);
//        System.out.println("TTDEBUG: disable table " + Bytes.toString(tableName));
        String coprocessorKey = rawAttributeName + indexOfAttribute;
        if(!ifUpdateorRemove) {
            desc.remove(Bytes.toBytes(coprocessorKey));
        } else {
            desc.setValue(coprocessorKey, value);
        }
        admin.modifyTable(tableName, desc);
//        System.out.println("TTDEBUG: modify table " + Bytes.toString(tableName));
        admin.enableTable(tableName);
//        System.out.println("TTDEBUG: enable table " + Bytes.toString(tableName));
        HTableDescriptor descNew = admin.getTableDescriptor(tableName);
        //modify table is asynchronous, has to loop over to check
        while (!desc.equals(descNew)){
            System.err.println("TTDEBUG: waiting for descriptor to change: from " + descNew + " to " + desc);
            try {Thread.sleep(500);} catch(InterruptedException ex) {}
            descNew = admin.getTableDescriptor(tableName);
        }
    }
 
开发者ID:tristartom,项目名称:key-value-store-indexing,代码行数:28,代码来源:HIndexConstantsAndUtils.java

示例3: createIndexTable

import org.apache.hadoop.hbase.client.HBaseAdmin; //导入方法依赖的package包/类
public static void createIndexTable(String userTable, Configuration conf,
    Map<String, List<String>> indexColumnFamily) throws IOException, InterruptedException,
    ClassNotFoundException {
  HBaseAdmin hbaseAdmin = new IndexAdmin(conf);

  try {
    HTableDescriptor tableDescriptor = hbaseAdmin.getTableDescriptor(Bytes.toBytes(userTable));

    String input = conf.get(TABLE_INPUT_COLS);

    HTableDescriptor ihtd = parse(userTable, tableDescriptor, input, indexColumnFamily);

    // disable the table
    hbaseAdmin.disableTable(userTable);
    // This will create the index table. Also modifies the existing table htable descriptor.
    hbaseAdmin.modifyTable(Bytes.toBytes(userTable), ihtd);
    hbaseAdmin.enableTable(Bytes.toBytes(userTable));
  } finally {
    if (hbaseAdmin != null) {
      hbaseAdmin.close();
    }
  }
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:24,代码来源:IndexUtils.java

示例4: modifyTableSync

import org.apache.hadoop.hbase.client.HBaseAdmin; //导入方法依赖的package包/类
private void modifyTableSync(HBaseAdmin admin, byte[] tableName, HTableDescriptor htd)
    throws IOException {
  admin.modifyTable(tableName, htd);
  //wait until modify table finishes
  for (int t = 0; t < 100; t++) { //10 sec timeout
    HTableDescriptor td = admin.getTableDescriptor(htd.getName());
    if (td.equals(htd)) {
      break;
    }
    Threads.sleep(100);
  }
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:13,代码来源:TestMasterObserver.java

示例5: updateCoprocessor

import org.apache.hadoop.hbase.client.HBaseAdmin; //导入方法依赖的package包/类
private static void updateCoprocessor(Configuration conf, byte[] dataTableName) throws IOException{
    HBaseAdmin admin = new HBaseAdmin(conf);
    HTableDescriptor desc = admin.getTableDescriptor(dataTableName);
    admin.disableTable(dataTableName);
    System.out.println("TTDEBUG: disable data table");
    if(INDEX_CP_CLASS.contains("null")) {
        desc.remove(Bytes.toBytes(INDEX_CP_NAME));
    } else {
        desc.setValue(INDEX_CP_NAME, INDEX_CP_PATH + "|" + INDEX_CP_CLASS + "|1001|arg1=1,arg2=2");
    }

    HColumnDescriptor descIndexCF = desc.getFamily(Bytes.toBytes("cf"));//TOREMOVE don't use cf, 
    //KEEP_DELETED_CELLS => 'true'
    descIndexCF.setKeepDeletedCells(true);
    descIndexCF.setTimeToLive(HConstants.FOREVER);
    descIndexCF.setMaxVersions(Integer.MAX_VALUE);

    admin.modifyTable(dataTableName, desc);
    System.out.println("TTDEBUG: modify data table");
    admin.enableTable(dataTableName);
    System.out.println("TTDEBUG: enable data table");
    HTableDescriptor descNew = admin.getTableDescriptor(dataTableName);
    //modify table is asynchronous, has to loop over to check
    while (!desc.equals(descNew)){
        System.out.println("TTDEBUG: waiting for descriptor to change: from " + descNew + " to " + desc);
        try {Thread.sleep(500);} catch(InterruptedException ex) {}
        descNew = admin.getTableDescriptor(dataTableName);
    }
}
 
开发者ID:tristartom,项目名称:key-value-store-indexing,代码行数:30,代码来源:UpdateCoprocessor.java

示例6: modifyTableSync

import org.apache.hadoop.hbase.client.HBaseAdmin; //导入方法依赖的package包/类
private void modifyTableSync(HBaseAdmin admin, TableName tableName, HTableDescriptor htd)
    throws IOException {
  admin.modifyTable(tableName, htd);
  //wait until modify table finishes
  for (int t = 0; t < 100; t++) { //10 sec timeout
    HTableDescriptor td = admin.getTableDescriptor(htd.getTableName());
    if (td.equals(htd)) {
      break;
    }
    Threads.sleep(100);
  }
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:13,代码来源:TestMasterObserver.java

示例7: perform

import org.apache.hadoop.hbase.client.HBaseAdmin; //导入方法依赖的package包/类
@Override
public void perform() throws Exception {
  Random random = new Random();
  HBaseTestingUtility util = context.getHBaseIntegrationTestingUtility();
  HBaseAdmin admin = util.getHBaseAdmin();

  LOG.info("Performing action: Change bloom filter on all columns of table "
      + tableName);
  HTableDescriptor tableDescriptor = admin.getTableDescriptor(Bytes
      .toBytes(tableName));
  HColumnDescriptor[] columnDescriptors = tableDescriptor.getColumnFamilies();

  if (columnDescriptors == null || columnDescriptors.length == 0) {
    return;
  }

  final BloomType[] bloomArray = BloomType.values();
  final int bloomArraySize = bloomArray.length;

  for (HColumnDescriptor descriptor : columnDescriptors) {
    int bloomFilterIndex = random.nextInt(bloomArraySize);
    LOG.debug("Performing action: About to set bloom filter type to "
        + bloomArray[bloomFilterIndex] + " on column "
        + descriptor.getNameAsString() + " of table " + tableName);
    descriptor.setBloomFilterType(bloomArray[bloomFilterIndex]);
    LOG.debug("Performing action: Just set bloom filter type to "
        + bloomArray[bloomFilterIndex] + " on column "
        + descriptor.getNameAsString() + " of table " + tableName);
  }

  admin.modifyTable(tableName, tableDescriptor);
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:33,代码来源:ChangeBloomFilterAction.java

示例8: modifyTable

import org.apache.hadoop.hbase.client.HBaseAdmin; //导入方法依赖的package包/类
@Test
public void modifyTable() throws Exception {
	String TABLE_NAME = "TEST_BENCHMARK";
	//
	Configuration configuration = createConfiguration();
	HBaseAdmin hbaseAdmin = createHBaseAdmin(configuration);
	HTableDescriptor htd = hbaseAdmin.getTableDescriptor(Bytes
			.toBytes(TABLE_NAME));
	//
	HTableDescriptor newHtd = new HTableDescriptor(htd);
	newHtd.setValue(HTableDescriptor.SPLIT_POLICY,
			ConstantSizeRegionSplitPolicy.class.getName());
	//
	boolean disabled = false;
	if (hbaseAdmin.isTableEnabled(TABLE_NAME)) {
		hbaseAdmin.disableTable(TABLE_NAME);
		disabled = true;
	}
	//
	hbaseAdmin.modifyTable(Bytes.toBytes(TABLE_NAME), newHtd);
	//
	if (disabled) {
		hbaseAdmin.enableTable(TABLE_NAME);
	}
	//
	System.out.println(newHtd);
}
 
开发者ID:mixaceh,项目名称:openyu-commons,代码行数:28,代码来源:BenchmarkHzBaoSupporterTest.java

示例9: main

import org.apache.hadoop.hbase.client.HBaseAdmin; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
	String quorum = "192.168.0.30,192.168.0.31,192.168.0.32";
	//quorum = "192.168.8.191,192.168.1.192,192.168.1.193";
	int port = 2181;
	String znode = "/hyperbase1";
	HBaseConnPool connPool = new HBaseClientManager(quorum, port, znode);
	HBaseDDLHandler ddlHandler = new HBaseDDLHandler(connPool);

	String tableName = "demo_test";
	System.out.println("=============================== : delete");
	ddlHandler.deleteTable(tableName);

	String columnFamily = "cf";
	System.out.println("=============================== : create");
	ddlHandler.createTable(tableName, columnFamily, "cf2");

	System.out.println("=============================== : desc");
	HBaseUtils.printTableInfo(ddlHandler.getTable(tableName));
	System.out.println("=============================== : alter");
	HBaseAdmin admin = new HBaseAdmin(connPool.getConn());
	admin.disableTable(tableName);
	HTableInterface htable = ddlHandler.getTable(tableName);
	HTableDescriptor tableDesc = admin.getTableDescriptor(htable.getTableName());
	tableDesc.removeFamily(Bytes.toBytes("cf2"));
	HColumnDescriptor newhcd = new HColumnDescriptor("cf3");
	newhcd.setMaxVersions(2);
	newhcd.setKeepDeletedCells(KeepDeletedCells.TRUE);
	tableDesc.addFamily(newhcd);

	admin.modifyTable(tableName, tableDesc);
	admin.enableTable(tableName);
	admin.close();

	System.out.println("=============================== : desc");
	HBaseUtils.printTableInfo(ddlHandler.getTable(tableName));
	System.out.println("=============================== : delete");
	ddlHandler.deleteTable(tableName);

	connPool.closeConn();
}
 
开发者ID:micmiu,项目名称:bigdata-tutorial,代码行数:41,代码来源:HBaseDDLHandlerTest.java

示例10: testHbckFixOrphanTable

import org.apache.hadoop.hbase.client.HBaseAdmin; //导入方法依赖的package包/类
@Test
public void testHbckFixOrphanTable() throws Exception {
  String table = "tableInfo";
  FileSystem fs = null;
  Path tableinfo = null;
  try {
    setupTable(table);
    HBaseAdmin admin = TEST_UTIL.getHBaseAdmin();

    Path hbaseTableDir = new Path(conf.get(HConstants.HBASE_DIR) + "/" + table );
    fs = hbaseTableDir.getFileSystem(conf);
    FileStatus status = FSTableDescriptors.getTableInfoPath(fs, hbaseTableDir);
    tableinfo = status.getPath();
    fs.rename(tableinfo, new Path("/.tableinfo"));

    //to report error if .tableinfo is missing.
    HBaseFsck hbck = doFsck(conf, false);
    assertErrors(hbck, new ERROR_CODE[] { ERROR_CODE.NO_TABLEINFO_FILE });

    // fix OrphanTable with default .tableinfo (htd not yet cached on master)
    hbck = doFsck(conf, true);
    assertNoErrors(hbck);
    status = null;
    status = FSTableDescriptors.getTableInfoPath(fs, hbaseTableDir);
    assertNotNull(status);

    HTableDescriptor htd = admin.getTableDescriptor(table.getBytes());
    htd.setValue("NOT_DEFAULT", "true");
    admin.disableTable(table);
    admin.modifyTable(table.getBytes(), htd);
    admin.enableTable(table);
    fs.delete(status.getPath(), true);

    // fix OrphanTable with cache
    htd = admin.getTableDescriptor(table.getBytes()); // warms up cached htd on master
    hbck = doFsck(conf, true);
    assertNoErrors(hbck);
    status = null;
    status = FSTableDescriptors.getTableInfoPath(fs, hbaseTableDir);
    assertNotNull(status);
    htd = admin.getTableDescriptor(table.getBytes());
    assertEquals(htd.getValue("NOT_DEFAULT"), "true");
  } finally {
    fs.rename(new Path("/.tableinfo"), tableinfo);
    deleteTable(table);
  }
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:48,代码来源:TestHBaseFsck.java

示例11: testHbckFixOrphanTable

import org.apache.hadoop.hbase.client.HBaseAdmin; //导入方法依赖的package包/类
@Test
public void testHbckFixOrphanTable() throws Exception {
  TableName table = TableName.valueOf("tableInfo");
  FileSystem fs = null;
  Path tableinfo = null;
  try {
    setupTable(table);
    HBaseAdmin admin = TEST_UTIL.getHBaseAdmin();

    Path hbaseTableDir = FSUtils.getTableDir(
        FSUtils.getRootDir(conf), table);
    fs = hbaseTableDir.getFileSystem(conf);
    FileStatus status = FSTableDescriptors.getTableInfoPath(fs, hbaseTableDir);
    tableinfo = status.getPath();
    fs.rename(tableinfo, new Path("/.tableinfo"));

    //to report error if .tableinfo is missing.
    HBaseFsck hbck = doFsck(conf, false);
    assertErrors(hbck, new ERROR_CODE[] { ERROR_CODE.NO_TABLEINFO_FILE });

    // fix OrphanTable with default .tableinfo (htd not yet cached on master)
    hbck = doFsck(conf, true);
    assertNoErrors(hbck);
    status = null;
    status = FSTableDescriptors.getTableInfoPath(fs, hbaseTableDir);
    assertNotNull(status);

    HTableDescriptor htd = admin.getTableDescriptor(table);
    htd.setValue("NOT_DEFAULT", "true");
    admin.disableTable(table);
    admin.modifyTable(table, htd);
    admin.enableTable(table);
    fs.delete(status.getPath(), true);

    // fix OrphanTable with cache
    htd = admin.getTableDescriptor(table); // warms up cached htd on master
    hbck = doFsck(conf, true);
    assertNoErrors(hbck);
    status = null;
    status = FSTableDescriptors.getTableInfoPath(fs, hbaseTableDir);
    assertNotNull(status);
    htd = admin.getTableDescriptor(table);
    assertEquals(htd.getValue("NOT_DEFAULT"), "true");
  } finally {
    fs.rename(new Path("/.tableinfo"), tableinfo);
    deleteTable(table);
  }
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:49,代码来源:TestHBaseFsck.java


注:本文中的org.apache.hadoop.hbase.client.HBaseAdmin.modifyTable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。