Examples of HConnection


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

   * @throws ServiceException
   */
  @Test
  public void testVerifyMetaRegionLocationFails()
  throws IOException, InterruptedException, KeeperException, ServiceException {
    HConnection connection = Mockito.mock(HConnection.class);
    ServiceException connectException =
      new ServiceException(new ConnectException("Connection refused"));
    final AdminProtos.AdminService.BlockingInterface implementation =
      Mockito.mock(AdminProtos.AdminService.BlockingInterface.class);
    Mockito.when(implementation.getRegionInfo((RpcController)Mockito.any(),
      (GetRegionInfoRequest)Mockito.any())).thenThrow(connectException);
    Mockito.when(connection.getAdmin(Mockito.any(ServerName.class), Mockito.anyBoolean())).
      thenReturn(implementation);
    final CatalogTracker ct = constructAndStartCatalogTracker(connection);

    MetaRegionTracker.setMetaLocation(this.watcher,
        new ServerName("example.com", 1234, System.currentTimeMillis()));
View Full Code Here

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

  }

  @Test (expected = NotAllMetaRegionsOnlineException.class)
  public void testTimeoutWaitForMeta()
  throws IOException, InterruptedException {
    HConnection connection = Mockito.mock(HConnection.class);
    final CatalogTracker ct = constructAndStartCatalogTracker(connection);
    ct.waitForMeta(100);
  }
View Full Code Here

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

   * @throws InterruptedException
   * @throws KeeperException
   */
  @Test public void testNoTimeoutWaitForMeta()
  throws IOException, InterruptedException, KeeperException {
    HConnection connection = Mockito.mock(HConnection.class);
    final CatalogTracker ct = constructAndStartCatalogTracker(connection);
    ServerName hsa = ct.getMetaLocation();
    Assert.assertNull(hsa);

    // Now test waiting on meta location getting set.
View Full Code Here

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

   * @throws IOException
   */
  private HConnection mockConnection(final AdminProtos.AdminService.BlockingInterface admin,
      final ClientProtos.ClientService.BlockingInterface client)
  throws IOException {
    HConnection connection =
      HConnectionTestingUtility.getMockedConnection(UTIL.getConfiguration());
    Mockito.doNothing().when(connection).close();
    // Make it so we return any old location when asked.
    final HRegionLocation anyLocation =
      new HRegionLocation(HRegionInfo.FIRST_META_REGIONINFO, SN);
    Mockito.when(connection.getRegionLocation((TableName) Mockito.any(),
        (byte[]) Mockito.any(), Mockito.anyBoolean())).
      thenReturn(anyLocation);
    Mockito.when(connection.locateRegion((TableName) Mockito.any(),
        (byte[]) Mockito.any())).
      thenReturn(anyLocation);
    if (admin != null) {
      // If a call to getHRegionConnection, return this implementation.
      Mockito.when(connection.getAdmin(Mockito.any(ServerName.class))).
        thenReturn(admin);
    }
    if (client != null) {
      // If a call to getClient, return this implementation.
      Mockito.when(connection.getClient(Mockito.any(ServerName.class))).
        thenReturn(client);
    }
    return connection;
  }
View Full Code Here

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

      Configuration conf = context.getConfiguration();
      cfRenameMap = createCfRenameMap(conf);
      filter = instantiateFilter(conf);

      try {
        HConnection connection = HConnectionManager.getConnection(conf);
        ZooKeeperWatcher zkw = connection.getZooKeeperWatcher();
        ReplicationZookeeper zkHelper = new ReplicationZookeeper(connection, conf, zkw);
        clusterId = zkHelper.getUUIDForCluster(zkw);
      } catch (ZooKeeperConnectionException e) {
        LOG.error("Problem connecting to ZooKeper during task setup", e);
      } catch (KeeperException e) {
View Full Code Here

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

        createHFile(fs, hfile, fam, QUAL, val, 1000);
        famPaths.add(new Pair<byte[], String>(fam, hfile.toString()));
      }

      // bulk load HFiles
      HConnection conn = UTIL.getHBaseAdmin().getConnection();
      byte[] tbl = Bytes.toBytes(tableName);
      new ServerCallable<Void>(conn, tbl, Bytes
          .toBytes("aaa")) {
        @Override
        public Void call() throws Exception {
View Full Code Here

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

      protected List<LoadQueueItem> tryAtomicRegionLoad(final HConnection conn,
          byte[] tableName, final byte[] first, Collection<LoadQueueItem> lqis)
      throws IOException {
        int i = attmptedCalls.incrementAndGet();
        if (i == 1) {
          HConnection errConn = null;
          try {
            errConn = getMockedConnection(util.getConfiguration());
          } catch (Exception e) {
            LOG.fatal("mocking cruft, should never happen", e);
            throw new RuntimeException("mocking cruft, should never happen");
View Full Code Here

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

    fail("doBulkLoad should have thrown an exception");
  }

  private HConnection getMockedConnection(final Configuration conf)
  throws IOException {
    HConnection c = Mockito.mock(HConnection.class);
    Mockito.when(c.getConfiguration()).thenReturn(conf);
    Mockito.doNothing().when(c).close();
    // Make it so we return a particular location when asked.
    final HRegionLocation loc = new HRegionLocation(HRegionInfo.FIRST_META_REGIONINFO,
        "example.org", 1234);
    Mockito.when(c.getRegionLocation((byte[]) Mockito.any(),
        (byte[]) Mockito.any(), Mockito.anyBoolean())).
      thenReturn(loc);
    Mockito.when(c.locateRegion((byte[]) Mockito.any(), (byte[]) Mockito.any())).
      thenReturn(loc);
    HRegionInterface hri = Mockito.mock(HRegionInterface.class);
    Mockito.when(hri.bulkLoadHFiles(Mockito.anyList(), (byte [])Mockito.any(),
      Mockito.anyBoolean())).thenThrow(new IOException("injecting bulk load error"));
    Mockito.when(c.getHRegionConnection(Mockito.anyString(), Mockito.anyInt())).
      thenReturn(hri);
    return c;
  }
View Full Code Here

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

  public void testClientSessionExpired()
  throws Exception {
    LOG.info("testClientSessionExpired");
    Configuration c = new Configuration(TEST_UTIL.getConfiguration());
    new HTable(c, HConstants.META_TABLE_NAME).close();
    HConnection connection = HConnectionManager.getConnection(c);
    ZooKeeperWatcher connectionZK = connection.getZooKeeperWatcher();
    TEST_UTIL.expireSession(connectionZK, false);

    // provoke session expiration by doing something with ZK
    ZKUtil.dump(connectionZK);

    // Check that the old ZK connection is closed, means we did expire
    System.err.println("ZooKeeper should have timed out");
    LOG.info("state=" + connectionZK.getRecoverableZooKeeper().getState());
    Assert.assertTrue(connectionZK.getRecoverableZooKeeper().getState().
      equals(States.CLOSED));

    // Check that the client recovered
    ZooKeeperWatcher newConnectionZK = connection.getZooKeeperWatcher();
    States state = newConnectionZK.getRecoverableZooKeeper().getState();
    LOG.info("state=" + state);
    Assert.assertTrue(state.equals(States.CONNECTED) || state.equals(States.CONNECTING));
  }
View Full Code Here

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

    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
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.