Jetspeed-2 provides components for collecting portal data for various application events.
PortalStatistics
provides APIs for collecting portal application events. The following event types
are supported out of the box:
PortalStatistics
implementation logs usage data based on the
Apache Common Log Format (CLF)
where each log entry is formatted in the form:
%h %l %u %t \"%r\" %>s %b
Statistics data is stored in 3 relational tables as illustrated below:
Each event type is mapped to a data holder that gets persisted in the statistics tables illustrated above.
Jetspeed-2 persists the collected data in batches through the BatchedStatistics
component.
The PortalStatistics
component is configured in WEB-INF/assembly/statistics.xml
and
requires the following configuration parameters:
The FIFO parameters may be adjusted depending on site specific needs. For example, tuning the events and times down makes the system less likely to loose events in the case of a failure, and also makes the user experience viewing the statistics more responsive to recent events. On the other hand, tuning them higher will reduce the overhead to the database. Generally newer sites with fewer users should use smaller tuning parameters and larger more mature sites should use larger ones.
A sample configuration is provided below:
<bean id="PortalStatistics" class="org.apache.jetspeed.statistics.impl.PortalStatisticsImpl" init-method="springInit" destroy-method="springDestroy"> <!-- logToCLF --> <constructor-arg index='0' type="boolean"><value>false</value></constructor-arg> <!-- logToDatabase --> <constructor-arg index='1' type="boolean"><value>true</value></constructor-arg> <!-- maxRecordToFlush_Portal --> <constructor-arg index='2'><value>300</value></constructor-arg> <!-- maxRecordToFlush_User --> <constructor-arg index='3'><value>50</value></constructor-arg> <!-- maxRecordToFlush_Page --> <constructor-arg index='4'><value>100</value></constructor-arg> <!-- maxTimeMsToFlush_Portal --> <constructor-arg index='5'><value>300000</value></constructor-arg> <!-- maxTimeMsToFlush_User --> <constructor-arg index='6'><value>5000</value></constructor-arg> <!-- maxTimeMsToFlush_Page --> <constructor-arg index='7><value>60000</value></constructor-arg> <!-- jetspeedDSEntry --> <constructor-arg index='8'><ref bean="JetspeedDS"/></constructor-arg> </bean>
Portal statistics events collection is injected at multiple points in the portal engine. Some examples are provided below.
For user events, the SecurityValveImpl
logs a user login event in getSubject(RequestContext request)
.
statistics.logUserLogin(request, 0);
For portlet events, the RenderingJobImpl
invoked in RenderingJob
buildRenderingJob
logs
a portlet access event.
statistics.logPortletAccess(requestContext, fragment.getName(), PortalStatistics.HTTP_OK, end - start);
Jetspeed-2 provides a mechanism for aggregating portal statistics for reporting purpose.
The PortalStatistics
component exposes a queryStatistics
method that given
a StatisticsQueryCriteria
will return AggregateStatistics
.
AggregateStatistics queryStatistics(StatisticsQueryCriteria criteria)
AggregateStatistics
can then be used for reporting purpose.
As illustrated in viewing statistics, Jetspeed-2 provides a default reporting portlet
for view statistics. To query statistics, a StatisticsQueryCriteria
must be set. According to this
criteria the PortalStatistics
queryStatistics()
method will return an AggregateStatistics
.
StatisticsQueryCriteria criteria = statistics.createStatisticsQueryCriteria(); ... criteria.setUser(user); criteria.setListsize("5"); criteria.setSorttype("count"); criteria.setSortorder("desc"); criteria.setTimePeriod(timeperiod); criteria.setQueryType(queryType); AggregateStatistics stats = statistics.getDefaultEmptyAggregateStatistics(); ... statistics.forceFlush(); stats = statistics.queryStatistics(criteria);