This document covers deploying, configuring, and managing the OpenCloud CDR Generation Resource Adaptor.

Note
About the CDR Generation Resource Adaptor

The CDR resource adaptor provides an interface for SBBs to write Call Detail Records (CDRs) to a series of CDR files. The RA supports automatic rollover by number of CDRs written, CDR file size, or elapsed time. CDR files can be automatically post-processed by an external program when they are completed.

Topics

This document includes the following topics:

Topic What it covers

Getting Started

  • how to deploy the resource adaptor

  • resource adaptor output formats

  • resource adaptor deactivation process

Configuration

  • how to configure the resource adaptor

Binary File Support

  • how to generate SBB-specific binary CDR files

  • user tools to query and display binary CDR file content in text format

Alarms

  • alarms generated by the resource adaptor

Example Service

  • how to install and run the example service

Download

Tip Download an evaluation version of the CDR Resource Adaptor package.

Getting Started

Below are overviews of how to deploy the CDR resource adaptor, its output format, and how to force immediate deactivation of a CDR resource adaptor entity.

Deploying the CDR resource adaptor

The CDR resource adaptor comes packaged in a deployable unit: cdr-ra-du.jar. It has a single dependency, on the Google Protobuf library. Protobuf deployable unit protobuf-library.du.jar is delivered with the CDR resource adaptor package.

The CDR resource adaptor does not come with a deployment script. Instead, an example service, distributed as part of the CDR resource adaptor package, includes a script that installs and configures the resource adaptor for that example. Developers and administrators should refer to the example script for the exact steps and adjust them to their own needs. The basic procedure is:

  1. Deploy the Protobuf library.

  2. Deploy the CDR resource adaptor.

  3. Create a CDR resource adaptor entity.

  4. Bind the CDR resource adaptor entity to a link name expected by the service.

Output format

A CDR resource adaptor entity can be configured to produce either binary or text CDR files.

Binary output format Text output format

Defined in the Google Protobuf definition CdrFileFormat.proto (can be found in the CDR resource adaptor package, under etc/).

The Protobuf definition can use tools and languages supported by the Protobuf project.

CdrFileFormat.proto defines a list of records, where a record is one of:

  • Header

  • FieldDescriptor

  • MessageDescriptor

  • BinaryCdr

  • StringCdr Footer

  • Timestamp

The format of a text CDR file consists of:

  • an optional one-line header containing the creation time of the CDR file (if Header is True)

  • zero or more CDRs, one per line

  • an optional one-line footer containing the completion time of the CDR file (if Footer is True).

All lines end with the platform-default line ending (LF \n on Unix, CRLF \r\n on Windows).

The format of an individual CDR is controlled by the calling service.

Immediate deactivation of a resource adaptor entity

When deactivated, a CDR resource adaptor entity remains in the STOPPING state until all pending CDRs are written and the CDR files completed and archived. If you need a faster shutdown, you can administratively remove the "CDR deactivation guard activities" (listed using the findactivities rhino-console command), to force the resource adaptor to transition to the INACTIVE state immediately.

Warning If the node exits for any reason before the write/archive process completes, partial CDR files needing manual recovery may be left behind.

Configuration

This page describes the configuration properties of the CDR resource adaptor. These properties are passed to the createRAEntity management operation when deploying the CDR resource adaptor.

Configuration properties

The following properties are passed to the createRAEntity management operation when deploying the CDR resource adaptor.

Property What it does Default

Directory

Name of the directory into which the CDRs will be written. The resource adaptor must have write permissions for it. This parameter is mandatory.

Note
See also
This property supports Property Expansion.
Warning

Changing this value will require adding a new FilePermission to the deployed unit. This can be done using REM.

In a clustered environment, each node manages its own set of CDR files. SBBs will write CDRs to the CDR file of whichever node they are executing on. Several nodes may safely write to the same output directory; but care should be taken to ensure that the final output filenames do not collide. Including a %n escape sequence (node ID) as part of the FilenamePattern is the simplest way to ensure this.

