Table of Contents Previous Next PDF


Using Oracle Tuxedo Distributed Caching (TDC) with Oracle Coherence

Using Oracle Tuxedo Distributed Caching (TDC) with Oracle Coherence
This topic contains the following sections:
For a quick start, see the following samples.
For more information about the Oracle Tuxedo ATMI APIs that relates to this feature, see Oracle Tuxedo Distributed Caching (TDC) Related ATMI APIs.
Overview
This feature leverages Oracle Coherence, and Oracle Tuxedo java server, which is working as a client of Oracle Coherence, assuring you taking all advantages that Oracle Coherence has for caching.
This feature supports the following caching strategies.
As Oracle Coherence and TMJAVASVR are used, it requires you to configure them both before actually using TDC.
After these configurations, you can use Oracle Tuxedo Distributed Caching.
Data Caching for Clients and Servers
When you enable data caching, you can store data in cache, and clients on other servers can retrieve the data from the cache. This offers you a new way of sharing data between clients and servers, especially sharing data for or from other servers.
This feature provides you
Unlike storing and retrieving data through queues, files or databases which usually means occupying a large amount of sources and wasting time, storing and retrieving through cache is faster and lighter.
Oracle Tuxedo also adopts other ways to achieve high performance, such as minimizing local buffer copies (ideally providing some zero copy use cases) and focusing on primarily read intensive operations (for example, make 2:1 read/write ratio or higher).
This feature supports many Oracle Tuxedo buffer types so that you do not need to manage to match your data with the data types that Oracle Tuxedo supports. The supported Tuxedo buffer types are CARRAY, FML, FML32, MBSTRING, STRING, VIEW, VIEW32, XML, RECORD, X_C_TYPE, and X_COMMON.
This feature can be transparent for you so you can use it without making any code changes, providing you an easy approach. Oracle Tuxedo encapsulates Oracle Coherence functions in java server container so that you can just use java server to implement all functions that pertain to this feature.
Result Caching for Oracle Tuxedo Services
When you enable result caching, Oracle Tuxedo first reaches the result from the cache entry instead of reaching the backend service; if it fails to reach it or if the cache or cache entry is expired, Oracle Tuxedo reaches the backend service and the result is stored in the cache for Oracle Tuxedo to reach it next time.
This feature provides you
Synchronous services that return results that do not change often are good candidates to have their results cached by Oracle Tuxedo. This can improve performance by reducing network overhead to access the backend service.
Oracle Tuxedo also adopts other ways to achieve high performance, such as minimizing local buffer copies (ideally providing some zero copy use cases) and focusing on primarily read intensive operations (for example, make 2:1 read/write ratio or higher).
By integrating with Oracle Coherence, Oracle Tuxedo takes advantage of its specialized scalable protocol and its creation of a cluster. A cluster can be seamlessly expanded to add more memory, processing power or both, and can avoid single point of failure as it transparently fails over if a cluster member fails. As a result this feature provides you a highly availability and scalability.
Also, taking advantage of Oracle Coherence, any cache entry can be replicated across two or more machines, and the data processing can be farmed out to where the data is and return results to you. This assures your data to be scalable.
This feature supports many Oracle Tuxedo buffer types so that you do not need to manage to match your data with the data types that Oracle Tuxedo supports. The supported Tuxedo buffer types are CARRAY, FML, FML32, MBSTRING, STRING, VIEW, VIEW32, XML, RECORD, X_C_TYPE, and X_COMMON.
This feature can be transparent for you so you can use it without making any code changes, providing you an easy approach. Oracle Tuxedo encapsulates Oracle Coherence functions in java server container so that you can just use java server to implement all functions that pertain to this feature.
Figure 13‑1 illustrates a typical deployment in an Oracle Tuxedo MP domain to use TDC based on Oracle Coherence.
Figure 13‑1 Result Caching for Oracle Tuxedo Services
As you can see from this figure, Oracle Tuxedo java server is taken as Oracle Coherence's client (member). You can directly use Oracle Tuxedo java server to cache results from multiple machines without worrying about how cluster members located in different machines communicate with each other.
Configuring Oracle Coherence
Configure the following files just like you configure on Oracle Coherence. See Oracle Fusion Middleware Developing Applications with Oracle Coherence for detailed instruction.
You can deploy the above configuration files into any path as long as this path is in the java class path and prior to where coherence.jar is. For example, you can put the configuration files into ${APPDIR}/config and then start Oracle Coherence server like this:
Listing 13‑1 Oracle Coherence Cluster Deployment
java -server -showversion $JAVA_OPTS -Dtangosol.coherence.mode=prod -cp $APPDIR/config: ${COHERENCE_HOME}/lib/coherence.jar com.tangosol.net.DefaultCacheServer
 
tangosol-coherence-override.xml
Listing 13‑2 is an example; note the properties in bold. In this example, coherence_tux is the name of the Oracle Coherence cluster whose multicast port number is 51697 and unicast port number is 51687.
Listing 13‑2 tangosol-coherence-override.xml
<?xml version='1.0'?>
<coherence xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://xmlns.oracle.com/coherence/coherence-operational-config"
xsi:schemaLocation="http://xmlns.oracle.com/coherence/coherence-operational-config coherence-operational-config.xsd">
<cluster-config>
<member-identity>
<cluster-name system-property="tangosol.coherence.cluster">coherence_tux</cluster-name>
</member-identity>
<unicast-listener>
<address system-property="tangosol.coherence.localhost">localhost</address>
<port system-property="tangosol.coherence.localport">51687</port>
</unicast-listener>
<multicast-listener>
<port system-property="tangosol.coherence.clusterport">51697</port>
</multicast-listener>
</cluster-config>
</coherence>
 
