Ejemplo n.º 1
0
  private void initializeTimer() {
    segmentTimer = new Timer();
    TimerTask task =
        new TimerTask() {
          @Override
          public void run() {
            for (Metadata metadata : rulesService.getRuleMetadatas()) {
              Rule rule = rulesService.getRule(metadata.getId());
              for (Action action : rule.getActions()) {
                if (action.getActionTypeId().equals("setEventOccurenceCountAction")) {
                  Condition pastEventCondition =
                      (Condition) action.getParameterValues().get("pastEventCondition");
                  if (pastEventCondition.containsParameter("numberOfDays")) {
                    updateExistingProfilesForPastEventCondition(
                        rule.getCondition(), pastEventCondition);
                  }
                }
              }
            }
          }
        };
    segmentTimer.scheduleAtFixedRate(task, getDay(1).getTime(), taskExecutionPeriod);

    task =
        new TimerTask() {
          @Override
          public void run() {
            allSegments = getAllSegmentDefinitions();
            allScoring = getAllScoringDefinitions();
          }
        };
    segmentTimer.scheduleAtFixedRate(task, 0, 1000);
  }
Ejemplo n.º 2
0
 private void cancelTimers() {
   if (segmentTimer != null) {
     segmentTimer.cancel();
   }
   logger.info("Segment purge: Purge unscheduled");
 }