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


Java HBaseAdmin.tableExists方法代码示例

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


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

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

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

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

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

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

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

示例7: createTable

import org.apache.hadoop.hbase.client.HBaseAdmin; //导入方法依赖的package包/类
private static void createTable(HBaseAdmin admin, String tableName, byte[][] families, byte[][] splitKeys,
                                int maxVersions)
        throws IOException {

    LOG.info("About to create Table named {} with {} splits", tableName, splitKeys.length);

    if (admin.tableExists(tableName)) {
        LOG.error("Table {} already exists. Table creation cancelled", tableName);
        return;
    }

    HTableDescriptor tableDescriptor = new HTableDescriptor(TableName.valueOf(tableName));

    for (byte[] family : families) {
        HColumnDescriptor colDescriptor = new HColumnDescriptor(family);
        colDescriptor.setMaxVersions(maxVersions);
        HBaseShims.addFamilyToHTableDescriptor(tableDescriptor, colDescriptor);
        LOG.info("\tAdding Family {}", colDescriptor);
    }

    admin.createTable(tableDescriptor, splitKeys);

    LOG.info("Table {} created. Regions: {}", tableName, admin.getTableRegions(Bytes.toBytes(tableName)).size());

}
 
开发者ID:apache,项目名称:incubator-omid,代码行数:26,代码来源:OmidTableManager.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: setUpBeforeClass

import org.apache.hadoop.hbase.client.HBaseAdmin; //导入方法依赖的package包/类
@BeforeClass
public static void setUpBeforeClass() throws Exception {
  conf = TEST_UTIL.getConfiguration();
  TEST_UTIL.startMiniCluster(3);
  REST_TEST_UTIL.startServletContainer(conf);
  context = JAXBContext.newInstance(
      CellModel.class,
      CellSetModel.class,
      RowModel.class);
  marshaller = context.createMarshaller();
  unmarshaller = context.createUnmarshaller();
  client = new Client(new Cluster().add("localhost", 
    REST_TEST_UTIL.getServletPort()));
  HBaseAdmin admin = TEST_UTIL.getHBaseAdmin();
  if (admin.tableExists(TABLE)) {
    return;
  }
  HTableDescriptor htd = new HTableDescriptor(TABLE);
  htd.addFamily(new HColumnDescriptor(CFA));
  htd.addFamily(new HColumnDescriptor(CFB));
  admin.createTable(htd);
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:23,代码来源:TestRowResource.java

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

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

示例12: init

import org.apache.hadoop.hbase.client.HBaseAdmin; //导入方法依赖的package包/类
public void init(String resourcePath) throws IOException {
  System.out.println("start init");
  Configuration conf = HBaseConfiguration.create();
  if (resourcePath != null) {
    conf.addResource(resourcePath);
  }
  HBaseAdmin admin = new HBaseAdmin(conf);

  if (admin.tableExists(tableName)) {
    admin.disableTable(tableName);
    admin.deleteTable(tableName);
    System.out.println("finish deleting existing table and index tables");
  }

  // for each kind
  initIRIndex(admin);
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:18,代码来源:LCCCreateIndexTable.java

示例13: createTableAndColumn

import org.apache.hadoop.hbase.client.HBaseAdmin; //导入方法依赖的package包/类
public static void createTableAndColumn(Configuration conf,
                                        String table,
                                        byte[] columnFamily)
    throws IOException {
  HBaseAdmin hbase = new HBaseAdmin(conf);
  HTableDescriptor desc = new HTableDescriptor(table);
  HColumnDescriptor meta = new HColumnDescriptor(columnFamily);
  desc.addFamily(meta);
  if (hbase.tableExists(table)) {
    if(hbase.isTableEnabled(table)) {
      hbase.disableTable(table);
    }
    hbase.deleteTable(table);
  }
  hbase.createTable(desc);
}
 
开发者ID:Hanmourang,项目名称:hiped2,代码行数:17,代码来源:HBaseWriter.java

示例14: generateHBaseDatasetCompositeKeyDate

import org.apache.hadoop.hbase.client.HBaseAdmin; //导入方法依赖的package包/类
public static void generateHBaseDatasetCompositeKeyDate(HBaseAdmin admin, String tableName, int numberRegions) throws Exception {
  if (admin.tableExists(tableName)) {
    admin.disableTable(tableName);
    admin.deleteTable(tableName);
  }

  HTableDescriptor desc = new HTableDescriptor(tableName);
  desc.addFamily(new HColumnDescriptor(FAMILY_F));

  if (numberRegions > 1) {
    admin.createTable(desc, Arrays.copyOfRange(SPLIT_KEYS, 0, numberRegions-1));
  } else {
    admin.createTable(desc);
  }

  HTable table = new HTable(admin.getConfiguration(), tableName);

  Date startDate = new Date(1408924800000L);
  long startTime  = startDate.getTime();
  long MILLISECONDS_IN_A_DAY  = (long)1000 * 60 * 60 * 24;
  long MILLISECONDS_IN_A_YEAR = MILLISECONDS_IN_A_DAY * 365;
  long endTime    = startTime + MILLISECONDS_IN_A_YEAR;
  long interval   = MILLISECONDS_IN_A_DAY / 3;

  for (long ts = startTime, counter = 0; ts < endTime; ts += interval, counter ++) {
    byte[] rowKey = ByteBuffer.allocate(16) .putLong(ts).array();

    for(int i = 0; i < 8; ++i) {
      rowKey[8 + i] = (byte)(counter >> (56 - (i * 8)));
    }

    Put p = new Put(rowKey);
    p.add(FAMILY_F, COLUMN_C, "dummy".getBytes());
    table.put(p);
  }

  table.flushCommits();
  table.close();
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:40,代码来源:TestTableGenerator.java

示例15: generateHBaseDatasetCompositeKeyInt

import org.apache.hadoop.hbase.client.HBaseAdmin; //导入方法依赖的package包/类
public static void generateHBaseDatasetCompositeKeyInt(HBaseAdmin admin, String tableName, int numberRegions) throws Exception {
  if (admin.tableExists(tableName)) {
    admin.disableTable(tableName);
    admin.deleteTable(tableName);
  }

  HTableDescriptor desc = new HTableDescriptor(tableName);
  desc.addFamily(new HColumnDescriptor(FAMILY_F));

  if (numberRegions > 1) {
    admin.createTable(desc, Arrays.copyOfRange(SPLIT_KEYS, 0, numberRegions-1));
  } else {
    admin.createTable(desc);
  }

  HTable table = new HTable(admin.getConfiguration(), tableName);

  int startVal = 0;
  int stopVal = 1000;
  int interval = 47;
  long counter = 0;
  for (int i = startVal; i < stopVal; i += interval, counter ++) {
    byte[] rowKey = ByteBuffer.allocate(12).putInt(i).array();

    for(int j = 0; j < 8; ++j) {
      rowKey[4 + j] = (byte)(counter >> (56 - (j * 8)));
    }

    Put p = new Put(rowKey);
    p.add(FAMILY_F, COLUMN_C, "dummy".getBytes());
    table.put(p);
  }

  table.flushCommits();
  table.close();
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:37,代码来源:TestTableGenerator.java


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