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 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);
    }
  }