Exemplo n.º 1
0
 public static synchronized void dropTableIfExists() throws Exception {
   HBaseAdmin admin = HBaseUtils.getHBaseAdmin();
   if (admin.tableExists(TABLE_NAME)) {
     admin.disableTable(TABLE_NAME);
     admin.deleteTable(TABLE_NAME);
   }
 }
Exemplo n.º 2
0
 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();
 }
Exemplo n.º 3
0
  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);
    }
  }