public static Resource computeTotalResourceChange(TopologyAPI.Topology topology,Map<String,Integer> componentChanges,Resource defaultInstanceResources,ScalingDirection scalingDirection){
  double cpu=0;
  long ram=0;
  long disk=0;
  Map<String,Long> 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+=parallelismChange * defaultInstanceResources.getDisk();
    if (ramMap.containsKey(component)) {
      ram+=parallelismChange * ramMap.get(component);
    }
 else {
      ram+=parallelismChange * defaultInstanceResources.getRam();
    }
  }
  return new Resource(cpu,ram,disk);
}

public static Resource computeTotalResourceChange ( TopologyAPI . Topology topology , Map < String , Integer > componentChanges , Resource defaultInstanceResources , ScalingDirection scalingDirection ) { double cpu = 0 ; long ram = 0 ; long disk = 0 ; Map < String , Long > 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 += parallelismChange * defaultInstanceResources . getDisk ( ) ; if ( ramMap . containsKey ( component ) ) { ram += parallelismChange * ramMap . get ( component ) ; } else { ram += parallelismChange * defaultInstanceResources . getRam ( ) ; } } return new Resource ( cpu , ram , disk ) ; }
identifies the resources reclaimed by the components that will be scaled down
