use of com.vmware.flowgate.common.model.PageModelImp in project flowgate by vmware.
the class PowerIQService method syncAllSensorMetricFormula.
public void syncAllSensorMetricFormula() {
restClient.setServiceKey(serviceKeyConfig.getServiceKey());
FacilitySoftwareConfig[] powerIQs = restClient.getFacilitySoftwareInternalByType(SoftwareType.PowerIQ).getBody();
for (FacilitySoftwareConfig powerIQ : powerIQs) {
logger.info("Start sync sensor metrics formula for " + powerIQ.getName());
List<Asset> pdusFromFlowgate = restClient.getAllAssetsBySourceAndType(powerIQ.getId(), AssetCategory.PDU);
Map<String, Asset> pduIDAndAssetMap = getPDUIDAndAssetMap(pdusFromFlowgate);
int pageSize = 200;
int pageNumber = 0;
List<Asset> sensors = null;
ResponseEntity<PageModelImp<Asset>> res = restClient.getAssetsBySourceAndType(powerIQ.getId(), AssetCategory.Sensors, pageNumber, pageSize);
while (!res.getBody().getContent().isEmpty()) {
sensors = res.getBody().getContent();
Set<Asset> pduAssetNeedToUpdate = updatePduMetricformular(sensors, pduIDAndAssetMap);
restClient.saveAssets(new ArrayList<Asset>(pduAssetNeedToUpdate));
pageNumber++;
res = restClient.getAssetsBySourceAndType(powerIQ.getId(), AssetCategory.Sensors, pageNumber, pageSize);
}
logger.info("Finished sync sensor metrics formula for " + powerIQ.getName());
}
}
Aggregations