public static synchronized void dropTableIfExists() throws Exception { HBaseAdmin admin = HBaseUtils.getHBaseAdmin(); if (admin.tableExists(TABLE_NAME)) { admin.disableTable(TABLE_NAME); admin.deleteTable(TABLE_NAME); } }
public H2MetaTable(Database database) throws Exception { createTableIfNotExists(); this.database = database; table = new HTable(HBaseUtils.getConfiguration(), TABLE_NAME); watcher = new ZooKeeperWatcher(table.getConfiguration(), "H2MetaTableWatcher", this); tracker = new H2MetaTableTracker(watcher, this); tracker.start(); }
public static synchronized void createTableIfNotExists() throws Exception { HBaseAdmin admin = HBaseUtils.getHBaseAdmin(); HTableDescriptor htd = new HTableDescriptor(TABLE_NAME); HColumnDescriptor hcd = new HColumnDescriptor(FAMILY); htd.addFamily(hcd); hcd.setMaxVersions(1); if (!admin.tableExists(TABLE_NAME)) { admin.createTable(htd); } }