use of net.atos.entng.statistics.controllers.StatisticsController in project statistics by OPEN-ENT-NG.
the class Statistics method start.
@Override
public void start() {
super.start();
JsonArray accessModules = container.config().getArray("access-modules", null);
if (accessModules == null || accessModules.size() == 0) {
log.error("Parameter access-modules is null or empty");
return;
}
// 1) Schedule daily aggregation
/* By default, fire aggregate-cron at 1:15am every day.
* Be careful when setting fire times between midnight and 1:00 AM
* - "daylight savings" can cause a skip or a repeat depending on whether the time moves back or jumps forward.
*/
final String aggregateEventsCron = container.config().getString("aggregate-cron", "0 15 1 ? * * *");
AggregateTask aggTask = new AggregateTask();
try {
new CronTrigger(vertx, aggregateEventsCron).schedule(aggTask);
} catch (ParseException e) {
log.fatal(e.getMessage(), e);
return;
}
// In development environment, launch aggregations if parameter "aggregateOnStart" is set to true in module configuration
if ("dev".equals(container.config().getString("mode", null)) && container.config().getBoolean("aggregateOnStart", false)) {
Date startDate = new Date();
// Thu, 30 Apr 2015 00:00:00 GMT
startDate.setTime(1430352000000L);
Date endDate = new Date();
// Fri, 01 May 2015 00:00:00 GMT
endDate.setTime(1430438400000L);
this.aggregateEvents(vertx, startDate, endDate);
}
// 2) Init controller
addController(new StatisticsController(vertx, MongoConstants.COLLECTIONS.stats.toString(), accessModules));
MongoDbConf.getInstance().setCollection(MongoConstants.COLLECTIONS.stats.toString());
// FIXME : the statistics will be kept one year to antoher. No repositoryEvents management
}
Aggregations