Package org.apache.hadoop.hbase

Examples of org.apache.hadoop.hbase.HServerLoad


   * @param serverName
   * @param returnMsgs
   */
  void assignRegions(HServerInfo info, String serverName,
    HRegionInfo[] mostLoadedRegions, ArrayList<HMsg> returnMsgs) {
    HServerLoad thisServersLoad = info.getLoad();
    synchronized (unassignedRegions) {
      // We need to hold a lock on assign attempts while we figure out what to
      // do so that multiple threads do not execute this method in parallel
      // resulting in assigning the same region to multiple servers.
     
      // figure out what regions need to be assigned and aren't currently being
      // worked on elsewhere.
      Set<HRegionInfo> regionsToAssign = regionsAwaitingAssignment();
      if (regionsToAssign.size() == 0) {
        // There are no regions waiting to be assigned. This is an opportunity
        // for us to check if this server is overloaded.
        double avgLoad = master.serverManager.getAverageLoad();
        if (avgLoad > 2.0 && thisServersLoad.getNumberOfRegions() > avgLoad) {
          if (LOG.isDebugEnabled()) {
            LOG.debug("Server " + serverName + " is overloaded. Server load: " +
              thisServersLoad.getNumberOfRegions() + " avg: " + avgLoad);
          }
          unassignSomeRegions(thisServersLoad, avgLoad, mostLoadedRegions,
            returnMsgs);
        }
      } else {
View Full Code Here


    nRegionsToAssign -= nregions;
    if (nRegionsToAssign > 0) {
      // We still have more regions to assign. See how many we can assign
      // before this server becomes more heavily loaded than the next
      // most heavily loaded server.
      HServerLoad heavierLoad = new HServerLoad();
      int nservers = computeNextHeaviestLoad(thisServersLoad, heavierLoad);

      nregions = 0;
     
      // Advance past any less-loaded servers
      for (HServerLoad load =
        new HServerLoad(thisServersLoad.getNumberOfRequests(),
            thisServersLoad.getNumberOfRegions());
      load.compareTo(heavierLoad) <= 0 && nregions < nRegionsToAssign;
      load.setNumberOfRegions(load.getNumberOfRegions() + 1), nregions++) {
        // continue;
      }

      if (nregions < nRegionsToAssign) {
        // There are some more heavily loaded servers
View Full Code Here

    // Pretend that we will assign regions to these more lightly loaded servers
    // until they reach load equal with ours. Then, see how many regions are left
    // unassigned. That is how many regions we should assign to this server.
    int nRegions = 0;
    for (Map.Entry<HServerLoad, Set<String>> e : lightServers.entrySet()) {
      HServerLoad lightLoad = new HServerLoad(e.getKey().getNumberOfRequests(),
        e.getKey().getNumberOfRegions());

      do {
        lightLoad.setNumberOfRegions(lightLoad.getNumberOfRegions() + 1);
        nRegions += 1;
      } while (lightLoad.compareTo(thisServersLoad) <= 0
          && nRegions < numUnassignedRegions);

      nRegions *= e.getValue().size();
      if (nRegions >= numUnassignedRegions) {
        break;
View Full Code Here

      } catch (Leases.LeaseStillHeldException e) {
        LOG.debug("Lease still held on " + e.getName());
        return;
      }
    }
    HServerLoad load = serversToLoad.remove(s);
    if (load != null) {
      // The startup message was from a known server.
      // Remove stale information about the server's load.
      synchronized (loadToServers) {
        Set<String> servers = loadToServers.get(load);
        if (servers != null) {
          servers.remove(s);
          loadToServers.put(load, servers);
        }
      }
    }

    HServerInfo storedInfo = serversToServerInfo.remove(s);
    if (storedInfo != null && !master.closed.get()) {
      // The startup message was from a known server with the same name.
      // Timeout the old one right away.
      HServerAddress root = master.getRootRegionLocation();
      if (root != null && root.equals(storedInfo.getServerAddress())) {
        master.regionManager.unassignRootRegion();
      }
      master.delayedToDoQueue.put(new ProcessServerShutdown(master, storedInfo));
    }

    // record new server
    load = new HServerLoad();
    serverInfo.setLoad(load);
    serversToServerInfo.put(s, serverInfo);
    serversToLoad.put(s, load);
    synchronized (loadToServers) {
      Set<String> servers = loadToServers.get(load);
View Full Code Here

    serverLeases.renewLease(serverName);

    // Refresh the info object and the load information
    serversToServerInfo.put(serverName, serverInfo);

    HServerLoad load = serversToLoad.get(serverName);
    if (load != null && !load.equals(serverInfo.getLoad())) {
      // We have previous information about the load on this server
      // and the load on this server has changed
      synchronized (loadToServers) {
        Set<String> servers = loadToServers.get(load);
View Full Code Here

        }
      }
      leaseCancelled = true;

      // update load information
      HServerLoad load = serversToLoad.remove(serverName);
      if (load != null) {
        synchronized (loadToServers) {
          Set<String> servers = loadToServers.get(load);
          if (servers != null) {
            servers.remove(serverName);
View Full Code Here

        HServerAddress root = master.getRootRegionLocation();
        if (root != null && root.equals(info.getServerAddress())) {
          master.regionManager.unassignRootRegion();
        }
        String serverName = info.getServerAddress().toString();
        HServerLoad load = serversToLoad.remove(serverName);
        if (load != null) {
          synchronized (loadToServers) {
            Set<String> servers = loadToServers.get(load);
            if (servers != null) {
              servers.remove(serverName);
View Full Code Here

   * @param mostLoadedRegions
   * @param returnMsgs
   */
  void assignRegions(HServerInfo info, HRegionInfo[] mostLoadedRegions,
      ArrayList<HMsg> returnMsgs) {
    HServerLoad thisServersLoad = info.getLoad();
    boolean isSingleServer = master.serverManager.numServers() == 1;

    // figure out what regions need to be assigned and aren't currently being
    // worked on elsewhere.
    Set<RegionState> regionsToAssign =
View Full Code Here

      nRegionsToAssign -= nregions;
      if (nRegionsToAssign > 0 || isMetaAssign) {
        // We still have more regions to assign. See how many we can assign
        // before this server becomes more heavily loaded than the next
        // most heavily loaded server.
        HServerLoad heavierLoad = new HServerLoad();
        int nservers = computeNextHeaviestLoad(thisServersLoad, heavierLoad);
        nregions = 0;
        // Advance past any less-loaded servers
        for (HServerLoad load = new HServerLoad(thisServersLoad);
        load.compareTo(heavierLoad) <= 0 && nregions < nRegionsToAssign;
        load.setNumberOfRegions(load.getNumberOfRegions() + 1), nregions++) {
          // continue;
        }
        LOG.debug("Doing for " + info + " nregions: " + nregions +
            " and nRegionsToAssign: " + nRegionsToAssign);
        if (nregions < nRegionsToAssign) {
View Full Code Here

    // Pretend that we will assign regions to these more lightly loaded servers
    // until they reach load equal with ours. Then, see how many regions are left
    // unassigned. That is how many regions we should assign to this server.
    int nRegions = 0;
    for (Map.Entry<HServerLoad, Set<String>> e: lightServers.entrySet()) {
      HServerLoad lightLoad = new HServerLoad(e.getKey());
      do {
        lightLoad.setNumberOfRegions(lightLoad.getNumberOfRegions() + 1);
        nRegions += 1;
      } while (lightLoad.compareTo(thisServersLoad) <= 0
          && nRegions < numUnassignedRegions);
      nRegions *= e.getValue().size();
      if (nRegions >= numUnassignedRegions) {
        break;
      }
View Full Code Here

TOP

Related Classes of org.apache.hadoop.hbase.HServerLoad

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.