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


Java HBaseAdmin类代码示例

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


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

示例1: getHealth

import org.apache.hadoop.hbase.client.HBaseAdmin; //导入依赖的package包/类
@Override
public HealthCheck.Result getHealth() {
    try {
        HBaseAdmin.checkHBaseAvailable(configuration);

        return HealthCheck.Result.builder()
                .healthy()
                .withMessage("HBase running on:")
                .withDetail("quorum", quorum)
                .withDetail("clientPort", clientPort)
                .withDetail("znodeParent", znodeParent)
                .build();
    } catch (Exception e) {
        return HealthCheck.Result.builder()
                .unhealthy(e)
                .build();
    }
}
 
开发者ID:gchq,项目名称:stroom-stats,代码行数:19,代码来源:HBaseConnection.java

示例2: creatTable

import org.apache.hadoop.hbase.client.HBaseAdmin; //导入依赖的package包/类
/**
 * Create a hbaseBtable in case the table is not there Else prints table already exist conf is the
 * configuration file object which needs to be passed, hbase-site.xml
 * @method creatTable
 * @inputParameters: tablename as String, ColumnFamalies as String Array[]
 * @return NA as is a voild method 
 **/
public static void creatTable(String myHbaseBtableName, String[] cfamlies) throws Exception {
  HBaseAdmin hbaseBadmin = new HBaseAdmin(hbaseBconf);
  if (hbaseBadmin.tableExists(myHbaseBtableName)) {
    System.out.println("Ohh.. this table is already there");
  } else {
    @SuppressWarnings("deprecation")
    HTableDescriptor hbaseBtableDesc = new HTableDescriptor(myHbaseBtableName);
    for (int i = 0; i < cfamlies.length; i++) {
      hbaseBtableDesc.addFamily(new HColumnDescriptor(cfamlies[i]));
    }
    hbaseBadmin.createTable(hbaseBtableDesc);// creating a table 
    System.out.println("create table " + myHbaseBtableName + " Done.");
    // Table is created and printed with the name.
  }
}
 
开发者ID:PacktPublishing,项目名称:HBase-High-Performance-Cookbook,代码行数:23,代码来源:HBaseRegularClient.java

示例3: open

import org.apache.hadoop.hbase.client.HBaseAdmin; //导入依赖的package包/类
/**
 * 连接HBase
 */
public static void open() {
	try {
		config = HBaseConfiguration.create();
		conn = HConnectionManager.createConnection(config);
		admin = new HBaseAdmin(conn);
		hbase_table = conn.getTable(ISAXIndex.TABLE_NAME);
	} catch (IOException e) {
		e.printStackTrace();
	}
}
 
开发者ID:ItGql,项目名称:SparkIsax,代码行数:14,代码来源:HBaseUtils.java

示例4: testDisableTableAndRestart

