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


Java HBaseAdmin.isTableDisabled方法代码示例

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


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

示例1: 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

示例2: deleteTable

import org.apache.hadoop.hbase.client.HBaseAdmin; //导入方法依赖的package包/类
/**
 * delete table in preparation for next test
 * 
 * @param tablename
 * @throws IOException
 */
void deleteTable(String tablename) throws IOException {
  HBaseAdmin admin = new HBaseAdmin(conf);
  admin.getConnection().clearRegionCache();
  byte[] tbytes = Bytes.toBytes(tablename);
  if (admin.isTableEnabled(tbytes)) {
    admin.disableTableAsync(tbytes);
  }
  while (!admin.isTableDisabled(tbytes)) {
    try {
      Thread.sleep(250);
    } catch (InterruptedException e) {
      e.printStackTrace();
      fail("Interrupted when trying to disable table " + tablename);
    }
  }
  admin.deleteTable(tbytes);
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:24,代码来源:TestHBaseFsck.java

示例3: deleteTable

import org.apache.hadoop.hbase.client.HBaseAdmin; //导入方法依赖的package包/类
private void deleteTable(HBaseAdmin admin, HTableDescriptor htd)
  throws IOException, InterruptedException {
  // Use disableTestAsync because disable can take a long time to complete
  System.out.print("Disabling table " + htd.getNameAsString() +" ");
  admin.disableTableAsync(htd.getName());

  long start = System.currentTimeMillis();
  // NOTE tables can be both admin.isTableEnabled=false and
  // isTableDisabled=false, when disabling must use isTableDisabled!
  while (!admin.isTableDisabled(htd.getName())) {
    System.out.print(".");
    Thread.sleep(1000);
  }
  long delta = System.currentTimeMillis() - start;
  System.out.println(" " + delta +" ms");
  System.out.println("Deleting table " + htd.getNameAsString() +" ");
  admin.deleteTable(htd.getName());
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:19,代码来源:IntegrationTestLoadAndVerify.java

示例4: deleteTable

import org.apache.hadoop.hbase.client.HBaseAdmin; //导入方法依赖的package包/类
/**
 * delete table in preparation for next test
 *
 * @param tablename
 * @throws IOException
 */
void deleteTable(TableName tablename) throws IOException {
  HBaseAdmin admin = new HBaseAdmin(conf);
  admin.getConnection().clearRegionCache();
  if (admin.isTableEnabled(tablename)) {
    admin.disableTableAsync(tablename);
  }
  long totalWait = 0;
  long maxWait = 30*1000;
  long sleepTime = 250;
  while (!admin.isTableDisabled(tablename)) {
    try {
      Thread.sleep(sleepTime);
      totalWait += sleepTime;
      if (totalWait >= maxWait) {
        fail("Waited too long for table to be disabled + " + tablename);
      }
    } catch (InterruptedException e) {
      e.printStackTrace();
      fail("Interrupted when trying to disable table " + tablename);
    }
  }
  admin.deleteTable(tablename);
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:30,代码来源:TestHBaseFsck.java

示例5: deleteTable

import org.apache.hadoop.hbase.client.HBaseAdmin; //导入方法依赖的package包/类
@Override
public void deleteTable(String tableName) {
    Util.checkEmptyString(tableName);

    try {
        HBaseAdmin hbaseAdmin = hbaseDataSource.getHBaseAdmin();
        // delete table if table exist.
        if (hbaseAdmin.tableExists(tableName)) {
            // disable table before delete it.
            if (!hbaseAdmin.isTableDisabled(tableName)) {
                hbaseAdmin.disableTable(tableName);
            }
            hbaseAdmin.deleteTable(tableName);
        }
    } catch (Exception e) {
        log.error(e);
        throw new SimpleHBaseException(e);
    }
}
 
开发者ID:xushaomin,项目名称:apple-data,代码行数:20,代码来源:SimpleHbaseAdminClientImpl.java

示例6: deleteTable

import org.apache.hadoop.hbase.client.HBaseAdmin; //导入方法依赖的package包/类
@Override
public void deleteTable(String tableName) {
    Util.checkEmptyString(tableName);
    try {
        HBaseAdmin hbaseAdmin = hbaseDataSource.getHBaseAdmin();
        // delete table if table exist.
        if (hbaseAdmin.tableExists(tableName)) {
            // disable table before delete it.
            if (!hbaseAdmin.isTableDisabled(tableName)) {
                hbaseAdmin.disableTable(tableName);
            }
            hbaseAdmin.deleteTable(tableName);
        }
    } catch (Exception e) {
        log.error(e);
        throw new SimpleHBaseException(e);
    }
}
 
开发者ID:xushaomin,项目名称:apple-data,代码行数:19,代码来源:SimpleHbaseAdminClientImpl.java

示例7: deleteTable

import org.apache.hadoop.hbase.client.HBaseAdmin; //导入方法依赖的package包/类
void deleteTable(HBaseAdmin admin, TableName tableName) throws IOException {
    if (admin.tableExists(tableName)) {
        if (admin.isTableDisabled(tableName)) {
            admin.deleteTable(tableName);
        } else {
            admin.disableTable(tableName);
            admin.deleteTable(tableName);
        }
    }
}
 
开发者ID:apache,项目名称:incubator-omid,代码行数:11,代码来源:OmidTestBase.java

示例8: setUp

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

    if (!admin.tableExists(TEST_TABLE)) {
        HTableDescriptor desc = new HTableDescriptor(TABLE_NAME);

        HColumnDescriptor datafam = new HColumnDescriptor(commitTableFamily);
        datafam.setMaxVersions(Integer.MAX_VALUE);
        desc.addFamily(datafam);

        HColumnDescriptor lowWatermarkFam = new HColumnDescriptor(lowWatermarkFamily);
        lowWatermarkFam.setMaxVersions(Integer.MAX_VALUE);
        desc.addFamily(lowWatermarkFam);

        desc.addCoprocessor("org.apache.hadoop.hbase.coprocessor.AggregateImplementation");
        admin.createTable(desc);
    }

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

示例9: merge

import org.apache.hadoop.hbase.client.HBaseAdmin; //导入方法依赖的package包/类
/**
 * Scans the table and merges two adjacent regions if they are small. This
 * only happens when a lot of rows are deleted.
 *
 * When merging the META region, the HBase instance must be offline.
 * When merging a normal table, the HBase instance must be online, but the
 * table must be disabled.
 *
 * @param conf        - configuration object for HBase
 * @param fs          - FileSystem where regions reside
 * @param tableName   - Table to be compacted
 * @param testMasterRunning True if we are to verify master is down before
 * running merge
 * @throws IOException
 */
public static void merge(Configuration conf, FileSystem fs,
  final byte [] tableName, final boolean testMasterRunning)
throws IOException {
  boolean masterIsRunning = false;
  if (testMasterRunning) {
    masterIsRunning = HConnectionManager
        .execute(new HConnectable<Boolean>(conf) {
          @Override
          public Boolean connect(HConnection connection) throws IOException {
            return connection.isMasterRunning();
          }
        });
  }
  if (Bytes.equals(tableName, HConstants.META_TABLE_NAME)) {
    if (masterIsRunning) {
      throw new IllegalStateException(
          "Can not compact META table if instance is on-line");
    }
    new OfflineMerger(conf, fs).process();
  } else {
    if(!masterIsRunning) {
      throw new IllegalStateException(
          "HBase instance must be running to merge a normal table");
    }
    HBaseAdmin admin = new HBaseAdmin(conf);
    if (!admin.isTableDisabled(tableName)) {
      throw new TableNotDisabledException(tableName);
    }
    new OnlineMerger(conf, fs, tableName).process();
  }
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:47,代码来源:HMerge.java

示例10: merge

import org.apache.hadoop.hbase.client.HBaseAdmin; //导入方法依赖的package包/类
/**
 * Scans the table and merges two adjacent regions if they are small. This
 * only happens when a lot of rows are deleted.
 *
 * When merging the hbase:meta region, the HBase instance must be offline.
 * When merging a normal table, the HBase instance must be online, but the
 * table must be disabled.
 *
 * @param conf        - configuration object for HBase
 * @param fs          - FileSystem where regions reside
 * @param tableName   - Table to be compacted
 * @param testMasterRunning True if we are to verify master is down before
 * running merge
 * @throws IOException
 */
public static void merge(Configuration conf, FileSystem fs,
  final TableName tableName, final boolean testMasterRunning)
throws IOException {
  boolean masterIsRunning = false;
  if (testMasterRunning) {
    masterIsRunning = HConnectionManager
        .execute(new HConnectable<Boolean>(conf) {
          @Override
          public Boolean connect(HConnection connection) throws IOException {
            return connection.isMasterRunning();
          }
        });
  }
  if (tableName.equals(TableName.META_TABLE_NAME)) {
    if (masterIsRunning) {
      throw new IllegalStateException(
          "Can not compact hbase:meta table if instance is on-line");
    }
    // TODO reenable new OfflineMerger(conf, fs).process();
  } else {
    if(!masterIsRunning) {
      throw new IllegalStateException(
          "HBase instance must be running to merge a normal table");
    }
    HBaseAdmin admin = new HBaseAdmin(conf);
    if (!admin.isTableDisabled(tableName)) {
      throw new TableNotDisabledException(tableName);
    }
    new OnlineMerger(conf, fs, tableName).process();
  }
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:47,代码来源:HMerge.java

示例11: runTestMultiTableConflict

import org.apache.hadoop.hbase.client.HBaseAdmin; //导入方法依赖的package包/类
@Test(timeOut = 10_000)
public void runTestMultiTableConflict(ITestContext context) throws Exception {
    TransactionManager tm = newTransactionManager(context);
    TTable tt = new TTable(hbaseConf, TEST_TABLE);
    String table2 = TEST_TABLE + 2;
    TableName table2Name = TableName.valueOf(table2);

    HBaseAdmin admin = new HBaseAdmin(hbaseConf);

    if (!admin.tableExists(table2)) {
        HTableDescriptor desc = new HTableDescriptor(table2Name);
        HColumnDescriptor datafam = new HColumnDescriptor(TEST_FAMILY);
        datafam.setMaxVersions(Integer.MAX_VALUE);
        desc.addFamily(datafam);

        admin.createTable(desc);
    }

    if (admin.isTableDisabled(table2)) {
        admin.enableTable(table2);
    }
    admin.close();

    TTable tt2 = new TTable(hbaseConf, table2);

    Transaction t1 = tm.begin();
    LOG.info("Transaction created " + t1);

    Transaction t2 = tm.begin();
    LOG.info("Transaction created" + t2);

    byte[] row = Bytes.toBytes("test-simple");
    byte[] row2 = Bytes.toBytes("test-simple2");
    byte[] fam = Bytes.toBytes(TEST_FAMILY);
    byte[] col = Bytes.toBytes("testdata");
    byte[] data1 = Bytes.toBytes("testWrite-1");
    byte[] data2 = Bytes.toBytes("testWrite-2");

    Put p = new Put(row);
    p.add(fam, col, data1);
    tt.put(t1, p);
    tt2.put(t1, p);

    Put p2 = new Put(row);
    p2.add(fam, col, data2);
    tt.put(t2, p2);
    p2 = new Put(row2);
    p2.add(fam, col, data2);
    tt2.put(t2, p2);

    tm.commit(t2);

    boolean aborted = false;
    try {
        tm.commit(t1);
        fail("Transaction commited successfully");
    } catch (RollbackException e) {
        aborted = true;
    }
    assertTrue(aborted, "Transaction didn't raise exception");

    ResultScanner rs = tt2.getHTable().getScanner(fam, col);

    int count = 0;
    Result r;
    while ((r = rs.next()) != null) {
        count += r.size();
    }
    assertEquals(count, 1, "Should have cell");
}
 
开发者ID:apache,项目名称:incubator-omid,代码行数:71,代码来源:TestTransactionConflict.java

示例12: addColumnFamily

import org.apache.hadoop.hbase.client.HBaseAdmin; //导入方法依赖的package包/类
@Test
public void addColumnFamily() throws Exception {
	String TABLE_NAME = "TEST_BENCHMARK";
	//
	Configuration configuration = createConfiguration();
	HBaseAdmin hbaseAdmin = createHBaseAdmin(configuration);
	//
	// 新增column時,須將table disable
	if (hbaseAdmin.isTableEnabled(TABLE_NAME)) {
		hbaseAdmin.disableTable(TABLE_NAME);
	}
	//
	String COLUMN_FAMILY = "seq";
	HColumnDescriptor hcd = new HColumnDescriptor(COLUMN_FAMILY);
	// hcd.setBloomFilterType(BloomType.ROWCOL);
	hcd.setBlockCacheEnabled(true);
	// hcd.setCompressionType(Algorithm.SNAPPY);
	hcd.setInMemory(true);
	hcd.setMaxVersions(1);
	hcd.setMinVersions(0);
	hcd.setTimeToLive(432000);// 秒為單位
	hbaseAdmin.addColumn(TABLE_NAME, hcd);// TableNotDisabledException,
	System.out.println("add column family [" + COLUMN_FAMILY + "]");
	//
	COLUMN_FAMILY = "id";
	hcd = new HColumnDescriptor(COLUMN_FAMILY);
	// hcd.setBloomFilterType(BloomType.ROWCOL);
	hcd.setBlockCacheEnabled(true);
	// hcd.setCompressionType(Algorithm.SNAPPY);
	hcd.setInMemory(true);
	hcd.setMaxVersions(1);
	hcd.setMinVersions(0);
	hcd.setTimeToLive(432000);// 秒為單位,5d
	hbaseAdmin.addColumn(TABLE_NAME, hcd);// TableNotDisabledException,
	System.out.println("add column family [" + COLUMN_FAMILY + "]");
	//
	COLUMN_FAMILY = "info";
	hcd = new HColumnDescriptor(COLUMN_FAMILY);
	// hcd.setBloomFilterType(BloomType.ROWCOL);
	hcd.setBlockCacheEnabled(true);
	// hcd.setCompressionType(Algorithm.SNAPPY);
	hcd.setInMemory(true);
	hcd.setMaxVersions(1);
	hcd.setMinVersions(0);
	hcd.setTimeToLive(432000);// 秒為單位
	hbaseAdmin.addColumn(TABLE_NAME, hcd);// TableNotDisabledException
	System.out.println("add column family [" + COLUMN_FAMILY + "]");

	// 新增column後,再將table enable
	if (hbaseAdmin.isTableDisabled(TABLE_NAME)) {
		hbaseAdmin.enableTable(TABLE_NAME);
	}
}
 
开发者ID:mixaceh,项目名称:openyu-commons,代码行数:54,代码来源:BenchmarkHzBaoSupporterTest.java


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