Package org.apache.hadoop.hbase.regionserver

Examples of org.apache.hadoop.hbase.regionserver.HRegionServer$SafeModeThread


  }

  public List<HRegion> getRegions(byte[] tableName) {
    List<HRegion> ret = new ArrayList<HRegion>();
    for (JVMClusterUtil.RegionServerThread rst : getRegionServerThreads()) {
      HRegionServer hrs = rst.getRegionServer();
      for (HRegion region : hrs.getOnlineRegionsLocalContext()) {
        if (Bytes.equals(region.getTableDesc().getName(), tableName)) {
          ret.add(region);
        }
      }
    }
View Full Code Here


   */
  public int getServerWith(byte[] regionName) {
    int index = -1;
    int count = 0;
    for (JVMClusterUtil.RegionServerThread rst: getRegionServerThreads()) {
      HRegionServer hrs = rst.getRegionServer();
      HRegion metaRegion =
        hrs.getOnlineRegion(regionName);
      if (metaRegion != null) {
        index = count;
        break;
      }
      count++;
View Full Code Here

  private void logFSTree(Path root) throws IOException {
    FSUtils.logFileSystemState(UTIL.getDFSCluster().getFileSystem(), root, LOG);
  }

  private void waitForTableToBeOnline(final byte[] tableName) throws IOException {
    HRegionServer rs = UTIL.getRSForFirstRegionInTable(tableName);
    List<HRegion> onlineRegions = rs.getOnlineRegions(tableName);
    for (HRegion region : onlineRegions) {
      region.waitForFlushesAndCompactions();
    }
  }
View Full Code Here

   * Split the known table in half.  (this is hard coded for this test suite)
   */
  private void forceSplit(String table) {
    try {
      // need to call regions server to by synchronous but isn't visible.
      HRegionServer hrs = util.getRSForFirstRegionInTable(Bytes
          .toBytes(table));

      for (HRegionInfo hri : hrs.getOnlineRegions()) {
        if (Bytes.equals(hri.getTableName(), Bytes.toBytes(table))) {
          // splitRegion doesn't work if startkey/endkey are null
          hrs.splitRegion(hri, rowkey(ROWCOUNT / 2)); // hard code split
        }
      }

      // verify that split completed.
      int regions;
      do {
        regions = 0;
        for (HRegionInfo hri : hrs.getOnlineRegions()) {
          if (Bytes.equals(hri.getTableName(), Bytes.toBytes(table))) {
            regions++;
          }
        }
        if (regions != 2) {
View Full Code Here

    TEST_UTIL.startMiniCluster(NUM_MASTERS, NUM_RS);
    String tableName = "testOpenedRegionHandlerOnMasterRestart";
    MiniHBaseCluster cluster = createRegions(tableName);
    abortMaster(cluster);

    HRegionServer regionServer = cluster.getRegionServer(0);
    HRegion region = getRegionBeingServed(cluster, regionServer);

    // forcefully move a region to OPENED state in zk
    // Create a ZKW to use in the test
    zkw = HBaseTestingUtility.createAndForceNodeToOpenedState(TEST_UTIL,
        region, regionServer.getServerName());

    // Start up a new master
    log("Starting up a new master");
    cluster.startMaster().getMaster();
    log("Waiting for master to be ready");
View Full Code Here

  }
 
  @Test
  public void testTransitionToFailedOpenEvenIfCleanupFails() throws Exception {
    MiniHBaseCluster cluster = HTU.getHBaseCluster();
    HRegionServer server =
        cluster.getLiveRegionServerThreads().get(0).getRegionServer();
    // Create it OFFLINE, which is what it expects
    ZKAssign.createNodeOffline(server.getZooKeeper(), TEST_HRI, server.getServerName());
    ZKAssign.transitionNodeOpening(server.getZooKeeper(), TEST_HRI, server.getServerName());
    // Create the handler
    OpenRegionHandler handler = new OpenRegionHandler(server, server, TEST_HRI, TEST_HTD) {
      @Override
      boolean updateMeta(HRegion r) {
        return false;
      };

      @Override
      void cleanupFailedOpen(HRegion region) throws IOException {
        throw new IOException("FileSystem got closed.");
      }
    };
    ((TestOpenRegionHandlerRegionServer)server).addRegionsInTransition(TEST_HRI, "OPEN");
    try {
      handler.process();
    } catch (Exception e) {
      // Ignore the IOException that we have thrown from cleanupFailedOpen
    }
    RegionTransitionData data =
        ZKAssign.getData(server.getZooKeeper(), TEST_HRI.getEncodedName());
    assertEquals(EventType.RS_ZK_REGION_FAILED_OPEN, data.getEventType());
  }
View Full Code Here

    installTable(new ZooKeeperWatcher(conf, "table-creation", null),
        "table", "family", 40);
    byte[] table = Bytes.toBytes("table");
    List<HRegionInfo> regions = null;
    HRegionServer hrs = null;
    for (int i = 0; i < NUM_RS; i++) {
      hrs = rsts.get(i).getRegionServer();
      regions = hrs.getOnlineRegions();
      if (regions.size() != 0) break;
    }
    final Path logDir = new Path(rootdir, HLog.getHLogDirectoryName(hrs
        .getServerName().toString()));
   
    LOG.info("#regions = " + regions.size());
    Iterator<HRegionInfo> it = regions.iterator();
    while (it.hasNext()) {
      HRegionInfo region = it.next();
      if (region.isMetaTable()) {
        it.remove();
      }
    }
    makeHLog(hrs.getWAL(), regions, "table",
        NUM_LOG_LINES, 100);

    slm.splitLogDistributed(logDir);

    int count = 0;
View Full Code Here

    List<RegionServerThread> rsts = cluster.getLiveRegionServerThreads();
    final ZooKeeperWatcher zkw = new ZooKeeperWatcher(conf, "table-creation", null);
    HTable ht = installTable(zkw, "table", "f", NUM_REGIONS_TO_CREATE);

    List<HRegionInfo> regions = null;
    HRegionServer hrs = null;
    for (int i = 0; i < NUM_RS; i++) {
      boolean isCarryingMeta = false;
      hrs = rsts.get(i).getRegionServer();
      regions = hrs.getOnlineRegions();
      for (HRegionInfo region : regions) {
        if (region.isRootRegion() || region.isMetaRegion()) {
          isCarryingMeta = true;
          break;
        }
      }
      if (isCarryingMeta) {
        continue;
      }
      break;
    }

    LOG.info("#regions = " + regions.size());
    Iterator<HRegionInfo> it = regions.iterator();
    while (it.hasNext()) {
      HRegionInfo region = it.next();
      if (region.isMetaTable()) {
        it.remove();
      }
    }
    makeHLog(hrs.getWAL(), regions, "table", NUM_LOG_LINES, 100);

    // abort master
    abortMaster(cluster);

    // abort RS
    int numRS = cluster.getLiveRegionServerThreads().size();
    LOG.info("Aborting region server: " + hrs.getServerName());
    hrs.abort("testing");

    // wait for the RS dies
    long start = EnvironmentEdgeManager.currentTimeMillis();
    while (cluster.getLiveRegionServerThreads().size() > (numRS - 1)) {
      if (EnvironmentEdgeManager.currentTimeMillis() - start > 60000) {
View Full Code Here

    final int NUM_LOG_LINES = 10000;
    final SplitLogManager slm = master.getMasterFileSystem().splitLogManager;
    FileSystem fs = master.getMasterFileSystem().getFileSystem();

    final List<RegionServerThread> rsts = cluster.getLiveRegionServerThreads();
    HRegionServer hrs = rsts.get(0).getRegionServer();
    Path rootdir = FSUtils.getRootDir(conf);
    final Path logDir = new Path(rootdir,
        HLog.getHLogDirectoryName(hrs.getServerName().toString()));

    installTable(new ZooKeeperWatcher(conf, "table-creation", null),
        "table", "family", 40);
    makeHLog(hrs.getWAL(), hrs.getOnlineRegions(), "table",
        NUM_LOG_LINES, 100);

    new Thread() {
      public void run() {
        waitForCounter(tot_wkr_task_acquired, 0, 1, 1000);
View Full Code Here

    List<RegionServerThread> rsts = cluster.getLiveRegionServerThreads();
    assertEquals(NUM_RS, rsts.size());

    for (RegionServerThread rst : rsts) {
      HRegionServer hrs = rst.getRegionServer();
      List<HRegionInfo> hris = hrs.getOnlineRegions();
      for (HRegionInfo hri : hris) {
        if (hri.isMetaTable()) {
          continue;
        }
        LOG.debug("adding data to rs = " + rst.getName() +
            " region = "+ hri.getRegionNameAsString());
        HRegion region = hrs.getOnlineRegion(hri.getRegionName());
        assertTrue(region != null);
        putData(region, hri.getStartKey(), nrows, Bytes.toBytes("q"), family);
      }
    }
  }
View Full Code Here

TOP

Related Classes of org.apache.hadoop.hbase.regionserver.HRegionServer$SafeModeThread

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.