Installing the Refiner Service

In Transformer, data transformation services are implemented in Transformer Modules. Caplin provides a Transformer module called Refiner that allows large lists of data (containers) to be efficiently filtered and sorted in real time on behalf of client applications. Refiner is supplied as a Service blade that’s deployed in the Caplin Platform Deployment Framework. This tutorial shows you how to deploy the Refiner blade and use it to sort and filter container responses.

Once you’ve completed the steps on this page, you should be familiar with how to deploy Refiner and how to request filtered and sorted data via Transformer.

In these instructions you’ll be using the dfw command of the Deployment Framework. Before entering any dfw command as ./dfw <command-name>, make sure your current (working) directory is set to the Deployment Framework’s topmost directory. In file paths, we’ve called this topmost directory <Framework-root>. For a list of dfw commands, click here.


Refiner is a Transformer Java module and has the following requirements:

  • Refiner must be deployed to a Transformer that is licensed to run Java Transformer modules. Check your Transformer licence contains the string below:

    module jtm transformer

    For questions regarding licensing, contact Caplin Support.

  • Transformer’s Java Virtual Machine (JVM) must be configured with a maximum heap size that allows Refiner to run your data transformation workloads comfortably without the JVM running out of memory. See Tuning Transformer’s JVM heap for Refiner.

Installation instructions

To install Refiner, follow the instructions below:

1. Install a Deployment Framework, Liberator and Transformer

Make sure you’ve installed a Deployment Framework and have deployed a Liberator and Transformer (see How can I…​ Deploy Platform components to the Framework).

The Framework has a built-in demonstration Adapter blade called DemoDataSource that you’ll use to show that Refiner is working. Make sure the DemoDataSource blade is active, by running the following dfw command from the <Framework-root> directory:

./dfw activate DemoDataSource

You can verify that the blade has been activated, by running the command:

./dfw versions

2. Deploy the Refiner Service blade

The Refiner Service blade is supplied in a zip file with a name like CPB_RefinerService-<version>-<build_number>.zip.

To deploy the Refiner Service blade, follow the instructions in Deploy core-component modules and Check what’s been deployed in How can I…​ Deploy Platform components to the Framework.

Testing the installation

Follow the instructions below to check the Refiner Service is available:

  1. Start the Liberator, Transformer and DemoDataSource adapter, by running ./dfw start from the <Framework-root> directory.

  2. Log on to Liberator from a web browser and navigate to the status page (for details of how to do this, see Check the Liberator is running correctly in Installing Liberator).

    The Liberator should recognise the following data services and DataSources. In particular, the status page should show a data service for the Refiner Service, as highlighted in red here:

    Refiner service status shown on Liberator status page
  3. Stop the Liberator, Transformer and DemoDataSource adapter, by running ./dfw stop from the <Framework-root> directory. This is so you can examine various log files to check Transformer’s working correctly.

  4. Examine the log file <Framework-root>/servers/Transformer/var/jtm.log

    If the Transformer is working correctly, this log contains the version number of the Transformer Module library:

    <YYYY/MM/DD-HH:MM:SS.NNN> +0000: INFO: Java Transformer module (6.2.0-297741) starting up
    <YYYY/MM/DD-HH:MM:SS.NNN> +0000: INFO: Loading user class with identifier jtm
    <YYYY/MM/DD-HH:MM:SS.NNN> +0000: CRIT: Thread [main/1]: Product: Java Transformer Module
    Version        : 6.2.3-bbbbbb
    Build Date     : dd-Mon-yyyy
    Build Time     : hh:mm
    Build Number   : bbbbbb
    Copyright      : Copyright 1995-2014 Caplin Systems Ltd

    In the same log file, you should also see Caplin Refiner registering as a provider for the namespace it uses:

    2011/12/16-15:41:05.703 +0000: INFO: Registering as a provider of </FILTER/*>
  5. Examine the log file <Framework-root>/servers/Transformer/var/refiner.log

    If Caplin Refiner is working correctly, this log contains its version number:

    <YYYY/MM/DD-HH:MM:SS.NNN> +0000 - Thread [main/1]: SEVERE: Refiner 6.2.3-bbbbbb
  6. If everything looks ok, restart the Liberator, Transformer and DemoDataSource adapter, by running: ./dfw start

  7. Log on to Liberator from a web browser and navigate to the Liberator Explorer page:

    1. From the menu on the Liberator’s home page, select Diagnostics

    2. On the Diagnostics page that’s displayed, select the Liberator Explorer link.

For more about using Liberator Explorer, see How can I…​ Use Liberator Explorer to request and send data.

Requesting an unfiltered container

The DemoDataSource adapter can supply a container called /EXAMPLES/PRICING/CONTAINERS/EQUITIES that’s populated with stock prices.

Use Liberator Explorer to request /EXAMPLES/PRICING/CONTAINERS/EQUITIES. This returns the un-filtered and un-sorted container:

Unfiltered container of stock prices

Requesting a filtered container

In Liberator Explorer, request /FILTER/EXAMPLES/PRICING/CONTAINERS/EQUITIES?filter=(BestBid>20)

Liberator routes this request to Transformer, because its RefinerService1 data service contains the include-pattern ^/FILTER/ (have a look in the Liberator configuration file for the Refiner Service blade at <Framework-root>/kits/CPB_RefinerService/CPB_RefinerService-<version>/Liberator/etc/rttp.conf).

The /FILTER prefix directs Transformer to pass the request on to its Refiner module, which then returns just those instruments whose BestBid field is greater than 20

Stock prices filtered by Refiner

Requesting a sorted container

In Liberator Explorer, request /FILTER/EXAMPLES/PRICING/CONTAINERS/EQUITIES?sort=FullName:text:ascending

Now Refiner sorts the instruments in ascending alphabetical order of the FullName field:

Stocks sorted by name by Refiner
Avoid filtering or sorting on record fields that are subject to frequent updates. Frequent updates can have an adverse affect on the performance of Caplin Refiner, Liberator, and the requesting clients.

Tuning Transformer’s JVM heap for Refiner

The default maximum heap size of Transformer’s JVM is 256MB. Before deploying Refiner to production, tune the maximum heap size of Transformer’s JVM to a size that can comfortably accommodate your data transformation workloads without running out of memory.

Follow the steps below:

  1. In the file <framework_root>/global_config/overrides/servers/Transformer/etc/java.conf, adjust the start and maximum JVM heap size to 2048MB or higher:

    # The size of the Java heap (in megabytes)
    define JVM_XMS_HEAP_SIZE        2048
    define JVM_XMX_HEAP_SIZE        2048

    Oracle recommend that the start and maximum size of the JVM are set to the same value to minimise garbage collection.

  2. Start (or restart) Transformer:

    ./dfw start Transformer
  3. From the same user account used to start Transformer, run a JVM profiler and connect to Transformer’s embedded JVM (which has the same PID as Transformer). The JVM profiler records heap memory allocation over time, which you refer to in step 6.

    Free JVM profilers are distributed with Oracle Java: JConsole (jconsole), Java Mission Control (jmc), and Java VisualVM (jvisualvm).
  4. Test Transformer with Refiner against your expected production workloads.

  5. If Transformer raises out-of-memory errors during your tests, then increase the maximum heap size and begin again from step 2.

  6. Referring to the JVM profiler’s graph of free heap memory, increase/decrease the JVM heap size to a size that can run your expected Refiner workloads while retaining a comfortable margin of free memory to cope with unexpected spikes in workload. After adjusting the JVM heap size, begin again from step 2.

See also: