/** * Stops the currently running service. If the service is not running then the command is silently * discarded. */ public synchronized void onStop() { m_status = STOP_PENDING; // shutdown and wait on the background processing thread to exit. LogUtils.debugf(this, "stop: closing communication paths."); try { if (m_registeredForTraps) { LogUtils.debugf(this, "stop: Closing SNMP trap session."); SnmpUtils.unregisterForTraps(this, getInetAddress(), getSnmpTrapPort()); LogUtils.debugf(this, "stop: SNMP trap session closed."); } else { LogUtils.debugf( this, "stop: not attemping to closing SNMP trap session--it was never opened"); } } catch (final IOException e) { LogUtils.warnf(this, e, "stop: exception occurred closing session"); } catch (final IllegalStateException e) { LogUtils.debugf(this, e, "stop: The SNMP session was already closed"); } LogUtils.debugf(this, "stop: Stopping queue processor."); m_processor.stop(); m_eventReader.close(); m_status = STOPPED; LogUtils.debugf(this, "stop: Trapd stopped"); }
/** * Create the SNMP trap session and create the communication channel to communicate with eventd. * * @exception java.lang.reflect.UndeclaredThrowableException if an unexpected database, or IO * exception occurs. * @see org.opennms.protocols.snmp.SnmpTrapSession * @see org.opennms.protocols.snmp.SnmpTrapHandler */ public synchronized void onStart() { m_status = STARTING; LogUtils.debugf(this, "start: Initializing the trapd config factory"); m_processor.start(); m_status = RUNNING; LogUtils.debugf(this, "start: Trapd ready to receive traps"); }
/** Resumes Trapd */ public void onResume() { if (m_status != PAUSED) { return; } m_status = RESUME_PENDING; LogUtils.debugf(this, "resume: Calling resume on processor"); m_processor.resume(); m_status = RUNNING; LogUtils.debugf(this, "resume: Trapd resumed"); }
/** Pauses Trapd */ public void onPause() { if (m_status != RUNNING) { return; } m_status = PAUSE_PENDING; LogUtils.debugf(this, "pause: Calling pause on processor"); m_processor.pause(); m_status = PAUSED; LogUtils.debugf(this, "pause: Trapd paused"); }