Package org.apache.hadoop.hbase.client

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


              + Bytes.toStringBinary(getRow()) + " with hfile group " + famPaths);
          byte[] regionName = getLocation().getRegionInfo().getRegionName();
          if(!userProvider.isHBaseSecurityEnabled()) {
            success = ProtobufUtil.bulkLoadHFile(getStub(), famPaths, regionName, assignSeqIds);
          } else {
            Table table = new HTable(conn.getConfiguration(), getTableName());
            secureClient = new SecureBulkLoadClient(table);
            success = secureClient.bulkLoadHFiles(famPaths, fsDelegationToken.getUserToken(),
              bulkToken, getLocation().getRegionInfo().getStartKey());
          }
          return success;
View Full Code Here


  /*
   * Loops over regions that owns this table, and output some information abouts the state.
   */
  private static void sniff(final Admin admin, final Sink sink, HTableDescriptor tableDesc)
      throws Exception {
    Table table = null;

    try {
      table = new HTable(admin.getConfiguration(), tableDesc.getName());
    } catch (TableNotFoundException e) {
      return;
    }

    try {
      for (HRegionInfo region : admin.getTableRegions(tableDesc.getTableName())) {
        try {
          sniffRegion(admin, sink, region, table);
        } catch (Exception e) {
          sink.publishReadFailure(region, e);
          LOG.debug("sniffRegion failed", e);
        }
      }
    } finally {
      table.close();
    }
  }
View Full Code Here

      LOG.debug("Writing permission with rowKey "+
          Bytes.toString(rowKey)+" "+
          Bytes.toString(key)+": "+Bytes.toStringBinary(value)
      );
    }
    Table acls = null;
    try {
      acls = new HTable(conf, ACL_TABLE_NAME);
      acls.put(p);
    } finally {
      if (acls != null) acls.close();
    }
  }
View Full Code Here

    if (LOG.isDebugEnabled()) {
      LOG.debug("Removing permission "+ userPerm.toString());
    }
    d.deleteColumns(ACL_LIST_FAMILY, key);
    Table acls = null;
    try {
      acls = new HTable(conf, ACL_TABLE_NAME);
      acls.delete(d);
    } finally {
      if (acls != null) acls.close();
    }
  }
View Full Code Here

    if (LOG.isDebugEnabled()) {
      LOG.debug("Removing permissions of removed table "+ tableName);
    }

    Table acls = null;
    try {
      acls = new HTable(conf, ACL_TABLE_NAME);
      acls.delete(d);
    } finally {
      if (acls != null) acls.close();
    }
  }
View Full Code Here

    HTableDescriptor desc = new HTableDescriptor(TableName.valueOf("testTimestamps"));
    HColumnDescriptor hcd = new HColumnDescriptor(TimestampTestBase.FAMILY_NAME);
    hcd.setMaxVersions(3);
    desc.addFamily(hcd);
    this.admin.createTable(desc);
    Table table = new HTable(UTIL.getConfiguration(), desc.getTableName());
    // TODO: Remove these deprecated classes or pull them in here if this is
    // only test using them.
    Incommon incommon = new HTableIncommon(table);
    TimestampTestBase.doTestDelete(incommon, new FlushCache() {
      public void flushcache() throws IOException {
        UTIL.getHBaseCluster().flushcache();
      }
     });

    // Perhaps drop and readd the table between tests so the former does
    // not pollute this latter?  Or put into separate tests.
    TimestampTestBase.doTestTimestampScanning(incommon, new FlushCache() {
      public void flushcache() throws IOException {
        UTIL.getMiniHBaseCluster().flushcache();
      }
    });

    table.close();
  }
