func GetResourceRequest(pod *api.Pod) *schedulercache.Resource {
	result := schedulercache.Resource{}
	for _, container := range pod.Spec.Containers {
		for rName, rQuantity := range container.Resources.Requests {
			switch rName {
			case api.ResourceMemory:
				result.Memory += rQuantity.Value()
			case api.ResourceCPU:
				result.MilliCPU += rQuantity.MilliValue()
			case api.ResourceNvidiaGPU:
				result.NvidiaGPU += rQuantity.Value()
			default:
				if api.IsOpaqueIntResourceName(rName) {
					// Lazily allocate this map only if required.
					if result.OpaqueIntResources == nil {
						result.OpaqueIntResources = map[api.ResourceName]int64{}
					}
					result.OpaqueIntResources[rName] += rQuantity.Value()
				}
			}
		}
	}
	// take max_resource(sum_pod, any_init_container)
	for _, container := range pod.Spec.InitContainers {
		for rName, rQuantity := range container.Resources.Requests {
			switch rName {
			case api.ResourceMemory:
				if mem := rQuantity.Value(); mem > result.Memory {
					result.Memory = mem
				}
			case api.ResourceCPU:
				if cpu := rQuantity.MilliValue(); cpu > result.MilliCPU {
					result.MilliCPU = cpu
				}
			case api.ResourceNvidiaGPU:
				if gpu := rQuantity.Value(); gpu > result.NvidiaGPU {
					result.NvidiaGPU = gpu
				}
			default:
				if api.IsOpaqueIntResourceName(rName) {
					// Lazily allocate this map only if required.
					if result.OpaqueIntResources == nil {
						result.OpaqueIntResources = map[api.ResourceName]int64{}
					}
					value := rQuantity.Value()
					if value > result.OpaqueIntResources[rName] {
						result.OpaqueIntResources[rName] = value
					}
				}
			}
		}
	}
	return &result
}
// Sets the overall node information.
func (n *NodeInfo) SetNode(node *api.Node) error {
	n.node = node
	for rName, rQuant := range node.Status.Allocatable {
		switch rName {
		case api.ResourceCPU:
			n.allocatableResource.MilliCPU = rQuant.MilliValue()
		case api.ResourceMemory:
			n.allocatableResource.Memory = rQuant.Value()
		case api.ResourceNvidiaGPU:
			n.allocatableResource.NvidiaGPU = rQuant.Value()
		case api.ResourcePods:
			n.allowedPodNumber = int(rQuant.Value())
		default:
			if api.IsOpaqueIntResourceName(rName) {
				// Lazily allocate opaque resource map.
				if n.allocatableResource.OpaqueIntResources == nil {
					n.allocatableResource.OpaqueIntResources = map[api.ResourceName]int64{}
				}
				n.allocatableResource.OpaqueIntResources[rName] = rQuant.Value()
			}
		}
	}
	n.generation++
	return nil
}
func calculateResource(pod *api.Pod) (res Resource, non0_cpu int64, non0_mem int64) {
	for _, c := range pod.Spec.Containers {
		for rName, rQuant := range c.Resources.Requests {
			switch rName {
			case api.ResourceCPU:
				res.MilliCPU += rQuant.MilliValue()
			case api.ResourceMemory:
				res.Memory += rQuant.Value()
			case api.ResourceNvidiaGPU:
				res.NvidiaGPU += rQuant.Value()
			default:
				if api.IsOpaqueIntResourceName(rName) {
					// Lazily allocate opaque resource map.
					if res.OpaqueIntResources == nil {
						res.OpaqueIntResources = map[api.ResourceName]int64{}
					}
					res.OpaqueIntResources[rName] += rQuant.Value()
				}
			}
		}

		non0_cpu_req, non0_mem_req := priorityutil.GetNonzeroRequests(&c.Resources.Requests)
		non0_cpu += non0_cpu_req
		non0_mem += non0_mem_req
		// No non-zero resources for GPUs or opaque resources.
	}
	return
}