${rhino.dir.home}${/}cdr

CdrFileType

The CDR file type to use. Either Text or Binary.

Binary

FilenamePattern

Pattern used to generate final CDR filenames.

Note
See also
This property supports Property Expansion and Filename Patterns.

cdr_%n_%t.log

TempFilePrefix

Prefix used as part of the temporary CDR filename. That is, the file to which currently generated call data records are written.

Note
See also
This property supports Property Expansion.

cdr_

MaxSize

Approximate maximum size in bytes before a new CDR file is started. After a CDR is written, the total file size is compared to MaxSize.

  • If the current file size is larger, it is completed.

  • If MaxSize is 0, no size-based rollover is done.

1,000,000
bytes (approx 1MB)

MaxLines

Number of CDRs to be written to a CDR file before a new file is started. The line count does not include the header and footer lines, if enabled.

  • If MaxLines is 0, no size-based rollover is done.

0
(no rollover)

MaxInterval

Number of milliseconds of operation before time-based file rollover. If a CDR file is used for more than MaxInterval seconds without being rolled over due to line- or size-based limits, it is completed anyway.

Note If CreateEmptyFiles is True, at least one CDR file is created every MaxInterval seconds, even if no CDRs are written.

0
(no rollover)

Header

If True, a one-line header containing the start time of the CDR file is put at the start of each file.

True

Footer

If True, a one-line footer containing the end time of the CDR file is put at the end of each file.

True

CreateEmptyFiles

If True, a new CDR file is created immediately on resource adaptor activation, and whenever a CDR file is rolled over.

If False, a new file is created when writing the first CDR record after activation or roll over of a CDR file.

False

ArchiveCommand

Command to run on each CDR file completion. The resource adaptor must have execute permissions for the designated command.

{0} in the command line denotes the absolute path to the CDR file.

If empty, no command is run.

Note
See also
This property supports Property Expansion.

empty

Encoding

Character encoding to use for the output file.

ISO-8859-1

WriteTimeout

Time, in milliseconds, to wait for a CDR write to complete before returning a timeout error to the calling SBB.

5000
(5 seconds)

WriteRetry

Delay, in milliseconds, to wait after a CDR write error before attempting another CDR write.

30000
(30 seconds)

WriteWait

If True, the resource adaptor waits until the CDR is written to file before reporting success to the calling SBB.

If False, the resource adaptor adds the CDR to a queue and returns immediately. This can be used to reduce latency in writing CDRs, but means that queued CDRs are lost in the event of a write error or node failure.

Warning If this property is set to False, then WriteSync should generally also be set to False, because the resource adaptor will already have returned to the calling SBB before FileDescriptor.sync() is called.

True

WriteSync

If True, FileDescriptor.sync() is called after writing CDRs, to flush them to disk before reporting success to the calling SBB.

If False, the call to sync() is skipped, resulting in considerably less disk I/O but a weaker guarantee to the calling SBB.

Warning If WriteWait is False, then this value has no effect on when control is returned to the calling SBB.

True

Filename patterns

The FilenamePattern configuration parameter should include escape sequences that are replaced to generate unique filenames. The supported sequences are:

Sequence Description

%%

A literal '%' character

%t

File completion timestamp, as milliseconds since Jan 1 1970 00:00 UTC

%T

File creation timestamp, as milliseconds since Jan 1 1970 00:00 UTC

%s

Auto-incrementing file sequence number, starting at 1

%d

File completion timestamp, formatted as YYYYMMDDhhmmss

%D

File creation timestamp, formatted as YYYYMMDDhhmmss

%n

Rhino node ID responsible for creating this file

Property expansion

Certain CDR resource adaptor configuration properties support system property expansion. This mechanism is similar to expanding variables in a shell. That is, when a string like: ${some.property} appears as part of a configuration property value, it will be expanded to the value of the system property. For example,

${user.home}/cdr

will expand ${user.home} to use the value of the user.home system property. If that property’s value is /home/cathy, then the above is equivalent to