coherence-cache-config.xml
Listing 13‑3 is an example; note the properties in bold. In this example, we create an Oracle Coherence cache named tux_distributed.
Listing 13‑3 coherence-cache-config.xml
<?xml version="1.0"?>
<cache-config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://xmlns.oracle.com/coherence/coherence-cache-config"
xsi:schemaLocation="http://xmlns.oracle.com/coherence/coherence-cache-config coherence-cache-config.xsd">
<caching-scheme-mapping>
<cache-mapping>
<cache-name>tux_distributed</cache-name>
<scheme-name>distributed</scheme-name>
</cache-mapping>
</caching-scheme-mapping>
 
<caching-schemes>
<distributed-scheme>
<scheme-name>distributed</scheme-name>
<service-name>DistributedCache</service-name>
<lease-granularity>member</lease-granularity>
<backing-map-scheme>
<local-scheme/>
</backing-map-scheme>
<autostart>true</autostart>
</distributed-scheme>
</caching-schemes>
</cache-config>
 
Configuring Oracle Tuxedo Java Server
Configuring Oracle Tuxedo Java Server Cofiguration file
Oracle Tuxedo Distributed Caching (TDC) introduces a new system-supplied Oracle Tuxedo java server, which converts the caching request to Oracle Coherence and sends back the reply. It works as a client of Oracle Coherence.
The java package used by this java server is com.oracle.tuxedo.tdcj.jar located in ${TUXDIR}/udataobj/tuxj/tdc.
Listing 13‑4 is an example of Oracle Tuxedo Java Server Configuration File that enables TDC. For more information, see Java Server Configuration Schema File for version 2.0.
In general, you should not change the code lines in bold. The class com.oracle.tuxedo.tdc.TCache4Coherence is the main class used by TDC which is located in ${TUXDIR}/udataobj/tuxj/tdc/com.oracle.tuxedo.tdcj.jar.
It is necessary to change the code lines in Italic due to different environment. Note that <APPDIR> must be replaced with the real path to make the file work.
Listing 13‑4 Configuring Oracle Tuxedo Java Server Configuration File
<?xml version="1.0" encoding="UTF-8"?>
<TJSconfig version="2.0">
<java-config>
<jvm-options>-XX:MaxPermSize=192m</jvm-options>
<jvm-options>-server</jvm-options>
<jvm-options>-Dtangosol.coherence.distributed.localstorage=false</jvm-options>
<jvm-options>-Dtangosol.coherence.mode=prod</jvm-options>
</java-config>
<tux-config>
<server-clopt>-f <APPDIR>/config/tdcsvr_coh.conf</server-clopt>
</tux-config>
<classpath-config>
</classpath-config>
<tux-resources>
</tux-resources>
<jdbc-resources>
</jdbc-resources>
<tux-server-config>
<classpath>${TUXDIR}/udataobj/tuxj/tdc/com.oracle.tuxedo.tdcj.jar</classpath>
<classpath>${TUXDIR}/udataobj/tuxj/tdc/dms.jar</classpath>
<classpath>${TUXDIR}/udataobj/tuxj/tdc/ojdl.jar</classpath>
<classpath>${APPDIR}/config</classpath>
<classpath>${COHERENCE_HOME}/lib/coherence.jar</classpath>
<server-class name="com.oracle.tuxedo.tdc.TCache4Coherence">
</server-class>
</tux-server-config>
</TJSconfig>
 
Configure Oracle Tuxedo Distributed Caching (TDC) Property File
It is required to add a new property file which specifies all properties about the caches for TDC. Oracle Tuxedo java server advertises services using the name of these caches. You can define many Oracle Tuxedo caches in a single property file.
Listing 13‑5 shows a template of the property file. You can find this template in $TUXDIR/udataobj/tuxj/tdc/tdcsvr_coh.conf.template. In this template, two Oracle Tuxedo cache names are configured: tc1 and tc2. tc1 uses Oracle Coherence cache tux_distributed and tc2 uses Oracle Coherence cache tux2_distributed.
See Oracle Tuxedo Distributed Caching (TDC) Property File Properties for more information about its properties.
Listing 13‑5 TDC Property File Template
#* global option encoding setting
#options.encoding=no
 
#* configurations for Tuxedo cache "tc"
 
#* option encoding setting
#cache.options.encoding.tc=no
#* physical cache used in Oracle Coherence
coh.cache.name.tc=tux_distributed
 
#* configurations for Tuxedo cache "tc2"
#
#* option encoding setting
#cache.options.encoding.tc2=no
#* physical cache used in Oracle Coherence
#coh.cache.name.tc2=tux2_distributed
 
Using Data Caching for Clients and Servers
Steps for Using Data Caching for Clients and Servers
Configure Oracle Coherence
For how to configure Oracle Coherence, see Configuring Oracle Coherence.
Start Oracle Coherence Cluster
If there is no Oracle Coherence Cluster is running, start your own cluster, making sure you configure the path of the configuration files into the Java Class Path and ahead of where coherence.jar is. See Listing 13‑1 for an example.
Configure Oracle Tuxedo Java Server
See Configuring Oracle Tuxedo Java Server for instruction.
Configure UBBCONFIG
Configure TMJAVASVR on UBBCONFIG. TMJAVASVR uses multi-threaded configuration to improve performance. Multi-instances configuration is also used to gain higher availability.
Listing 13‑6 UBBCONFIG for TMJAVASVR
*RESOURCE
...
MODEL SHM
...
*MACHINES
"m1" LMID=L1
...
*GROUPS
JGRP1 LMID=L1 GRPNO=10
 
...
TMJAVASVR SRVGRP=JGRP1 SRVID=10
MINDISPATCHTHREADS=4 MAXDISPATCHTHREADS=4 MIN=2 MAX=2
CLOPT="-- -c /home/scott/tuxedo/dom1/config/tdcsvr_coh.xml"
...
 
