use of com.vmware.flowgate.common.model.MetricData in project flowgate by vmware.
the class TranslateFunctionServiceTest method testConvertServerAverageUsedPowerEnergyConsumptionAverageTemperature.
@Test
public void testConvertServerAverageUsedPowerEnergyConsumptionAverageTemperature() {
String assetId = "752c0c7637104a39a4242031cd48785e";
long startTime = System.currentTimeMillis();
long endTime = startTime + 30000;
ValueUnit valueUnit = new ValueUnit();
valueUnit.setTime(endTime);
valueUnit.setExtraidentifier(String.valueOf(startTime));
valueUnit.setKey(MetricName.SERVER_AVERAGE_USED_POWER);
valueUnit.setUnit(ValueUnit.MetricUnit.kW.toString());
valueUnit.setValueNum(0.06906666666666665);
String displayName = MetricName.SERVER_AVERAGE_USED_POWER;
Function<TranslateContext, MetricData> function = TranslateFunctionService.serverFormulaKeyAndFunction.get(MetricName.SERVER_AVERAGE_USED_POWER);
Map<String, ValueUnit> valueUnitMap = new HashMap<>();
valueUnitMap.put(assetId, valueUnit);
TranslateContext translateContext = TranslateContext.buildByValueUnitsAndDisplayNameAndFormula(valueUnitMap, displayName, assetId);
MetricData metricData = function.apply(translateContext);
TestCase.assertEquals(valueUnit.getKey(), metricData.getMetricName());
TestCase.assertEquals(startTime, metricData.getTimeStamp());
TestCase.assertEquals(valueUnit.getValueNum(), metricData.getValueNum());
TestCase.assertEquals(valueUnit.getUnit(), metricData.getUnit());
}
use of com.vmware.flowgate.common.model.MetricData in project flowgate by vmware.
the class TranslateFunctionServiceTest method testServerConvertValue.
@Test
public void testServerConvertValue() {
String assetId = "752c0c7637104a39a4242031cd48785e";
long currentTimeMillis = System.currentTimeMillis();
ValueUnit valueUnit = new ValueUnit();
valueUnit.setTime(currentTimeMillis);
valueUnit.setKey(MetricName.SERVER_CPUUSAGE);
valueUnit.setUnit(ValueUnit.MetricUnit.percent.name());
valueUnit.setValue("value");
String displayName = MetricName.SERVER_CPUUSAGE;
Function<TranslateContext, MetricData> function = TranslateFunctionService.convert;
Map<String, ValueUnit> valueUnitMap = new HashMap<>();
valueUnitMap.put(assetId, valueUnit);
TranslateContext translateContext = TranslateContext.buildByValueUnitsAndDisplayNameAndFormula(valueUnitMap, displayName, assetId);
MetricData metricData = function.apply(translateContext);
TestCase.assertEquals(valueUnit.getKey(), metricData.getMetricName());
TestCase.assertEquals(valueUnit.getTime(), metricData.getTimeStamp());
TestCase.assertEquals("value", metricData.getValue());
TestCase.assertEquals(0.0, metricData.getValueNum());
TestCase.assertEquals(valueUnit.getUnit(), metricData.getUnit());
}
use of com.vmware.flowgate.common.model.MetricData in project flowgate by vmware.
the class TranslateFunctionServiceTest method testConvertServerPeakUsedPowerMinimumUsedPowerPeakTemperature.
@Test
public void testConvertServerPeakUsedPowerMinimumUsedPowerPeakTemperature() {
String assetId = "752c0c7637104a39a4242031cd48785e";
long startTime = System.currentTimeMillis();
long maxValueTime = startTime + 2000;
long endTime = startTime + 30000;
ValueUnit valueUnit = new ValueUnit();
valueUnit.setTime(endTime);
valueUnit.setExtraidentifier(startTime + FlowgateConstant.SEPARATOR + maxValueTime);
valueUnit.setKey(MetricName.SERVER_PEAK_USED_POWER);
valueUnit.setUnit(ValueUnit.MetricUnit.kW.toString());
valueUnit.setValueNum(0.07);
String displayName = MetricName.SERVER_PEAK_USED_POWER;
Function<TranslateContext, MetricData> function = TranslateFunctionService.serverFormulaKeyAndFunction.get(MetricName.SERVER_PEAK_USED_POWER);
Map<String, ValueUnit> valueUnitMap = new HashMap<>();
valueUnitMap.put(assetId, valueUnit);
TranslateContext translateContext = TranslateContext.buildByValueUnitsAndDisplayNameAndFormula(valueUnitMap, displayName, assetId);
MetricData metricData = function.apply(translateContext);
TestCase.assertEquals(valueUnit.getKey(), metricData.getMetricName());
TestCase.assertEquals(maxValueTime, metricData.getTimeStamp());
TestCase.assertEquals(valueUnit.getValueNum(), metricData.getValueNum());
TestCase.assertEquals(valueUnit.getUnit(), metricData.getUnit());
}
use of com.vmware.flowgate.common.model.MetricData in project flowgate by vmware.
the class VROAsyncJob method syncVROMetricData.
private void syncVROMetricData(SDDCSoftwareConfig config) {
if (!config.checkIsActive()) {
return;
}
VROConfig vro = new VROConfig(config);
long currentTime = System.currentTimeMillis();
MetricClient metricClient = null;
List<ResourceDto> hosts = null;
try {
metricClient = new MetricClient(vro, publisher);
hosts = metricClient.getHostSystemsResources();
} catch (AuthException authException) {
logger.error("Failed to connect to VROps manager ", authException);
IntegrationStatus integrationStatus = config.getIntegrationStatus();
if (integrationStatus == null) {
integrationStatus = new IntegrationStatus();
}
integrationStatus.setStatus(IntegrationStatus.Status.ERROR);
integrationStatus.setDetail(authException.getMessage());
integrationStatus.setRetryCounter(FlowgateConstant.DEFAULTNUMBEROFRETRIES);
updateIntegrationStatus(config);
return;
} catch (Exception e) {
if (e.getCause() instanceof UndeclaredThrowableException) {
UndeclaredThrowableException undeclaredThrowableException = (UndeclaredThrowableException) e.getCause();
if (undeclaredThrowableException.getUndeclaredThrowable().getCause() instanceof ConnectException) {
checkAndUpdateIntegrationStatus(config, undeclaredThrowableException.getUndeclaredThrowable().getCause().getMessage());
return;
}
}
throw e;
}
// read all host/asset maaping from apiserver
Map<String, Asset> assetDictionary = new HashMap<String, Asset>();
try {
restClient.setServiceKey(serviceKeyConfig.getServiceKey());
Asset[] servers = restClient.getAssetsByVRO(vro.getId()).getBody();
for (Asset server : servers) {
assetDictionary.put(server.getId(), server);
}
} catch (HttpClientErrorException clientError) {
if (clientError.getRawStatusCode() != HTTP_NOTFOUND) {
throw clientError;
}
}
ServerMapping[] mappings = null;
try {
mappings = restClient.getServerMappingsByVRO(vro.getId()).getBody();
} catch (HttpClientErrorException clientError) {
if (clientError.getRawStatusCode() != HTTP_NOTFOUND) {
throw clientError;
}
mappings = new ServerMapping[0];
}
HashMap<String, ServerMapping> entityNameDictionary = new HashMap<String, ServerMapping>();
HashMap<String, ServerMapping> objectIDDictionary = new HashMap<String, ServerMapping>();
for (ServerMapping mapping : mappings) {
entityNameDictionary.put(mapping.getVroVMEntityName(), mapping);
objectIDDictionary.put(mapping.getVroVMEntityObjectID(), mapping);
// vcIDDictionary.put(mapping.getVroVMEntityVCID(), mapping);
}
List<ServerMapping> validMapping = new ArrayList<ServerMapping>();
for (ResourceDto host : hosts) {
// There are several things that can be used as a identifier of a host.
// the first is the Name
// beside that there are three other identifier
// VMEntityName -- 10.112.113.160
// VMEntityObjectID host-81 the mobID of the host.
// VMEntityVCID this is the uuid of the vc object.
// currently we only add new servers and don't delete servers
List<ResourceIdentifier> identifiers = host.getResourceKey().getResourceIdentifiers();
boolean newHost = true;
String entityName = "";
String objectID = "";
String vcID = "";
ServerMapping refer = null;
for (ResourceIdentifier identifier : identifiers) {
if (!newHost) {
break;
}
switch(identifier.getIdentifierType().getName()) {
case EntityName:
entityName = identifier.getValue();
if (entityNameDictionary.containsKey(entityName)) {
newHost = false;
refer = entityNameDictionary.get(entityName);
}
break;
case VMEntityObjectID:
objectID = identifier.getValue();
if (objectIDDictionary.containsKey(objectID)) {
newHost = false;
refer = objectIDDictionary.get(objectID);
}
break;
case VMEntityVCID:
vcID = identifier.getValue();
break;
default:
break;
}
}
if (newHost) {
// try to notify the other system.
String ipaddress = IPAddressUtil.getIPAddress(entityName);
if (null != ipaddress) {
publisher.publish(null, ipaddress);
ipaddress = entityName;
}
ServerMapping newMapping = new ServerMapping();
newMapping.setVroID(vro.getId());
newMapping.setVroResourceName(host.getResourceKey().getName());
newMapping.setVroVMEntityName(entityName);
newMapping.setVroVMEntityObjectID(objectID);
newMapping.setVroVMEntityVCID(vcID);
newMapping.setVroResourceID(host.getIdentifier().toString());
AssetIPMapping[] ipMappings = restClient.getHostnameIPMappingByIP(ipaddress).getBody();
if (null != ipMappings && ipMappings.length > 0) {
// update the mapping
String assetName = ipMappings[0].getAssetname();
Asset asset = restClient.getAssetByName(assetName).getBody();
if (asset != null) {
newMapping.setAsset(asset.getId());
}
}
restClient.saveServerMapping(newMapping);
validMapping.add(newMapping);
} else {
if (refer.getAsset() == null) {
String ipaddress = IPAddressUtil.getIPAddress(refer.getVroVMEntityName());
AssetIPMapping[] ipMappings = restClient.getHostnameIPMappingByIP(ipaddress).getBody();
if (null != ipMappings && ipMappings.length > 0) {
// update the mapping
String assetName = ipMappings[0].getAssetname();
Asset asset = restClient.getAssetByName(assetName).getBody();
if (asset != null) {
refer.setAsset(asset.getId());
restClient.saveServerMapping(refer);
validMapping.add(refer);
}
} else {
if (null != ipaddress) {
logger.info("Notify Infoblox to query the assetname");
publisher.publish(null, ipaddress);
}
}
} else {
validMapping.add(refer);
}
}
}
// validMapping.stream().map(ServerMapping::getAssetID).collect(Collectors.toSet());
if (validMapping.isEmpty()) {
logger.info("No Mapping find.Sync nothing for this execution.");
return;
}
Long latencyFactor = latencyFactorMap.get(config.getServerURL());
if (latencyFactor == null) {
latencyFactor = 24L;
}
Long lastUpdateTimeStamp = lastUpdateTimeMap.get(config.getServerURL());
if (lastUpdateTimeStamp == null) {
lastUpdateTimeStamp = currentTime - FIVE_MINUTES * latencyFactor;
}
boolean hasNewData = false;
logger.info(String.format("Start prepare data.%s, lastUpdateTime:%s, latencyFactor:%s", executionCount, lastUpdateTimeStamp, latencyFactor));
long newUpdateTimeStamp = lastUpdateTimeStamp;
for (ServerMapping mapping : validMapping) {
if (mapping.getAsset() != null) {
MetricData[] sensorDatas = restClient.getServerRelatedSensorDataByServerID(mapping.getAsset(), lastUpdateTimeStamp, FIVE_MINUTES * latencyFactor).getBody();
Asset server = restClient.getAssetByID(mapping.getAsset()).getBody();
List<String> pdus = server.getPdus();
StatContents contents = new StatContents();
StatContent frontTemp = new StatContent();
List<Double> frontValues = new ArrayList<Double>();
List<Long> frontTimes = new ArrayList<Long>();
StatContent backTemp = new StatContent();
List<Double> backValues = new ArrayList<Double>();
List<Long> backTimes = new ArrayList<Long>();
StatContent pduAMPSValue = new StatContent();
List<Double> pduAMPSValues = new ArrayList<Double>();
List<Long> pduAMPSTimes = new ArrayList<Long>();
StatContent pduRealtimeVoltage = new StatContent();
List<Double> voltageValues = new ArrayList<Double>();
List<Long> voltageTimes = new ArrayList<Long>();
StatContent pduRealtimePower = new StatContent();
List<Double> powerValues = new ArrayList<Double>();
List<Long> powerTimes = new ArrayList<Long>();
StatContent frontHumidityPercent = new StatContent();
List<Double> frontHumidityValues = new ArrayList<Double>();
List<Long> frontHumidityTimes = new ArrayList<Long>();
StatContent backHumidityPercent = new StatContent();
List<Double> backHumidityValues = new ArrayList<Double>();
List<Long> backHumidityTimes = new ArrayList<Long>();
StatContent currentLoad = new StatContent();
List<Double> currentLoadValues = new ArrayList<Double>();
List<Long> currentLoadTimes = new ArrayList<Long>();
StatContent powerLoad = new StatContent();
List<Double> powerLoadValues = new ArrayList<Double>();
List<Long> powerLoadTimes = new ArrayList<Long>();
String pduId = null;
String currentMetricName = MetricName.SERVER_CONNECTED_PDU_CURRENT;
String powerMetricName = MetricName.SERVER_CONNECTED_PDU_POWER;
String voltageMetricName = MetricName.SERVER_VOLTAGE;
String currentLoadMetricName = MetricName.PDU_CURRENT_LOAD;
String powerLoadMetricName = MetricName.PDU_POWER_LOAD;
if (pdus != null && !pdus.isEmpty()) {
pduId = pdus.get(0);
currentMetricName = String.format(MetricKeyName.SERVER_CONNECTED_PDUX_TOTAL_CURRENT, pduId);
powerMetricName = String.format(MetricKeyName.SERVER_CONNECTED_PDUX_TOTAL_POWER, pduId);
currentLoadMetricName = String.format(MetricKeyName.SERVER_CONNECTED_PDUX_CURRENT_LOAD, pduId);
powerLoadMetricName = String.format(MetricKeyName.SERVER_CONNECTED_PDUX_POWER_LOAD, pduId);
}
for (MetricData data : sensorDatas) {
if (data.getTimeStamp() > newUpdateTimeStamp) {
newUpdateTimeStamp = data.getTimeStamp();
hasNewData = true;
}
String metricName = data.getMetricName();
if (metricName.equals(currentMetricName)) {
pduAMPSValues.add(data.getValueNum());
pduAMPSTimes.add(data.getTimeStamp());
continue;
} else if (metricName.equals(powerMetricName)) {
powerValues.add(data.getValueNum());
powerTimes.add(data.getTimeStamp());
continue;
} else if (metricName.equals(voltageMetricName)) {
voltageValues.add(data.getValueNum());
voltageTimes.add(data.getTimeStamp());
continue;
} else if (metricName.equals(currentLoadMetricName)) {
currentLoadValues.add(data.getValueNum());
currentLoadTimes.add(data.getTimeStamp());
continue;
} else if (metricName.equals(powerLoadMetricName)) {
powerLoadValues.add(data.getValueNum());
powerLoadTimes.add(data.getTimeStamp());
continue;
} else if (metricName.contains(MetricName.SERVER_FRONT_HUMIDITY)) {
frontHumidityValues.add(data.getValueNum());
frontHumidityTimes.add(data.getTimeStamp());
continue;
} else if (metricName.contains(MetricName.SERVER_FRONT_TEMPERATURE)) {
frontValues.add(data.getValueNum());
frontTimes.add(data.getTimeStamp());
continue;
} else if (metricName.contains(MetricName.SERVER_BACK_TEMPREATURE)) {
backValues.add(data.getValueNum());
backTimes.add(data.getTimeStamp());
continue;
} else if (metricName.contains(MetricName.SERVER_BACK_HUMIDITY)) {
backHumidityValues.add(data.getValueNum());
backHumidityTimes.add(data.getTimeStamp());
continue;
}
}
if (!frontValues.isEmpty()) {
frontTemp.setStatKey(VROConsts.ENVRIONMENT_FRONT_TEMPERATURE_METRIC);
frontTemp.setData(frontValues.stream().mapToDouble(Double::valueOf).toArray());
frontTemp.setTimestamps(frontTimes.stream().mapToLong(Long::valueOf).toArray());
contents.addStatContent(frontTemp);
}
if (!backValues.isEmpty()) {
backTemp.setStatKey(VROConsts.ENVRIONMENT_BACK_TEMPERATURE_METRIC);
backTemp.setData(backValues.stream().mapToDouble(Double::valueOf).toArray());
backTemp.setTimestamps(backTimes.stream().mapToLong(Long::valueOf).toArray());
contents.addStatContent(backTemp);
}
if (!pduAMPSValues.isEmpty()) {
pduAMPSValue.setStatKey(VROConsts.ENVRIONMENT_PDU_AMPS_METRIC);
pduAMPSValue.setData(pduAMPSValues.stream().mapToDouble(Double::valueOf).toArray());
pduAMPSValue.setTimestamps(pduAMPSTimes.stream().mapToLong(Long::valueOf).toArray());
contents.addStatContent(pduAMPSValue);
}
if (!voltageValues.isEmpty()) {
pduRealtimeVoltage.setStatKey(VROConsts.ENVRIONMENT_PDU_VOLTS_METRIC);
pduRealtimeVoltage.setData(voltageValues.stream().mapToDouble(Double::valueOf).toArray());
pduRealtimeVoltage.setTimestamps(voltageTimes.stream().mapToLong(Long::valueOf).toArray());
contents.addStatContent(pduRealtimeVoltage);
}
if (!powerValues.isEmpty()) {
pduRealtimePower.setStatKey(VROConsts.ENVRIONMENT_PDU_POWER_METRIC);
pduRealtimePower.setData(powerValues.stream().mapToDouble(Double::valueOf).toArray());
pduRealtimePower.setTimestamps(powerTimes.stream().mapToLong(Long::valueOf).toArray());
contents.addStatContent(pduRealtimePower);
}
if (!frontHumidityValues.isEmpty()) {
frontHumidityPercent.setStatKey(VROConsts.ENVRIONMENT_FRONT_HUMIDITY_METRIC);
frontHumidityPercent.setData(frontHumidityValues.stream().mapToDouble(Double::valueOf).toArray());
frontHumidityPercent.setTimestamps(frontHumidityTimes.stream().mapToLong(Long::valueOf).toArray());
contents.addStatContent(frontHumidityPercent);
}
if (!backHumidityValues.isEmpty()) {
backHumidityPercent.setStatKey(VROConsts.ENVRIONMENT_BACK_HUMIDITY_METRIC);
backHumidityPercent.setData(backHumidityValues.stream().mapToDouble(Double::valueOf).toArray());
backHumidityPercent.setTimestamps(backHumidityTimes.stream().mapToLong(Long::valueOf).toArray());
contents.addStatContent(backHumidityPercent);
}
if (!currentLoadValues.isEmpty()) {
currentLoad.setStatKey(VROConsts.ENVRIONMENT_PDU_AMPS_LOAD_METRIC);
currentLoad.setData(currentLoadValues.stream().mapToDouble(Double::valueOf).toArray());
currentLoad.setTimestamps(currentLoadTimes.stream().mapToLong(Long::valueOf).toArray());
contents.addStatContent(currentLoad);
}
if (!powerLoadValues.isEmpty()) {
powerLoad.setStatKey(VROConsts.ENVRIONMENT_PDU_POWER_LOAD_METRIC);
powerLoad.setData(powerLoadValues.stream().mapToDouble(Double::valueOf).toArray());
powerLoad.setTimestamps(powerLoadTimes.stream().mapToLong(Long::valueOf).toArray());
contents.addStatContent(powerLoad);
}
if (!contents.getStatContents().isEmpty()) {
logger.info("Push data to VRO: " + config.getServerURL());
metricClient.addStats(null, UUID.fromString(mapping.getVroResourceID()), contents, false);
}
// UPDATE THE PROPERTIES
if (executionCount % 1000 == 0) {
PropertyContents propertyContents = new PropertyContents();
packagingPropertyContent(assetDictionary.get(mapping.getAsset()), propertyContents);
metricClient.addProperties(null, UUID.fromString(mapping.getVroResourceID()), propertyContents);
}
}
}
if (hasNewData) {
Long factor = (currentTime - newUpdateTimeStamp) / FIVE_MINUTES + 1;
if (factor > 24) {
factor = 24L;
} else if (factor < 0) {
factor = 1L;
}
latencyFactorMap.put(config.getServerURL(), factor);
if (newUpdateTimeStamp > currentTime) {
newUpdateTimeStamp = currentTime;
}
lastUpdateTimeMap.put(config.getServerURL(), newUpdateTimeStamp);
} else {
latencyFactor = latencyFactor + 1;
if (latencyFactor > 24) {
latencyFactor = 24L;
}
latencyFactorMap.put(config.getServerURL(), latencyFactor);
}
executionCount++;
logger.info("Finished Sync metric data for VRO: " + config.getServerURL());
}
use of com.vmware.flowgate.common.model.MetricData in project flowgate by vmware.
the class AssetControllerTest method testGetServerMetricsByID.
@Test
public void testGetServerMetricsByID() {
Asset asset = createAsset();
List<RealTimeData> realTimeDatas = new ArrayList<RealTimeData>();
long time = System.currentTimeMillis();
int duration = 30 * 60 * 1000;
long startTime = time - duration;
RealTimeData pduUsageMetricData = createPduAllRealTimeData(startTime);
pduUsageMetricData.setAssetID("0001bdc8b25d4c2badfd045ab61aabfa");
RealTimeData tempRealTimeData = createTemperatureSensorRealtimeData(startTime, "00027ca37b004a9890d1bf20349d5ac1");
RealTimeData humdityRealTimeData = createHumiditySensorRealtimeData(startTime, "34527ca37b004a9890d1bf20349d5ac1");
RealTimeData backTemperature = createBackTemperatureSensorRealtimeData(startTime, "968765a37b004a9890d1bf20349d5ac1");
RealTimeData backHumidity = createBackHumiditySensorRealtimeData(startTime, "486970a37b004a9890d1bf20349d5ac1");
RealTimeData hostRealTimeData = createServerHostRealTimeData(startTime);
hostRealTimeData.setAssetID(asset.getId());
realTimeDatas.add(hostRealTimeData);
realTimeDatas.add(humdityRealTimeData);
realTimeDatas.add(tempRealTimeData);
realTimeDatas.add(backHumidity);
realTimeDatas.add(backTemperature);
realTimeDatas.add(pduUsageMetricData);
realtimeDataRepository.saveAll(realTimeDatas);
asset = fillingMetricsformula(asset);
HashMap<String, String> justificationfields = new HashMap<>();
justificationfields.put(FlowgateConstant.PDU_PORT_FOR_SERVER, "power-2_FIELDSPLIT_CAN1-MDF-R01-PDU-BUILDING_FIELDSPLIT_OUTLET:1_FIELDSPLIT_0001bdc8b25d4c2badfd045ab61aabfa");
asset.setJustificationfields(justificationfields);
asset = assetRepository.save(asset);
List<MetricData> metricDatas = assetService.getMetricsByID(asset.getId(), startTime, duration);
Set<String> specialMetricNames = new HashSet<String>();
specialMetricNames.add(MetricName.SERVER_AVERAGE_USED_POWER);
specialMetricNames.add(MetricName.SERVER_PEAK_USED_POWER);
specialMetricNames.add(MetricName.SERVER_MINIMUM_USED_POWER);
specialMetricNames.add(MetricName.SERVER_AVERAGE_TEMPERATURE);
specialMetricNames.add(MetricName.SERVER_PEAK_TEMPERATURE);
for (MetricData serverdata : metricDatas) {
String metricName = serverdata.getMetricName();
if (String.format(MetricKeyName.SERVER_CONNECTED_PDUX_OUTLETX_CURRENT, "0001bdc8b25d4c2badfd045ab61aabfa", "OUTLET:1").equals(metricName)) {
TestCase.assertEquals(0.365, serverdata.getValueNum());
} else if (String.format(MetricKeyName.SERVER_CONNECTED_PDUX_OUTLETX_POWER, "0001bdc8b25d4c2badfd045ab61aabfa", "OUTLET:1").equals(metricName)) {
TestCase.assertEquals(0.081, serverdata.getValueNum());
} else if (String.format(MetricKeyName.SERVER_CONNECTED_PDUX_OUTLETX_VOLTAGE, "0001bdc8b25d4c2badfd045ab61aabfa", "OUTLET:1").equals(metricName)) {
TestCase.assertEquals(221.0, serverdata.getValueNum());
} else if (String.format(MetricKeyName.SERVER_CONNECTED_PDUX_POWER_LOAD, "0001bdc8b25d4c2badfd045ab61aabfa").equals(metricName)) {
TestCase.assertEquals(0.05, serverdata.getValueNum());
} else if (String.format(MetricKeyName.SERVER_CONNECTED_PDUX_CURRENT_LOAD, "0001bdc8b25d4c2badfd045ab61aabfa").equals(metricName)) {
TestCase.assertEquals(0.05, serverdata.getValueNum());
} else if (String.format(MetricKeyName.SERVER_CONNECTED_PDUX_TOTAL_CURRENT, "0001bdc8b25d4c2badfd045ab61aabfa").equals(metricName)) {
TestCase.assertEquals(1.455, serverdata.getValueNum());
} else if (String.format(MetricKeyName.SERVER_CONNECTED_PDUX_TOTAL_POWER, "0001bdc8b25d4c2badfd045ab61aabfa").equals(metricName)) {
TestCase.assertEquals(0.322, serverdata.getValueNum());
} else if (String.format(MetricKeyName.SERVER_BACK_HUMIDITY_LOCATIONX, "OUTLET").equals(metricName)) {
TestCase.assertEquals(19.0, serverdata.getValueNum());
} else if (String.format(MetricKeyName.SERVER_BACK_TEMPREATURE_LOCATIONX, "OUTLET").equals(metricName)) {
TestCase.assertEquals(25.0, serverdata.getValueNum());
} else if (String.format(MetricKeyName.SERVER_FRONT_HUMIDITY_LOCATIONX, "INLET").equals(metricName)) {
TestCase.assertEquals(serverdata.getValueNum(), 20.0);
} else if (String.format(MetricKeyName.SERVER_FRONT_TEMPERATURE_LOCATIONX, "INLET").equals(metricName)) {
TestCase.assertEquals(serverdata.getValueNum(), 32.0);
} else if (MetricName.SERVER_VOLTAGE.equals(metricName)) {
TestCase.assertEquals(221.0, serverdata.getValueNum());
} else if (MetricName.SERVER_STORAGEUSAGE.equals(metricName)) {
if (serverdata.getTimeStamp() == startTime + 240000) {
TestCase.assertEquals(65.0, serverdata.getValueNum());
}
} else if (MetricName.SERVER_MEMORYUSAGE.equals(metricName)) {
if (serverdata.getTimeStamp() == startTime + 20000) {
TestCase.assertEquals(87.22, serverdata.getValueNum());
}
} else if (MetricName.SERVER_CPUUSEDINMHZ.equals(metricName)) {
if (serverdata.getTimeStamp() == startTime + 20000) {
TestCase.assertEquals(746.00, serverdata.getValueNum());
}
} else if (MetricName.SERVER_CPUUSAGE.equals(metricName)) {
if (serverdata.getTimeStamp() == startTime + 20000) {
TestCase.assertEquals(4.67, serverdata.getValueNum());
}
} else if (MetricName.SERVER_ACTIVEMEMORY.equals(metricName)) {
if (serverdata.getTimeStamp() == startTime + 20000) {
TestCase.assertEquals(1561416.00, serverdata.getValueNum());
}
} else if (MetricName.SERVER_SHAREDMEMORY.equals(metricName)) {
if (serverdata.getTimeStamp() == startTime + 20000) {
TestCase.assertEquals(8.00, serverdata.getValueNum());
}
} else if (MetricName.SERVER_CONSUMEDMEMORY.equals(metricName)) {
if (serverdata.getTimeStamp() == startTime + 20000) {
TestCase.assertEquals(18291220.00, serverdata.getValueNum());
}
} else if (MetricName.SERVER_SWAPMEMORY.equals(metricName)) {
TestCase.assertEquals(0.00, serverdata.getValueNum());
} else if (MetricName.SERVER_BALLOONMEMORY.equals(metricName)) {
TestCase.assertEquals(0.0, serverdata.getValueNum());
} else if (MetricName.SERVER_NETWORKUTILIZATION.equals(metricName)) {
if (serverdata.getTimeStamp() == startTime + 20000) {
TestCase.assertEquals(146.00, serverdata.getValueNum());
}
} else if (MetricName.SERVER_STORAGEIORATEUSAGE.equals(metricName)) {
if (serverdata.getTimeStamp() == startTime + 20000) {
TestCase.assertEquals(330.00, serverdata.getValueNum());
}
} else if (MetricName.SERVER_POWER.equals(metricName)) {
if (serverdata.getTimeStamp() == startTime + 20000) {
TestCase.assertEquals(0.069, serverdata.getValueNum());
}
} else if (MetricName.SERVER_ENERGY_CONSUMPTION.equals(metricName)) {
if (serverdata.getTimeStamp() == startTime) {
TestCase.assertEquals(0.00038805555555555555, serverdata.getValueNum());
}
} else if (specialMetricNames.contains(metricName)) {
TestCase.fail("Duration API not support this metric " + metricName);
}
}
assetRepository.deleteById(asset.getId());
realtimeDataRepository.deleteById(pduUsageMetricData.getId());
realtimeDataRepository.deleteById(tempRealTimeData.getId());
realtimeDataRepository.deleteById(humdityRealTimeData.getId());
realtimeDataRepository.deleteById(backHumidity.getId());
realtimeDataRepository.deleteById(backTemperature.getId());
realtimeDataRepository.deleteById(hostRealTimeData.getId());
}
Aggregations