/home/cathy/cdr

In order to assist in platform-independent configuration, you can also use the special notation of ${/}, which is a shortcut for ${file.separator}.

Persistence, error handling, and operational state

If both WriteWait and WriteSync configuration properties are set to True, the CDR resource adaptor ensures that all written CDR data has been flushed to disk (using java.io.FileDescriptor.sync()) before returning to a SBB. In that case, after a successful writeCDR call, SBBs should assume that all CDR data has been saved to disk.

If there is a write error while writing the CDR, and the WriteWait configuration property is True, this will be reported to the SBB as an IOException. If the CDR could not be written within the configured WriteTimeout of the RA entity, com.opencloud.slee.resources.cdr.WriteTimeoutException (a subclass of IOException) is reported to the SBB.

Note In general, receiving an exception means that the CDR RA could not guarantee that the CDR was successfully written. (It might eventually be written successfully, but there is no guarantee.)

Under normal operation, CDRProvider.isOperational() returns True. If a write error or timeout error occurred recently, isOperational() returns False and all attempts to write CDRs are immediately rejected without attempting to write them to disk. This state persists for 2*WriteTimeout milliseconds (for timeout errors) or WriteRetry milliseconds (for write errors). Additionally, isOperational() returns False if the RA entity is currently deactivated. Services should test isOperational() if they wish to behave differently when CDR writing is unavailable due to error.

In the event of a write error, or if a Rhino node unexpectedly exits, partial CDR files may be left in the CDR directory. With the default configuration value of TempFilePrefix, these files are named cdr_nodeID_*.tmp where * denotes a random number. If they contain useful CDR data, these files will need to be manually examined and processed.

Binary File Support

This section describes CDR resource adaptor support for writing binary CDR files.

Binary CDR file support using Google Protobuf definition

The CDR resource adaptor:

  • uses the Google Protocol Buffers to support writing CDR files with binary encoded CDR records

  • enables SBBs to store any protocol buffer protocol message.

Note
See also
Google’s Protocol Buffer documentation includes an extensive description of the .proto file syntax and a tutorial on using the protocol buffers.

To use Protobuf functionality in an SBB, the developer must:

  1. Define a protocol buffer message that will be generated and written by creating a .proto file

  2. Use the protocol buffer compiler to generate code that supports creation, writing, and reading the protocol buffer message specified in .proto file

  3. Use the Java protocol buffer API in the SBB to create messages and pass them to the CDR resource adaptor for writing

  4. Package the generated protocol buffer code so that it can be used by the SBB at runtime (for example, include it in an sbb.jar or create and reference a library jar).

Note There is no need to package the protocol buffer library code itself, as it is already distributed as a library jar with the CDR resource adaptor package.

Binary CDR file format

The binary CDR file format is specified as the protocol buffer’s .proto file. It is distributed as part of the CDR resource adaptor package in /etc/CdrFileFormat.proto. Here’s what it looks like:

Binary CDR file format
package com.opencloud.slee.resources.cdr.protobuf;

option java_outer_classname = "CdrFileFormat";

message CdrFile {

    repeated Record record = 1;

    message Record {
        optional Header header = 1;
        optional MDescriptor messageDescriptor = 2;
        optional FDescriptor fileDescriptor = 3;
        optional BinaryCDR  binaryCdr = 4;
        optional StringCDR stringCdr = 5;
        optional Footer footer = 6;
        optional DateTime timestamp = 7;
    }

    message Header {
        optional string ra_name = 1;
        optional string ra_vendor = 2;
        optional string ra_version = 3;
        optional string ra_release = 4;
        optional string ra_build = 5;
        optional string ra_revision = 6;
        optional string description = 7;
        optional string rhino_node = 8;
        optional string ra_entity = 9;
        optional string hostname = 10;
    }

    // Contains a single encoded FileDescriptorProto.
    // The descriptor can subsequently be referred to by 'fid'
    message FDescriptor {
        required int32 fid = 1;
        required bytes encoded_descriptor = 2;
        repeated int32 dependency = 3 [packed=true];  // List of dependencies, referring to previously-encoded fids
    }

    // Associates a 'mid' with a particular named message in a previously-encoded FileDescriptor
    message MDescriptor {
        required int32 mid = 1;
        required int32 fid = 2;
        required string message_name = 3;
    }

    message BinaryCDR {
        required int32 mid = 1;
        required bytes cdr = 2;
    }

    message StringCDR {
        required string cdr = 1;
    }

    message Footer {
    }

    message DateTime {
      required int64 milliseconds_since_epoch = 1;
      required sint32 zoneoffset_minutes = 2;
    }

}

