/** * This method creates a {@link ReportingRecord} object with values from commodity , service * entity and attribute provided to it every hour. * * @param reportingExtension Extension object * @param vObj ServiceEntity object * @param attribute attribute reported on * @param commodityName Commodity named element * @param commodity {@link Commodity} object to get provider uuid * @param isNumProduces whether reporting on numProduces attribute * @return {@link ReportingRecord} object */ private ReportingRecord createReportingRecord( ReportingExtension reportingExtension, VMTRootObject vObj, EStructuralFeature attribute, ENamedElement commodityName, Commodity commodity, boolean isNumProduces, long snapshotTime) { ReportingRecord record = ReportingFactory.eINSTANCE.createReportingRecord(); try { // long snapshotTime = (System.currentTimeMillis() - (1000*60*60)); if (reportingExtension.eClass() == ReportingExtensionsPackage.eINSTANCE.getCommodityReportingExt()) { CommodityReportingExt crExt = (CommodityReportingExt) reportingExtension; if (crExt.getMinUtilization() == -1d || crExt.getMaxUtilization() == -1d) { return null; } record.setTimeStamp(snapshotTime); record.setSeUuId(vObj.getUuid()); record.setPropertyType(commodityName.getName()); record.setPropertySubType(attribute.getName()); record.setMinUtilization(crExt.getMinUtilization()); record.setMaxUtilization(crExt.getMaxUtilization()); record.setAvgUtilization(crExt.getAvgUtilization()); record.setCapacity(crExt.getCapacity()); record.setRelation(crExt.getRelation()); if (crExt.getCommodityKey() != null) { String commodityKey = truncateString(crExt.getCommodityKey(), 80); record.setCommodityKey(commodityKey); } if (!commodity.getConsumes().isEmpty() && commodity.getConsumes().get(0).getSoldBy() != null) { record.setProviderUuId(commodity.getConsumes().get(0).getSoldBy().getUuid()); } // record.setStdDev(0); } else if (reportingExtension.eClass() == ReportingExtensionsPackage.eINSTANCE.getServiceEntityReportingExt()) { ServiceEntityReportingExt seExt = (ServiceEntityReportingExt) reportingExtension; if (isNumProduces) { if (seExt.getMinNumProduces() == -1 || seExt.getMaxNumProduces() == -1) { return null; } record.setTimeStamp(snapshotTime); record.setSeUuId(vObj.getUuid()); record.setPropertyType(attribute.getName()); record.setPropertySubType(attribute.getName()); record.setMinUtilization(seExt.getMinNumProduces()); record.setMaxUtilization(seExt.getMaxNumProduces()); record.setAvgUtilization(seExt.getAvgProduces()); record.setRelation(-1); record.setCommodityKey(null); // record.setStdDev(0); } else { if (seExt.getMinPropValue() == -1d || seExt.getMaxPropValue() == -1d) { return null; } if (attribute == AnalysisPackage.eINSTANCE.getServiceEntity_PriceIndex()) { if ((seExt.getMinPropValue() < 0) || (seExt.getMaxPropValue() < 0) || (seExt.getAvgPropValue() < 0)) { if (logger.isDebugEnabled()) { logger.error( "SE : " + vObj.toVMTString() + " has max, min and avg PriceIndex values of " + seExt.getMaxPropValue() + ", " + seExt.getMinPropValue() + " and " + seExt.getAvgPropValue() + " respectively"); } return null; } } record.setTimeStamp(snapshotTime); record.setSeUuId(vObj.getUuid()); record.setPropertyType(attribute.getName()); record.setPropertySubType(attribute.getName()); record.setRelation(-1); record.setCommodityKey(null); record.setMinUtilization(seExt.getMinPropValue()); record.setMaxUtilization(seExt.getMaxPropValue()); record.setAvgUtilization(seExt.getAvgPropValue()); } } } catch (Exception e) { logger.error("Exception in creating record ", e); } return record; }