You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by cz...@apache.org on 2015/04/22 11:58:40 UTC
svn commit: r1675308 - in
/sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs:
queues/JobQueueImpl.java stats/StatisticsManager.java
Author: cziegeler
Date: Wed Apr 22 09:58:39 2015
New Revision: 1675308
URL: http://svn.apache.org/r1675308
Log:
SLING-4642 : Revisit statistics implementation
Modified:
sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/queues/JobQueueImpl.java
sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/stats/StatisticsManager.java
Modified: sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/queues/JobQueueImpl.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/queues/JobQueueImpl.java?rev=1675308&r1=1675307&r2=1675308&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/queues/JobQueueImpl.java (original)
+++ sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/queues/JobQueueImpl.java Wed Apr 22 09:58:39 2015
@@ -276,7 +276,11 @@ public class JobQueueImpl
if ( handler.getConsumer() != null ) {
this.services.configuration.getAuditLogger().debug("START OK : {}", job.getId());
final long queueTime = handler.started - job.getProperty(JobImpl.PROPERTY_JOB_QUEUED, Calendar.class).getTime().getTime();
+ // update statistics
+ this.services.statisticsManager.jobStarted(this.queueName, job.getTopic(), queueTime);
+ // send notification
NotificationUtility.sendNotification(this.services.eventAdmin, NotificationConstants.TOPIC_JOB_STARTED, job, queueTime);
+
synchronized ( this.processingJobsLists ) {
this.processingJobsLists.put(job.getId(), handler);
}
Modified: sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/stats/StatisticsManager.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/stats/StatisticsManager.java?rev=1675308&r1=1675307&r2=1675308&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/stats/StatisticsManager.java (original)
+++ sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/stats/StatisticsManager.java Wed Apr 22 09:58:39 2015
@@ -29,7 +29,6 @@ import org.apache.felix.scr.annotations.
import org.apache.felix.scr.annotations.Service;
import org.apache.sling.event.impl.jobs.InternalJobState;
import org.apache.sling.event.impl.jobs.config.JobManagerConfiguration;
-import org.apache.sling.event.impl.jobs.notifications.NotificationUtility;
import org.apache.sling.event.jobs.Job;
import org.apache.sling.event.jobs.NotificationConstants;
import org.apache.sling.event.jobs.Statistics;
@@ -48,7 +47,6 @@ import org.osgi.service.event.EventHandl
@Properties({
@Property(name=EventConstants.EVENT_TOPIC,
value={NotificationConstants.TOPIC_JOB_ADDED,
- NotificationConstants.TOPIC_JOB_STARTED,
NotificationConstants.TOPIC_JOB_REMOVED})
})
public class StatisticsManager implements EventHandler {
@@ -145,14 +143,6 @@ public class StatisticsManager implement
queueStats.incQueued();
}
- } else if ( event.getTopic().equals(NotificationConstants.TOPIC_JOB_STARTED) ) {
- final Long time = (Long)event.getProperty(NotificationUtility.PROPERTY_TIME);
- ts.addActivated(time == null ? -1 : time);
- this.globalStatistics.addActive(time == null ? -1 : time);
- if ( queueStats != null ) {
- queueStats.addActive(time == null ? -1 : time);
- }
-
} else if ( event.getTopic().equals(NotificationConstants.TOPIC_JOB_REMOVED) ) {
this.globalStatistics.decQueued();
this.globalStatistics.cancelledJob();
@@ -198,6 +188,23 @@ public class StatisticsManager implement
}
}
+ }
+
+ public void jobStarted(final String queueName,
+ final String topic,
+ final long queueTime) {
+ final StatisticsImpl queueStats = getStatisticsForQueue(queueName);
+
+ TopicStatisticsImpl ts = (TopicStatisticsImpl)this.topicStatistics.get(topic);
+ if ( ts == null ) {
+ this.topicStatistics.putIfAbsent(topic, new TopicStatisticsImpl(topic));
+ ts = (TopicStatisticsImpl)this.topicStatistics.get(topic);
+ }
+ ts.addActivated(queueTime);
+ this.globalStatistics.addActive(queueTime);
+ if ( queueStats != null ) {
+ queueStats.addActive(queueTime);
+ }
}
}