Package org.apache.hadoop.hbase.client

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


  }

  private Table doPutsWithDiffCols(TableName tableName) throws IOException,
      InterruptedIOException, RetriesExhaustedWithDetailsException, InterruptedException {
    Table table;
    Admin hBaseAdmin = TEST_UTIL.getHBaseAdmin();
    HColumnDescriptor colDesc = new HColumnDescriptor(fam);
    colDesc.setMaxVersions(5);
    HTableDescriptor desc = new HTableDescriptor(tableName);
    desc.addFamily(colDesc);
    hBaseAdmin.createTable(desc);
    table = new HTable(conf, tableName);
    Put put = new Put(Bytes.toBytes("row1"));
    put.add(fam, qual, 123l, value);
    put.setCellVisibility(new CellVisibility(CONFIDENTIAL));
    table.put(put);
View Full Code Here


  }

  private Table doPutsWithoutVisibility(TableName tableName) throws IOException,
      InterruptedIOException, RetriesExhaustedWithDetailsException, InterruptedException {
    Table table;
    Admin hBaseAdmin = TEST_UTIL.getHBaseAdmin();
    HColumnDescriptor colDesc = new HColumnDescriptor(fam);
    colDesc.setMaxVersions(5);
    HTableDescriptor desc = new HTableDescriptor(tableName);
    desc.addFamily(colDesc);
    hBaseAdmin.createTable(desc);
    table = new HTable(conf, tableName);
    Put put = new Put(Bytes.toBytes("row1"));
    put.add(fam, qual, 123l, value);
    table.put(put);
    put = new Put(Bytes.toBytes("row1"));
View Full Code Here

  @Test
  public void testDeleteColumnsWithDiffColsAndTags() throws Exception {
    TableName tableName = TableName.valueOf(TEST_NAME.getMethodName());
    Table table = null;
    try {
      Admin hBaseAdmin = TEST_UTIL.getHBaseAdmin();
      HColumnDescriptor colDesc = new HColumnDescriptor(fam);
      colDesc.setMaxVersions(5);
      HTableDescriptor desc = new HTableDescriptor(tableName);
      desc.addFamily(colDesc);
      hBaseAdmin.createTable(desc);
      table = new HTable(conf, tableName);
      Put put = new Put(Bytes.toBytes("row1"));
      put.add(fam, qual1, 125l, value);
      put.setCellVisibility(new CellVisibility(CONFIDENTIAL));
      table.put(put);
View Full Code Here

  @Test
  public void testDeleteColumnsWithDiffColsAndTags1() throws Exception {
    TableName tableName = TableName.valueOf(TEST_NAME.getMethodName());
    Table table = null;
    try {
      Admin hBaseAdmin = TEST_UTIL.getHBaseAdmin();
      HColumnDescriptor colDesc = new HColumnDescriptor(fam);
      colDesc.setMaxVersions(5);
      HTableDescriptor desc = new HTableDescriptor(tableName);
      desc.addFamily(colDesc);
      hBaseAdmin.createTable(desc);
      table = new HTable(conf, tableName);
      Put put = new Put(Bytes.toBytes("row1"));
      put.add(fam, qual1, 125l, value);
      put.setCellVisibility(new CellVisibility(CONFIDENTIAL));
      table.put(put);
View Full Code Here

  public void testVisibilityExpressionWithNotEqualORCondition() throws Exception {
    setAuths();
    TableName tableName = TableName.valueOf(TEST_NAME.getMethodName());
    Table table = null;
    try {
      Admin hBaseAdmin = TEST_UTIL.getHBaseAdmin();
      HColumnDescriptor colDesc = new HColumnDescriptor(fam);
      colDesc.setMaxVersions(5);
      HTableDescriptor desc = new HTableDescriptor(tableName);
      desc.addFamily(colDesc);
      hBaseAdmin.createTable(desc);
      table = new HTable(conf, tableName);
      Put put = new Put(Bytes.toBytes("row1"));
      put.add(fam, qual, 123l, value);
      put.setCellVisibility(new CellVisibility(CONFIDENTIAL));
      table.put(put);
View Full Code Here

    util.shutdownMiniCluster();
  }

  @Before
  public void setUp() throws Exception {
    Admin admin = util.getHBaseAdmin();
    if (admin.tableExists(tableName)) {
      if (admin.isTableEnabled(tableName)) {
        admin.disableTable(tableName);
      }
      admin.deleteTable(tableName);
    }
    util.createTable(tableName, new byte[][] {dummy, test});
  }
View Full Code Here

    HTableDescriptor other = new HTableDescriptor(otherTable);
    other.addFamily(new HColumnDescriptor(family));


    Admin admin = UTIL.getHBaseAdmin();
    admin.createTable(primary);
    admin.createTable(other);

    Table table = new HTable(UTIL.getConfiguration(), "primary");
    Put p = new Put(new byte[] { 'a' });
    p.add(family, null, new byte[] { 'a' });
    table.put(p);
View Full Code Here

    int numPresplits = getConf().getInt("loadmapper.numPresplits", 5);
    // create HTableDescriptor for specified table
    HTableDescriptor htd = new HTableDescriptor(getTablename());
    htd.addFamily(new HColumnDescriptor(TEST_FAMILY));

    Admin admin = new HBaseAdmin(getConf());
    try {
      admin.createTable(htd, Bytes.toBytes(0L), Bytes.toBytes(-1L), numPresplits);
    } finally {
      admin.close();
    }
    doLoad(getConf(), htd);
    doVerify(getConf(), htd);
    getTestingUtil(getConf()).deleteTable(htd.getName());
    return 0;
View Full Code Here

  }

  @Test(timeout=60000)
  public void testAssignmentListener() throws IOException, InterruptedException {
    AssignmentManager am = TEST_UTIL.getHBaseCluster().getMaster().getAssignmentManager();
    Admin admin = TEST_UTIL.getHBaseAdmin();

    DummyAssignmentListener listener = new DummyAssignmentListener();
    am.registerListener(listener);
    try {
      final String TABLE_NAME_STR = "testtb";
      final TableName TABLE_NAME = TableName.valueOf(TABLE_NAME_STR);
      final byte[] FAMILY = Bytes.toBytes("cf");

      // Create a new table, with a single region
      LOG.info("Create Table");
      TEST_UTIL.createTable(TABLE_NAME, FAMILY);
      listener.awaitModifications(1);
      assertEquals(1, listener.getLoadCount());
      assertEquals(0, listener.getCloseCount());

      // Add some data
      Table table = new HTable(TEST_UTIL.getConfiguration(), TABLE_NAME);
      try {
        for (int i = 0; i < 10; ++i) {
          byte[] key = Bytes.toBytes("row-" + i);
          Put put = new Put(key);
          put.add(FAMILY, null, key);
          table.put(put);
        }
      } finally {
        table.close();
      }

      // Split the table in two
      LOG.info("Split Table");
      listener.reset();
      admin.split(TABLE_NAME, Bytes.toBytes("row-3"));
      listener.awaitModifications(3);
      assertEquals(2, listener.getLoadCount());     // daughters added
      assertEquals(1, listener.getCloseCount());    // parent removed

      // Wait for the Regions to be mergeable
      MiniHBaseCluster miniCluster = TEST_UTIL.getMiniHBaseCluster();
      int mergeable = 0;
      while (mergeable < 2) {
        Thread.sleep(100);
        admin.majorCompact(TABLE_NAME);
        mergeable = 0;
        for (JVMClusterUtil.RegionServerThread regionThread: miniCluster.getRegionServerThreads()) {
          for (HRegion region: regionThread.getRegionServer().getOnlineRegions(TABLE_NAME)) {
            mergeable += region.isMergeable() ? 1 : 0;
          }
        }
      }

      // Merge the two regions
      LOG.info("Merge Regions");
      listener.reset();
      List<HRegionInfo> regions = admin.getTableRegions(TABLE_NAME);
      assertEquals(2, regions.size());
      admin.mergeRegions(regions.get(0).getEncodedNameAsBytes(),
        regions.get(1).getEncodedNameAsBytes(), true);
      listener.awaitModifications(3);
      assertEquals(1, admin.getTableRegions(TABLE_NAME).size());
      assertEquals(1, listener.getLoadCount());     // new merged region added
      assertEquals(2, listener.getCloseCount());    // daughters removed

      // Delete the table
      LOG.info("Drop Table");
View Full Code Here

    if (sleepTime > 0) {
      Thread.sleep(sleepTime);
    }

    HBaseTestingUtility util = context.getHBaseIntegrationTestingUtility();
    Admin admin = util.getHBaseAdmin();

    LOG.info("Performing action: Move random region of table " + tableName);
    List<HRegionInfo> regions = admin.getTableRegions(tableName);
    if (regions == null || regions.isEmpty()) {
      LOG.info("Table " + tableName + " doesn't have regions to move");
      return;
    }

    HRegionInfo region = PolicyBasedChaosMonkey.selectRandomItem(
      regions.toArray(new HRegionInfo[regions.size()]));
    LOG.debug("Unassigning region " + region.getRegionNameAsString());
    admin.unassign(region.getRegionName(), false);
    if (sleepTime > 0) {
      Thread.sleep(sleepTime);
    }
  }
View Full Code Here

TOP

Related Classes of org.apache.hadoop.hbase.client.Admin

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.