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


Java HBaseAdmin.close方法代码示例

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


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

示例1: setupBeforeClass

import org.apache.hadoop.hbase.client.HBaseAdmin; //导入方法依赖的package包/类
@BeforeClass
public static void setupBeforeClass() throws Exception {
  // set configure to indicate which cp should be loaded
  Configuration conf = util.getConfiguration();
  conf.setStrings(CoprocessorHost.REGION_COPROCESSOR_CONF_KEY,
      org.apache.hadoop.hbase.coprocessor.ColumnAggregationEndpoint.class.getName(),
      ProtobufCoprocessorService.class.getName());
  conf.setStrings(CoprocessorHost.MASTER_COPROCESSOR_CONF_KEY,
      ProtobufCoprocessorService.class.getName());
  util.startMiniCluster(2);
  HBaseAdmin admin = new HBaseAdmin(conf);
  HTableDescriptor desc = new HTableDescriptor(TEST_TABLE);
  desc.addFamily(new HColumnDescriptor(TEST_FAMILY));
  admin.createTable(desc, new byte[][]{ROWS[rowSeperator1], ROWS[rowSeperator2]});
  util.waitUntilAllRegionsAssigned(TEST_TABLE);
  admin.close();

  HTable table = new HTable(conf, TEST_TABLE);
  for (int i = 0; i < ROWSIZE; i++) {
    Put put = new Put(ROWS[i]);
    put.add(TEST_FAMILY, TEST_QUALIFIER, Bytes.toBytes(i));
    table.put(put);
  }
  table.close();
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:26,代码来源:TestCoprocessorEndpoint.java

示例2: deleteTable

import org.apache.hadoop.hbase.client.HBaseAdmin; //导入方法依赖的package包/类
/**
 * @param tableName
 * @return
 */
public boolean deleteTable(String tableName) throws IOException {

	HBaseAdmin admin = new HBaseAdmin(conn);
	if (admin.tableExists(tableName)) {
		try {
			admin.disableTable(tableName);
			admin.deleteTable(tableName);
			LOGGER.info(">>>> Table {} delete success!", tableName);
		} catch (Exception ex) {
			LOGGER.error("delete table error:", ex);
			return false;
		}
	} else {
		LOGGER.warn(">>>> Table {} delete but not exist.", tableName);
	}
	admin.close();
	return true;
}
 
开发者ID:micmiu,项目名称:bigdata-tutorial,代码行数:23,代码来源:HBaseFactoryTest.java

示例3: prepareForLoadTest

import org.apache.hadoop.hbase.client.HBaseAdmin; //导入方法依赖的package包/类
protected void prepareForLoadTest() throws IOException {
  LOG.info("Starting load test: dataBlockEncoding=" + dataBlockEncoding +
      ", isMultiPut=" + isMultiPut);
  numKeys = numKeys();
  HBaseAdmin admin = new HBaseAdmin(conf);
  while (admin.getClusterStatus().getServers().size() < NUM_RS) {
    LOG.info("Sleeping until " + NUM_RS + " RSs are online");
    Threads.sleepWithoutInterrupt(1000);
  }
  admin.close();

  HTableDescriptor htd = new HTableDescriptor(TABLE);
  HColumnDescriptor hcd = new HColumnDescriptor(CF)
    .setCompressionType(compression)
    .setDataBlockEncoding(dataBlockEncoding);
  createPreSplitLoadTestTable(htd, hcd);

  LoadTestDataGenerator dataGen = new MultiThreadedAction.DefaultDataGenerator(CF);
  writerThreads = prepareWriterThreads(dataGen, conf, TABLE);
  readerThreads = prepareReaderThreads(dataGen, conf, TABLE, 100);
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:22,代码来源:TestMiniClusterLoadSequential.java

示例4: connect

import org.apache.hadoop.hbase.client.HBaseAdmin; //导入方法依赖的package包/类
@Override
public void connect() throws IOException
{
  super.connect();
  HTableDescriptor tdesc = table.getTableDescriptor();
  if (!tdesc.hasFamily(columnFamilyBytes)) {
    HBaseAdmin admin = new HBaseAdmin(table.getConfiguration());
    admin.disableTable(table.getTableName());
    try {
      HColumnDescriptor cdesc = new HColumnDescriptor(columnFamilyBytes);
      admin.addColumn(table.getTableName(), cdesc);
    } finally {
      admin.enableTable(table.getTableName());
      admin.close();
    }
  }
}
 
开发者ID:apache,项目名称:apex-malhar,代码行数:18,代码来源:HBaseWindowStore.java

示例5: getTable

import org.apache.hadoop.hbase.client.HBaseAdmin; //导入方法依赖的package包/类
/**
    * Gets a handle of a specific table.
    * @param tableName of the table to be accessed.
    * @return HTable of the table found.
    */
   @Override
   public HTable getTable(String tableName) {
logger.debug("NATIVE Begin of getTable for " + tableName);
       HTable table = tableNameHandleMap.get(tableName);
       if (table != null) {
           logger.debug("NATIVE Found a cached handle for table " + tableName);
           return table;
       }
       try {
           logger.debug("NATIVE Looking for a handle of table: " + tableName);
           HBaseAdmin admin = new HBaseAdmin(this.getHbcfg());
           HTableDescriptor[] resources = admin.listTables(tableName);
    Preconditions.checkElementIndex(0, resources.length, "no table " + tableName + " found");
           admin.close();
           table = new HTable(this.getHbcfg(), tableName);
       } catch (IOException e) {
           logger.error("NATIVE Error while trying to obtain table: " + tableName);
           logger.error(e.getMessage());
       };
       tableNameHandleMap.put(tableName, table);
       logger.debug("NATIVE Cached a handle of table: " + tableName);
       return table;
   }
 
开发者ID:dkmfbk,项目名称:knowledgestore,代码行数:29,代码来源:HBaseUtils.java

示例6: createTable

import org.apache.hadoop.hbase.client.HBaseAdmin; //导入方法依赖的package包/类
public Boolean createTable(String tableName, String familyName) throws Exception {
	HBaseAdmin admin = new HBaseAdmin(conn);
	if (admin.tableExists(tableName)) {
		LOGGER.warn(">>>> Table {} exists!", tableName);
		admin.close();
		return false;
	}
	HTableDescriptor tableDesc = new HTableDescriptor(TableName.valueOf(tableName));
	tableDesc.addFamily(new HColumnDescriptor(familyName));
	admin.createTable(tableDesc);
	LOGGER.info(">>>> Table {} create success!", tableName);

	admin.close();
	return true;

}
 
开发者ID:micmiu,项目名称:bigdata-tutorial,代码行数:17,代码来源:HBaseFactoryTest.java

示例7: testTableDeletion

import org.apache.hadoop.hbase.client.HBaseAdmin; //导入方法依赖的package包/类
@Test
public void testTableDeletion() throws Exception {
  User TABLE_ADMIN = User.createUserForTesting(conf, "TestUser", new String[0]);

  // Grant TABLE ADMIN privs
  grantOnTable(TEST_UTIL, TABLE_ADMIN.getShortName(),
    TEST_TABLE.getTableName(), null, null,
    Permission.Action.ADMIN);

  AccessTestAction deleteTableAction = new AccessTestAction() {
    @Override
    public Object run() throws Exception {
      HBaseAdmin admin = new HBaseAdmin(TEST_UTIL.getConfiguration());
      try {
        admin.disableTable(TEST_TABLE.getTableName());
        admin.deleteTable(TEST_TABLE.getTableName());
      } finally {
        admin.close();
      }
      return null;
    }
  };

  verifyDenied(deleteTableAction, USER_RW, USER_RO, USER_NONE);
  verifyAllowed(deleteTableAction, TABLE_ADMIN);
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:27,代码来源:TestAccessController.java

示例8: deleteTable

import org.apache.hadoop.hbase.client.HBaseAdmin; //导入方法依赖的package包/类
/**
 * @param tableName
 * @return
 */
public boolean deleteTable(String tableName) throws IOException {

	HBaseAdmin admin = new HBaseAdmin(getConnPool().getConn());
	if (admin.tableExists(tableName)) {
		try {
			if (admin.isTableEnabled(tableName)) {
				admin.disableTable(tableName);
			}
			admin.deleteTable(tableName);
			LOGGER.info(">>>> Table {} delete success!", tableName);
		} catch (Exception ex) {
			LOGGER.error("delete table error:", ex);
			return false;
		}
	} else {
		LOGGER.warn(">>>> Table {} delete but not exist.", tableName);
	}
	admin.close();
	return true;
}
 
开发者ID:micmiu,项目名称:bigdata-tutorial,代码行数:25,代码来源:HBaseDDLHandler.java

示例9: createTableIfMissing

import org.apache.hadoop.hbase.client.HBaseAdmin; //导入方法依赖的package包/类
private void createTableIfMissing() throws IOException {
  try {
    HTableDescriptor ihtd = new HTableDescriptor(TableName.valueOf(TABLE_NAME));
    for (byte[] family : FAMILIES) {
      ihtd.addFamily(new HColumnDescriptor(family));
    }
    IndexSpecification iSpec = new IndexSpecification("ScanIndex");
    iSpec.addIndexColumn(new HColumnDescriptor(Bytes.toString(FAMILY_A)),
      Bytes.toString(QUALIFIER_NAME) + "1", ValueType.String, 10);
    TableIndices indices = new TableIndices();
    indices.addIndex(iSpec);
    HBaseAdmin admin = new IndexAdmin(util.getConfiguration());
    admin.createTable(ihtd);
    admin.close();
  } catch (TableExistsException tee) {
  }
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:18,代码来源:TestAcidGuaranteesForIndex.java

示例10: createTable

import org.apache.hadoop.hbase.client.HBaseAdmin; //导入方法依赖的package包/类
public Boolean createTable(String tableName, String familyName) throws Exception {
	HBaseAdmin admin = new HBaseAdmin(hconn);
	if (admin.tableExists(tableName)) {
		LOGGER.warn(">>>> Table {} exists!", tableName);
		admin.close();
		return false;
	}
	HTableDescriptor tableDesc = new HTableDescriptor(TableName.valueOf(tableName));
	tableDesc.addFamily(new HColumnDescriptor(familyName));
	admin.createTable(tableDesc);
	LOGGER.info(">>>> Table {} create success!", tableName);

	admin.close();
	return true;

}
 
开发者ID:micmiu,项目名称:bigdata-tutorial,代码行数:17,代码来源:HBaseSimpleDemo.java

示例11: RegionSizeCalculator

import org.apache.hadoop.hbase.client.HBaseAdmin; //导入方法依赖的package包/类
/**
 * Computes size of each region for table and given column families.
 * 
 * @deprecated Use {@link #RegionSizeCalculator(RegionLocator, Admin)} instead.
 */
@Deprecated
public RegionSizeCalculator(HTable table) throws IOException {
  HBaseAdmin admin = new HBaseAdmin(table.getConfiguration());
  try {
    init(table.getRegionLocator(), admin);
  } finally {
    admin.close();
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:15,代码来源:RegionSizeCalculator.java

示例12: createTable

import org.apache.hadoop.hbase.client.HBaseAdmin; //导入方法依赖的package包/类
private void createTable(Configuration conf, String tableName) throws IOException {
	HBaseAdmin admin = new HBaseAdmin(conf);
	if (admin.tableExists(tableName)) {
		admin.close();
		return;
	}
	HTableDescriptor table = new HTableDescriptor(tableName);
	table.addFamily(new HColumnDescriptor("info"));
	admin.createTable(table);
	admin.close();
}
 
开发者ID:BGI-flexlab,项目名称:SOAPgaea,代码行数:12,代码来源:LoadVCFToHBase.java

示例13: LoadHFile2HBase

import org.apache.hadoop.hbase.client.HBaseAdmin; //导入方法依赖的package包/类
private void LoadHFile2HBase(Configuration conf,String tableName,String hfile) throws Exception{
	conf.set("hbase.metrics.showTableName", "false");
	LoadIncrementalHFiles loader = new LoadIncrementalHFiles(conf);
	HBaseAdmin admin = new HBaseAdmin(conf);
	HTable table = new HTable(conf, tableName);

	loader.doBulkLoad(new Path(hfile), table);
	table.flushCommits();
	table.close();
	admin.close();
}
 
开发者ID:BGI-flexlab,项目名称:SOAPgaea,代码行数:12,代码来源:LoadVCFToHBase.java

示例14: enableOmidCompaction

import org.apache.hadoop.hbase.client.HBaseAdmin; //导入方法依赖的package包/类
public static void enableOmidCompaction(Configuration conf,
                                        TableName table, byte[] columnFamily) throws IOException {
    HBaseAdmin admin = new HBaseAdmin(conf);
    try {
        HTableDescriptor desc = admin.getTableDescriptor(table);
        HColumnDescriptor cfDesc = desc.getFamily(columnFamily);
        cfDesc.setValue(OmidCompactor.OMID_COMPACTABLE_CF_FLAG,
                Boolean.TRUE.toString());
        admin.modifyColumn(table, cfDesc);
    } finally {
        admin.close();
    }
}
 
开发者ID:apache,项目名称:incubator-omid,代码行数:14,代码来源:CompactorUtil.java

示例15: disableOmidCompaction

import org.apache.hadoop.hbase.client.HBaseAdmin; //导入方法依赖的package包/类
public static void disableOmidCompaction(Configuration conf,
                                         TableName table, byte[] columnFamily) throws IOException {
    HBaseAdmin admin = new HBaseAdmin(conf);
    try {
        HTableDescriptor desc = admin.getTableDescriptor(table);
        HColumnDescriptor cfDesc = desc.getFamily(columnFamily);
        cfDesc.setValue(OmidCompactor.OMID_COMPACTABLE_CF_FLAG,
                Boolean.FALSE.toString());
        admin.modifyColumn(table, cfDesc);
    } finally {
        admin.close();
    }
}
 
开发者ID:apache,项目名称:incubator-omid,代码行数:14,代码来源:CompactorUtil.java


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