コード例 #1
0
    private void doAggregateEvent(PortalEvent item) {
      checkShutdown();

      eventCounter.increment();

      for (final ApplicationEventFilter<PortalEvent> applicationEventFilter :
          applicationEventFilters) {
        if (!applicationEventFilter.supports(item)) {
          logger.trace(
              "Skipping event {} - {} excluded by filter {}",
              new Object[] {eventCounter, item, applicationEventFilter});
          return;
        }
      }
      logger.trace("Aggregating event {} - {}", eventCounter, item);

      // Load or create the event session
      EventSession eventSession = getEventSession(item);

      // Give each interval aware aggregator a chance at the event
      for (final IntervalAwarePortalEventAggregator<PortalEvent> portalEventAggregator :
          intervalAwarePortalEventAggregators) {
        if (checkSupports(portalEventAggregator, item)) {
          final Class<? extends IPortalEventAggregator<?>> aggregatorType =
              PortalRawEventsAggregatorImpl.this.getClass(portalEventAggregator);

          // Get aggregator specific interval info map
          final Map<AggregationInterval, AggregationIntervalInfo> aggregatorIntervalInfo =
              this.getAggregatorIntervalInfo(aggregatorType);

          // If there is an event session get the aggregator specific version of it
          if (eventSession != null) {
            final AggregatedGroupConfig aggregatorGroupConfig =
                getAggregatorGroupConfig(aggregatorType);

            final CacheKey key =
                CacheKey.build(EVENT_SESSION_CACHE_KEY_SOURCE, eventSession, aggregatorGroupConfig);
            EventSession filteredEventSession = this.eventAggregationContext.getAttribute(key);
            if (filteredEventSession == null) {
              filteredEventSession = new FilteredEventSession(eventSession, aggregatorGroupConfig);
              this.eventAggregationContext.setAttribute(key, filteredEventSession);
            }
            eventSession = filteredEventSession;
          }

          // Aggregation magic happens here!
          portalEventAggregator.aggregateEvent(
              item, eventSession, eventAggregationContext, aggregatorIntervalInfo);
        }
      }

      // Give each simple aggregator a chance at the event
      for (final SimplePortalEventAggregator<PortalEvent> portalEventAggregator :
          simplePortalEventAggregators) {
        if (checkSupports(portalEventAggregator, item)) {
          portalEventAggregator.aggregateEvent(item, eventSession);
        }
      }
    }
コード例 #2
0
    protected EventSession getEventSession(PortalEvent item) {
      final String eventSessionId = item.getEventSessionId();

      // First check the aggregation context for a cached session event, fall back
      // to asking the DAO if nothing in the context, cache the result
      final CacheKey key = CacheKey.build(EVENT_SESSION_CACHE_KEY_SOURCE, eventSessionId);
      EventSession eventSession = this.eventAggregationContext.getAttribute(key);
      if (eventSession == null) {
        eventSession = eventSessionDao.getEventSession(item);
        this.eventAggregationContext.setAttribute(key, eventSession);
      }

      // Record the session access
      eventSession.recordAccess(item.getTimestampAsDate());
      eventSessionDao.storeEventSession(eventSession);

      return eventSession;
    }