Package org.apache.hadoop.hbase

Examples of org.apache.hadoop.hbase.HBaseAdmin


  private void singleTableTest() throws IOException, InterruptedException {
    HTableDescriptor desc = new HTableDescriptor(TABLE_NAME);
    desc.addFamily(new HColumnDescriptor(FAMILY));

    // Create a table.
    HBaseAdmin admin = new HBaseAdmin(this.conf);
    admin.createTable(desc);

    // insert some data into the test table
    HTable table = new HTable(conf, new Text(TABLE_NAME));

    for (int i = 0; i < NUM_ROWS; i++) {
View Full Code Here


    super.setUp();
    // Capture System.out so we can grep for stuff in it.  Have to do it once
    // only because ConsoleTable sets up STDOUT in a static initialization
    this.baos = new ByteArrayOutputStream();
    System.setOut(new PrintStream(this.baos));
    this.admin = new HBaseAdmin(this.conf);
  }
View Full Code Here

      // Start up HBase cluster
      hCluster = new MiniHBaseCluster(conf, 1, dfsCluster);

      // Create a table.
      HBaseAdmin admin = new HBaseAdmin(conf);
      admin.createTable(desc);

      // Populate a table into multiple regions
      MultiRegionTable.makeMultiRegionTable(conf, hCluster, null, TABLE_NAME,
        INPUT_COLUMN);
View Full Code Here

        this.columns.size() == 0) {
      return new ReturnMsg(0, "Syntax error : Please check 'Select' syntax.");
    }
    try {
      HTable table = new HTable(conf, this.tableName);
      HBaseAdmin admin = new HBaseAdmin(conf);
      int count = 0;
      if (this.whereClause) {
        count = compoundWherePrint(table, admin);
      } else {
        count = scanPrint(table, admin);
View Full Code Here

    super(o);
  }

  public ReturnMsg execute(Configuration conf) {
    try {
      HBaseAdmin admin = new HBaseAdmin(conf);
      Set<String> columns = null;
      HColumnDescriptor columnDesc = null;
      switch (operationType) {
      case ADD:
        disableTable(admin, table);
        columns = columnSpecMap.keySet();
        for (String c : columns) {
          columnDesc = getColumnDescriptor(c, columnSpecMap.get(c));
          println("Adding " + c + " to " + table +
            "... Please wait.");
          admin.addColumn(new Text(table), columnDesc);
        }
        enableTable(admin, table);
        break;
      case DROP:
        disableTable(admin, table);
        println("Dropping " + column + " from " + table +
          "... Please wait.");
        column = appendDelimiter(column);
        admin.deleteColumn(new Text(table), new Text(column));
        enableTable(admin, table);
        break;
      case CHANGE:
        // Not yet supported
        return new ReturnMsg(0, "" + operationType + " is not yet supported.");
View Full Code Here

  public ReturnMsg execute(Configuration conf) {
    assert tableName != null;
   
    try {
      HBaseAdmin admin = new HBaseAdmin(conf);
      admin.disableTable(new Text(tableName));
     
      return new ReturnMsg(1, "Table disabled successfully.");
    } catch (IOException e) {
      String[] msg = e.getMessage().split("[\n]");
      return new ReturnMsg(0, msg[0]);
View Full Code Here

  public ReturnMsg execute(Configuration conf) {
    if (columnList == null) {
      throw new IllegalArgumentException("Column list is null");
    }
    try {
      HBaseAdmin admin = new HBaseAdmin(conf);
      HTable hTable = new HTable(conf, new Text(tableName));
      long lockID = hTable.startUpdate(new Text(rowKey));
      for (Text column : getColumnList(admin, hTable)) {
        hTable.delete(lockID, new Text(column));
      }
View Full Code Here

    HTableDescriptor desc = new HTableDescriptor(SINGLE_REGION_TABLE_NAME);
    desc.addFamily(new HColumnDescriptor(INPUT_COLUMN));
    desc.addFamily(new HColumnDescriptor(OUTPUT_COLUMN));
   
    // Create a table.
    HBaseAdmin admin = new HBaseAdmin(this.conf);
    admin.createTable(desc);

    // insert some data into the test table
    HTable table = new HTable(conf, new Text(SINGLE_REGION_TABLE_NAME));

    for(int i = 0; i < values.length; i++) {
View Full Code Here

    HTableDescriptor desc = new HTableDescriptor(MULTI_REGION_TABLE_NAME);
    desc.addFamily(new HColumnDescriptor(INPUT_COLUMN));
    desc.addFamily(new HColumnDescriptor(OUTPUT_COLUMN));
   
    // Create a table.
    HBaseAdmin admin = new HBaseAdmin(this.conf);
    admin.createTable(desc);

    // Populate a table into multiple regions
    MultiRegionTable.makeMultiRegionTable(conf, hCluster, fs,
        MULTI_REGION_TABLE_NAME, INPUT_COLUMN);
   
View Full Code Here

    if (tableList == null) {
      throw new IllegalArgumentException("List of tables is null");
    }
    try {
      HBaseAdmin admin = new HBaseAdmin(conf);
     
      for (String table : tableList) {
        println("Dropping " + table + "... Please wait.");
        admin.deleteTable(new Text(table));
      }
     
      return new ReturnMsg(1, "Table(s) dropped successfully.");
    } catch (IOException e) {
      return new ReturnMsg(0, extractErrMsg(e));
View Full Code Here

TOP

Related Classes of org.apache.hadoop.hbase.HBaseAdmin

Copyright © 2018 www.massapicom. 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.