Tivoli Confidential

com.tivoli.tec.event_delivery
Class TECAgent

java.lang.Object
  |
  +--com.tivoli.tec.event_delivery.TECAgent

public class TECAgent
extends Object

A TECAgent object is the top level object created by the Enhanced EIF user to enable sending events to a TEC event consumer - Sender delivery mode - or receiving events from a TEC event source - Receiver delivery mode.

Since:
TEC 3.8
Version:
1.41 12/10/04
Author:
Andrea Chiavegatto, Joe Kerr

Field Summary
static int COMM_CFG
          Specifies that configuration should be used.
static int COMM_LCF
          Specifies that TME Endpoint (LCF) communications should be used.
static int COMM_NONTME
          Specifies that non-TME communications should be used.
static int COMM_NONTME_SOCKET
          Specifies that non-TME communications should be used.
static int COMM_TME
          Specifies that TME Managed Node communications should be used.
static int RECEIVER_MODE
          Specifies that Receiver delivery mode should be used.
static int SEND_FAILURE
          Returned by sendEvent() when event wasn't successfully sent to the server or buffered on disk.
static int SEND_FILTERED
          Returned by sendEvent() when event successfully match the filter and is discarded.
static int SENDER_MODE
          Specifies that Sender delivery mode should be used.
 
Constructor Summary
TECAgent(Reader configStream, int tmeMode)
          Deprecated. This constructor is externalized by EIF API 3.8 just to avoid backward compatibility issues.
TECAgent(Reader configStream, int deliveryMode, boolean oneway)
          Constructor used to create the Enhanced EIF API.
 
Method Summary
 void disconnect()
          Closes any open connection to the servers.
 void disconnect(int max_seconds_to_wait)
          Closes any open connection to the servers.
 String getConfigVal(String key)
          Retrieves a value from the TECAgent's configuration.
static void main(String[] argv)
          Supports postzmsg/wpostzmsg style command line sends of events.
 String receiveEvent()
          Receive events from all the servers specified in the configuration file used to initialize the TECAgent.
 void registerListener(IEventProcessing evProc)
          This method should be used to register the application object responsible to receive events asynchrously through this API and that should be notified when a event is ready for processing.
 int sendEvent(String events)
          Try to send events to one of the servers specified in the configuration file used to initialize the TECAgent.
 int sendEvent(String[] events)
          Try to send events to one of the servers specified in the configuration file used to initialize the TECAgent.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SEND_FAILURE

public static final int SEND_FAILURE
Returned by sendEvent() when event wasn't successfully sent to the server or buffered on disk.

SEND_FILTERED

public static final int SEND_FILTERED
Returned by sendEvent() when event successfully match the filter and is discarded.

COMM_NONTME

public static final int COMM_NONTME
Specifies that non-TME communications should be used. - Used to keep backward compatibility

SENDER_MODE

public static final int SENDER_MODE
Specifies that Sender delivery mode should be used. To be used in the TECAgent constructors.

RECEIVER_MODE

public static final int RECEIVER_MODE
Specifies that Receiver delivery mode should be used. To be used in the TECAgent constructors.

COMM_TME

public static final int COMM_TME
Specifies that TME Managed Node communications should be used. - For internal use only

COMM_NONTME_SOCKET

public static final int COMM_NONTME_SOCKET
Specifies that non-TME communications should be used. For internal use only

COMM_LCF

public static final int COMM_LCF
Specifies that TME Endpoint (LCF) communications should be used. For internal use only

COMM_CFG

public static final int COMM_CFG
Specifies that configuration should be used. For internal use only
Constructor Detail

TECAgent

public TECAgent(Reader configStream,
                int tmeMode)
         throws EDException
Deprecated. This constructor is externalized by EIF API 3.8 just to avoid backward compatibility issues.

Backward compatibility Constructor. It uses by default deliveryMode equals to SENDER_MODE and the EIF 3.7.1 configuration only.
Parameters:
configStream - object to be used to read the configuration keywords.
tmeMode - the communication mode to be used. It should to be COMM_NONTME, which is the only communication mode supported by EIF 3.7.1.

TECAgent

public TECAgent(Reader configStream,
                int deliveryMode,
                boolean oneway)
         throws EDException
Constructor used to create the Enhanced EIF API. The deliveryMode
Parameters:
configStream - object to be used to read the configuration keywords.
deliveryMode - Specifies which delivery mode should be used. The values SENDER_MODE and RECEIVE_MODE are valid.
oneway - Used for TME Managed Node connections only to designate whether calls to sendEvent() will return exceptions to the caller in the event of failure. A value of 0 means that exceptions should not be returned to the caller; a value of 1 means that exception should be returned to the caller.
Method Detail

getConfigVal

public String getConfigVal(String key)
Retrieves a value from the TECAgent's configuration.
Parameters:
key - Specifies the configuration keyword label
Returns:
The string value associated with key in the configuration file used to initialize the TECAgent. If key didn't appear in the configuration file, then null is returned. For keys such as "Filter" that can have multiple values, only the last value specified in the configuration file is returned.

sendEvent

public int sendEvent(String events)
Try to send events to one of the servers specified in the configuration file used to initialize the TECAgent. If the cache file is persistent, then the events are cached and persistent before sent.
Parameters:
event - Event data you want to send to the server. If event is non-null, then it must be at least TECEvent.MIN_EVENT_LEN chars long or sendEvent() returns w/ error immediately.
Returns:
Returns:
  • -1 (SEND_FAILURE), if an error occurs
  • 0 (SEND_FILTERED), if the event was filtered
  • >0 (number of bytes sent), if success

  • sendEvent

    public int sendEvent(String[] events)
    Try to send events to one of the servers specified in the configuration file used to initialize the TECAgent. If the cache file is persistent, then the events are cached and persistent before sent.
    Parameters:
    events - Array of event data you want to send to the server. If each event data in the events array is non-null, then it must be at least TECEvent.MIN_EVENT_LEN chars long or sendEvent() returns w/ error.
    Returns:
    Returns:
  • -1 (SEND_FAILURE), if an error occurs
  • 0 (SEND_FILTERED), if the event was filtered
  • >0 (number of bytes sent), if success

  • receiveEvent

    public String receiveEvent()
    Receive events from all the servers specified in the configuration file used to initialize the TECAgent.
    Returns:
    Event data that was received by this API. The delimitor TECEvent.TECAD_EVENT_END_CHAR (A) is used to separated the events returned in this string.

    disconnect

    public void disconnect(int max_seconds_to_wait)
    Closes any open connection to the servers. The parameters indicate that the caller wants the cache flushed before disconnecting.
    Parameters:
    max_seconds_to_wait - < 0 - Wait forever or until cache is emptied. If the server is down this routine will not return. = 0 - Send events from the cache while the connection remains up. It could take a while to send all the events if the cache is large. >= 0 - Stop emptying the cache after the specified number of seconds. For all values, control wil be returned to the caller as soon as the cache is emptied.

    disconnect

    public void disconnect()
    Closes any open connection to the servers.

    registerListener

    public void registerListener(IEventProcessing evProc)
    This method should be used to register the application object responsible to receive events asynchrously through this API and that should be notified when a event is ready for processing.
    Parameters:
    evProc - object responsible to process event received asynchronously by the API.

    main

    public static void main(String[] argv)
    Supports postzmsg/wpostzmsg style command line sends of events.

    Tivoli Confidential