A CDR file is a collection of records. If the Header configuration property is set to True, the first record in CDR file contains the header message. Similarly, based on the Footer configuration property, the last record in CDR file might be the footer message.

SBB-generated CDRs represented by protocol buffer messages are stored in the record as BinaryCDR messages. If the SBB generates text CDRs, they are stored in the record as StringCDR messages. Each record that contains either a BinaryCDR or StringCDR message also includes a timestamp representing date and time when the CDR was generated.

Whenever an SBB requests a write of a binary CDR (protocol buffer message), the resource adaptor checks if this type of binary CDR is written, for the first time, in the current CDR file. If it is, then the resource adaptor first generates and writes one or more records containing an FDescriptor message, followed by a record containing an MDescriptor message. These messages contain protocol buffer metadata that describes the format of the binary CDR (SBB-generated protocol buffer message). The encoded_descriptor field of the FDescriptor message contains encoded bytes representing a com.google.protobuf.Descriptors.FileDescriptor for the binary CDR (SBB-generated protocol buffer message) and can be used to recreate and programmatically interrogate the protocol buffer’s description (effectively the .proto file) of the stored binary CDR records.

Note
See also
For more information on how to use Descriptors.FileDescriptor, see the protocol buffer documentation on Self-describing Messages, and the Protocol Buffers Java API.

Binary CDR file interrogation tools

The CDR resource adaptor package contains two user tools that can be used to display the content of a binary CDR file in text format.

Tool Description

listcdrs.py

A Python script that displays the content of a binary CDR file in text format.

Usage:

listcdrs.py CDRFILE
Note This script requires the Python protocol buffers module, which is available as part of a complete protocol buffers installation. (Depending on your operating system type and vendor, it might also be available as part of your standard software distribution system.)

listcdrs.sh

A shell script that starts a Java program capable of querying and displaying a binary CDR file’s content in text format.

Usage:

listcdrs.sh [--field field --regex regex] [--formatted] CDRFILE [CDRFILE]...
Tip To list possible values for the --field parameter, display the binary CDR file content without the --field parameter. Any text followed by = is a field name.

The --regex parameter takes a regular expression; only CDRs with matching field values display. The supported regular expression format is described in the Pattern class documentation.

The --formatted option results in using a multiline display format.

This tool also supports CDR binary files in gzip format. Each file that ends with a .gz suffix is treated as compressed. That is, there is no need to decompress such CDR files before running the tool.

Note Short usage message is displayed by each tool when invoked without parameters.

Alarms

CDR resource adaptor generates alarms related to CDR write and CDR file archive failures.

For all of these alarm types use the CDR resource adaptor entity name as the alarm instanceID:

Alarm type When raised When cleared Action to take

cdr.write-timeout

A CDR could not be written and flushed to disk within the configured WriteTimeout.

The write thread has been operating normally with no timeouts for at least 2*WriteTimeout milliseconds.

Check that the CDR directory is accessible and that the disk is not overloaded. Check that Rhino has available spare CPU time.

cdr.write-failure

An I/O error has occurred when creating a CDR file, writing to a CDR file, or closing a CDR file.

A CDR is successfully written to disk without errors.

Examine the Rhino logs for detailed error information and correct the underlying error. Manually recover CDR data if necessary.

cdr.archive-failure

Execution of the CDR ArchiveCommand fails, or the command returns a non-zero exit code.

