Index: opennms-daemon/src/main/filtered/etc/notifd-configuration.xml =================================================================== --- opennms-daemon/src/main/filtered/etc/notifd-configuration.xml (.../tags/opennms-1.5.93-1-import/source) (revision 32659) +++ opennms-daemon/src/main/filtered/etc/notifd-configuration.xml (.../branches/bdymek-notifyQbug/source) (revision 32659) @@ -49,7 +49,7 @@ default 20s - org.opennms.netmgt.notifd.DefaultQueueHandler + org.opennms.netmgt.notifd.NotificationQueueHandler Index: opennms-services/src/test/resources/org/opennms/netmgt/notifd/notifd-configuration.xml =================================================================== --- opennms-services/src/test/resources/org/opennms/netmgt/notifd/notifd-configuration.xml (.../tags/opennms-1.5.93-1-import/source) (revision 32659) +++ opennms-services/src/test/resources/org/opennms/netmgt/notifd/notifd-configuration.xml (.../branches/bdymek-notifyQbug/source) (revision 32659) @@ -41,7 +41,7 @@ default 100ms - org.opennms.netmgt.notifd.DefaultQueueHandler + org.opennms.netmgt.notifd.NotificationQueueHandler Index: opennms-services/src/test/resources/org/opennms/netmgt/config/notifd-configuration.xml =================================================================== --- opennms-services/src/test/resources/org/opennms/netmgt/config/notifd-configuration.xml (.../tags/opennms-1.5.93-1-import/source) (revision 32659) +++ opennms-services/src/test/resources/org/opennms/netmgt/config/notifd-configuration.xml (.../branches/bdymek-notifyQbug/source) (revision 32659) @@ -14,7 +14,7 @@ default 20s - org.opennms.netmgt.notifd.DefaultQueueHandler + org.opennms.netmgt.notifd.NotificationQueueHandler - \ No newline at end of file + Index: opennms-services/src/main/java/org/opennms/netmgt/notifd/NotificationTask.java =================================================================== --- opennms-services/src/main/java/org/opennms/netmgt/notifd/NotificationTask.java (.../tags/opennms-1.5.93-1-import/source) (revision 32659) +++ opennms-services/src/main/java/org/opennms/netmgt/notifd/NotificationTask.java (.../branches/bdymek-notifyQbug/source) (revision 32659) @@ -69,7 +69,7 @@ * notificationCommands.xml by: * @author David Hustace */ -public class NotificationTask extends Thread { +public class NotificationTask implements Runnable { /** * The User object the notification needs to go out to */ @@ -340,7 +340,6 @@ public synchronized void start() { m_started = true; - super.start(); } public boolean isStarted() { Index: opennms-services/src/main/java/org/opennms/netmgt/notifd/NotificationQueueHandler.java =================================================================== --- opennms-services/src/main/java/org/opennms/netmgt/notifd/NotificationQueueHandler.java (.../tags/opennms-1.5.93-1-import/source) (revision 0) +++ opennms-services/src/main/java/org/opennms/netmgt/notifd/NotificationQueueHandler.java (.../branches/bdymek-notifyQbug/source) (revision 32659) @@ -0,0 +1,307 @@ +// +// This file is part of the OpenNMS(R) Application. +// +// OpenNMS(R) is Copyright (C) 2002-2003 The OpenNMS Group, Inc. All rights reserved. +// OpenNMS(R) is a derivative work, containing both original code, included code and modified +// code that was published under the GNU General Public License. Copyrights for modified +// and included code are below. +// +// OpenNMS(R) is a registered trademark of The OpenNMS Group, Inc. +// +// Modifications: +// +// 2003 Jan 31: Cleaned up some unused imports. +// +// Original code base Copyright (C) 1999-2001 Oculan Corp. All rights reserved. +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// +// For more information contact: +// OpenNMS Licensing +// http://www.opennms.org/ +// http://www.opennms.com/ +// +// Tab Size = 8 +// + +package org.opennms.netmgt.notifd; + +import java.util.*; +import java.util.concurrent.*; + +import org.apache.log4j.Category; +import org.opennms.core.utils.ThreadCategory; +import org.opennms.core.utils.TimeConverter; + +/** + * This class is used as a thread for executing notices for events that are + * discovered by the notice daemon. The notices are read from an scheduler queue + * and the processes are created by the fiber. Each created process is added to + * garbage collection list that is periodically polled and culled based upon the + * status of the process or how long the process is run. If the process has run + * long than allocated it is terminated during collection. + * + * @author STARTING and will transisition to + * RUNNING + * when the fiber finishes initializing and begins processing the + * encapsulaed queue. + * + * @throws java.lang.IllegalStateException + * Thrown if the fiber is stopped or has never run. + * + */ + public synchronized void start() { + m_status = STARTING; + + m_threadPool = Executors.newFixedThreadPool(m_poolSize); + Thread thread = new Thread(this, m_queueID); + thread.start(); + } + + /** + * Stops a currently running fiber. If the fiber has already been stopped + * then the command is silently ignored. If the fiber was never started then + * an exception is generated. + * + * @throws java.lang.IllegalStateException + * Thrown if the fiber was never started. + * + */ + public synchronized void stop() { + if (m_status != STOPPED) + m_status = STOP_PENDING; + + notifyAll(); + + // Bug???, do not allow an endless supply of NotificationTasks to execute and + // run wild! Demote from Thread to just Runnable + m_threadPool.shutdownNow(); + m_threadPool = null; + } + + /** + * Pauses a currently running fiber. If the fiber was not in a running or + * resuming state then the command is silently discarded. If the fiber is + * not running or has terminated then an exception is generated. + * + * @throws java.lang.IllegalStateException + * Thrown if the fiber is stopped or has never run. + * + */ + public synchronized void pause() { + if (m_status == RUNNING || m_status == RESUME_PENDING) { + m_status = PAUSE_PENDING; + notifyAll(); + } + } + + /** + * Resumes the fiber if it is paused. If the fiber was not in a paused or + * pause pending state then the request is discarded. If the fiber has not + * been started or has already stopped then an exception is generated. + * + * @throws java.lang.IllegalStateException + * Thrown if the fiber is stopped or has never run. + * + */ + public synchronized void resume() { + if (m_status == PAUSED || m_status == PAUSE_PENDING) { + m_status = RESUME_PENDING; + notifyAll(); + } + } + + /** + * Returns the name of this fiber. + * + * @return The name of the fiber. + */ + public String getName() { + return m_queueID; + } + + /** + * Returns the current status of the pausable fiber. + * + * @return The current status of the fiber. + * + * @see org.opennms.core.fiber.PausableFiber + * @see org.opennms.core.fiber.Fiber + */ + public synchronized int getStatus() { + return m_status; + } +}