Identifies the resources reclaimed by the components that will be scaled down

@return Total resources reclaimed
967603
public static Resource computeTotalResourceChange(TopologyAPI.Topology topology,
                                                    Map<String, Integer> componentChanges,
                                                    Resource defaultInstanceResources,
                                                    ScalingDirection scalingDirection) {
    double cpu = 0;
    ByteAmount ram = ByteAmount.ZERO;
    ByteAmount disk = ByteAmount.ZERO;
    Map<String, ByteAmount> ramMap = TopologyUtils.getComponentRamMapConfig(topology);
    Map<String, Integer> componentsToScale = PackingUtils.getComponentsToScale(
        componentChanges, scalingDirection);
    for (String component : componentsToScale.keySet()) {
      int parallelismChange = Math.abs(componentChanges.get(component));
      cpu += parallelismChange * defaultInstanceResources.getCpu();
      disk = disk.plus(defaultInstanceResources.getDisk().multiply(parallelismChange));
      if (ramMap.containsKey(component)) {
        ram = ram.plus(ramMap.get(component).multiply(parallelismChange));
      } else {
        ram = ram.plus(defaultInstanceResources.getRam().multiply(parallelismChange));
      }
    }
    return new Resource(cpu, ram, disk);
  }
744986
protected ProcResourceValues sortReduceParts() {
    long sortStartMilli = System.currentTimeMillis();
    ProcResourceValues sortStartProcVals =
        task.getCurrentProcResourceValues();
    long sortStart = task.jmxThreadInfoTracker.getTaskCPUTime("MAIN_TASK");
    // sort
    for (int i = 0; i < reducePartitions.length; i++) {
      reducePartitions[i].groupOrSort();
    }
    long sortEndMilli = System.currentTimeMillis();
    ProcResourceValues sortEndProcVals =
        task.getCurrentProcResourceValues();
    long sortEnd = task.jmxThreadInfoTracker.getTaskCPUTime("MAIN_TASK");
    mapSpillSortCounter.incCountersPerSort(sortStartProcVals,
        sortEndProcVals, sortEndMilli - sortStartMilli);
    mapSpillSortCounter.incJVMCPUPerSort(sortStart, sortEnd);
    return sortEndProcVals;
  }
125910
@GuardedBy("lock")
	private CompletableFuture<Void> shutDownResourceManagerComponents() {

		final Collection<CompletableFuture<Void>> terminationFutures = new ArrayList<>(dispatcherResourceManagerComponents.size());

		for (DispatcherResourceManagerComponent<?> dispatcherResourceManagerComponent : dispatcherResourceManagerComponents) {
			terminationFutures.add(dispatcherResourceManagerComponent.closeAsync());
		}

		final FutureUtils.ConjunctFuture<Void> dispatcherTerminationFuture = FutureUtils.completeAll(terminationFutures);

		return FutureUtils.runAfterwards(
			dispatcherTerminationFuture,
			() -> {
				Exception exception = null;

				synchronized (lock) {
					if (resourceManagerLeaderRetriever != null) {
						try {
							resourceManagerLeaderRetriever.stop();
						} catch (Exception e) {
							exception = ExceptionUtils.firstOrSuppressed(e, exception);
						}

						resourceManagerLeaderRetriever = null;
					}

					if (dispatcherLeaderRetriever != null) {
						try {
							dispatcherLeaderRetriever.stop();
						} catch (Exception e) {
							exception = ExceptionUtils.firstOrSuppressed(e, exception);
						}

						dispatcherLeaderRetriever = null;
					}

					if (webMonitorLeaderRetrievalService != null) {
						try {
							webMonitorLeaderRetrievalService.stop();
						} catch (Exception e) {
							exception = ExceptionUtils.firstOrSuppressed(e, exception);
						}

						webMonitorLeaderRetrievalService = null;
					}
				}

				if (exception != null) {
					throw exception;
				}
			});
	}
1050664
public List<TimephasedCost> getTimephasedActualCost()
   {
      if (m_timephasedActualCost == null)
      {
         Resource r = getResource();
         ResourceType type = r != null ? r.getType() : ResourceType.WORK;

         //for Work and Material resources, we will calculate in the normal way
         if (type != ResourceType.COST)
         {
            if (m_timephasedActualWork != null && m_timephasedActualWork.hasData())
            {
               if (hasMultipleCostRates())
               {
                  m_timephasedActualCost = getTimephasedCostMultipleRates(getTimephasedActualWork(), getTimephasedActualOvertimeWork());
               }
               else
               {
                  m_timephasedActualCost = getTimephasedCostSingleRate(getTimephasedActualWork(), getTimephasedActualOvertimeWork());
               }
            }
         }
         else
         {
            m_timephasedActualCost = getTimephasedActualCostFixedAmount();
         }

      }

      return m_timephasedActualCost;
   }
