private ComputeStats getContainerHostStats(ComputeState compute, ComputeDescription description) { ComputeStats stats = new ComputeStats(); stats.totalMemoryBytes = PropertyUtils.getPropertyLong(compute.customProperties, ContainerHostService.DOCKER_HOST_TOTAL_MEMORY_PROP_NAME).orElse(0L); stats.cpuCoreCount = PropertyUtils.getPropertyLong(compute.customProperties, ContainerHostService.DOCKER_HOST_NUM_CORES_PROP_NAME).orElse(1L); stats.availableMemoryBytes = PropertyUtils.getPropertyLong(compute.customProperties, ContainerHostService.DOCKER_HOST_AVAILABLE_MEMORY_PROP_NAME).orElse( stats.totalMemoryBytes); stats.cpuUsage = PropertyUtils.getPropertyDouble(compute.customProperties, ContainerHostService.DOCKER_HOST_CPU_USAGE_PCT_PROP_NAME).orElse(0.0); return stats; }
@Test public void getPropertyDoubleTest() { Map<String, String> props = new HashMap<>(); String testKey = "testKey"; String testValue = "5.55"; props.put(testKey, testValue); Optional<Double> val = PropertyUtils.getPropertyDouble(props, testKey); assertEquals(Double.valueOf(testValue), val.get()); props.put(testKey, "non-number"); val = PropertyUtils.getPropertyDouble(props, testKey); assertEquals(Optional.empty(), val); }
ContainerHostDataCollectionService.RESOURCE_POOL_AVAILABLE_MEMORY_CUSTOM_PROP) .orElse(0L); ePZClusterDto.cpuUsage = PropertyUtils.getPropertyDouble( resourcePoolState.customProperties, ContainerHostDataCollectionService.RESOURCE_POOL_CPU_USAGE_CUSTOM_PROP) if (PlacementZoneUtil.isSchedulerPlacementZone(resourcePoolState)) { ePZClusterDto.address = computeStates.get(0).address; ePZClusterDto.totalCpu = PropertyUtils.getPropertyDouble( computeStates.get(0).customProperties, ContainerHostService.DOCKER_HOST_NUM_CORES_PROP_NAME)
ContainerHostService.DOCKER_HOST_NUM_CORES_PROP_NAME).orElse(1L); Double hostCpuUsage = PropertyUtils.getPropertyDouble(computeState.customProperties, ContainerHostService.DOCKER_HOST_CPU_USAGE_PCT_PROP_NAME).orElse(0.0);