org.opennms.bb.dp.events
Class EventImport

java.lang.Object
  |
  +--org.opennms.bb.dp.events.EventImport
All Implemented Interfaces:
Serializable

public class EventImport
extends Object
implements Serializable

EventImport sends events in the XML format to the specified remote host via either TCP or UDP

Version:
$Revision: 1.9 $
Author:
Sowmya Kumaraswamy, OpenNMS.org
See Also:
Serialized Form

Field Summary
private  int EVENTD_TCP_PORT
          the port at which 'eventd' listens for events coming in thru' TCP
private  int EVENTD_UDP_PORT
          the port at which 'eventd' listens for events coming in thru' UDP
private  String m_fileName
          filename which contains the event xml to be sent
private  String m_host
          the remote host to which the events are to be sent
private  boolean m_tcp
          indicates if user has specified TCP
private  boolean m_udp
          indicates if user has specified UDP
private  int READ_LEN
          the length to be read each time while reading the file
 
Constructor Summary
EventImport(String[] args)
          Constructs the EventImport class - process the arguments, reads from the file and sends it to the remote host using the mode specified
 
Method Summary
private  byte[] getMessageToSend()
          Read the data to be sent from the filename specified
static void main(String[] args)
          Start up EventImport
static void printUsage()
          print the usage instructions
private  boolean processArgs(String[] args)
          Process and extract the arguments to get the filename and the mode to be used to send the data
private  void tcpSend(byte[] xmlStr)
          Send to the TCP port of eventd
private  void udpSend(byte[] xmlStr)
          Send to udp port of eventd
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

m_tcp

private boolean m_tcp
indicates if user has specified TCP

m_udp

private boolean m_udp
indicates if user has specified UDP

m_fileName

private String m_fileName
filename which contains the event xml to be sent

m_host

private String m_host
the remote host to which the events are to be sent

READ_LEN

private final int READ_LEN
the length to be read each time while reading the file

EVENTD_TCP_PORT

private final int EVENTD_TCP_PORT
the port at which 'eventd' listens for events coming in thru' TCP

EVENTD_UDP_PORT

private final int EVENTD_UDP_PORT
the port at which 'eventd' listens for events coming in thru' UDP
Constructor Detail

EventImport

public EventImport(String[] args)
            throws IOException
Constructs the EventImport class - process the arguments, reads from the file and sends it to the remote host using the mode specified
Parameters:
args[] - the argument list sent to the class
Method Detail

processArgs

private boolean processArgs(String[] args)
Process and extract the arguments to get the filename and the mode to be used to send the data
Returns:
false if error in arguments, true otherwise

getMessageToSend

private byte[] getMessageToSend()
                         throws IOException
Read the data to be sent from the filename specified

tcpSend

private void tcpSend(byte[] xmlStr)
              throws IOException
Send to the TCP port of eventd

udpSend

private void udpSend(byte[] xmlStr)
              throws IOException
Send to udp port of eventd

printUsage

public static void printUsage()
print the usage instructions

main

public static void main(String[] args)
Start up EventImport