Package org.apache.hadoop.hbase.client

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


  static final long SIZE = 10;

  @Override
  protected void setUp() throws Exception {
    super.setUp();
    HBaseAdmin admin = new HBaseAdmin(conf);
    if (!admin.tableExists(TABLE)) {
      HTableDescriptor htd = new HTableDescriptor(TABLE);
      htd.addFamily(new HColumnDescriptor(USER));
      admin.createTable(htd);
      HTable table = new HTable(TABLE);
      Put put = new Put(Bytes.toBytes(USER_TOKEN));
      put.add(USER, NAME, Bytes.toBytes(USER_USERNAME));
      put.add(USER, TOKENS_RATE, Bytes.toBytes(RATE));
      put.add(USER, TOKENS_SIZE, Bytes.toBytes(SIZE));
View Full Code Here


    return user;
  }

  private final TableListModel getTableList() throws IOException {
    TableListModel tableList = new TableListModel();
    HBaseAdmin admin = new HBaseAdmin(servlet.getConfiguration());
    HTableDescriptor[] list = admin.listTables();
    for (HTableDescriptor htd: list) {
      tableList.add(new TableModel(htd.getNameAsString()));
    }
    return tableList;
  }
View Full Code Here

    TableListModel tableList;
    if (user.isAdmin()) {
      tableList = getTableList();
    } else {
      tableList = new TableListModel();
      HBaseAdmin admin = new HBaseAdmin(servlet.getConfiguration());
      HTableDescriptor[] list = admin.listTables();
      String prefix = user.getName() + ".";
      for (HTableDescriptor htd: list) {
        String name = htd.getNameAsString();
        if (!name.startsWith(prefix)) {
          continue;
View Full Code Here

    if (!servlet.userRequestLimit(user, 1)) {
      Response.status(509).build();
    }
    servlet.getMetrics().incrementRequests(1);
    try {
      HBaseAdmin admin = new HBaseAdmin(servlet.getConfiguration());
      ClusterStatus status = admin.getClusterStatus();
      StorageClusterStatusModel model = new StorageClusterStatusModel();
      model.setRegions(status.getRegionsCount());
      model.setRequests(status.getRequestsCount());
      model.setAverageLoad(status.getAverageLoad());
      for (HServerInfo info: status.getServerInfo()) {
View Full Code Here

    Get g = new Get("TEST".getBytes());
    g.addFamily(cf.getBytes());
    hTable.get(g);
    assertTimeVaryingMetricCount(1, TABLE_NAME, cf, regionName, "get_");
    HBaseAdmin admin = TEST_UTIL.getHBaseAdmin();
    admin.disableTable(TABLE_NAME.getBytes());
    admin.deleteTable(TABLE_NAME.getBytes());

    assertTimeVaryingMetricCount(0, TABLE_NAME, cf, regionName, "get_");

    hTable.close();
  }
View Full Code Here

    byte[] CF1 = Bytes.toBytes(cf1Name);
    byte[] CF2 = Bytes.toBytes(cf2Name);

    long ts = 1234;
    HTable hTable = TEST_UTIL.createTable(TABLE, new byte[][]{CF1, CF2});
    HBaseAdmin admin = new HBaseAdmin(TEST_UTIL.getConfiguration());

    Put p = new Put(ROW);
    p.add(CF1, CF1, ts, CF1);
    p.add(CF2, CF2, ts, CF2);
    hTable.put(p);
View Full Code Here

            System.out.println("Unittest table already exists: " + EXAMPLE_TABLE_NAME);
            // table already exists
            return;
        }

        HBaseAdmin admin = _dataContext.getHBaseAdmin();
        System.out.println("Creating table");
        final HTableDescriptor tableDescriptor = new HTableDescriptor(EXAMPLE_TABLE_NAME.getBytes());
        tableDescriptor.addFamily(new HColumnDescriptor("foo".getBytes()));
        tableDescriptor.addFamily(new HColumnDescriptor("bar".getBytes()));
        admin.createTable(tableDescriptor);
        System.out.println("Created table");
    }
View Full Code Here

      // create a table : master coprocessor will throw an exception and not
      // catch it.
      HTableDescriptor htd = new HTableDescriptor(TEST_TABLE);
      htd.addFamily(new HColumnDescriptor(TEST_FAMILY));
      try {
        HBaseAdmin admin = UTIL.getHBaseAdmin();
        admin.createTable(htd);
        fail("BuggyMasterObserver failed to throw an exception.");
      } catch (IOException e) {
        assertEquals("HBaseAdmin threw an interrupted IOException as expected.",
            e.getClass().getName(), "java.io.InterruptedIOException");
      }
View Full Code Here

        _admin = admin;
    }

    private HBaseAdmin createHbaseAdmin(Configuration config) {
        try {
            return new HBaseAdmin(config);
        } catch (Exception e) {
            if (e instanceof RuntimeException) {
                throw (RuntimeException) e;
            }
            throw new MetaModelException(e);
View Full Code Here

    table.close();
  }

  @Test
  public void testMasterGeneric() throws Throwable {
    HBaseAdmin admin = new HBaseAdmin(util.getConfiguration());
    GenericProtocol protocol = admin.coprocessorProxy(GenericProtocol.class);
    String workResult1 = protocol.doWork("foo");
    assertEquals("foo", workResult1);
    byte[] workResult2 = protocol.doWork(new byte[]{1});
    assertArrayEquals(new byte[]{1}, workResult2);
    byte workResult3 = protocol.doWork((byte)1);
View Full Code Here

TOP

Related Classes of org.apache.hadoop.hbase.client.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.