Put an Oracle Tuxedo buffer associated with a key into an Oracle Tuxedo cache
On Oracle Tuxedo native client or workstation client, use TDC API tpgetcache and tpcacheput to put an Oracle Tuxedo buffer associated with a key into an Oracle Tuxedo cache. For more information about tpgetcache and tpcacheput, see Oracle Tuxedo Distributed Caching (TDC) Related ATMI APIs.
Listing 13‑7 Put an Oracle Tuxedo buffer associated with a key into an Oracle Tuxedo cache
...
TCACHE* mycache = NULL;
char mykey[128];
char* databuf = NULL;
 
tpinit(NULL);
databuf = tpalloc("STRING", NULL, 256);
 
mycache = tpgetcache("tc");
strcpy(mykey, "myname");
strcpy(databuf, "scott");
tpcacheput(mycache, mykey, databuf, 0, 0L);
 
tpfree(databuf);
...
 
Get an Oracle Tuxedo buffer from an Oracle Tuxedo cache according to the key
On Oracle Tuxedo native client or workstation client, use TDC API tpgetcache and tpcacheget to get an Oracle Tuxedo buffer associated with a key into an Oracle Tuxedo cache. For more information about tpgetcache and tpcacheget, see Oracle Tuxedo Distributed Caching (TDC) Related ATMI APIs.
Listing 13‑8 Get an Oracle Tuxedo buffer from an Oracle Tuxedo cache according to the key
...
TCACHE* mycache = NULL;
char mykey[128];
char* databuf = NULL;
 
tpinit(NULL);
databuf = tpalloc("STRING", NULL, 256);
 
mycache = tpgetcache("tc");
strcpy(mykey, "myname");
tpcacheget(mycache, mykey, &databuf, NULL, 0L);
tpfree(databuf);
...
 
Sample: Using Data Caching for Clients and Servers
Suppose ${APPDIR} is /home/scott/tuxedo/dom1.
Sample: Configure Oracle Coherence
Prepare tangosol-coherence-override.xml in ${APPDIR}/config. See Listing 13‑9.
Configure Oracle Coherence cluster coherence_tux whose multicast port number is 51697 and unicast port number is 51687.
Prepare coherence-cache-config.xml in ${APPDIR}/config. See Listing 13‑10.
Configure Oracle Coherence cache tux_distributed.
Listing 13‑9 Prepare tangosol-coherence-override.xml
<?xml version='1.0'?>
<coherence xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://xmlns.oracle.com/coherence/coherence-operational-config"
xsi:schemaLocation="http://xmlns.oracle.com/coherence/coherence-operational-config coherence-operational-config.xsd">
<cluster-config>
<member-identity>
<cluster-name system-property="tangosol.coherence.cluster">coherence_tux</cluster-name>
</member-identity>
<unicast-listener>
<address system-property="tangosol.coherence.localhost">localhost</address>
<port system-property="tangosol.coherence.localport">51687</port>
</unicast-listener>
<multicast-listener>
<port system-property="tangosol.coherence.clusterport">51697</port>
</multicast-listener>
</cluster-config>
</coherence>
 
Listing 13‑10 Prepare coherence-cache-config.xml
<?xml version="1.0"?>
<cache-config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://xmlns.oracle.com/coherence/coherence-cache-config"
xsi:schemaLocation="http://xmlns.oracle.com/coherence/coherence-cache-config coherence-cache-config.xsd">
<caching-scheme-mapping>
<cache-mapping>
<cache-name>tux_distributed</cache-name>
<scheme-name>distributed</scheme-name>
</cache-mapping>
</caching-scheme-mapping>
 
<caching-schemes>
<distributed-scheme>
<scheme-name>distributed</scheme-name>
<service-name>DistributedCache</service-name>
<lease-granularity>member</lease-granularity>
<backing-map-scheme>
<local-scheme/>
</backing-map-scheme>
<autostart>true</autostart>
</distributed-scheme>
</caching-schemes>
</cache-config>
 
Sample: Start Oracle Coherence cluster
If no Oracle Coherence cluster is running, you can start your own cluster.
java -server -showversion $JAVA_OPTS -Dtangosol.coherence.mode=prod -cp ${APPDIR}/config: ${COHERENCE_HOME}/lib/coherence.jar com.tangosol.net.DefaultCacheServer
Sample: Configure Oracle Tuxedo Java Server
Preparing tdcsvr_coh.xml for Oracle Tuxedo java server
Preparing tdcsvr_coh.xml for Oracle Tuxedo java server in ${APPDIR}/config.
See Listing 13‑11, where the <server-clopt>-f /home/scott/tuxedo/dom1/config/tdcsvr_coh.conf</server-clopt> property specifies the TDC property file.
Listing 13‑11 Configure Oracle Tuxedo Java Server Configuration File
<?xml version="1.0" encoding="UTF-8"?>
<TJSconfig version="2.0">
<java-config>
<jvm-options>-XX:MaxPermSize=192m</jvm-options>
<jvm-options>-server</jvm-options>
<jvm-options>-Dtangosol.coherence.distributed.localstorage=false</jvm-options>
<jvm-options>-Dtangosol.coherence.mode=prod</jvm-options>
</java-config>
<tux-config>
<server-clopt>-f /home/scott/tuxedo/dom1/config/tdcsvr_coh.conf</server-clopt>
</tux-config>
<classpath-config>
</classpath-config>
<tux-resources>
</tux-resources>
<jdbc-resources>
</jdbc-resources>
<tux-server-config>
<classpath>${TUXDIR}/udataobj/tuxj/tdc/com.oracle.tuxedo.tdcj.jar</classpath>
<classpath>${TUXDIR}/udataobj/tuxj/tdc/dms.jar</classpath>
<classpath>${TUXDIR}/udataobj/tuxj/tdc/ojdl.jar</classpath>
<classpath>${COHERENCE_HOME}/lib/coherence.jar</classpath>
<classpath>${APPDIR}/config</classpath>
<server-class name="com.oracle.tuxedo.tdc.TCache4Coherence">
</server-class>
</tux-server-config>
</TJSconfig>
 
