Package org.apache.hadoop.hbase

Examples of org.apache.hadoop.hbase.HBaseAdmin


    super(o);
  }
 
  public ReturnMsg execute(Configuration conf) {
    try {
      HBaseAdmin admin = new HBaseAdmin(conf);
      HTableDescriptor tableDesc = new HTableDescriptor(tableName);
      HColumnDescriptor columnDesc = null;
      Set<String> columns = columnSpecMap.keySet();
      for (String column : columns) {
        columnDesc = getColumnDescriptor(column, columnSpecMap.get(column));
        tableDesc.addFamily(columnDesc);
      }
     
      println("Creating table... Please wait.");
     
      admin.createTable(tableDesc);
      return new ReturnMsg(0, "Table created successfully.");
    }
    catch (Exception e) {
      return new ReturnMsg(0, extractErrMsg(e));
    }
View Full Code Here


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

  public ReturnMsg execute(final Configuration conf) {
    if (this.command == null) {
      return new ReturnMsg(0, "Syntax error : Please check 'Show' syntax");
    }
    try {
      HBaseAdmin admin = new HBaseAdmin(conf);
      int tableLength = 0;
      if ("tables".equals(this.command)) {
        HTableDescriptor[] tables = admin.listTables();
        tableLength = tables.length;
        if (tableLength == 0) {
          return new ReturnMsg(0, "No tables found");
        }
        formatter.header(HEADER);
View Full Code Here

            "Filesystem must be available for upgrade to run.");
      }

      LOG.info("Verifying that HBase is not running...");
      try {
        HBaseAdmin admin = new HBaseAdmin(conf);
        if (admin.isMasterRunning()) {
          throw new IllegalStateException(
            "HBase cluster must be off-line during upgrade.");
        }
      } catch (MasterNotRunningException e) {
        // ignore
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));

    try {
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
    makeMultiRegionTable(conf, hCluster, fs, MULTI_REGION_TABLE_NAME,
        INPUT_COLUMN);
   
View Full Code Here

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

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

      // Populate a table into multiple regions
      makeMultiRegionTable(conf, hCluster, this.fs, TABLE_NAME, INPUT_COLUMN);

      // Verify table indeed has multiple regions
View Full Code Here

  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

    HTableDescriptor desc = new HTableDescriptor(TABLE_NAME);
    desc.addFamily(new HColumnDescriptor("A:"));
    desc.addFamily(new HColumnDescriptor("B:"));

    // 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

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.