A CDR file is successfully archived without errors.

Examine the Rhino logs for detailed error information and correct the underlying error. Manually process any CDR files that were not processed automatically if necessary.

cdr.write-thread-failure

The CDR write thread exits unexpectedly. Suggests a bug in the CDR RA code.

The RA is deactivated.

Deactivate, then activate the CDR RA entity. Contact OpenCloud support for further diagnosis.

cdr.archive-thread-failure

The CDR archive thread exits unexpectedly. Suggests a bug in the CDR RA code.

The RA is deactivated.

Deactivate, then activate the CDR RA entity. Contact OpenCloud support for further diagnosis.

Example Service

The CDR resource adaptor comes with the CDR Generation example service. To deploy the example:

1

Start Rhino:

$RHINO_HOME/start-rhino.sh

2

Unpack the CDR resource adaptor distribution package into $RHINO_HOME.

Note If unpacked elsewhere, adjust the client.home configuration property in the build.properties file.

3

The properties in build.properties are used to configure the CDR resource adaptor during deployment. Edit it to verify that the configuration is correct for your local environment. In particular, verify these properties:

Property

cdr.directory={rhino.dir.home}{/}cdr

Specifies

Name of the directory into which the CDRs will be written. The resource adaptor must have write permissions for it. This parameter is mandatory, and its value is set to $RHINO_HOME/cdr.

Note If you intend to modify the value of cdr.directory to point to somewhere else, you need to update the security-permissions in the resource-adaptor-jar.xml deployment descriptor, in the resource adaptor’s deployable unit.

Property

cdr.archivecommand=${rhino.dir.base}/cdr-ra-VERSION/examples/archive-cdr-log.sh {0}

Specifies

Command to run on each CDR file completion. The resource adaptor must have execute permissions for the designated command.

{0} in the command line denotes the absolute path to the CDR file.

If empty, no command is run.

4

To deploy the examples, using Ant, execute the deploy-all target:

$ cd $RHINO_HOME/cdr-ra-VERSION/examples
$ ant deploy-all

This deploys the CDR resource adaptor, example (telnet) resource adaptor, and the CDR Generation example service.

5

Use a telnet utility to connect to the example resource adaptor:

telnet localhost 9999

6

Try these commands:

Command Description Example

send <number>

Sends the number of message events to SLEE

send 1

close

Closes the telnet connection and exits

close

help

Displays the usage commands

help

Tip Source code for the example service can be found in the examples/src subdirectory of CDR resource adaptor package. This code may be freely altered and reused. It is made available under a BSD-style license.

CDR Resource Adaptor Type API

The OpenCloud CDR Resource Adaptor implements the CDR Resource Adaptor Type API.

Changelog

Version 2.2.0.3

  • Added '--formatted' option to the ListCdrs tool to produce more easily readable output. (CDR-25)

Version 2.2.0.2

  • Added new config property "WriteWait". When set to "False", the resource adaptor will not wait for the CDR to be written to the file before reporting success to the calling SBB. This can be used to reduce latency in writing CDRs but means that queued CDRs will be lost in the event of a write error or node failure. When set to "True", the resource adaptor will only report success to the caller once the CDR has been written to the file. The default is "True", which gives the same behaviour as previous versions. (CDR-24)

Version 2.2.0.1

  • Fixed a NullPointerException that occurred when a text CDR file was closed if the resource adaptor was configured not to output a footer line to the file. (CDR-20)

  • Updated configuration default values in documentation. (CDR-21)

Version 2.2.0.0

  • Added binary CDR file support. (CDR-15)

  • Added support for CDR objects which have type com.google.protobuf.Message or Object. (CDR-8)

Version 2.1.0

  • The CDR RA 2.1 has been ported to the JAIN SLEE 1.1 Resource Adaptor API.

Version 2.0.0

  • The CDR RA 2.0 implements the recommended CDR 2.0 RA Type.

  • The CDR examples now include an test implementation of a simple CDR test service.