880860
public int getTotalFree(){
		int total=0;
		for (int i=0; i < this.partitionCount && this.partitions[i] != null ; i++){
			total+=this.partitions[i].getAvailableConnections();
		}
		return total;
	}
1281314
public Set<URI> getResourceOnlySet() {
        final Set<URI> res = new HashSet<>(resourceOnlySet);
        res.removeAll(normalProcessingRoleSet);
        return res;
    }
731380
public function getResources()
    {
        $resources = array();
        foreach ($this->resources as $r) {
            $resources = array_merge($resources, $r);
        }

        return $resources;
    }
1220025
private Set<Source> calculateRemovedSources() {
        Set<Source> removed = new HashSet<>();
        for (String src : prev.sources().keySet()) {
            if (now.sources().get(src) == null) {
                removed.add(prev.sources().get(src));
            }
        }
        return removed;
    }
1290860
public List<ResourceFileSource> getSources() {
		List<ResourceFileSource> sources = new ArrayList<ResourceFileSource>();
		sources.add(this);
		return sources;
	}
253741
public Map<Integer, Map<ResourceType, Integer>> getCpuToResourcePartitioning() {
    if (cachedCpuToResourcePartitioning == null) {
      cachedCpuToResourcePartitioning =
          getUncachedCpuToResourcePartitioning(this);
    }
    return cachedCpuToResourcePartitioning;
  }
401857
public function getEnabledComponents()
    {
        // Answer Cached Components (if available):
        
        if ($this->cacheEnabledComponents) {
            return $this->cacheEnabledComponents;
        }
        
        // Obtain Component Objects:
        
        $components = ArrayList::create();
        
        foreach ($this->getEnabledChildren() as $child) {
            $components->push($child);
            $components->merge($child->getEnabledComponents());
        }
        
        $this->cacheEnabledComponents = $components;
        
        // Answer Component Objects:
        
        return $this->cacheEnabledComponents;
    }
407666
public boolean getOverAllocated()
   {
      Boolean overallocated = (Boolean) getCachedValue(ResourceField.OVERALLOCATED);
      if (overallocated == null)
      {
         Number peakUnits = getPeakUnits();
         Number maxUnits = getMaxUnits();
         overallocated = Boolean.valueOf(NumberHelper.getDouble(peakUnits) > NumberHelper.getDouble(maxUnits));
         set(ResourceField.OVERALLOCATED, overallocated);
      }
      return (overallocated.booleanValue());
   }
627058
public java.util.List<ResourceDataSyncItem> getResourceDataSyncItems() {
        if (resourceDataSyncItems == null) {
            resourceDataSyncItems = new com.amazonaws.internal.SdkInternalList<ResourceDataSyncItem>();
        }
        return resourceDataSyncItems;
    }
447963
public List<ResourceBundleKey> getDisplayValues()
	{
		final List<ResourceBundleKey> rbk = new ArrayList<>();
		for (final ResourceBundleKey key : getValues())
		{
			final ResourceBundleKey clone = (ResourceBundleKey)key.clone();
			clone.setKey(getPropertiesKey(key.getKey()));
			rbk.add(clone);
		}
		return rbk;
	}
804555
public java.util.List<CapacityReservation> getCapacityReservations() {
        if (capacityReservations == null) {
            capacityReservations = new com.amazonaws.internal.SdkInternalList<CapacityReservation>();
        }
        return capacityReservations;
    }
217876
public long getMemoryUsageBytes() {
    long total = 0;
    for (int i = 0; i < maps_.length; i++) {
      if (maps_[i] != null) {
        total += maps_[i].getMemoryUsageBytes();
      }
    }
    return total;
  }
735799
public List<String> getSortedResources() {
		List<String> resources = new ArrayList<>();
		try (BufferedReader bf = new BufferedReader(reader)) {
			String res;
			while ((res = bf.readLine()) != null) {
				String name = PathNormalizer.normalizePath(res.trim());

				for (String available : availableResources) {
					if (PathNormalizer.normalizePath(available).equals(name)) {
						if (name.endsWith(".js") || name.endsWith(".css"))
							resources.add(PathNormalizer.joinPaths(dirName, name));
						else
							resources.add(PathNormalizer.joinPaths(dirName, name + "/"));
						availableResources.remove(available);
						break;
					}
				}
			}
		} catch (IOException e) {
			throw new BundlingProcessException("Unexpected IOException reading sort file", e);
		}
		return resources;
	}