use of com.vmware.flowgate.common.model.RealTimeData in project flowgate by vmware.
the class NlyteDataService method getRealTimeDatas.
public List<RealTimeData> getRealTimeDatas(NlyteAPIClient nlyteAPIclient, FacilitySoftwareConfig facilitySoftwareConfig, Set<String> assetIds) {
List<RealTimeData> realTimeDatas = new ArrayList<RealTimeData>();
for (String assetId : assetIds) {
Asset asset = restClient.getAssetByID(assetId).getBody();
if (asset == null || !facilitySoftwareConfig.getId().equals(asset.getAssetSource())) {
continue;
}
RealTimeData realTimeData = null;
try {
realTimeData = generateRealTimeData(asset, nlyteAPIclient, getAdvanceSetting(facilitySoftwareConfig));
} catch (HttpClientErrorException e) {
logger.error("Failed to query data from Nlyte", e);
IntegrationStatus integrationStatus = facilitySoftwareConfig.getIntegrationStatus();
if (integrationStatus == null) {
integrationStatus = new IntegrationStatus();
}
integrationStatus.setStatus(IntegrationStatus.Status.ERROR);
integrationStatus.setDetail(e.getMessage());
integrationStatus.setRetryCounter(FlowgateConstant.DEFAULTNUMBEROFRETRIES);
updateIntegrationStatus(facilitySoftwareConfig);
break;
} catch (ResourceAccessException e1) {
if (e1.getCause().getCause() instanceof ConnectException) {
checkAndUpdateIntegrationStatus(facilitySoftwareConfig, e1.getMessage());
break;
}
}
if (realTimeData == null) {
continue;
}
realTimeDatas.add(realTimeData);
}
return realTimeDatas;
}
use of com.vmware.flowgate.common.model.RealTimeData in project flowgate by vmware.
the class NlyteDataService method generateRealTimeData.
public RealTimeData generateRealTimeData(Asset asset, NlyteAPIClient nlyteAPIclient, HashMap<AdvanceSettingType, String> advanceSettingMap) {
RealTimeData realTimeData = null;
JsonResultForPDURealtimeValue result = nlyteAPIclient.getPowerStripsRealtimeValue(asset.getAssetNumber()).getBody();
List<ValueUnit> valueUnits = generateValueUnits(result.getValue(), advanceSettingMap);
if (!valueUnits.isEmpty()) {
realTimeData = new RealTimeData();
realTimeData.setAssetID(asset.getId());
realTimeData.setValues(valueUnits);
realTimeData.setTime(valueUnits.get(0).getTime());
realTimeData.setId(realTimeData.getAssetID() + "_" + realTimeData.getTime());
}
return realTimeData;
}
use of com.vmware.flowgate.common.model.RealTimeData in project flowgate by vmware.
the class OpenManageJobTest method getMetricDatasSourceIsDifferent.
@Test
public void getMetricDatasSourceIsDifferent() {
FacilitySoftwareConfig config = new FacilitySoftwareConfig();
config.setId(createAsset().getAssetSource() + "SourceIsDifferent");
List<RealTimeData> metricDatas = openmanageJobService.getMetricDatas(config, openManageAPIClient);
TestCase.assertEquals(true, metricDatas.isEmpty());
}
use of com.vmware.flowgate.common.model.RealTimeData in project flowgate by vmware.
the class SyncSensorMetaDataJobTest method testGetSensorRealTimeData1.
@Test
public void testGetSensorRealTimeData1() {
HashMap<String, String> justificationfields = generateExtraInfo("6566");
Asset asset = createAsset();
asset.setId("123o89qw4jjasd0");
asset.setJustificationfields(justificationfields);
Sensor sensor = createSensor();
sensor.setId(6566);
sensor.setName("HumiditySensor");
sensor.setSerialNumber("8999");
sensor.setType("HumiditySensor");
Mockito.when(this.powerIQAPIClient.getSensorById("6566")).thenReturn(sensor);
List<Asset> assets = new ArrayList<Asset>();
assets.add(asset);
List<RealTimeData> realTimeDatas = powerIQService.getSensorRealTimeData(createFacility(), assets);
TestCase.assertEquals(0, realTimeDatas.size());
}
use of com.vmware.flowgate.common.model.RealTimeData in project flowgate by vmware.
the class SyncSensorMetaDataJobTest method testGetSensorRealTimeData2.
@Test
public void testGetSensorRealTimeData2() {
HashMap<String, String> justificationfields = generateExtraInfo("6566");
Asset asset = createAsset();
asset.setId("123o89qw4jjasd0");
asset.setJustificationfields(justificationfields);
HashMap<String, String> justificationfields1 = generateExtraInfo("6567");
Asset asset1 = createAsset();
asset1.setId("123o89qw4jjasd1");
asset1.setJustificationfields(justificationfields1);
Sensor sensor = createSensor();
SensorReading sensorReading = createReading();
sensorReading.setUom("%");
sensor.setId(6566);
sensor.setName("HumiditySensor");
sensor.setSerialNumber("8999");
sensor.setType("HumiditySensor");
sensor.setReading(sensorReading);
Mockito.when(this.powerIQAPIClient.getSensorById("6566")).thenReturn(sensor);
Sensor sensor1 = createSensor();
SensorReading sensorReading1 = createReading();
sensorReading1.setUom("F");
sensor1.setId(6567);
sensor1.setName("TemperatureSensor");
sensor1.setSerialNumber("9000");
sensor1.setType("TemperatureSensor");
sensor1.setReading(sensorReading1);
Mockito.when(this.powerIQAPIClient.getSensorById("6567")).thenReturn(sensor1);
Set<String> assetIds = new HashSet<String>();
assetIds.add("123o89qw4jjasd0");
assetIds.add("123o89qw4jjasd1");
List<Asset> assets = new ArrayList<Asset>();
assets.add(asset);
assets.add(asset1);
List<RealTimeData> realTimeDatas = powerIQService.getSensorRealTimeData(createFacility(), assets);
for (RealTimeData realtimedata : realTimeDatas) {
if ("123o89qw4jjasd0".equals(realtimedata.getAssetID())) {
TestCase.assertEquals((double) 100, realtimedata.getValues().get(0).getValueNum());
} else {
TestCase.assertEquals((double) (100 - 32) * 5 / 9, realtimedata.getValues().get(0).getValueNum());
}
}
}
Aggregations