Prepare tdcsvr_coh.conf for TDC property file
Prepare tdcsvr_coh.conf for TDC property file in ${APPDIR}/config.
See Listing 13‑12, where it configures Oracle Tuxedo cache tc, which actually uses Oracle Coherence cache tux_distributed.
Listing 13‑12 Configure Oracle Tuxedo Distributed Caching (TDC) Property File
#* global option encoding setting
#options.encoding=no
 
#* configurations for Tuxedo cache "tc"
 
#* option encoding setting
#cache.options.encoding.tc=no
#* physical cache used in Oracle Coherence
coh.cache.name.tc=tux_distributed
 
Sample: Configure TMJAVASVR in UBBCONFIG
Configure TMJAVASVR in UBBCONFIG.
See Listing 13‑13, where multi-threaded configuration is enabled and TMJAVASVR configuration file tdcsvr_coh.xml is set.
Listing 13‑13 Configure TMJAVASVR in UBBCONFIG
*RESOURCES
...
MODEL SHM
...
*MACHINES
"m1" LMID=L1
...
*GROUPS
JGRP1 LMID=L1 GRPNO=10
 
...
TMJAVASVR SRVGRP=JGRP1 SRVID=10
MINDISPATCHTHREADS=4 MAXDISPATCHTHREADS=4 MIN=2 MAX=2
CLOPT="-- -c /home/scott/tuxedo/dom1/config/tdcsvr_coh.xml"
...
 
Sample: Put an Oracle Tuxedo buffer associated with a key into an Oracle Tuxedo cache
Put an Oracle Tuxedo STRING buffer associated with a key mykey into an Oracle Tuxedo cache tc.
Listing 13‑14 Put an Oracle Tuxedo buffer
...
TCACHE* mycache = NULL;
char mykey[128];
char* databuf = NULL;
 
tpinit(NULL);
databuf = tpalloc("STRING", NULL, 256);
 
mycache = tpgetcache("tc");
strcpy(mykey, "myname");
strcpy(databuf, "scott");
tpcacheput(mycache, mykey, databuf, 0, 0L);
 
tpfree(databuf);
...
 
Sample: Get an Oracle Tuxedo buffer from an Oracle Tuxedo cache according to the key
Get an Oracle Tuxedo typed buffer from an Oracle Tuxedo cache tc according to a key mykey.
Listing 13‑15 Get an Oracle Tuxedo buffer
...
TCACHE* mycache = NULL;
char mykey[128];
char* databuf = NULL;
 
tpinit(NULL);
databuf = tpalloc("STRING", NULL, 256);
 
mycache = tpgetcache("tc");
strcpy(mykey, "myname");
tpcacheget(mycache, mykey, &databuf, NULL, 0L);
tpfree(databuf);
...
 
Using Result Caching for Oracle Tuxedo Services
Steps for Using Result Caching for Oracle Tuxedo Services
You can also use MIB to dynamically make changes for TDC.
Configure Oracle Coherence
See Configuring Oracle Coherence for instruction.
Start Oracle Coherence Cluster
If there is no Oracle Coherence Cluster is running, start your own cluster, making sure you configure the path of the configuration files into the Java Class Path and ahead of where coherence.jar is. See Listing 13‑1 for an example.
Configure Oracle Tuxedo Java Server
See Configuring Oracle Tuxedo Java Server for instruction.
Configure UBBCONFIG
Configure TDC on UBBCONFIG.
SERVICES Section
Specify CACHING=string_value as the name of the caching criteria used for caching for this service. For more information, see Oracle Tuxedo Distributed Caching (TDC) Related UBBCONFIG Parameters.
CACHING Section
Specify this CACHING section on UBBCONFIG. For more information, see Oracle Tuxedo Distributed Caching (TDC) Related UBBCONFIG Parameters.
Listing 13‑16 shows an example, where
Svccache1 uses Oracle Tuxedo cache tc1. Other configurations are default. (It means KEY=$service+$request and KEY_BUFTYPE=STRING).
Svccache2 uses Oracle Tuxedo cache tc1. The request is used to figure out the key when caching the response data. Other configurations are default. (It means KEY_BUFTYPE=STRING).
Svccache3 uses Oracle Tuxedo cache tc1. The fixed string key1 is used as the key. Other configurations are default.
Svccache4 uses Oracle Tuxedo cache tc1. The buffer type of the request message to the service is VIEW32 whose subtype is mystruct1. The value of the field name in the subtype mystruct1 is used as the key.
Svccache5 uses Oracle Tuxedo cache tc1. The buffer types of the FML32 and VIEW32: mystruct1 have the same field1 and field2 (name and data type should be the same; value can be different); the request message will use the values of field1 and field2 as the key.
Listing 13‑16 UBBCONFIG CACHING Section Configuration
...
*CACHING
Svccache1
CACHENAME="tc1"
 
Svccache2
CACHENAME="tc1"
KEY="$request"
 
Svccache3
CACHENAME="tc1"
KEY="key1"
 
Svccache4
CACHENAME="tc1"
KEY="$request"
KEY_BUFTYPE="IEW32:mystruct1"
KEY_FIELD="name"
 
Svccache5
CACHENAME="tc1"
KEY="mykey_$request"
KEY_BUFTYPE="FML32;VIEW32:mystruct1"
KEY_FIELD="field1+field2"
 
...
 
Use MIB to Dynamically Make Changes for TDC
You can use MIB to dynamically make changes for TDC.
For more information, see Oracle Tuxedo Distributed Caching (TDC) Related MIB Attributes.
Sample: Using Result Caching for Oracle Tuxedo Services
Sample: Configure VIEWTABLE
Configure your VIEWTABLE. See Listing 13‑17, where the buffer type is VIEW and the subtype is mystruct1.
Listing 13‑17 Configure VIEWTABLE
...
VIEW mystruct1
# type cname fbname count flag size null
string name - 1 - 31 -
string address - 1 - 255 -
char age - 1 - - -
END
...
 
