OpenNMS API 1.2.3

org.opennms.netmgt.eventd.adaptors.tcp
Class TcpServer

java.lang.Object
  extended byorg.opennms.netmgt.eventd.adaptors.tcp.TcpServer
All Implemented Interfaces:
java.lang.Runnable

final class TcpServer
extends java.lang.Object
implements java.lang.Runnable

This class implement the server features necessary to receive events from incomming connections.

Author:
Brian Weaver , OpenNMS

Field Summary
private  java.lang.Thread m_context
          The thread which is executing the server context
private  java.util.List m_handlers
          The list of event handlers
private  java.lang.String m_logPrefix
          The logging context
private  Fiber m_parent
          The parent fiber.
private  java.util.LinkedList m_receivers
           The list of receivers that are currently being processed.
private  int m_recsPerConn
          the events per connection
private  boolean m_stop
          When set true the server thread will exit.
private  int m_tcpPort
          The TCP/IP Port for the server socket's binding.
private  java.net.ServerSocket m_tcpSock
          The TCP/IP Port for the server socket's binding.
(package private) static int TCP_PORT
          The default TCP/IP port where the server listens for connections.
 
Constructor Summary
(package private) TcpServer(Fiber parent, java.util.List handlers)
          Constructs a new instance of an server to handle incomming tcp connections.
(package private) TcpServer(Fiber parent, java.util.List handlers, int port)
          Constructs a new instance of an server to handle incomming tcp connections.
 
Method Summary
(package private)  boolean isAlive()
          Returns true if this runnable is executing.
 void run()
          The logic execution context to accept and process incomming connection requests.
 void setEventsPerConnection(int number)
           
 void setLogPrefix(java.lang.String prefix)
           
(package private)  void stop()
          This is called inform the current execution of this object is stopped.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TCP_PORT

static final int TCP_PORT
The default TCP/IP port where the server listens for connections. Each connection to the server will be processed by its own thread.

See Also:
Constant Field Values

m_tcpPort

private int m_tcpPort
The TCP/IP Port for the server socket's binding. By default this should be equal to TCP_PORTbut it can be overridden in the constructor.


m_tcpSock

private java.net.ServerSocket m_tcpSock
The TCP/IP Port for the server socket's binding. By default this should be equal to TCP_PORTbut it can be overridden in the constructor.


m_stop

private volatile boolean m_stop
When set true the server thread will exit.


m_receivers

private java.util.LinkedList m_receivers

The list of receivers that are currently being processed. Each instance in this list is of type Threadand will remain in the list so long as it's alive.

This list is periodically cleaned by the main server thread.


m_context

private java.lang.Thread m_context
The thread which is executing the server context


m_parent

private Fiber m_parent
The parent fiber.


m_handlers

private java.util.List m_handlers
The list of event handlers


m_logPrefix

private java.lang.String m_logPrefix
The logging context


m_recsPerConn

private int m_recsPerConn
the events per connection

Constructor Detail

TcpServer

TcpServer(Fiber parent,
          java.util.List handlers)
    throws java.io.IOException
Constructs a new instance of an server to handle incomming tcp connections.

Parameters:
parent - The parent fiber

TcpServer

TcpServer(Fiber parent,
          java.util.List handlers,
          int port)
    throws java.io.IOException
Constructs a new instance of an server to handle incomming tcp connections.

Parameters:
parent - The parent fiber
port - The port to listen on.
Method Detail

stop

void stop()
    throws java.lang.InterruptedException
This is called inform the current execution of this object is stopped. Once called the object cannot be reused in another thread.

Throws:
java.lang.InterruptedException

isAlive

boolean isAlive()
Returns true if this runnable is executing.


run

public void run()
The logic execution context to accept and process incomming connection requests. When a new connection is received a new thread of control is crated to process the connection. This method encapsulates that control logic so that it can be executed in it's own java thread.

Specified by:
run in interface java.lang.Runnable

setLogPrefix

public void setLogPrefix(java.lang.String prefix)

setEventsPerConnection

public void setEventsPerConnection(int number)

OpenNMS API 1.2.3

Generated by eevans on May 29 2005 2015.