Changes between Version 2 and Version 3 of NCHCCloudCourse100929_4_HBEX5


Ignore:
Timestamp:
Sep 28, 2010, 7:14:29 PM (14 years ago)
Author:
waue
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • NCHCCloudCourse100929_4_HBEX5

    v2 v3  
    1414{{{
    1515#!java
     16
    1617package org.nchc.hbase;
    1718
     
    2526public class DropTable {
    2627
    27         static void drop(String tablename) {
    28                 HBaseConfiguration conf = new HBaseConfiguration();
     28  static void drop(String tablename) {
     29    HBaseConfiguration conf = new HBaseConfiguration();
    2930
    30                 HBaseAdmin admin;
    31                 try {
    32                         admin = new HBaseAdmin(conf);
    33                         if (admin.tableExists(tablename)) {
    34                                 admin.disableTable(tablename);
    35                                 admin.deleteTable(tablename);
    36                                 System.out.println("Droped the table [" + tablename + "]");
    37                         } else {
    38                                 System.out.println("Table [" + tablename + "] was not found!");
    39                         }
     31    HBaseAdmin admin;
     32    try {
     33      admin = new HBaseAdmin(conf);
     34      if (admin.tableExists(tablename)) {
     35        admin.disableTable(tablename);
     36        admin.deleteTable(tablename);
     37        System.out.println("Droped the table [" + tablename + "]");
     38      } else {
     39        System.out.println("Table [" + tablename + "] was not found!");
     40      }
    4041
    41                 } catch (IOException e) {
    42                         e.printStackTrace();
    43                 }
    44         }
     42    } catch (IOException e) {
     43      e.printStackTrace();
     44    }
     45  }
    4546
    46         public static void main(String[] argv) {
    47 
    48                 String[] otherArgs = new GenericOptionsParser(new Configuration(), argv)
    49                                 .getRemainingArgs();
    50                 if (otherArgs.length < 1) {
    51                         System.out.println("DropTable <TableName> ");
    52                         return;
    53                 }
    54                
    55                 drop(otherArgs[0]);
    56         }
     47  public static void main(String[] argv) {
     48            // eclipse only
     49            String[] arg = {"ex1Table"};
     50            argv = arg;
     51    String[] otherArgs = new GenericOptionsParser(new Configuration(), argv)
     52        .getRemainingArgs();
     53    if (otherArgs.length < 1) {
     54      System.out.println("DropTable <TableName> ");
     55      return;
     56    }
     57   
     58    drop(otherArgs[0]);
     59  }
    5760}
    5861