Sample: Configure UBBCONFIG
Configure your UBBCONFIG. See Listing 13‑18, where
TMJAVASVR is configured
Multi-threaded configuration is enabled and the configuration file tdcsvr_coh.xml is set.
Oracle Tuxedo service mysvc1 uses caching entry svccache1 to improve performance. svccache1 uses Oracle Tuxedo cache tc1 to cache the service result. The corresponding key of the response is the value of the request data.
Listing 13‑18 Configure UBBCONFIG
...
*GROUPS
JGRP1 LMID=L1 GRPNO=10
 
...
TMJAVASVR SRVGRP=JGRP1 SRVID=10
MINDISPATCHTHREADS=4 MAXDISPATCHTHREADS=4 MIN=2 MAX=2
CLOPT="-- -c /home/scott/tuxedo/dom1/config/tdcsvr_coh.xml"
...
*SERVICES
mysvc1
...
CACHING="svccache1"
...
*CACHING
svccache1
CACHENAME="tc1"
KEY=$request
...
 
Sample: Set on Server Side
Configure on server side. See Listing 13‑19, where the request of mysvc1 is set as STRING and the response of mysvc1 is a VIEW32 mystruct1.
Listing 13‑19 Configure on Server Side
...
struct mystruct1* rsp;
int tpsvrinit(int argc, char *argv[])
{
rsp = tpalloc("VIEW32", "mystruct1", sizeof(struct mystruct1));
}
...
void mysvc1(TPSVCINFO *rqst)
{
int ret = 0;
/*rqst->data is the name, getrsp will get data from the database and store into rsp*/
ret = getrsp(rqst->data, rsp);
if(ret < 0){
tpreturn(TPFAIL, 0, NULL, 0L, 0);
}
tpreturn(TPSUCCESS, 0, rsp, 0L, 0);
}
...
 
Sample: Set on Client Side
Assume a data file is like this:
Listing 13‑20 Data File Example
...
Scott
Mike
Andy
Scott
Ben
Brian
Scott
Clark
...
 
Set on your client set like Listing 13‑21.
At the first time where Scott is taken as the request, mysvc1 is invoked and the response is sent back and the response is cached into Oracle Tuxedo cache tc1 with a key Scott. As long as the data in the cache tc1 is not expired, all following requests for Scott to service mysvc1 will get response from the cache tc1 instead of invoking the service itself.
Listing 13‑21 Set on Client Set
...
struct mystruct1* rsp;
char* req;
int main(int argc, char *argv[])
{
int ret;
long olen = 0;
rsp = tpalloc("VIEW32", "mystruct1", sizeof(struct mystruct1));
req = tpalloc("STRING", NULL, 32);
/*get name from the data file*/
while(getname(req) == 0){
tpcall("mysvc1",req, 0, &rsp, &olen,0);
}
}
...
 
Propagating Execution Context ID (ECID) to Oracle Coherence
Oracle Coherence can use the Execution Context ID (ECID) in its logs. This globally unique ID can be attached to requests between Oracle components. ECID allows you to track log messages pertaining to the same request when multiple requests are processed in parallel. Oracle Coherence logs will include ECID only if you already have an activated ECID prior to calling Oracle Coherence operations. ECID may be passed from another component or obtained in the client code.
Working as a client of Oracle Coherence, Oracle Tuxedo TDC enables you to propagate ECID to Oracle Coherence.
Enabling ECID
Oracle Tuxedo has two flags which you can add to OPTIONS in UBBCONFIG to control ECID.
Indicates that the ECID (Execution Context Identifier) creation function is enabled. In this case, boundary nodes (including Native/WS/Jolt clients and domain gateways) can generate the ECID.
If the identifier ECID_USERLOG is set and the ECID is not a null string, ECID will be appended to the userlog.
See Oracle Coherence documentation for instructions.
Enabling ECID for TDC
Prepare tangosol-coherence-override.xml in ${APPDIR}/config. More specifically,
<destination> element is used to configure path and file name for emitting log messages to a file. The specified path must already exist.
Add ecid into < message-format > element to enable ECID.
<severity-level> element can be used to change log level.
Listing 13‑22  
<?xml version='1.0'?>
<coherence xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://xmlns.oracle.com/coherence/coherence-operational-config"
xsi:schemaLocation="http://xmlns.oracle.com/coherence/coherence-operational-config coherence-operational-config.xsd">
<cluster-config>
<member-identity>
<cluster-name system-property="tangosol.coherence.cluster">coherence_tux</cluster-name>
</member-identity>
<unicast-listener>
<address system-property="tangosol.coherence.localhost">localhost</address>
<port system-property="tangosol.coherence.localport">51687</port>
</unicast-listener>
<multicast-listener>
<port system-property="tangosol.coherence.clusterport">51697</port>
</multicast-listener>
</cluster-config>
 
<logging-config>
<destination system-property="tangosol.coherence.log">/tmp/coherence.log</destination>
<severity-level system-property="tangosol.coherence.log.level">9</severity-level>
<message-format>{date}/{uptime} {product} ecid={ecid} {version} &lt;{level}&gt;(thread={thread},member={member}):{text}</message-format>
</logging-config>
</coherence>
 
 
Oracle Tuxedo Distributed Caching (TDC) Related ATMI APIs
 
