Examples of HBaseAdmin


Examples of org.apache.hadoop.hbase.client.HBaseAdmin

        HConstants.EMPTY_START_ROW);
    ServerName hsa = ServerName.valueOf(metaLocation.getHostnamePort(), 0L);
    HRegionInfo hri = metaLocation.getRegionInfo();
    if (unassign) {
      LOG.info("Undeploying meta region " + hri + " from server " + hsa);
      undeployRegion(new HBaseAdmin(conf), hsa, hri);
    }

    if (regionInfoOnly) {
      LOG.info("deleting hdfs .regioninfo data: " + hri.toString() + hsa.toString());
      Path rootDir = FSUtils.getRootDir(conf);
View Full Code Here

Examples of org.apache.hadoop.hbase.client.HBaseAdmin

      int regionCountBeforeMerge = tbl.getRegionLocations().size();

      assertNotEquals(region1, region2);

      // do a region merge
      HBaseAdmin admin = TEST_UTIL.getHBaseAdmin();
      admin.mergeRegions(region1.getEncodedNameAsBytes(),
          region2.getEncodedNameAsBytes(), false);

      // wait until region merged
      long timeout = System.currentTimeMillis() + 30 * 1000;
      while (true) {
View Full Code Here

Examples of org.apache.hadoop.hbase.client.HBaseAdmin

        ScanLabelGenerator.class);
    util.startMiniCluster();
    // Wait for the labels table to become available
    util.waitTableEnabled(VisibilityConstants.LABELS_TABLE_NAME.getName(), 50000);
    createLabels();
    HBaseAdmin admin = new HBaseAdmin(util.getConfiguration());
    util.startMiniMapReduceCluster();
  }
View Full Code Here

Examples of org.apache.hadoop.hbase.client.HBaseAdmin

      //set global read so RegionServer can move it
      setPermission(loadPath, FsPermission.valueOf("-rwxrwxrwx"));

      HTable table = new HTable(conf, tableName);
      try {
        HBaseAdmin admin = new HBaseAdmin(TEST_UTIL.getConfiguration());
        TEST_UTIL.waitTableEnabled(admin, tableName.getName());
        LoadIncrementalHFiles loader = new LoadIncrementalHFiles(conf);
        loader.doBulkLoad(loadPath, table);
      } finally {
        table.close();
View Full Code Here

Examples of org.apache.hadoop.hbase.client.HBaseAdmin

  private void setupReplication() throws Exception {
    ReplicationAdmin admin1 = new ReplicationAdmin(conf1);
    ReplicationAdmin admin2 = new ReplicationAdmin(conf2);

    HBaseAdmin ha = new HBaseAdmin(conf1);
    ha.createTable(t1_syncupSource);
    ha.createTable(t2_syncupSource);
    ha.close();

    ha = new HBaseAdmin(conf2);
    ha.createTable(t1_syncupTarget);
    ha.createTable(t2_syncupTarget);
    ha.close();

    // Get HTable from Master
    ht1Source = new HTable(conf1, t1_su);
    ht1Source.setWriteBufferSize(1024);
    ht2Source = new HTable(conf1, t2_su);
View Full Code Here

Examples of org.apache.hadoop.hbase.client.HBaseAdmin

  }

  protected HBaseAdmin getHBaseAdmin(JobConf conf) throws MasterNotRunningException, ZooKeeperConnectionException {
    if (hBaseAdmin == null) {
      Configuration hbaseConf = HBaseConfiguration.create(conf);
      hBaseAdmin = new HBaseAdmin(hbaseConf);
    }

    return hBaseAdmin;
  }
View Full Code Here

Examples of org.apache.hadoop.hbase.client.HBaseAdmin

    return hBaseCollector;
  }

  @Override
  public boolean createResource(JobConf jobConf) throws IOException {
    HBaseAdmin hBaseAdmin = getHBaseAdmin(jobConf);

    if (hBaseAdmin.tableExists(tableName)) {
      return true;
    }

    LOG.info("creating hbase table: {}", tableName);

    HTableDescriptor tableDescriptor = new HTableDescriptor(tableName);

    String[] familyNames = ((HBaseScheme) getScheme()).getFamilyNames();

    for (String familyName : familyNames) {
      tableDescriptor.addFamily(new HColumnDescriptor(familyName));
    }

    hBaseAdmin.createTable(tableDescriptor);

    return true;
  }
View Full Code Here

Examples of org.apache.hadoop.hbase.client.HBaseAdmin

   }
  
   public void CreateTable() throws IOException, ZooKeeperConnectionException{
     Configuration conf = HBaseConfiguration.create();
     
     HBaseAdmin hbase = new HBaseAdmin(conf);
     HTableDescriptor[] wordcounts = hbase.listTables("wordcount");
     
     if(wordcounts.length != 0){ //Drop Table if Exists
        hbase.disableTable(TABLE_NAME);
       hbase.deleteTable(TABLE_NAME);
     }
    
     HTableDescriptor wordcount = new HTableDescriptor(TABLE_NAME);
     hbase.createTable(wordcount);
     // Cannot edit a stucture on an active table.
     hbase.disableTable(TABLE_NAME);
     HColumnDescriptor columnFamily = new HColumnDescriptor(COLUMN_FAMILY);
     hbase.addColumn(TABLE_NAME, columnFamily);
     hbase.enableTable(TABLE_NAME);
    
     hbase.close();
   }
View Full Code Here

Examples of org.apache.hadoop.hbase.client.HBaseAdmin

    classes.add(clazz);
  }
 
  public void updateSchema() throws IOException {
    Configuration config = HBaseConfiguration.create();
    HBaseAdmin admin = new HBaseAdmin(config);
    HTableDescriptor[] descriptors = admin.listTables();
   
    List<String> tables = new ArrayList<String>();
   
    for (HTableDescriptor hTableDescriptor : descriptors) {
      tables.add(hTableDescriptor.getNameAsString());
    }
   
    for (Class<?> clazz : classes) {
      ClassInfo info = ClassInfo.getClassInfo(clazz);
      String tableName = info.tableName;
     
      if(!tables.contains(tableName)) {
        // create table
        HTableDescriptor descriptor = createTable(tableName);
        admin.createTable(descriptor);
      }
      tables.remove(tableName);
    }
   
    for (String table : tables) {
      admin.disableTable(table);
      admin.deleteTable(table);
    }
  }
View Full Code Here

Examples of org.apache.hadoop.hbase.client.HBaseAdmin

  }
 
  public void dropTables() {
    HBaseConfiguration config = new HBaseConfiguration();
    try {
      HBaseAdmin admin = new HBaseAdmin(config);
      HTableDescriptor[] descriptors = admin.listTables();
      for (HTableDescriptor hTableDescriptor : descriptors) {
        String name = hTableDescriptor.getNameAsString();
        admin.disableTable(name);
        admin.deleteTable(name);
      }
    } catch(IOException e) {
      throw new SienaException(e);
    }
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.