import org.apache.hadoop.hbase.client.HBaseAdmin; //导入依赖的package包/类
@Test(timeout = 300000)
public void testDisableTableAndRestart() throws Exception {
  final TableName tableName = TableName.valueOf("testDisableTableAndRestart");
  final MiniHBaseCluster cluster = TEST_UTIL.getHBaseCluster();
  final HBaseAdmin admin = TEST_UTIL.getHBaseAdmin();
  final HTableDescriptor desc = new HTableDescriptor(tableName);
  desc.addFamily(new HColumnDescriptor(FAMILYNAME));
  admin.createTable(desc);
  admin.disableTable(tableName);
  TEST_UTIL.waitTableDisabled(tableName.getName());

  TEST_UTIL.getHBaseCluster().shutdown();
  TEST_UTIL.getHBaseCluster().waitUntilShutDown();

  TEST_UTIL.restartHBaseCluster(2);

  admin.enableTable(tableName);
  TEST_UTIL.waitTableEnabled(tableName);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:20,代码来源:TestEnableTableHandler.java

示例5: createTable

import org.apache.hadoop.hbase.client.HBaseAdmin; //导入依赖的package包/类
public static void createTable(HBaseTestingUtility testUtil, HBaseAdmin admin,
  HTableDescriptor htd, byte [][] splitKeys)
throws Exception {
  // NOTE: We need a latch because admin is not sync,
  // so the postOp coprocessor method may be called after the admin operation returned.
  MasterSyncObserver observer = (MasterSyncObserver)testUtil.getHBaseCluster().getMaster()
    .getMasterCoprocessorHost().findCoprocessor(MasterSyncObserver.class.getName());
  observer.tableCreationLatch = new CountDownLatch(1);
  if (splitKeys != null) {
    admin.createTable(htd, splitKeys);
  } else {
    admin.createTable(htd);
  }
  observer.tableCreationLatch.await();
  observer.tableCreationLatch = null;
  testUtil.waitUntilAllRegionsAssigned(htd.getTableName());
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:18,代码来源:TestEnableTableHandler.java

示例6: deleteTable

import org.apache.hadoop.hbase.client.HBaseAdmin; //导入依赖的package包/类
public static void deleteTable(HBaseTestingUtility testUtil, HBaseAdmin admin,
  TableName tableName)
throws Exception {
  // NOTE: We need a latch because admin is not sync,
  // so the postOp coprocessor method may be called after the admin operation returned.
  MasterSyncObserver observer = (MasterSyncObserver)testUtil.getHBaseCluster().getMaster()
    .getMasterCoprocessorHost().findCoprocessor(MasterSyncObserver.class.getName());
  observer.tableDeletionLatch = new CountDownLatch(1);
  try {
    admin.disableTable(tableName);
  } catch (Exception e) {
    LOG.debug("Table: " + tableName + " already disabled, so just deleting it.");
  }
  admin.deleteTable(tableName);
  observer.tableDeletionLatch.await();
  observer.tableDeletionLatch = null;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:18,代码来源:TestEnableTableHandler.java

示例7: 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();
  Admin 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,项目名称:ditb,代码行数:22,代码来源:TestMiniClusterLoadSequential.java

示例8: getDeployedHRIs

import org.apache.hadoop.hbase.client.HBaseAdmin; //导入依赖的package包/类
/**
 * Get region info from local cluster.
 */
Map<ServerName, List<String>> getDeployedHRIs(final HBaseAdmin admin) throws IOException {
  ClusterStatus status = admin.getClusterStatus();
  Collection<ServerName> regionServers = status.getServers();
  Map<ServerName, List<String>> mm =
      new HashMap<ServerName, List<String>>();
  for (ServerName hsi : regionServers) {
    AdminProtos.AdminService.BlockingInterface server = ((HConnection) connection).getAdmin(hsi);

    // list all online regions from this region server
    List<HRegionInfo> regions = ProtobufUtil.getOnlineRegions(server);
    List<String> regionNames = new ArrayList<String>();
    for (HRegionInfo hri : regions) {
      regionNames.add(hri.getRegionNameAsString());
    }
    mm.put(hsi, regionNames);
  }
  return mm;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:22,代码来源:TestHBaseFsck.java

示例9: prepareData

import org.apache.hadoop.hbase.client.HBaseAdmin; //导入依赖的package包/类
private Store prepareData() throws IOException {
  HBaseAdmin admin = TEST_UTIL.getHBaseAdmin();
  if (admin.tableExists(tableName)) {
    admin.disableTable(tableName);
    admin.deleteTable(tableName);
  }
  HTable table = TEST_UTIL.createTable(tableName, family);
  Random rand = new Random();
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      byte[] value = new byte[128 * 1024];
      rand.nextBytes(value);
      table.put(new Put(Bytes.toBytes(i * 10 + j)).add(family, qualifier, value));
    }
    admin.flush(tableName);
  }
  return getStoreWithName(tableName);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:19,代码来源:TestCompactionWithThroughputController.java

示例10: compactAndWait

import org.apache.hadoop.hbase.client.HBaseAdmin; //导入依赖的package包/类
private void compactAndWait() throws IOException, InterruptedException {
  LOG.debug("Compacting table " + tableName);
  HRegionServer rs = TEST_UTIL.getMiniHBaseCluster().getRegionServer(0);
  HBaseAdmin admin = TEST_UTIL.getHBaseAdmin();
  admin.majorCompact(tableName);

  // Waiting for the compaction to start, at least .5s.
  final long maxWaitime = System.currentTimeMillis() + 500;
  boolean cont;
  do {
    cont = rs.compactSplitThread.getCompactionQueueSize() == 0;
    Threads.sleep(1);
  } while (cont && System.currentTimeMillis() < maxWaitime);

  while (rs.compactSplitThread.getCompactionQueueSize() > 0) {
    Threads.sleep(1);
  }
  LOG.debug("Compaction queue size reached 0, continuing");
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:20,代码来源:TestChangingEncoding.java

示例11: runTestFromCommandLine

import org.apache.hadoop.hbase.client.HBaseAdmin; //导入依赖的package包/类
@Override
public int runTestFromCommandLine() throws Exception {
  IntegrationTestingUtility.setUseDistributedCluster(getConf());
  int numPresplits = getConf().getInt("loadmapper.numPresplits", 5);
  // create HTableDescriptor for specified table
  HTableDescriptor htd = new HTableDescriptor(getTablename());
  htd.addFamily(new HColumnDescriptor(TEST_FAMILY));

  Admin admin = new HBaseAdmin(getConf());
  try {
    admin.createTable(htd, Bytes.toBytes(0L), Bytes.toBytes(-1L), numPresplits);
  } finally {
    admin.close();
  }
  doLoad(getConf(), htd);
  doVerify(getConf(), htd);
  getTestingUtil(getConf()).deleteTable(htd.getName());
  return 0;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:20,代码来源:IntegrationTestWithCellVisibilityLoadAndVerify.java

示例12: create

import org.apache.hadoop.hbase.client.HBaseAdmin; //导入依赖的package包/类
public static void create() throws Exception {
	HBaseAdmin admin = new HBaseAdmin(cfg);
	if (admin.tableExists(tableName)) {
		System.out.println("[info]table has created!");
	} else {
		try {
			TableName table = TableName.valueOf(tableName);
			HTableDescriptor tableDescriptor = new HTableDescriptor(table);
			tableDescriptor.addFamily(new HColumnDescriptor(familyName));

			admin.createTable(tableDescriptor);
		} catch (TableExistsException e) {
			System.out.println("[warning] table exists!");
		}
	}
	System.out.println("[info]create table success!");
}
 
开发者ID:gglinux,项目名称:wifi,代码行数:18,代码来源:HBaseTable.java

示例13: create

import org.apache.hadoop.hbase.client.HBaseAdmin; //导入依赖的package包/类
public static void create() throws Exception
{
	HBaseAdmin admin = new HBaseAdmin(cfg);
	if (admin.tableExists(tableName)) {
		System.out.println("[info]table has created!");
	} else {
		TableName table = TableName.valueOf(tableName);
		HTableDescriptor tableDescriptor = new HTableDescriptor(table);
		tableDescriptor.addFamily(new HColumnDescriptor(familyName));
		try{
			admin.createTable(tableDescriptor);
		}catch(TableExistsException e)
		{
			System.out.println("[warning] table exists!");
		}
	}
	System.out.println("[info]create table success!");
}
 
开发者ID:gglinux,项目名称:wifi,代码行数:19,代码来源:HBaseTable.java

示例14: delete

import org.apache.hadoop.hbase.client.HBaseAdmin; //导入依赖的package包/类
public static boolean delete(String tablename) throws IOException{
        
        HBaseAdmin admin=new HBaseAdmin(cfg);
        if(admin.tableExists(tablename)){
                try
                {
                        admin.disableTable(tablename);
                        admin.deleteTable(tablename);
                }catch(Exception ex){
                        ex.printStackTrace();
                        return false;
                }
                
        }
        return true;
}
 
开发者ID:gglinux,项目名称:wifi,代码行数:17,代码来源:HbaseTestCase.java

示例15: setUp

import org.apache.hadoop.hbase.client.HBaseAdmin; //导入依赖的package包/类
@BeforeMethod
public void setUp() throws Exception {
    HBaseAdmin admin = testutil.getHBaseAdmin();

    if (!admin.tableExists(DEFAULT_TIMESTAMP_STORAGE_TABLE_NAME)) {
        HTableDescriptor desc = new HTableDescriptor(TABLE_NAME);
        HColumnDescriptor datafam = new HColumnDescriptor(DEFAULT_TIMESTAMP_STORAGE_CF_NAME);
        datafam.setMaxVersions(Integer.MAX_VALUE);
        desc.addFamily(datafam);

        admin.createTable(desc);
    }

    if (admin.isTableDisabled(DEFAULT_TIMESTAMP_STORAGE_TABLE_NAME)) {
        admin.enableTable(DEFAULT_TIMESTAMP_STORAGE_TABLE_NAME);
    }
    HTableDescriptor[] tables = admin.listTables();
    for (HTableDescriptor t : tables) {
        LOG.info(t.getNameAsString());
    }
}
 
开发者ID:apache,项目名称:incubator-omid,代码行数:22,代码来源:TestHBaseTimestampStorage.java


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