Examples of ServerLoad


Examples of org.apache.hadoop.hbase.ServerLoad

  public void testKeepRegionLoad() throws Exception {

    ServerName sn = new ServerName("test:8080", 100);
    int numClusterStatusToAdd = 20000;
    for (int i = 0; i < numClusterStatusToAdd; i++) {
      ServerLoad sl = mock(ServerLoad.class);

      RegionLoad rl = mock(RegionLoad.class);
      when(rl.getStores()).thenReturn(i);

      Map<byte[], RegionLoad> regionLoadMap =
          new TreeMap<byte[], RegionLoad>(Bytes.BYTES_COMPARATOR);
      regionLoadMap.put(Bytes.toBytes(REGION_KEY), rl);
      when(sl.getRegionsLoad()).thenReturn(regionLoadMap);

      ClusterStatus clusterStatus = mock(ClusterStatus.class);
      when(clusterStatus.getServers()).thenReturn(Arrays.asList(sn));
      when(clusterStatus.getLoad(sn)).thenReturn(sl);
View Full Code Here

Examples of org.apache.hadoop.hbase.ServerLoad

  @Override
  public RegionServerReportResponse regionServerReport(
      RpcController controller, RegionServerReportRequest request) throws ServiceException {
    try {
      ClusterStatusProtos.ServerLoad sl = request.getLoad();
      this.serverManager.regionServerReport(ProtobufUtil.toServerName(request.getServer()), new ServerLoad(sl));
      if (sl != null && this.metricsMaster != null) {
        // Up our metrics.
        this.metricsMaster.incrementRequests(sl.getTotalNumberOfRequests());
      }
    } catch (IOException ioe) {
View Full Code Here

Examples of org.apache.hadoop.hbase.ServerLoad

    // However we temporarily need the old loads so we can use them to keep the rolling average.
    Map<String, Deque<RegionLoad>> oldLoads = loads;
    loads = new HashMap<String, Deque<RegionLoad>>();

    for (ServerName sn : clusterStatus.getServers()) {
      ServerLoad sl = clusterStatus.getLoad(sn);
      if (sl == null) {
        continue;
      }
      for (Entry<byte[], RegionLoad> entry : sl.getRegionsLoad().entrySet()) {
        Deque<RegionLoad> rLoads = oldLoads.get(Bytes.toString(entry.getKey()));
        if (rLoads == null) {
          // There was nothing there
          rLoads = new ArrayDeque<RegionLoad>();
        } else if (rLoads.size() >= 15) {
View Full Code Here

Examples of org.apache.hadoop.hbase.ServerLoad

  public RegionServerReportResponse regionServerReport(
      RpcController controller, RegionServerReportRequest request) throws ServiceException {
    try {
      ClusterStatusProtos.ServerLoad sl = request.getLoad();
      ServerName serverName = ProtobufUtil.toServerName(request.getServer());
      ServerLoad oldLoad = serverManager.getLoad(serverName);
      this.serverManager.regionServerReport(serverName, new ServerLoad(sl));
      if (sl != null && this.metricsMaster != null) {
        // Up our metrics.
        this.metricsMaster.incrementRequests(sl.getTotalNumberOfRequests()
          - (oldLoad != null ? oldLoad.getTotalNumberOfRequests() : 0));
      }
    } catch (IOException ioe) {
      throw new ServiceException(ioe);
    }
View Full Code Here

Examples of org.apache.hadoop.hbase.ServerLoad

  protected void unbalanceRegions(ClusterStatus clusterStatus,
      List<ServerName> fromServers, List<ServerName> toServers,
      double fractionOfRegions) throws Exception {
    List<byte[]> victimRegions = new LinkedList<byte[]>();
    for (ServerName server : fromServers) {
      ServerLoad serverLoad = clusterStatus.getLoad(server);
      // Ugh.
      List<byte[]> regions = new LinkedList<byte[]>(serverLoad.getRegionsLoad().keySet());
      int victimRegionCount = (int)Math.ceil(fractionOfRegions * regions.size());
      LOG.debug("Removing " + victimRegionCount + " regions from " + server.getServerName());
      for (int i = 0; i < victimRegionCount; ++i) {
        int victimIx = RandomUtils.nextInt(regions.size());
        String regionId = HRegionInfo.encodeRegionName(regions.remove(victimIx));
View Full Code Here

Examples of org.apache.hadoop.hbase.ServerLoad

      addRegionToMap(assignmentMapForFavoredNodes, region, primaryHost);
    } else if (secondaryHost != null && tertiaryHost != null) {
      // assign the region to the one with a lower load
      // (both have the desired hdfs blocks)
      ServerName s;
      ServerLoad tertiaryLoad = super.services.getServerManager().getLoad(tertiaryHost);
      ServerLoad secondaryLoad = super.services.getServerManager().getLoad(secondaryHost);
      if (secondaryLoad.getLoad() < tertiaryLoad.getLoad()) {
        s = secondaryHost;
      } else {
        s = tertiaryHost;
      }
      addRegionToMap(assignmentMapForFavoredNodes, region, s);
View Full Code Here

Examples of org.apache.hadoop.hbase.ServerLoad

    // However we temporarily need the old loads so we can use them to keep the rolling average.
    Map<String, List<RegionLoad>> oldLoads = loads;
    loads = new HashMap<String, List<RegionLoad>>();

    for (ServerName sn : clusterStatus.getServers()) {
      ServerLoad sl = clusterStatus.getLoad(sn);
      if (sl == null) {
        continue;
      }
      for (Entry<byte[], RegionLoad> entry : sl.getRegionsLoad().entrySet()) {
        List<RegionLoad> rLoads = oldLoads.get(Bytes.toString(entry.getKey()));
        if (rLoads != null) {
          // We're only going to keep 15.  So if there are that many already take the last 14
          if (rLoads.size() >= numRegionLoadsToRemember) {
            int numToRemove = 1 + (rLoads.size() - numRegionLoadsToRemember);
View Full Code Here

Examples of org.apache.hadoop.hbase.ServerLoad

  @Override
  public RegionServerReportResponse regionServerReport(
      RpcController controller, RegionServerReportRequest request) throws ServiceException {
    try {
      ClusterStatusProtos.ServerLoad sl = request.getLoad();
      this.serverManager.regionServerReport(ProtobufUtil.toServerName(request.getServer()), new ServerLoad(sl));
      if (sl != null && this.metricsMaster != null) {
        // Up our metrics.
        this.metricsMaster.incrementRequests(sl.getTotalNumberOfRequests());
      }
    } catch (IOException ioe) {
View Full Code Here

Examples of org.apache.hadoop.hbase.ServerLoad

  public RegionServerReportResponse regionServerReport(
      RpcController controller, RegionServerReportRequest request) throws ServiceException {
    try {
      ClusterStatusProtos.ServerLoad sl = request.getLoad();
      ServerName serverName = ProtobufUtil.toServerName(request.getServer());
      ServerLoad oldLoad = serverManager.getLoad(serverName);
      this.serverManager.regionServerReport(serverName, new ServerLoad(sl));
      if (sl != null && this.metricsMaster != null) {
        // Up our metrics.
        this.metricsMaster.incrementRequests(sl.getTotalNumberOfRequests()
          - (oldLoad != null ? oldLoad.getTotalNumberOfRequests() : 0));
      }
    } catch (IOException ioe) {
      throw new ServiceException(ioe);
    }
View Full Code Here

Examples of org.apache.hadoop.hbase.ServerLoad

    protected void unbalanceRegions(ClusterStatus clusterStatus,
        List<ServerName> fromServers, List<ServerName> toServers,
        double fractionOfRegions) throws Exception {
      List<byte[]> victimRegions = new LinkedList<byte[]>();
      for (ServerName server : fromServers) {
        ServerLoad serverLoad = clusterStatus.getLoad(server);
        // Ugh.
        List<byte[]> regions = new LinkedList<byte[]>(serverLoad.getRegionsLoad().keySet());
        int victimRegionCount = (int)Math.ceil(fractionOfRegions * regions.size());
        LOG.debug("Removing " + victimRegionCount + " regions from " + server.getServerName());
        for (int i = 0; i < victimRegionCount; ++i) {
          int victimIx = random.nextInt(regions.size());
          String regionId = HRegionInfo.encodeRegionName(regions.remove(victimIx));
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.