@Override public void run() { try { Map<AggregationKey, AggregationValue> removedKeysMinute = process(reportingDao.averageAggregator.getMinute(), GraphGranularityType.MINUTE); Map<AggregationKey, AggregationValue> removedKeysHour = process(reportingDao.averageAggregator.getHourly(), GraphGranularityType.HOURLY); Map<AggregationKey, AggregationValue> removedKeysDay = process(reportingDao.averageAggregator.getDaily(), GraphGranularityType.DAILY); reportingDBManager.insertReporting(removedKeysMinute, GraphGranularityType.MINUTE); reportingDBManager.insertReporting(removedKeysHour, GraphGranularityType.HOURLY); reportingDBManager.insertReporting(removedKeysDay, GraphGranularityType.DAILY); reportingDBManager.insertReportingRaw(reportingDao.rawDataProcessor.rawStorage); reportingDBManager.cleanOldReportingRecords(Instant.now()); } catch (Exception e) { log.error("Error during reporting job.", e); } }
@Override public void run() { try { var stat = new Stat(sessionDao, userDao, blockingIOProcessor, stats, reportScheduler, true); log.info(stat); reportingDBManager.insertStat(this.region, stat); } catch (Exception e) { log.error("Error making stats.", e); } }
@Override public void close() { if (isDBEnabled()) { System.out.println("Closing Reporting DB..."); ds.close(); } }
this.reportingDBManager = new ReportingDBManager(blockingIOProcessor, enableDB); this.stats = new GlobalStats(); this.reportingDiskDao = new ReportingDiskDao(serverProperties.getReportingFolder(), serverProperties.isRawDBEnabled() && reportingDBManager.isDBEnabled());
public ReportingDBManager(String propsFilename, BlockingIOProcessor blockingIOProcessor, boolean isEnabled) { this.blockingIOProcessor = blockingIOProcessor; DBProperties dbProperties = new DBProperties(propsFilename); if (!isEnabled || dbProperties.size() == 0) { log.info("Separate DB storage disabled."); this.ds = null; this.cleanOldReporting = false; return; } HikariConfig config = initConfig(dbProperties); log.info("Reporting DB url : {}", config.getJdbcUrl()); log.info("Reporting DB user : {}", config.getUsername()); log.info("Connecting to reporting DB..."); HikariDataSource hikariDataSource; try { hikariDataSource = new HikariDataSource(config); } catch (Exception e) { log.error("Not able connect to reporting DB. Skipping. Reason : {}", e.getMessage()); this.ds = null; this.cleanOldReporting = false; return; } this.ds = hikariDataSource; this.reportingDBDao = new ReportingDBDao(hikariDataSource); this.cleanOldReporting = dbProperties.cleanReporting(); log.info("Connected to reporting database successfully."); }
public void close() { sessionDao.close(); transportTypeHolder.close(); asyncHttpClient.close(); reportingDiskDao.close(); System.out.println("Stopping BlockingIOProcessor..."); blockingIOProcessor.close(); reportScheduler.shutdown(); System.out.println("Stopping DBManager..."); dbManager.close(); reportingDBManager.close(); tokensPool.close(); } }
this.reportingDBManager = new ReportingDBManager(dbFileName, blockingIOProcessor, enableDB); serverProperties.isRawDBEnabled() && reportingDBManager.isDBEnabled());
public void insertStat(String region, Stat stat) { if (isDBEnabled()) { reportingDBDao.insertStat(region, stat); } }
public void insertReporting(Map<AggregationKey, AggregationValue> map, GraphGranularityType graphGranularityType) { if (isDBEnabled() && map.size() > 0) { blockingIOProcessor.executeDB(() -> reportingDBDao.insert(map, graphGranularityType)); } }
public void insertReportingRaw(Map<AggregationKey, Object> rawData) { if (isDBEnabled() && rawData.size() > 0) { blockingIOProcessor.executeDB(() -> reportingDBDao.insertRawData(rawData)); } }
public void cleanOldReportingRecords(Instant now) { if (isDBEnabled() && cleanOldReporting) { blockingIOProcessor.executeDB(() -> reportingDBDao.cleanOldReportingRecords(now)); } }