tpgetcache(3c)
Name
tpgetcache - Get an Oracle Tuxedo Cache handle according to the configuration
Synopsis
#include "atmi.h"
TCACHE* tpgetcache(const char* name);
Description
tpgetcache(3c) gets an Oracle Tuxedo cache handle according to Oracle Tuxedo cache name, which indicates the name of Oracle Tuxedo cache to be retrieved. The name must be 78 characters or less in length. tpgetcache(3c) is a thread-level API. The return handle TCACHE can only be used in the same thread.
Return Values
Upon success, tpgetcache(3c) returns a handle typed TCACHE while is an internal structure.
Upon failure, tpgetcache(3c) returns NULL and sets tperrno to indicate the error condition. If a call fails with a particular tperrno value, a subsequent call to tperrordetail(3c), with no intermediate ATMI calls, may provide more detailed information about the generated error. Refer to the tperrordetail(3c) reference page for more information.
Errors
[TPEINVAL]
Invalid arguments were given (for example, conf is NULL).
[TPENOENT]
The requested cache does not exist.
[TPETIME]
This error code indicates that a timeout has occurred
[TPESYSTEM]
An Oracle Tuxedo system error has occurred. The exact nature of the error is added to the ULOG.
[TPEOS]
An operating system error has occurred.
[TPESVCFAIL]
The Oracle Tuxedo cache server meets an error. tpurcode contains the exact error value. The possible values of tpurcode are list below:
TDC_ERR_CACHE_NOTEXIST
The error code indicates the requested Oracle Tuxedo cache does not exist.
TDC_ERR_CACHE_UNAVAIL
The error code indicates the requested Oracle Tuxedo cache is unavailable.
TDC_ERR_CACHENAME_INVALID
The error code indicates the requested Oracle Tuxedo cache is invalid.
tpcacheput(3c)
Name
tpcacheput - put an Oracle Tuxedo typed buffer into a cache, associating that buffer with a key
Synopsis
#include "atmi.h"
int tpcacheput(TCACHE* tc, char* key, char* data, long len, long flags);
Description
tpcacheput(3c) puts an Oracle Tuxedo typed buffer into a cache, associating that buffer with a key. tc is returned by tpgetcache(3c). data points to the tuxedo typed buffer allocated by tpalloc(3c). len is the length of the data. If the type of the data does not require a length to be specified (for example, an FML fielded buffer), len is ignored (and may be 0). flags is reserved and must be 0L.
Return Values
Upon success, tpcacheput(3c) returns 0.
Upon failure, tpcacheput(3c) returns -1 and sets tperrno to indicate the error condition. If a call fails with a particular tperrno value, a subsequent call to tperrordetail(3c), with no intermediate ATMI calls, may provide more detailed information about the generated error. Refer to the tperrordetail(3c) reference page for more information.
Errors
[TPEINVAL]
Invalid arguments were given.
[TPENOENT]
The requested cache does not exist.
[TPETIME]
This error code indicates that a timeout has occurred
[TPESYSTEM]
An Oracle Tuxedo system error has occurred. The exact nature of the error is added to the ULOG.
[TPEOS]
An operating system error has occurred.
[TPESVCFAIL]
The Oracle Tuxedo cache server meets an error. tpurcode contains the exact error value. The possible values of tpurcode are list below:
TDC_ERR_CACHE_NOTEXIST
The error code indicates the requested Oracle Tuxedo cache does not exist.
TDC_ERR_CACHE_UNAVAIL
The error code indicates the requested Oracle Tuxedo cache is unavailable.
TDC_ERR_CACHENAME_INVALID
The error code indicates the requested Oracle Tuxedo cache is invalid.
tpcacheget(3c)
Name
tpcacheget - get the Oracle Tuxedo typed buffer associated with the key from a cache
Synopsis
#include "atmi.h"
int tpcacheget(TCACHE* tc, char* key, char** odata, long* olen, long flags);
Description
tpcacheget(3c) gets the Oracle Tuxedo typed buffer associated with the key from a cache. tc is returned by tpgetcache(3c). odata is the address of a pointer to the buffer where the data of the key is read into. It must point to a buffer originally allocated by tpalloc(3c). olen points to the length of the data. flags is reserved and must be 0L.
Return Values
Upon success, tpcacheget(3c) returns 0.
Upon failure, tpcacheget(3c) returns -1 and sets tperrno to indicate the error condition. If a call fails with a particular tperrno value, a subsequent call to tperrordetail(3c), with no intermediate ATMI calls, may provide more detailed information about the generated error. Refer to the tperrordetail(3c) reference page for more information.
Errors
[TPEINVAL]
Invalid arguments were given.
[TPENOENT]
The requested cache does not exist.
[TPETIME]
This error code indicates that a timeout has occurred.
[TPESYSTEM]
An Oracle Tuxedo system error has occurred. The exact nature of the error is added to the ULOG.
[TPEOS]
An operating system error has occurred.
[TPESVCFAIL]
The Oracle Tuxedo cache server meets an error. tpurcode contains the exact error value. The possible values of tpurcode are list below:
TDC_ERR_CACHE_NOTEXIST
The error code indicates the requested Oracle Tuxedo cache does not exist.
TDC_ERR_CACHE_UNAVAIL
The error code indicates the requested Oracle Tuxedo cache is unavailable.
TDC_ERR_CACHENAME_INVALID
The error code indicates the requested Oracle Tuxedo cache is invalid.
TDC_ERR_KEY_NOTEXIST
The error code indicates the requested entry does not exist according to the specified key.
tpcacheremove(3c)
Name
tpcacheremove - remove the cache entry associated with the parameter key from a cache
Synopsis
#include "atmi.h"
int tpcacheremove(TCACHE* tc, char* key, long flags);
Description
tpcacheremove(3c) removes the cache entry associated with the parameter key from a cache. tc is returned by tpgetcache(3c). flags is reserved and must be 0L.
Return Values
Upon success, tpcacheremove(3c) returns 0.
Upon failure, tpcacheremove(3c) returns -1 and sets tperrno to indicate the error condition. If a call fails with a particular tperrno value, a subsequent call to tperrordetail(3c), with no intermediate ATMI calls, may provide more detailed information about the generated error. Refer to the tperrordetail(3c) reference page for more information.
Errors
[TPEINVAL]
Invalid arguments were given.
[TPENOENT]
The requested cache does not exist.
[TPETIME]
This error code indicates that a timeout has occurred.
[TPESYSTEM]
An Oracle Tuxedo system error has occurred. The exact nature of the error is added to the ULOG.
[TPEOS]
An operating system error has occurred.
[TPESVCFAIL]
The Oracle Tuxedo cache server meets an error. tpurcode contains the exact error value. The possible values of tpurcode are list below:
TDC_ERR_CACHE_NOTEXIST
The error code indicates the requested Oracle Tuxedo cache does not exist.
TDC_ERR_CACHE_UNAVAIL
The error code indicates the requested Oracle Tuxedo cache is unavailable.
TDC_ERR_CACHENAME_INVALID
The error code indicates the requested Oracle Tuxedo cache is invalid.
tpcachemremove(3c)
Name
tpcachemremove - remove cache entries associated with the parameter keyarray from a cache
Synopsis
#include "atmi.h"
int tpcachemremove(TCACHE* tc, char* keyarray[], int size, long flags);
Description
tpcachemremove(3c) removes cache entries associated with the parameter keyarray from a cache. tc is returned by tpgetcache(3c). keyarray is an array of keys to be removed. size is the size of the keyarray. flags is reserved and must be 0L.
Return Values
Upon success, tpcachemremove(3c) returns 0.
Upon failure, tpcachemremove(3c) returns -1 and sets tperrno to indicate the error condition. If a call fails with a particular tperrno value, a subsequent call to tperrordetail(3c), with no intermediate ATMI calls, may provide more detailed information about the generated error. Refer to the tperrordetail(3c) reference page for more information.
Errors
[TPEINVAL]
Invalid arguments were given.
[TPENOENT]
The requested cache does not exist.
[TPETIME]
This error code indicates that a timeout has occurred
[TPESYSTEM]
An Oracle Tuxedo system error has occurred. The exact nature of the error is added to the ULOG.
[TPEOS]
An operating system error has occurred.
[TPESVCFAIL]
The Oracle Tuxedo cache server meets an error. tpurcode contains the exact error value. The possible values of tpurcode are list below:
TDC_ERR_CACHE_NOTEXIST
The error code indicates the requested Oracle Tuxedo cache does not exist.
TDC_ERR_CACHE_UNAVAIL
The error code indicates the requested Oracle Tuxedo cache is unavailable.
TDC_ERR_CACHENAME_INVALID
The error code indicates the requested Oracle Tuxedo cache is invalid.
tpcacheremoveall(3c)
Name
tpcacheremoveall - remove all cache entries from a cache
Synopsis
#include "atmi.h"
int tpcacheremoveall(TCACHE* tc, long flags);
Description
tpcacheremoveall(3c) removes all entries from a cache. tc is returned by tpgetcache(3c). flags is reserved and must be 0L.
Return Values
Upon success, tpcacheremoveall(3c) returns 0.
Upon failure, tpcacheremoveall(3c) returns -1 and sets tperrno to indicate the error condition. If a call fails with a particular tperrno value, a subsequent call to tperrordetail(3c), with no intermediate ATMI calls, may provide more detailed information about the generated error. Refer to the tperrordetail(3c) reference page for more information.
Errors
[TPEINVAL]
Invalid arguments were given.
[TPENOENT]
The requested cache does not exist.
[TPETIME]
This error code indicates that a timeout has occurred.
[TPESYSTEM]
An Oracle Tuxedo system error has occurred. The exact nature of the error is added to the ULOG.
[TPEOS]
An operating system error has occurred.
[TPESVCFAIL]
The Oracle Tuxedo cache server meets an error. tpurcode contains the exact error value. The possible values of tpurcode are list below:
TDC_ERR_CACHE_NOTEXIST
The error code indicates the requested Oracle Tuxedo cache does not exist.
TDC_ERR_CACHE_UNAVAIL
The error code indicates the requested Oracle Tuxedo cache is unavailable.
TDC_ERR_CACHENAME_INVALID
The error code indicates the requested Oracle Tuxedo cache is invalid.
Oracle Tuxedo Distributed Caching (TDC) Property File Properties
 
