Package org.apache.hadoop.hbase

Examples of org.apache.hadoop.hbase.HServerLoad


        nRegionsToAssign + ", regions to give other servers than this=" +
        otherServersRegionsCount + ", isMetaAssign=" + isMetaAssign);

      // 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);
      int 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;
      }
      if (nregions < nRegionsToAssign) {
        // There are some more heavily loaded servers
        // but we can't assign all the regions to this server.
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

     * @param mostLoadedRegions - array of most loaded regions
     * @param returnMsgs - array of return massages
     */
    void loadBalancing(HServerInfo info, HRegionInfo[] mostLoadedRegions,
        ArrayList<HMsg> returnMsgs) {
      HServerLoad servLoad = info.getLoad();
      double avg = master.getAverageLoad();

      // nothing to balance if server load not more then average load
      if(servLoad.getLoad() <= Math.ceil(avg) || avg <= 2.0) {
        return;
      }

      // check if current server is overloaded
      int numRegionsToClose = balanceFromOverloaded(info.getServerName(),
View Full Code Here

            outboundArray =
              this.outboundMsgs.toArray(new HMsg[outboundMsgs.size()]);
            this.outboundMsgs.clear();
          }
          try {
            this.serverInfo.setLoad(new HServerLoad(requestCount.get(),
                onlineRegions.size()));
            this.requestCount.set(0);
            HMsg msgs[] = hbaseMaster.regionServerReport(
              serverInfo, outboundArray, getMostLoadedRegions());
            lastMsg = System.currentTimeMillis();
View Full Code Here

    MapWritable result = null;
    long lastMsg = 0;
    while(!stopRequested.get()) {
      try {
        this.requestCount.set(0);
        this.serverInfo.setLoad(new HServerLoad(0, onlineRegions.size()));
        lastMsg = System.currentTimeMillis();
        result = this.hbaseMaster.regionServerStartup(serverInfo);
        break;
      } catch (Leases.LeaseStillHeldException e) {
        LOG.info("Lease " + e.getName() + " already held on master. Check " +
View Full Code Here

   * @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

  throws IOException {
    if (!keepLooping() && hbaseMaster == null) {
      // the current server is stopping
      return;
    }
    HServerLoad hsl = buildServerLoad();
    // Why we do this?
    this.requestCount.set(0);
    try {
      this.hbaseMaster.regionServerReport(this.serverNameFromMasterPOV.getVersionedBytes(), hsl);
    } catch (IOException ioe) {
View Full Code Here

    for (HRegion region: regions) {
      regionLoads.put(region.getRegionName(), createRegionLoad(region));
    }
    MemoryUsage memory =
      ManagementFactory.getMemoryMXBean().getHeapMemoryUsage();
    return new HServerLoad(requestCount.get(),(int)metrics.getRequests(),
      (int)(memory.getUsed() / 1024 / 1024),
      (int) (memory.getMax() / 1024 / 1024), regionLoads,
      this.hlog.getCoprocessorHost().getCoprocessors());
  }
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.