Author: ieb
Date: Wed Feb 20 05:12:24 2013
New Revision: 1448005
URL: http://svn.apache.org/r1448005
Log:
SLING-2597 Added some beans for general monitoring of event queues. Work In
Progress. The bundle builds and passes all tests, but does nothing at present.
Added:
sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/QueueStatusEvent.java
(with props)
sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/jobs/jmx/
sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/jobs/jmx/AbstractJobStatistics.java
(with props)
sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/jobs/jmx/AllJobStatisticsMBean.java
(with props)
sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/jobs/jmx/EmptyStatistics.java
(with props)
sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/jobs/jmx/QueueMBeanImpl.java
(with props)
sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/jobs/jmx/QueuesMBean.java
(with props)
sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/jobs/jmx/QueuesMBeanImpl.java
(with props)
sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/jobs/jmx/StatisticsMBean.java
(with props)
Modified:
sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/DefaultJobManager.java
sling/trunk/bundles/extensions/event/src/test/java/org/apache/sling/event/impl/AbstractTest.java
sling/trunk/bundles/extensions/event/src/test/java/org/apache/sling/event/impl/SimpleEventAdmin.java
sling/trunk/bundles/extensions/event/src/test/java/org/apache/sling/event/impl/jobs/AbstractJobEventHandlerTest.java
Modified:
sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/DefaultJobManager.java
URL:
http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/DefaultJobManager.java?rev=1448005&r1=1448004&r2=1448005&view=diff
==============================================================================
---
sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/DefaultJobManager.java
(original)
+++
sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/DefaultJobManager.java
Wed Feb 20 05:12:24 2013
@@ -59,6 +59,7 @@ import org.apache.sling.event.jobs.Queue
import org.apache.sling.event.jobs.Statistics;
import org.apache.sling.event.jobs.TopicStatistics;
import org.osgi.service.event.Event;
+import org.osgi.service.event.EventAdmin;
import org.osgi.service.event.EventHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -110,6 +111,10 @@ public class DefaultJobManager
/** The scheduler service. */
@Reference
private Scheduler scheduler;
+
+ /** The job manager emits events when queues are added and removed */
+ @Reference
+ private EventAdmin eventAdmin;
/** Lock object for the queues map - we don't want to sync directly on the
concurrent map. */
private final Object queuesLock = new Object();
@@ -228,6 +233,7 @@ public class DefaultJobManager
while ( i.hasNext() ) {
final AbstractJobQueue jbq = i.next();
jbq.close();
+ eventAdmin.sendEvent(new QueueStatusEvent(null, jbq));
}
this.queues.clear();
logger.info("Apache Sling Job Event Handler stopped on instance {}",
Environment.APPLICATION_ID);
@@ -269,6 +275,7 @@ public class DefaultJobManager
this.baseStatistics.add(jbq);
// remove
i.remove();
+ eventAdmin.sendEvent(new QueueStatusEvent(null, jbq));
} else {
// mark to be removed during next cycle
jbq.markForRemoval();
@@ -389,6 +396,7 @@ public class DefaultJobManager
return;
}
queues.put(queueName, queue);
+ eventAdmin.sendEvent(new QueueStatusEvent(queue, null));
queue.start();
}
}
@@ -817,11 +825,13 @@ public class DefaultJobManager
queue.close();
// copy statistics
this.baseStatistics.add(queue);
+ eventAdmin.sendEvent(new QueueStatusEvent(null, queue));
} else {
// notify queue
queue.rename(queue.getName() + "<outdated>(" + queue.hashCode() +
")");
// readd with new name
this.queues.put(queue.getName(), queue);
+ eventAdmin.sendEvent(new QueueStatusEvent(queue, queue));
}
}
Added:
sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/QueueStatusEvent.java
URL:
http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/QueueStatusEvent.java?rev=1448005&view=auto
==============================================================================
---
sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/QueueStatusEvent.java
(added)
+++
sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/QueueStatusEvent.java
Wed Feb 20 05:12:24 2013
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The SF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ */
+package org.apache.sling.event.impl.jobs;
+
+import java.util.Hashtable;
+
+import org.apache.sling.event.jobs.Queue;
+import org.osgi.service.event.Event;
+
+public class QueueStatusEvent extends Event {
+
+ public static final String TOPIC = "org/apache/sling/event/Queue";
+ private Queue queue;
+ private Queue oldqueue;
+
+
+ @SuppressWarnings({ "rawtypes" })
+ public QueueStatusEvent(Queue queue, Queue oldqueue) {
+ super(TOPIC, new Hashtable());
+ this.queue = queue;
+ this.oldqueue = oldqueue;
+ }
+ public boolean isNew() {
+ return this.oldqueue == null;
+ }
+ public boolean isUpdate() {
+ return this.queue == this.oldqueue;
+ }
+ public boolean isRemoved() {
+ return this.queue == null;
+ }
+ public Queue getQueue() {
+ return queue;
+ }
+ public Queue getOldQueue() {
+ return oldqueue;
+ }
+
+
+}
Propchange:
sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/jobs/QueueStatusEvent.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/jobs/jmx/AbstractJobStatistics.java
URL:
http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/jobs/jmx/AbstractJobStatistics.java?rev=1448005&view=auto
==============================================================================
---
sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/jobs/jmx/AbstractJobStatistics.java
(added)
+++
sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/jobs/jmx/AbstractJobStatistics.java
Wed Feb 20 05:12:24 2013
@@ -0,0 +1,95 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The SF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ */
+package org.apache.sling.event.jobs.jmx;
+
+import java.util.Date;
+
+import javax.management.StandardMBean;
+
+import org.apache.sling.event.jobs.Statistics;
+
+public abstract class AbstractJobStatistics extends StandardMBean implements
+ StatisticsMBean {
+
+ public AbstractJobStatistics() {
+ super(StatisticsMBean.class, false);
+ }
+
+ protected abstract Statistics getAggregateStatistics();
+
+ public long getAverageProcessingTime() {
+ return getAggregateStatistics().getAverageProcessingTime();
+ }
+
+ public long getAverageWaitingTime() {
+ return getAggregateStatistics().getAverageWaitingTime();
+ }
+
+ public long getLastActivatedJobTime() {
+ return getAggregateStatistics().getLastActivatedJobTime();
+ }
+
+ public long getLastFinishedJobTime() {
+ return getAggregateStatistics().getLastFinishedJobTime();
+ }
+
+ public long getNumberOfActiveJobs() {
+ return getAggregateStatistics().getNumberOfActiveJobs();
+ }
+
+ public long getNumberOfCancelledJobs() {
+ return getAggregateStatistics().getNumberOfCancelledJobs();
+ }
+
+ public long getStartTime() {
+ return getAggregateStatistics().getStartTime();
+ }
+
+ public long getNumberOfFinishedJobs() {
+ return getAggregateStatistics().getNumberOfFinishedJobs();
+ }
+
+ public long getNumberOfFailedJobs() {
+ return getAggregateStatistics().getNumberOfFailedJobs();
+ }
+
+ public long getNumberOfProcessedJobs() {
+ return getAggregateStatistics().getNumberOfProcessedJobs();
+ }
+
+ public long getNumberOfQueuedJobs() {
+ return getAggregateStatistics().getNumberOfQueuedJobs();
+ }
+
+ public long getNumberOfJobs() {
+ return getAggregateStatistics().getNumberOfJobs();
+ }
+
+ public void reset() {
+ getAggregateStatistics().reset();
+ }
+
+ public Date getLastActivatedJobDate() {
+ return new Date(getAggregateStatistics().getLastActivatedJobTime());
+ }
+
+ public Date getLastFinishedJobDate() {
+ return new Date(getAggregateStatistics().getLastFinishedJobTime());
+ }
+
+}
Propchange:
sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/jobs/jmx/AbstractJobStatistics.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/jobs/jmx/AllJobStatisticsMBean.java
URL:
http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/jobs/jmx/AllJobStatisticsMBean.java?rev=1448005&view=auto
==============================================================================
---
sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/jobs/jmx/AllJobStatisticsMBean.java
(added)
+++
sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/jobs/jmx/AllJobStatisticsMBean.java
Wed Feb 20 05:12:24 2013
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The SF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ */
+package org.apache.sling.event.jobs.jmx;
+
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Properties;
+import org.apache.felix.scr.annotations.Property;
+import org.apache.felix.scr.annotations.Reference;
+import org.apache.felix.scr.annotations.Service;
+import org.apache.sling.event.jobs.JobManager;
+import org.apache.sling.event.jobs.Statistics;
+
+@Component(immediate = true, enabled = false)
+// disabled while dev in progress.
+@Service(value = StatisticsMBean.class)
+@Properties(@Property(name = "jmx.objectname", value =
"org.apache.sling.event.AllJobs;type=Statistics"))
+public class AllJobStatisticsMBean extends AbstractJobStatistics {
+ private static final long TTL = 1000L;
+ private long agregateStatisticsTTL = 0L;
+ private Statistics aggregateStatistics;
+ @Reference
+ private JobManager jobManager;
+
+ /**
+ * @return the aggregate stats from the job manager.
+ */
+ protected Statistics getAggregateStatistics() {
+ if (System.currentTimeMillis() > agregateStatisticsTTL) {
+ aggregateStatistics = jobManager.getStatistics();
+ agregateStatisticsTTL = System.currentTimeMillis() + TTL;
+ }
+ return aggregateStatistics;
+ }
+
+}
Propchange:
sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/jobs/jmx/AllJobStatisticsMBean.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/jobs/jmx/EmptyStatistics.java
URL:
http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/jobs/jmx/EmptyStatistics.java?rev=1448005&view=auto
==============================================================================
---
sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/jobs/jmx/EmptyStatistics.java
(added)
+++
sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/jobs/jmx/EmptyStatistics.java
Wed Feb 20 05:12:24 2013
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The SF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ */
+package org.apache.sling.event.jobs.jmx;
+
+import org.apache.sling.event.jobs.Statistics;
+
+public class EmptyStatistics implements Statistics {
+
+ public long getStartTime() {
+ return 0;
+ }
+
+ public long getNumberOfFinishedJobs() {
+ return 0;
+ }
+
+ public long getNumberOfCancelledJobs() {
+ return 0;
+ }
+
+ public long getNumberOfFailedJobs() {
+ return 0;
+ }
+
+ public long getNumberOfProcessedJobs() {
+ return 0;
+ }
+
+ public long getNumberOfActiveJobs() {
+ return 0;
+ }
+
+ public long getNumberOfQueuedJobs() {
+ return 0;
+ }
+
+ public long getNumberOfJobs() {
+ return 0;
+ }
+
+ public long getLastActivatedJobTime() {
+ return 0;
+ }
+
+ public long getLastFinishedJobTime() {
+ return 0;
+ }
+
+ public long getAverageWaitingTime() {
+ return 0;
+ }
+
+ public long getAverageProcessingTime() {
+ return 0;
+ }
+
+ public void reset() {
+ }
+
+}
Propchange:
sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/jobs/jmx/EmptyStatistics.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/jobs/jmx/QueueMBeanImpl.java
URL:
http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/jobs/jmx/QueueMBeanImpl.java?rev=1448005&view=auto
==============================================================================
---
sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/jobs/jmx/QueueMBeanImpl.java
(added)
+++
sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/jobs/jmx/QueueMBeanImpl.java
Wed Feb 20 05:12:24 2013
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The SF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ */
+package org.apache.sling.event.jobs.jmx;
+
+import org.apache.sling.event.jobs.Queue;
+import org.apache.sling.event.jobs.Statistics;
+
+public class QueueMBeanImpl extends AbstractJobStatistics {
+
+ private Queue queue;
+ private Statistics emptyStatistics = new EmptyStatistics();
+
+ public QueueMBeanImpl(Queue queue) {
+ this.queue = queue;
+ }
+
+ public void notifyUpdate(Queue queue) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void notifyRemove() {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ protected Statistics getAggregateStatistics() {
+ if (queue instanceof Statistics) {
+ return (Statistics) queue;
+ }
+ return emptyStatistics;
+ }
+
+}
Propchange:
sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/jobs/jmx/QueueMBeanImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/jobs/jmx/QueuesMBean.java
URL:
http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/jobs/jmx/QueuesMBean.java?rev=1448005&view=auto
==============================================================================
---
sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/jobs/jmx/QueuesMBean.java
(added)
+++
sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/jobs/jmx/QueuesMBean.java
Wed Feb 20 05:12:24 2013
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The SF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ */
+package org.apache.sling.event.jobs.jmx;
+
+/**
+ * A Marker interface to allow the implementation to register as a service with
+ * the JMX whiteboard.
+ */
+public interface QueuesMBean {
+
+}
Propchange:
sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/jobs/jmx/QueuesMBean.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/jobs/jmx/QueuesMBeanImpl.java
URL:
http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/jobs/jmx/QueuesMBeanImpl.java?rev=1448005&view=auto
==============================================================================
---
sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/jobs/jmx/QueuesMBeanImpl.java
(added)
+++
sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/jobs/jmx/QueuesMBeanImpl.java
Wed Feb 20 05:12:24 2013
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The SF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ */
+package org.apache.sling.event.jobs.jmx;
+
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import javax.management.StandardMBean;
+
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Properties;
+import org.apache.felix.scr.annotations.Property;
+import org.apache.felix.scr.annotations.Service;
+import org.apache.sling.event.impl.jobs.QueueStatusEvent;
+import org.osgi.service.event.Event;
+import org.osgi.service.event.EventHandler;
+
+@Component(immediate = true, enabled = false)
+// disabled while dev in progress
+@Service(value = { QueuesMBean.class, EventHandler.class })
+@Properties({
+ @Property(name = "jmx.objectname", propertyPrivate = true, value =
"org.apache.sling.event.Queues;type=Statistics"),
+ @Property(name = "event.topics", propertyPrivate = true, value = {
QueueStatusEvent.TOPIC }) })
+public class QueuesMBeanImpl extends StandardMBean implements QueuesMBean,
+ EventHandler {
+
+ private Map<String, QueueMBeanImpl> queues = new ConcurrentHashMap<String,
QueueMBeanImpl>();
+
+ public QueuesMBeanImpl() {
+ super(QueuesMBean.class, false);
+ }
+
+ public void handleEvent(Event event) {
+ if (event instanceof QueueStatusEvent) {
+ QueueStatusEvent e = (QueueStatusEvent) event;
+ if (e.isNew()) {
+ bindQueueMBean(e);
+ } else if (e.isRemoved()) {
+ unbindQueueMBean(e);
+ } else {
+ updateQueueMBean(e);
+ }
+ }
+ }
+
+ private void updateQueueMBean(QueueStatusEvent e) {
+ QueueMBeanImpl queueMBean = queues.get(e.getQueue().getName());
+ if (queueMBean != null) {
+ queueMBean.notifyUpdate(e.getQueue());
+ }
+ }
+
+ private void unbindQueueMBean(QueueStatusEvent e) {
+ QueueMBeanImpl queueMBean = queues.get(e.getQueue().getName());
+ if (queueMBean != null) {
+ queueMBean.notifyRemove();
+ }
+ }
+
+ private void bindQueueMBean(QueueStatusEvent e) {
+ QueueMBeanImpl queueMBean = queues.get(e.getQueue().getName());
+ if (queueMBean != null) {
+ queueMBean.notifyRemove();
+ }
+ queueMBean = new QueueMBeanImpl(e.getQueue());
+
+ }
+
+}
Propchange:
sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/jobs/jmx/QueuesMBeanImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/jobs/jmx/StatisticsMBean.java
URL:
http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/jobs/jmx/StatisticsMBean.java?rev=1448005&view=auto
==============================================================================
---
sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/jobs/jmx/StatisticsMBean.java
(added)
+++
sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/jobs/jmx/StatisticsMBean.java
Wed Feb 20 05:12:24 2013
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The SF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ */
+package org.apache.sling.event.jobs.jmx;
+
+import java.util.Date;
+
+import org.apache.sling.event.jobs.Statistics;
+
+public interface StatisticsMBean extends Statistics {
+
+ Date getLastActivatedJobDate();
+
+ Date getLastFinishedJobDate();
+
+}
Propchange:
sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/jobs/jmx/StatisticsMBean.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified:
sling/trunk/bundles/extensions/event/src/test/java/org/apache/sling/event/impl/AbstractTest.java
URL:
http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/event/src/test/java/org/apache/sling/event/impl/AbstractTest.java?rev=1448005&r1=1448004&r2=1448005&view=diff
==============================================================================
---
sling/trunk/bundles/extensions/event/src/test/java/org/apache/sling/event/impl/AbstractTest.java
(original)
+++
sling/trunk/bundles/extensions/event/src/test/java/org/apache/sling/event/impl/AbstractTest.java
Wed Feb 20 05:12:24 2013
@@ -87,7 +87,7 @@ public abstract class AbstractTest {
session.save();
}
// activate
- this.activate(null);
+ this.activate(new SimpleEventAdmin(null, null));
}
protected int activateCount = 1;
Modified:
sling/trunk/bundles/extensions/event/src/test/java/org/apache/sling/event/impl/SimpleEventAdmin.java
URL:
http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/event/src/test/java/org/apache/sling/event/impl/SimpleEventAdmin.java?rev=1448005&r1=1448004&r2=1448005&view=diff
==============================================================================
---
sling/trunk/bundles/extensions/event/src/test/java/org/apache/sling/event/impl/SimpleEventAdmin.java
(original)
+++
sling/trunk/bundles/extensions/event/src/test/java/org/apache/sling/event/impl/SimpleEventAdmin.java
Wed Feb 20 05:12:24 2013
@@ -36,7 +36,7 @@ public class SimpleEventAdmin implements
if ( topics == null && handler != null ) {
throw new IllegalArgumentException("If topics is null, handler
must be null as well");
}
- if ( topics.length != handler.length ) {
+ if ( topics != null && topics.length != handler.length ) {
throw new IllegalArgumentException("Topics and handler must have
the same size.");
}
}
Modified:
sling/trunk/bundles/extensions/event/src/test/java/org/apache/sling/event/impl/jobs/AbstractJobEventHandlerTest.java
URL:
http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/event/src/test/java/org/apache/sling/event/impl/jobs/AbstractJobEventHandlerTest.java?rev=1448005&r1=1448004&r2=1448005&view=diff
==============================================================================
---
sling/trunk/bundles/extensions/event/src/test/java/org/apache/sling/event/impl/jobs/AbstractJobEventHandlerTest.java
(original)
+++
sling/trunk/bundles/extensions/event/src/test/java/org/apache/sling/event/impl/jobs/AbstractJobEventHandlerTest.java
Wed Feb 20 05:12:24 2013
@@ -55,10 +55,12 @@ public abstract class AbstractJobEventHa
PrivateAccessor.setField(this.jobManager, "configManager",
this.configManager);
PrivateAccessor.setField(this.jobManager, "environment",
this.environment);
PrivateAccessor.setField(this.jobManager, "scheduler", new
SimpleScheduler());
+ PrivateAccessor.setField(this.jobManager, "eventAdmin", ea);
this.handler = new PersistenceHandler();
PrivateAccessor.setField(this.handler, "environment",
this.environment);
PrivateAccessor.setField(this.handler, "jobManager", this.jobManager);
PrivateAccessor.setField(this.handler, "lockManager", new
LockManager());
+
// lets set up the bundle context
final BundleContext bundleContext =
this.getMockery().mock(BundleContext.class, "beforeBundleContext" +
activateCount);