Oracle Tuxedo TDC property file is a file in a simple line-oriented format.
Properties are processed in terms of lines. There are two kinds of line, natural lines and logical lines.
A natural line is defined as a line of characters that is terminated either by a set of line terminator characters (\\n or \\r or \\r\\n) or by the end of the stream. A natural line may be either a blank line, a comment line, or hold all or some of a key-element pair.
A logical line holds all the data of a key-element pair, which may be spread out across several adjacent natural lines by escaping the line terminator sequence with a backslash character \\.
A natural line that contains only white space characters is considered blank and is ignored. A comment line has an ASCII '#' or '!' as its first non-white space character; the key contains all of the characters in the line starting with the first non-white space character and up to, but not including, the first unescaped '=', ':'. Any white space after the key is skipped; if the first non-white space character after the key is '=' or ':', then it is ignored and any white space characters after it are also skipped. All remaining characters on the line become part of the associated element string; if there are no remaining characters, the element is the empty string "".
If there are several properties with the same key, the last property of them will be used.
Table 13‑2 lists the supported TDC property file properties.
 
yes (all caching data must be encoded)
no (default)
This value can be overridden by cache.options.encode.[cachename].
yes indicates all caching data in Oracle Tuxedo cache [cachename] must be encoded. It should be enabled when caching users are located in machines that have different data representation.
If this property is not set, options.encoding value is used.
Note:
[cachename] must be 78 characters or less in length.
Oracle Tuxedo Distributed Caching (TDC) Related UBBCONFIG Parameters
UBBCONFIG SERVICES Section
 
The string_value should be the CACHING_CRITERIA_NAME defined in the CACHING section. You must specify this parameter; otherwise, service caching will not be enabled. The string_value must be 127 characters or less in length.
UBBCONFIG CACHING Section
 