View Full Code Here

    hcd.setMaxVersions(3);
    desc.addFamily(hcd);
    this.admin.createTable(desc);
    Put put = new Put(row, timestamp1);
    put.add(contents, contents, value1);
    Table table = new HTable(UTIL.getConfiguration(), tableName);
    table.put(put);
    // Shut down and restart the HBase cluster
    table.close();
    UTIL.shutdownMiniHBaseCluster();
    LOG.debug("HBase cluster shut down -- restarting");
    UTIL.startMiniHBaseCluster(1, NUM_SLAVES);
    // Make a new connection.  Use new Configuration instance because old one
    // is tied to an HConnection that has since gone stale.
    table = new HTable(new Configuration(UTIL.getConfiguration()), tableName);
    // Overwrite previous value
    put = new Put(row, timestamp2);
    put.add(contents, contents, value2);
    table.put(put);
    // Now verify that getRow(row, column, latest) works
    Get get = new Get(row);
    // Should get one version by default
    Result r = table.get(get);
    assertNotNull(r);
    assertFalse(r.isEmpty());
    assertTrue(r.size() == 1);
    byte [] value = r.getValue(contents, contents);
    assertTrue(value.length != 0);
    assertTrue(Bytes.equals(value, value2));
    // Now check getRow with multiple versions
    get = new Get(row);
    get.setMaxVersions();
    r = table.get(get);
    assertTrue(r.size() == 2);
    value = r.getValue(contents, contents);
    assertTrue(value.length != 0);
    assertTrue(Bytes.equals(value, value2));
    NavigableMap<byte[], NavigableMap<byte[], NavigableMap<Long, byte[]>>> map =
      r.getMap();
    NavigableMap<byte[], NavigableMap<Long, byte[]>> familyMap =
      map.get(contents);
    NavigableMap<Long, byte[]> versionMap = familyMap.get(contents);
    assertTrue(versionMap.size() == 2);
    assertTrue(Bytes.equals(value1, versionMap.get(timestamp1)));
    assertTrue(Bytes.equals(value2, versionMap.get(timestamp2)));
    table.close();
  }
View Full Code Here

    new HBaseAdmin(conf2).createTable(tabC);
    new HBaseAdmin(conf3).createTable(tabA);
    new HBaseAdmin(conf3).createTable(tabB);
    new HBaseAdmin(conf3).createTable(tabC);

    Table htab1A = new HTable(conf1, tabAName);
    Table htab2A = new HTable(conf2, tabAName);
    Table htab3A = new HTable(conf3, tabAName);

    Table htab1B = new HTable(conf1, tabBName);
    Table htab2B = new HTable(conf2, tabBName);
    Table htab3B = new HTable(conf3, tabBName);

    Table htab1C = new HTable(conf1, tabCName);
    Table htab2C = new HTable(conf2, tabCName);
    Table htab3C = new HTable(conf3, tabCName);

    // A. add cluster2/cluster3 as peers to cluster1
    admin1.addPeer("2", utility2.getClusterKey(), "TC;TB:f1,f3");
    admin1.addPeer("3", utility3.getClusterKey(), "TA;TB:f1,f2");
View Full Code Here

  /**
   * Puts the specified HRegionInfo into META.
   */
  public static void fixMetaHoleOnline(Configuration conf,
      HRegionInfo hri) throws IOException {
    Table meta = new HTable(conf, TableName.META_TABLE_NAME);
    MetaTableAccessor.addRegionToMeta(meta, hri);
    meta.close();
  }
View Full Code Here

    long seqNum0 = random.nextLong();
    long seqNum1 = random.nextLong();
    long seqNum100 = random.nextLong();


    Table meta = MetaTableAccessor.getMetaHTable(hConnection);
    try {
      MetaTableAccessor.updateRegionLocation(hConnection, primary, serverName0, seqNum0);

      // assert that the server, startcode and seqNum columns are there for the primary region
      assertMetaLocation(meta, primary.getRegionName(), serverName0, seqNum0, 0, true);

      // add replica = 1
      MetaTableAccessor.updateRegionLocation(hConnection, replica1, serverName1, seqNum1);
      // check whether the primary is still there
      assertMetaLocation(meta, primary.getRegionName(), serverName0, seqNum0, 0, true);
      // now check for replica 1
      assertMetaLocation(meta, primary.getRegionName(), serverName1, seqNum1, 1, true);

      // add replica = 1
      MetaTableAccessor.updateRegionLocation(hConnection, replica100, serverName100, seqNum100);
      // check whether the primary is still there
      assertMetaLocation(meta, primary.getRegionName(), serverName0, seqNum0, 0, true);
      // check whether the replica 1 is still there
      assertMetaLocation(meta, primary.getRegionName(), serverName1, seqNum1, 1, true);
      // now check for replica 1
      assertMetaLocation(meta, primary.getRegionName(), serverName100, seqNum100, 100, true);
    } finally {
      meta.close();
    }
  }
View Full Code Here

TOP

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

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.