Package org.apache.hadoop.hbase.client

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


    ZooKeeperWatcher zkw = new ZooKeeperWatcher(UTIL.getConfiguration(),
      this.getClass().getSimpleName(), ABORTABLE, true);
    // This is a servername we use in a few places below.
    ServerName sn = new ServerName("example.com", 1234, System.currentTimeMillis());

    HConnection connection = null;
    CatalogTracker ct = null;
    try {
      // Mock an HRegionInterface. Our mock implementation will fail a few
      // times when we go to open a scanner.
      final HRegionInterface implementation = Mockito.mock(HRegionInterface.class);
View Full Code Here


    throw new IOException("did timeout waiting for service to stop:" + serverName);
  }

  @Override
  public HMasterInterface getMasterAdmin() throws IOException {
    HConnection conn = HConnectionManager.getConnection(conf);
    return conn.getMaster();
  }
View Full Code Here

    return false;
  }

  @Override
  public ServerName getServerHoldingRegion(byte[] regionName) throws IOException {
    HConnection connection = admin.getConnection();
    HRegionLocation regionLoc = connection.locateRegion(regionName);
    if (regionLoc == null) {
      return null;
    }

    org.apache.hadoop.hbase.HServerInfo sn
    = connection.getHRegionConnection(regionLoc.getHostname(), regionLoc.getPort()).getHServerInfo();

    return new ServerName(sn.getServerAddress().getHostname(), sn.getServerAddress().getPort(), sn.getStartCode());
  }
View Full Code Here

    ht.close();
    HRegionServer server = TEST_UTIL.getHBaseCluster().getRegionServer(0);
    byte []firstRow = Bytes.toBytes("aaa");
    byte []splitRow = Bytes.toBytes("lll");
    byte []lastRow = Bytes.toBytes("zzz");
    HConnection con = HConnectionManager
        .getConnection(TEST_UTIL.getConfiguration());
    // this will also cache the region
    byte[] regionName = con.locateRegion(tableName, splitRow).getRegionInfo()
        .getRegionName();
    HRegion region = server.getRegion(regionName);
    SplitTransaction split = new SplitTransaction(region, splitRow);
    split.prepare();
View Full Code Here

      LOG.info("createMultiRegions: deleting meta row -> " +
        Bytes.toStringBinary(row));
      meta.delete(new Delete(row));
    }
    // flush cache of regions
    HConnection conn = table.getConnection();
    conn.clearRegionCache();
    return count;
  }
View Full Code Here

   * @throws TableNotFoundException if table does not yet exist
   */
  public void doBulkLoad(Path hfofDir, HTable table)
    throws TableNotFoundException, IOException
  {
    HConnection conn = table.getConnection();
   
    if (!conn.isTableAvailable(table.getTableName())) {
      throw new TableNotFoundException("Table " +
          Bytes.toStringBinary(table.getTableName()) +
          "is not currently available.");
    }
   
View Full Code Here

    new HTable(conf, HConstants.META_TABLE_NAME);

    ZooKeeperWrapper zkw = new ZooKeeperWrapper(conf, EmptyWatcher.instance);
    String quorumServers = zkw.getQuorumServers();
    int sessionTimeout = 5 * 1000; // 5 seconds
    HConnection connection = HConnectionManager.getConnection(conf);
    ZooKeeperWrapper connectionZK = connection.getZooKeeperWrapper();
    long sessionID = connectionZK.getSessionID();
    byte[] password = connectionZK.getSessionPassword();

    ZooKeeper zk = new ZooKeeper(quorumServers, sessionTimeout,
        EmptyWatcher.instance, sessionID, password);
    zk.close();

    Thread.sleep(sessionTimeout * 3L);

    System.err.println("ZooKeeper should have timed out");
    connection.relocateRegion(HConstants.ROOT_TABLE_NAME, HConstants.EMPTY_BYTE_ARRAY);
  }
View Full Code Here

   * @throws IOException
   */
  public static void merge(HBaseConfiguration conf, FileSystem fs,
    final byte [] tableName)
  throws IOException {
    HConnection connection = HConnectionManager.getConnection(conf);
    boolean masterIsRunning = connection.isMasterRunning();
    HConnectionManager.deleteConnectionInfo(conf);
    if (Bytes.equals(tableName, META_TABLE_NAME)) {
      if (masterIsRunning) {
        throw new IllegalStateException(
            "Can not compact META table if instance is on-line");
View Full Code Here

    throws IOException {
    ClusterStatus status = admin.getMaster().getClusterStatus();
    Collection<ServerName> regionServers = status.getServers();
    Map<ServerName, List<String>> mm =
        new HashMap<ServerName, List<String>>();
    HConnection connection = admin.getConnection();
    for (ServerName hsi : regionServers) {
      HRegionInterface server =
        connection.getHRegionConnection(hsi.getHostname(), hsi.getPort());

      // list all online regions from this region server
      List<HRegionInfo> regions = server.getOnlineRegions();
      List<String> regionNames = new ArrayList<String>();
      for (HRegionInfo hri : regions) {
View Full Code Here

    ZooKeeperWatcher zkw = new ZooKeeperWatcher(UTIL.getConfiguration(),
      this.getClass().getSimpleName(), ABORTABLE, true);
    // This is a servername we use in a few places below.
    ServerName sn = new ServerName("example.com", 1234, System.currentTimeMillis());

    HConnection connection = null;
    CatalogTracker ct = null;
    try {
      // Mock an HRegionInterface. Our mock implementation will fail a few
      // times when we go to open a scanner.
      final HRegionInterface implementation = Mockito.mock(HRegionInterface.class);
View Full Code Here

TOP

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

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.