CACHING_CRITERIA_NAME (string_value) is the name assigned to the CACHING parameter for a particular service entry in the SERVICES section. CACHING_CRITERIA_NAME must be 127 characters or less in length.
Specifies the name of Oracle Tuxedo cache to be used. string_value must be 78 characters or less in length.
Specifies how to compose the key associating the cached data. string_value must be 127 characters or less in length.
This parameter is optional. If not specified, the key is generated as a combination of the service name and the serialized user data in the request. string_value can import the built-in variables to compose key by $. The variable request indicates to use part of or total user data in the request.
For example, mykey_$request indicates the key's format is mykey_servicename_[user data in request].
KEY_BUFTYPE and KEY_FIELD parameters can help to specify which part of the user data will be used.
The type must be one of the following: STRING, CARRAY, FML, FML32, XML, VIEW, VIEW32, RECORD, MBSTRING, X_C_TYPE, or X_COMMON. No subtypes can be specified for types STRING, CARRAY, FML, FML32, MBSTRING, or XML. Subtypes are required for type VIEW, VIEW32, RECORD, X_C_TYPE, and X_COMMON (* is not allowed). Subtype name should not contain semicolon, colon, comma, or asterisk characters. Duplicate type/subtype pairs cannot be specified for the same caching criteria name; more than one caching entry can have the same criteria name as long as the type/subtype pairs are unique. If multiple buffer types are specified for a single caching entry, the data types of the caching field for each buffer type must be the same.
STRING is used if this parameter is not specified.
This parameter is ignored if KEY is not set to request.
Each field can be an XML element, element attribute, or field name in an FML field table (using FLDTBLDIR and FIELDTBLS environment variables, or FLDTBLDIR32 and FIELDTBLS32 environment variables), or an FML view table (using VIEWDIR and VIEWFILES environment variables, or VIEWDIR32 and VIEWFILES32 environment variables). This information is used to get the associated field value for service caching when sending a message.
If KEY_BUFTYPE is set to STRING or CARRAY, define the field with the following syntax:
Index1 indicates the beginning index of the field in the buffer and index2 indicates the ending index of the field. The whole buffer is taken as the key if this parameter is not defined. The index should be set from 1.
This parameter is ignored if KEYBUFTYPE is not set or KEY is not set to request.
Oracle Tuxedo Distributed Caching (TDC) Related MIB Attributes
T_SERVICE Class Definition
 
TA_CACHING
This T_SERVICE object indicates the caching criteria name. Any updates on this attribute will be reflected in all associated T_SVCGRP objects.
T_CACHING Class Definition
This T_CACHING class represents configuration attributes of caching specifications for an application. These attribute values identify and characterize application caching criteria (such as buffer types, field names and caching definitions).
 
Notes:
(k) GET key field
(*) GET/SET key, one or more required for SET operations
The specified u (uniqueness) permission means aht the combination of TA_CACHING_NAME and TA_CACHING_KEY_BUFTYPE must be unique.
TA_CACHING_NAME: string[1..127]
Specifies the caching criteria name.
TA_CACHING_CACHENAME: string[1..78]
Specifies the name of the Oracle Tuxedo cache to be used.
TA_CACHING_KEY: string[0..127]
Specifies how to compose the key associating the cached data.
TA_CACHING_KEY_BUFTYPE: string[0..255]
Specifies a list of types and subtypes of data buffers for which this caching entry is valid to use to generate the key. This parameter can be up to 255 characters in length and a maximum of 32 type/subtype combinations.
The type must be one of the following:
STRING, CARRAY, FML, FML32, XML, VIEW, VIEW32, RECORD, MBSTRING, X_C_TYPE, or X_COMMON. No subtypes can be specified for types STRING, CARRAY, FML, FML32, MBSTRING, or XML. Subtypes are required for type VIEW, VIEW32, RECORD, X_C_TYPE, and X_COMMON (* is not allowed). Subtype name should not contain semicolon, colon, comma, or asterisk characters. Duplicate type/subtype pairs cannot be specified for the same routing caching criteria name; more than one routing caching entry can have the same criteria name as long as the type/subtype pairs are unique.
If multiple buffer types are specified for a single caching entry, the data types of the caching field for each buffer type must be the same.
TA_CACHING_KEY_FIELD: string[0..255]
Specifies the name of the fields in the buffer used to generate the key. It must be 255 characters or less and a maximum of 8 fields are allowed.
Each field can be an XML element, element attribute, or field name in an FML field table (using
FLDTBLDIR and FIELDTBLS environment variables, or FLDTBLDIR32 and FIELDTBLS32 environment variables), or an FML view table (using VIEWDIR and VIEWFILES environment variables, or VIEWDIR32 and VIEWFILES32 environment variables). This information is used to get the associated field value for service caching when sending a message.
For XML element content or element attribute in the XML buffer, define the name of the field with the following syntax:
root_element[/child_element][/child_element][/. . .][/@attribute_name]
The element name and attribute name combined may contain no more than 35 characters. Oracle Tuxedo recognizes only the first occurrence of a given element type when processing an XML buffer for service caching. XML strictly defines the set of characters that may be used in an attribute name. An attribute name must be a string consisting of a single letter, underscore, or colon followed by one or more name characters. Both element names and attribute names are case-sensitive. See XML documentation for more information.
If KEY_BUFTYPE is set to STRING or CARRAY, define the field with the following syntax:
[index1, index2]
Index1
indicates the beginning index of the field in the buffer and index2 indicates the ending index of the field. The whole buffer is taken as the key if this parameter is not defined. The index should be set from 1.
TA_STATE
GET: "{VALid}"
A GET operation will retrieve configuration information for the selected T_CACHING object(s). The following state indicates the meaning of a TA_STATE returned in response to a GET request. States not listed will not be returned.
VALid: T_CACHING object is defined. Note that this is the only valid state for this class.
SET: "{NEW | INValid}"
A SET operation will update configuration information for the selected T_CACHING object. The following states indicate the meaning of a TA_STATE set in a SET request. States not listed may not be set.
NEW: Create T_CACHING object for application. State change allowed only when in the INValid state. Successful return leaves the object in the VALid state.
INValid: Delete T_CACHING object for application. State change allowed only when in the VALid state. Successful return leaves the object in the INValid state.

Copyright © 1994, 2017, Oracle and/or its affiliates. All rights reserved.