|
OpenNMS API 1.2.3 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.opennms.netmgt.eventd.adaptors.tcp.TcpEventReceiver
This class is the access point for the agents to hook into the event queue. This fiber sets up an server socket that accepts incomming connections on the configured port (port 5814 by default). When a connection is established a new thread is started to process the socket connection. The event document is decoded and each of the events are passed to the handlers. Based upon the action of the handlers an event recipt is generated and sent to the remote client.
Field Summary | |
private java.util.List |
m_handlers
The registered list of event handlers. |
private java.lang.String |
m_logPrefix
The logging prefix |
private int |
m_recsPerConn
The number of event records per connection. |
private TcpServer |
m_server
The server socket |
private int |
m_status
The fiber's status. |
private int |
m_tcpPort
The TCP server to listen on |
private java.lang.Thread |
m_worker
The main server thread. |
(package private) static int |
UNLIMITED_EVENTS
The value that defines unlimited events per connection. |
Fields inherited from interface org.opennms.core.fiber.Fiber |
RUNNING, START_PENDING, STARTING, STATUS_NAMES, STOP_PENDING, STOPPED |
Constructor Summary | |
TcpEventReceiver()
Constructs a new TCP/IP event receiver on the default TCP/IP port. |
|
TcpEventReceiver(int port)
Constructs a new TCP/IP event receiver on the passed port. |
Method Summary | |
void |
addEventHandler(EventHandler handler)
Adds a new event handler to receiver. |
void |
addEventHandler(java.lang.String name)
Adds a new event handler by its managed name. |
void |
destroy()
Called when the fiber is destroyed |
java.lang.String |
getName()
Returns the name of this Fiber. |
java.lang.Integer |
getPort()
Returns the where a listener is waiting to process new request. |
int |
getStatus()
Returns the status of this Fiber. |
void |
init()
Called when the fiber is initialized |
void |
removeEventHandler(EventHandler handler)
Removes an event handler from the list of handler called when an event is received. |
void |
removeEventHandler(java.lang.String name)
Removes an event handler. |
void |
setEventsPerConnection(java.lang.Integer number)
The number of event records a new connection is allowed to send before the connection is terminated by the server. |
void |
setLogPrefix(java.lang.String prefix)
The logging prefix to use |
void |
setPort(java.lang.Integer port)
Sets the port where new requests will be handled. |
void |
start()
Allocates the server socket and starts up the server socket processor thread. |
void |
stop()
Stops the TCP/IP event receiver. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
static final int UNLIMITED_EVENTS
private java.lang.Thread m_worker
private TcpServer m_server
private java.util.List m_handlers
private volatile int m_status
private int m_tcpPort
private java.lang.String m_logPrefix
private int m_recsPerConn
Constructor Detail |
public TcpEventReceiver() throws java.io.IOException
public TcpEventReceiver(int port) throws java.io.IOException
port
- The binding port for the TCP/IP server socket.Method Detail |
public void start()
runtime exception
is thrown.
start
in interface Fiber
java.lang.reflect.UndeclaredThrowableException
- Thrown if an error occurs allocating the server socket.
java.lang.RuntimeException
- Thrown if the fiber is in an erronous state or the underlying
thread cannot be started.public void stop()
joined
.
stop
in interface Fiber
public java.lang.String getName()
getName
in interface Fiber
Fiber
.public int getStatus()
getStatus
in interface Fiber
Fiber
.public void init()
init
in interface InitializableFiber
public void destroy()
destroy
in interface InitializableFiber
public void addEventHandler(EventHandler handler)
addEventHandler
in interface EventReceiver
handler
- A reference to an event handlerpublic void removeEventHandler(EventHandler handler)
equals()
inherieted from the Object
class.
removeEventHandler
in interface EventReceiver
handler
- A reference to the event handler.public java.lang.Integer getPort()
TcpEventReceiverMBean
getPort
in interface TcpEventReceiverMBean
public void setPort(java.lang.Integer port)
TcpEventReceiverMBean
setPort
in interface TcpEventReceiverMBean
port
- The port to listen on.public void addEventHandler(java.lang.String name) throws javax.management.MalformedObjectNameException, javax.management.InstanceNotFoundException
TcpEventReceiverMBean
addEventHandler
in interface TcpEventReceiverMBean
name
- The name of the handler to add.
javax.management.MalformedObjectNameException
- Thrown if the passed name is not a valid ObjectName.
javax.management.InstanceNotFoundException
- Thrown if no managed bean can be found that matches the name.public void removeEventHandler(java.lang.String name) throws javax.management.MalformedObjectNameException, javax.management.InstanceNotFoundException
TcpEventReceiverMBean
removeEventHandler
in interface TcpEventReceiverMBean
name
- The name of the handler to remove.
javax.management.InstanceNotFoundException
- Thrown if no managed bean can be found that matches the name.
javax.management.MalformedObjectNameException
- Thrown if the passed name is not a valid ObjectName.public void setLogPrefix(java.lang.String prefix)
TcpEventReceiverMBean
setLogPrefix
in interface TcpEventReceiverMBean
public void setEventsPerConnection(java.lang.Integer number)
setEventsPerConnection
in interface TcpEventReceiverMBean
number
- The number of event records.
|
OpenNMS API 1.2.3 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |