SAP CC 3.0 BART API

com.highdeal.bart.message
Class CDRServiceClient

java.lang.Object
  extended by com.highdeal.bart.message.CDRServiceClient

public class CDRServiceClient
extends java.lang.Object

This class allows a user to send some CDRs to SAP Convergent Charging BART Server by using an efficient message protocol based on TCP/IP.


Constructor Summary
CDRServiceClient()
          Creates a non-initialized message client.
CDRServiceClient(java.lang.String hostName, int port)
          Creates a message client and connect it with the CDR Service server.
CDRServiceClient(java.lang.String hostName, int port, int timeout)
          Creates a message client and connect it with the CDR Service server.
CDRServiceClient(java.lang.String hostName, int port, java.lang.String bindAddress, int timeout)
          Initializes a message client and connect it with the CDR service server.
 
Method Summary
 AcquireCDRResult acquireCDR(java.util.Vector<CDRModel> cdrs, AcquisitionSessionModel session)
          Asks the server to acquire the specified cdrs .
 void close()
          Closes the connection with the CDR Service server.
 void connect(java.lang.String hostName, int port)
          Connect this cdr service client using the round robin with the server.
 void connect(java.lang.String hostName, int port, int timeout)
          Connect this cdr service client using the round robin with the server.
 void connect(java.lang.String hostName, int port, java.lang.String bindAddress, int timeout)
          Connect this cdr service client using the round robin with the server.
 void connect(java.lang.String hostname, int port, java.lang.String bindAddress, int timeout, ServiceClientTuning config)
          Connects this cdr service client to the remote cdr service server of BART.
 int getTimeout()
          Returns the timeout in milliseconds for each request (or -1 to wait indefinitely)
 boolean isConnected()
          Gets the connected status.
 AcquisitionSessionModel startAcquisitionSession(AcquisitionSessionModel session)
          Starts an acquisition session.
 AcquisitionSessionModel stopAcquisitionSession(AcquisitionSessionModel session, boolean withErrors)
          Stops an acquisition session.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CDRServiceClient

public CDRServiceClient()
Creates a non-initialized message client.

One of the methods connect() must then be used to connect it to a CDRs Service server.


CDRServiceClient

public CDRServiceClient(java.lang.String hostName,
                        int port)
                 throws java.io.IOException
Creates a message client and connect it with the CDR Service server.

Parameters:
hostName - the host name of the server.
port - the port on which the server waits for request.
Throws:
java.io.IOException - if the client cannot connect to the server (if server is not running, for instance).

CDRServiceClient

public CDRServiceClient(java.lang.String hostName,
                        int port,
                        int timeout)
                 throws java.io.IOException
Creates a message client and connect it with the CDR Service server.

Parameters:
hostName - the host name of the server.
port - the port on which the server waits for request.
timeout - the timeout in milliseconds for each request (or -1 to wait indefinitely). If you use zero and acknowledgments are requested then a CommunicationFailureException will be thrown without sending request.
Throws:
java.io.IOException - if the client cannot connect to the server (if server is not running, for instance).

CDRServiceClient

public CDRServiceClient(java.lang.String hostName,
                        int port,
                        java.lang.String bindAddress,
                        int timeout)
                 throws java.io.IOException
Initializes a message client and connect it with the CDR service server.

Parameters:
hostName - the host name of the server.
port - the port on which the server waits for request.
bindAddress - the address to bind to, can be null
timeout - the timeout in milliseconds for each request (or -1 to wait indefinitely). If you use zero and acknowledgments are requested then a CommunicationFailureException will be thrown without sending request.
Throws:
java.io.IOException - if the client cannot connect to the servers.
Method Detail

getTimeout

public int getTimeout()
Returns the timeout in milliseconds for each request (or -1 to wait indefinitely)

Returns:
the timeout in milliseconds, or -1 if no timeout has been defined.

acquireCDR

public AcquireCDRResult acquireCDR(java.util.Vector<CDRModel> cdrs,
                                   AcquisitionSessionModel session)
                            throws InvalidCDRException,
                                   InvalidAcquisitionException,
                                   ServerFailureException,
                                   CommunicationFailureException
Asks the server to acquire the specified cdrs .

Parameters:
cdrs - a vector of CDRs to acquire.
session - the acquisition session which these CDRs will be linked to
Returns:
a vector containing the CDRs with status ACQUIRED/DUPLICATE
Throws:
InvalidCDRException - if the cdr is not valid
InvalidAcquisitionException - if the acquisition session is not valid
ServerFailureException - if the server is not available
CommunicationFailureException - if a communication failure occurs

startAcquisitionSession

public AcquisitionSessionModel startAcquisitionSession(AcquisitionSessionModel session)
                                                throws InvalidAcquisitionException,
                                                       ServerFailureException,
                                                       CommunicationFailureException
Starts an acquisition session.

Parameters:
session - the acquisition session to start
Returns:
the session as it is created on server side
Throws:
InvalidAcquisitionException - if the acquisition session is not valid
ServerFailureException - if the server is not available
CommunicationFailureException - if a communication failure occurs

stopAcquisitionSession

public AcquisitionSessionModel stopAcquisitionSession(AcquisitionSessionModel session,
                                                      boolean withErrors)
                                               throws InvalidAcquisitionException,
                                                      ServerFailureException,
                                                      CommunicationFailureException
Stops an acquisition session.

Parameters:
session - the acquisition session to stop
withErrors - in case client want to notify BART server that some errors occurred during acquisition
Returns:
the session as it is created on server side
Throws:
InvalidAcquisitionException - if the acquisition session is not valid
ServerFailureException - if the server is not available
CommunicationFailureException - if a communication failure occurs

connect

public void connect(java.lang.String hostName,
                    int port,
                    int timeout)
             throws java.io.IOException
Connect this cdr service client using the round robin with the server.

Parameters:
hostName - the host name of the server.
port - the port on which the server waits for request.
timeout - the timeout for the client's requests.
Throws:
java.io.IOException - if the client cannot connect to the server (if server is not running, for instance).

connect

public void connect(java.lang.String hostName,
                    int port)
             throws java.io.IOException
Connect this cdr service client using the round robin with the server.

Parameters:
hostName - the host name of the server.
port - the port on which the server waits for request.
Throws:
java.io.IOException - if the client cannot connect to the server (if server is not running, for instance).

connect

public void connect(java.lang.String hostName,
                    int port,
                    java.lang.String bindAddress,
                    int timeout)
             throws java.io.IOException
Connect this cdr service client using the round robin with the server.

Parameters:
hostName - the host name of the server.
port - the port on which the server waits for request.
bindAddress - the address to bind description.
timeout - the timeout for the clients request.
Throws:
java.io.IOException - if the client cannot connect to the server (if server is not running, for instance).

connect

public void connect(java.lang.String hostname,
                    int port,
                    java.lang.String bindAddress,
                    int timeout,
                    ServiceClientTuning config)
             throws java.lang.IllegalStateException,
                    java.lang.IllegalArgumentException,
                    java.io.IOException
Connects this cdr service client to the remote cdr service server of BART.

The cdr service server is identified by its hostname on which it is running and its listening port. Please see BART documentation in order to find the value of this properties.

This client can be bound to one or all the network interface(s) of the running host. If you want to force this client to be bound to one specific network interface, just specified the argument bindAddress with a valid ip address or a valid hostname. Otherwise this client will be bound to all the network interfaces.
Whatever the bind address, the port of this client will be choosen automatically between all the available ports of the network interface(s).

After having invoked this method, this client will maintain the connection with the server opened. If the connection is closed because of network problem, this client will try to open again the connection with the server every 2 seconds. This period can be updated using the ServiceClientTuning.

Parameters:
hostname - the ip address or the name of the host on which the cdr service server is running. Mustn't be null.
port - the port on which the cdr service server is listening. It is a positive integer up to 65535.
bindAddress - the local address (ip address or host name) to which this client has to be bound. If not specified (i.e. is null), this client will be bound to all the available addresses. The bound port will be the choosen between all the available port.
timeout - the maximal duration in second, the response of a message has to be expected whatever the sent message. If no timeout is needed, set timeout to NO_TIMEOUT.
config - sensitive parameter set useful in order to tune the high availability (HA) of this service. Should be null or may be specified only in order to resolve HA issue. If null, the default values of ServiceClientTuning are used.
Throws:
java.lang.IllegalStateException - if this client is already connected with a remote cdr service server.
java.lang.IllegalArgumentException - if hostname is null or if port is outside the range of a valid port values.
java.io.IOException - if this client cannot be connected to the server because of an I/O error.

isConnected

public boolean isConnected()
Gets the connected status.

Returns:
true if the cleint is connected and false otherwise.

close

public void close()
Closes the connection with the CDR Service server. This method allows to release all resources attached (sockets and buffers).


SAP CC 3.0 BART API

(c) Copyright 2011 SAP AG. All rights reserved. SAP Convergent Charging 3.0