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; }
private Map<String, HostSelection> buildHostSelectionMap(QueryResult rpQueryResult) { Collection<ComputeState> computes = rpQueryResult.computesByLink.values(); final Map<String, HostSelection> initHostSelectionMap = new LinkedHashMap<>( computes.size()); for (ComputeState computeState : computes) { final HostSelection hostSelection = new HostSelection(); hostSelection.hostLink = computeState.documentSelfLink; hostSelection.resourcePoolLinks = rpQueryResult.rpLinksByComputeLink .get(computeState.documentSelfLink); hostSelection.deploymentPolicyLink = computeState.customProperties .get(ContainerHostService.CUSTOM_PROPERTY_DEPLOYMENT_POLICY); hostSelection.availableMemory = getPropertyLong( computeState.customProperties, ContainerHostService.DOCKER_HOST_AVAILABLE_MEMORY_PROP_NAME) .orElse(Long.MAX_VALUE); hostSelection.clusterStore = computeState.customProperties .get(ContainerHostService.DOCKER_HOST_CLUSTER_STORE_PROP_NAME); hostSelection.plugins = computeState.customProperties .get(ContainerHostService.DOCKER_HOST_PLUGINS_PROP_NAME); hostSelection.name = computeState.name != null ? computeState.name : "N/A"; hostSelection.hostType = ContainerHostUtil.getDeclaredContainerHostType(computeState); initHostSelectionMap.put(hostSelection.hostLink, hostSelection); } return initHostSelectionMap; }
private void parseVicStats(ComputeState computeState, Map<String, Object> properties) { Long totalMemory = PropertyUtils.getPropertyLong(computeState.customProperties, ContainerHostService.DOCKER_HOST_TOTAL_MEMORY_PROP_NAME).orElse(0L); Double usedMemory = 0d;
@Test public void getPropertyLongTest() { Map<String, String> props = new HashMap<>(); String testKey = "testKey"; String testValue = "5"; props.put(testKey, testValue); Optional<Long> val = PropertyUtils.getPropertyLong(props, testKey); assertEquals(Long.valueOf(testValue), val.get()); props.put(testKey, "non-number"); val = PropertyUtils.getPropertyLong(props, testKey); assertEquals(Optional.empty(), val); }
for (ComputeState computeState : computeStates) { Long hostTotalMemory = PropertyUtils.getPropertyLong(computeState.customProperties, ContainerHostService.DOCKER_HOST_TOTAL_MEMORY_PROP_NAME).orElse(Long.MAX_VALUE); Long numCores = PropertyUtils.getPropertyLong(computeState.customProperties, ContainerHostService.DOCKER_HOST_NUM_CORES_PROP_NAME).orElse(1L); .getPropertyLong(computeState.customProperties, ContainerHostService.DOCKER_HOST_AVAILABLE_MEMORY_PROP_NAME) .orElse(PropertyUtils .getPropertyLong(computeState.customProperties, ContainerHostService.DOCKER_HOST_TOTAL_MEMORY_PROP_NAME) .orElse(0L));
private void updateResourcePool(ComputeState computeState, Collection<String> rpLinks, boolean remove, boolean noHostOperation) { Long totalMemory = PropertyUtils.getPropertyLong(computeState.customProperties, ContainerHostService.DOCKER_HOST_TOTAL_MEMORY_PROP_NAME).orElse(0L); Long hostAvailableMemory = PropertyUtils.getPropertyLong(computeState.customProperties, ContainerHostService.DOCKER_HOST_AVAILABLE_MEMORY_PROP_NAME) .orElse(totalMemory); .getPropertyLong(resourcePoolState.customProperties, RESOURCE_POOL_AVAILABLE_MEMORY_CUSTOM_PROP) .orElse(null)
ePZClusterDto.name = resourcePoolState.name; ePZClusterDto.clusterCreationTimeMicros = PropertyUtils .getPropertyLong(resourcePoolState.customProperties, ClusterService.CLUSTER_CREATION_TIME_MICROS_CUSTOM_PROP) .orElse(0L); ePZClusterDto.totalMemory = resourcePoolState.maxMemoryBytes == null ? 0 : resourcePoolState.maxMemoryBytes; ePZClusterDto.memoryUsage = ePZClusterDto.totalMemory - PropertyUtils.getPropertyLong( resourcePoolState.customProperties, ContainerHostDataCollectionService.RESOURCE_POOL_AVAILABLE_MEMORY_CUSTOM_PROP)
resourcePoolState.documentSelfLink); Long availableMemory = PropertyUtils .getPropertyLong(resourcePoolStateUpdated.customProperties, ContainerHostDataCollectionService .RESOURCE_POOL_AVAILABLE_MEMORY_CUSTOM_PROP) .orElse(0L); Long cpuUsage = PropertyUtils .getPropertyLong(resourcePoolStateUpdated.customProperties, ContainerHostDataCollectionService.RESOURCE_POOL_CPU_USAGE_CUSTOM_PROP) .orElse(0L); resourcePoolState.documentSelfLink); return resourcePoolStateUpdated.maxMemoryBytes == 1500 && PropertyUtils .getPropertyLong(resourcePoolStateUpdated.customProperties, ContainerHostDataCollectionService .RESOURCE_POOL_AVAILABLE_MEMORY_CUSTOM_PROP) .getPropertyLong(resourcePoolStateUpdated.customProperties, ContainerHostDataCollectionService.RESOURCE_POOL_CPU_USAGE_CUSTOM_PROP) .get() == 90; resourcePoolState.documentSelfLink); return resourcePoolStateUpdated.maxMemoryBytes == 1000 && PropertyUtils .getPropertyLong(resourcePoolStateUpdated.customProperties, ContainerHostDataCollectionService .RESOURCE_POOL_AVAILABLE_MEMORY_CUSTOM_PROP) resourcePoolState.documentSelfLink); Long availableMemory = PropertyUtils