Package org.apache.hadoop.hbase.client

Examples of org.apache.hadoop.hbase.client.HBaseAdmin.tableExists()


  static public final byte[] IMAGES_COLFAM_B = Bytes.toBytes(IMAGES_COLFAM);

  public static HTable summon(Configuration conf, byte[] tname, byte[] cfam)
                                                           throws IOException {
    final HBaseAdmin admin = new HBaseAdmin(conf);
    if (!admin.tableExists(tname)) {
      final HTableDescriptor tableDesc = new HTableDescriptor(tname);
      if (!tableDesc.hasFamily(cfam)) {
        final HColumnDescriptor colFamDesc = new HColumnDescriptor(cfam);
        colFamDesc.setCompressionType(Compression.Algorithm.GZ);
        tableDesc.addFamily(colFamDesc);
View Full Code Here


        createTableIfNotExists(tableName, DEFAULT_COLUMN_FAMILY);
    }

    public synchronized static void createTableIfNotExists(byte[] tableName, byte[] family) throws IOException {
        HBaseAdmin admin = HBaseUtils.getHBaseAdmin();
        if (!admin.tableExists(tableName)) {
            HColumnDescriptor hcd = new HColumnDescriptor(family);
            hcd.setMaxVersions(1); //只需要保留最新版本即可

            HTableDescriptor htd = new HTableDescriptor(tableName);
            htd.addFamily(hcd);
View Full Code Here

        }
    }

    public synchronized static void dropTableIfExists(byte[] tableName) throws IOException {
        HBaseAdmin admin = HBaseUtils.getHBaseAdmin();
        if (admin.tableExists(tableName)) {
            admin.disableTable(tableName);
            admin.deleteTable(tableName);
        }
    }
}
View Full Code Here

    try {
      // This method will be concurrent called
      // current we thought this is might be a right place to create the hbase
      // table
      HBaseAdmin admin = new HBaseAdmin(getConf());
      if (!admin.tableExists(tableName)) {
        LOG.warn(tableName + " have been already deleted.");
        admin.close();
        return;
      }
      admin.disableTable(tableName);
View Full Code Here

  public static void checkAndInit(Configuration conf) throws MetaException {
    try {
      HBaseAdmin admin = new HBaseAdmin(conf);
      String metaTable = conf.get(FConstants.METASTORE_TABLE,
          FConstants.DEFAULT_METASTORE_TABLE);
      if (!admin.tableExists(metaTable)) {
        // if meta table don't exists just create it.
        HTableDescriptor desc = new HTableDescriptor(metaTable);
        HColumnDescriptor family = new HColumnDescriptor(
            FConstants.CATALOG_FAMILY_STR);
        family.setInMemory(true);
View Full Code Here

  public static boolean clean(Configuration conf) {
    try {
      HBaseAdmin admin = new HBaseAdmin(conf);
      String metaTable = conf.get(FConstants.METASTORE_TABLE,
          FConstants.DEFAULT_METASTORE_TABLE);
      if (admin.tableExists(metaTable)) {
        admin.disableTable(metaTable);
        admin.deleteTable(metaTable);
      }
      admin.close();
      return true;
View Full Code Here

  }

  @Test
  public void testCheckAndInit() throws IOException {
    HBaseAdmin admin = new HBaseAdmin(conf);
    assertTrue(admin.tableExists(metaTable));
    assertTrue(admin.isTableEnabled(metaTable));
    admin.close();
  }

  @Test
View Full Code Here

  @Test
  public void testClean() throws IOException {
    boolean success = FMetaUtil.clean(conf);
    assertTrue(success);
    HBaseAdmin admin = new HBaseAdmin(conf);
    assertFalse(admin.tableExists(metaTable));
    admin.close();
    FMetaUtil.checkAndInit(conf);
  }

  @Test
View Full Code Here

    this.renew.start();
  }

  public void initlize() throws IOException {
    HBaseAdmin admin = new HBaseAdmin(this.conf);
    if (!admin.tableExists(FConstants.MESSAGEQUEUE_TABLENAME)) {
      HColumnDescriptor family = new HColumnDescriptor(FConstants.MESSAGEQUEUE_FAMILIY);
      family.setCompressionType(Compression.Algorithm.GZ);
      HTableDescriptor tableDes = new HTableDescriptor(FConstants.MESSAGEQUEUE_TABLENAME);
      tableDes.addFamily(family);
      admin.createTable(tableDes);
View Full Code Here

        for (String familyName : familyNames) {
            HColumnDescriptor hcd = new HColumnDescriptor(familyName);
            htd.addFamily(hcd);
        }

        if (!admin.tableExists(htd.getName())) {
            admin.createTable(htd);
        }
        admin.close();
    }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.