In this post, we configure WebLogic and an in-memory data grid, such as Coherence and present scripts to start and stop the environment. We start with creating a Coherence Server (which will be our storage enabled node in the cluster). The steps to create a Coherence Server are provided here. When the server is created, click on the created server and subsequently on the server start, configuration tab, in order to set the class path and some JVM parameters. Enter the following properties:

  • Java Home: Specify the location of the JDK installation directory such that /bin/java exists, in our example we will use /home/weblogic/jrockit-jdk1.6.0_29-R28.2.2-4.1.0
  • Java Vendor: Oracle
  • Class Path: /home/weblogic/weblogic12.1.1/installation/coherence_3.7/lib/coherence.jar: /home/weblogic/weblogic12.1.1/installation/modules/features/weblogic.server.modules.coherence.server_12.1.1.0.jar: /home/weblogic/weblogic12.1.1/configuration/applications/base_domain/security/test.jar
  • Arguments: -jrockit -Xms256m -Xmx256m -XXkeepAreaRatio:25 -Xgc:pausetime -XpauseTarget:200m -XX:+UseCallProfiling -XX:+UseLargePagesForHeap -Dtangosol.coherence.mode=prod -Dtangosol.coherence.cacheconfig=security-cache-config.xml -Dtangosol.coherence.management=all -Dtangosol.coherence.management.remote=true

Above, we have specified the class path to included coherence.jar and weblogic.server.modules.coherence.server_12.1.1.0.jar, which are needed to make Coherence available. The test.jar contains our Coherence configuration and serializable classes. These are presented in the post JBoss RichFaces, Facelets and Coherence on WebLogic.

Note that the JVM parameters also included Coherence system settings, such as, -Dtangosol.coherence.mode=prod and -Dtangosol.coherence.cacheconfig=security-cache-config.xml. With the first one, we tell Coherence to run with production settings. The second one defines the cache configuration file to use. Unfortunately, the configuration provided in a Coherence override is not picked up.

<?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">SecurityCoherenceCluster</cluster-name>
        </member-identity>
        <unicast-listener>
            <well-known-addresses>
                <socket-address id="1">
                    <address>192.168.1.150</address>
                    <port>8088</port>
                </socket-address>
            </well-known-addresses>
        </unicast-listener>
    </cluster-config>
    <configurable-cache-factory-config>
        <class-name>com.tangosol.net.DefaultConfigurableCacheFactory</class-name>
        <init-params>
            <init-param>
                <param-type>java.lang.String</param-type>
                <param-value system-property="tangosol.coherence.cacheconfig">security-cache-config.xml</param-value>
            </init-param>
        </init-params>
    </configurable-cache-factory-config>
    <license-config>
        <license-mode system-property="tangosol.coherence.mode">prod</license-mode>
    </license-config>
</coherence>

But the well-known-address definition is (as we will shortly see when the server is started).

With the Coherence Server in place, something like the following should be present in the WebLogic configuration file (config.xml)

<coherence-server>
    <name>coherence-server1</name>
    <machine>machine1</machine>
    <coherence-cluster-system-resource xsi:nil="true"></coherence-cluster-system-resource>
    <unicast-listen-address>localhost</unicast-listen-address>
    <unicast-listen-port>8088</unicast-listen-port>
    <unicast-port-auto-adjust>true</unicast-port-auto-adjust>
    <coherence-server-start>
		<java-vendor>Oracle</java-vendor>
		<java-home>/home/weblogic/jrockit-jdk1.6.0_29-R28.2.2-4.1.0</java-home>
		<class-path>/home/weblogic/weblogic12.1.1/installation/coherence_3.7/lib/coherence.jar:/home/weblogic/weblogic12.1.1/installation/modules/features/weblogic.server.modules.coherence.server_12.1.1.0.jar:/home/weblogic/weblogic12.1.1/configuration/applications/base_domain/security/test.jar</class-path>
		<arguments>-jrockit -Xms256m -Xmx256m -XXkeepAreaRatio:25 -Xgc:pausetime -XpauseTarget:200m -XX:+UseCallProfiling -XX:+UseLargePagesForHeap -Dtangosol.coherence.mode=prod -Dtangosol.coherence.cacheconfig=security-cache-config.xml -Dtangosol.coherence.management=all -Dtangosol.coherence.management.remote=true</arguments>
    </coherence-server-start>
</coherence-server>

Before, we can start the Coherence Server, the node manager must be running (examples of stop and start scripts for the node manager can be found in the post WLST Starting and Stopping a WebLogic Environment). When the node manager is running, in the WebLogic admin console, click in the created server, click the control tab, select the Coherence Server and click start.

The output log is present in the ${DOMAIN_HOME}/servers_coherence/${COHERENCE_SERVER_NAME}/logs

<Jan 9, 2013 11:37:08 AM> <INFO> <NodeManager> <Starting Coherence server with command line: /home/weblogic/jrockit-jdk1.6.0_29-R28.2.2-4.1.0/bin/java -Dtangosol.coherence.member=coherence-server1 -Dtangosol.coherence.localport=8088 -Dtangosol.coherence.localhost=localhost -Djava.class.path=/home/weblogic/weblogic12.1.1/installation/coherence_3.7/lib/coherence.jar:/home/weblogic/weblogic12.1.1/installation/modules/features/weblogic.server.modules.coherence.server_12.1.1.0.jar:/home/weblogic/weblogic12.1.1/configuration/applications/base_domain/security/test.jar -jrockit -Xms256m -Xmx256m -XXkeepAreaRatio:25 -Xgc:pausetime -XpauseTarget:200m -XX:+UseCallProfiling -XX:+UseLargePagesForHeap -Dtangosol.coherence.mode=prod -Dtangosol.coherence.cacheconfig=security-cache-config.xml -Dtangosol.coherence.management=all -Dtangosol.coherence.management.remote=true -Dweblogic.RootDirectory=/home/weblogic/weblogic12.1.1/configuration/domains/base_domain weblogic.nodemanager.server.provider.WeblogicCacheServer >
<Jan 9, 2013 11:37:08 AM> <INFO> <NodeManager> <Working directory is '/home/weblogic/weblogic12.1.1/configuration/domains/base_domain'>
<Jan 9, 2013 11:37:08 AM> <INFO> <NodeManager> <Server output log file is '/home/weblogic/weblogic12.1.1/configuration/domains/base_domain/servers_coherence/coherence-server1/logs/coherence-server1.out'>
2013-01-09 11:37:09.756/1.432 Oracle Coherence 3.7.1.1 <Info> (thread=Main Thread, member=n/a): Loaded operational configuration from "jar:file:/home/weblogic/weblogic12.1.1/installation/coherence_3.7/lib/coherence.jar!/tangosol-coherence.xml"
2013-01-09 11:37:09.785/1.460 Oracle Coherence 3.7.1.1 <Info> (thread=Main Thread, member=n/a): Loaded operational overrides from "jar:file:/home/weblogic/weblogic12.1.1/installation/coherence_3.7/lib/coherence.jar!/tangosol-coherence-override-prod.xml"
2013-01-09 11:37:09.803/1.478 Oracle Coherence 3.7.1.1 <Info> (thread=Main Thread, member=n/a): Loaded operational overrides from "jar:file:/home/weblogic/weblogic12.1.1/configuration/applications/base_domain/security/test.jar!/tangosol-coherence-override.xml"
2013-01-09 11:37:09.809/1.484 Oracle Coherence 3.7.1.1 <D5> (thread=Main Thread, member=n/a): Optional configuration override "/custom-mbeans.xml" is not specified

Oracle Coherence Version 3.7.1.1 Build 28901
 Grid Edition: Production mode
Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.

2013-01-09 11:37:10.679/2.354 Oracle Coherence GE 3.7.1.1 <Info> (thread=Main Thread, member=n/a): Loaded Reporter configuration from "jar:file:/home/weblogic/weblogic12.1.1/installation/coherence_3.7/lib/coherence.jar!/reports/report-group.xml"
2013-01-09 11:37:11.456/3.131 Oracle Coherence GE 3.7.1.1 <D4> (thread=Main Thread, member=n/a): TCMP bound to /192.168.1.150:8088 using SystemSocketProvider
2013-01-09 11:37:42.014/33.689 Oracle Coherence GE 3.7.1.1 <Info> (thread=Cluster, member=n/a): Created a new cluster "SecurityCoherenceCluster" with Member(Id=1, Timestamp=2013-01-09 11:37:11.526, Address=192.168.1.150:8088, MachineId=65081, Location=site:,machine:middleware-magic,process:5877,member:coherence-server1, Role=WeblogicWeblogicCacheServer, Edition=Grid Edition, Mode=Production, CpuCount=4, SocketCount=1) UID=0xC0A801960000013C1EE295E6FE391F98
2013-01-09 11:37:42.065/33.740 Oracle Coherence GE 3.7.1.1 <Info> (thread=Main Thread, member=n/a): Started cluster Name=SecurityCoherenceCluster

WellKnownAddressList(Size=1,
  WKA{Address=192.168.1.150, Port=8088}
  )

MasterMemberSet(
  ThisMember=Member(Id=1, Timestamp=2013-01-09 11:37:11.526, Address=192.168.1.150:8088, MachineId=65081, Location=site:,machine:middleware-magic,process:5877,member:coherence-server1, Role=WeblogicWeblogicCacheServer)
  OldestMember=Member(Id=1, Timestamp=2013-01-09 11:37:11.526, Address=192.168.1.150:8088, MachineId=65081, Location=site:,machine:middleware-magic,process:5877,member:coherence-server1, Role=WeblogicWeblogicCacheServer)
  ActualMemberSet=MemberSet(Size=1
    Member(Id=1, Timestamp=2013-01-09 11:37:11.526, Address=192.168.1.150:8088, MachineId=65081, Location=site:,machine:middleware-magic,process:5877,member:coherence-server1, Role=WeblogicWeblogicCacheServer)
    )
  MemberId|ServiceVersion|ServiceJoined|MemberState
    1|3.7.1|2013-01-09 11:37:42.019|JOINED
  RecycleMillis=1200000
  RecycleSet=MemberSet(Size=0
    )
  )

TcpRing{Connections=[]}
IpMonitor{AddressListSize=0}

2013-01-09 11:37:42.195/33.870 Oracle Coherence GE 3.7.1.1 <D5> (thread=Invocation:Management, member=1): Service Management joined the cluster with senior service member 1
2013-01-09 11:37:42.428/34.103 Oracle Coherence GE 3.7.1.1 <Info> (thread=DistributedCache, member=1): Loaded POF configuration from "jar:file:/home/weblogic/weblogic12.1.1/configuration/applications/base_domain/security/test.jar!/security-pof-config.xml"
2013-01-09 11:37:42.436/34.111 Oracle Coherence GE 3.7.1.1 <Info> (thread=DistributedCache, member=1): Loaded included POF configuration from "jar:file:/home/weblogic/weblogic12.1.1/installation/coherence_3.7/lib/coherence.jar!/coherence-pof-config.xml"
2013-01-09 11:37:42.545/34.220 Oracle Coherence GE 3.7.1.1 <D5> (thread=DistributedCache, member=1): Service DistributedCache joined the cluster with senior service member 1
2013-01-09 11:37:42.627/34.302 Oracle Coherence GE 3.7.1.1 <Info> (thread=Main Thread, member=1):
Services
  (
  ClusterService{Name=Cluster, State=(SERVICE_STARTED, STATE_JOINED), Id=0, Version=3.7.1, OldestMemberId=1}
  InvocationService{Name=Management, State=(SERVICE_STARTED), Id=1, Version=3.1, OldestMemberId=1}
  PartitionedCache{Name=DistributedCache, State=(SERVICE_STARTED), LocalStorage=enabled, PartitionCount=257, BackupCount=1, AssignedPartitions=257, BackupPartitions=0}
  )

Started DefaultCacheServer...

The application (presented in the post JBoss RichFaces, Facelets and Coherence on WebLogic, which also includes details on how to create shared libraries) will be deployed on a WebLogic managed server with the following settings

<server>
    <name>security-server</name>
    <ssl>
		<enabled>false</enabled>
    </ssl>
    <machine>machine1</machine>
    <listen-port>8001</listen-port>
    <cluster xsi:nil="true"></cluster>
    <web-server>
		<web-server-log>
			<number-of-files-limited>false</number-of-files-limited>
		</web-server-log>
    </web-server>
    <listen-address>middleware-magic.com</listen-address>
    <server-start>
		<java-vendor>Oracle</java-vendor>
		<java-home>/home/weblogic/jrockit-jdk1.6.0_29-R28.2.2-4.1.0</java-home>
		<arguments>-jrockit -Xms512m -Xmx512m -Xns128m -XXkeepAreaRatio:25 -Xgc:pausetime -XpauseTarget:200ms -XX:+UseCallProfiling -XX:+UseLargePagesForHeap -Dtangosol.coherence.mode=prod -Dtangosol.coherence.distributed.localstorage=false</arguments>
    </server-start>
</server>

Note that this server has the storage disabled (-Dtangosol.coherence.distributed.localstorage=false). The cache configuration is set here by using a Coherence override as was present above. When the WebLogic server and the application are started, the following is observed in the Coherence Server logging

2013-01-09 11:44:19.563/431.240 Oracle Coherence GE 3.7.1.1 <D5> (thread=Cluster, member=1): Member(Id=2, Timestamp=2013-01-09 11:44:19.326, Address=192.168.1.150:8090, MachineId=65081, Location=site:,machine:middleware-magic,process:3852, Role=WeblogicServer) joined Cluster with senior member 1
2013-01-09 11:44:19.658/431.334 Oracle Coherence GE 3.7.1.1 <D5> (thread=Cluster, member=1): Member 2 joined Service Management with senior member 1
2013-01-09 11:44:19.710/431.385 Oracle Coherence GE 3.7.1.1 <D5> (thread=Cluster, member=1): Member 2 joined Service DistributedCache with senior member 1

To monitor the Coherence cache server, we have added -Dtangosol.coherence.management=all and -Dtangosol.coherence.management.remote=true as JVM parameters. By using an MBean browser (for example, JRockit Mission Control), we get an idea what is going on in the server

In order to start and stop the Coherence cache servers we can use WLST. The CoherenceServerLifeCycleRuntimeMBean provides methods that transition servers from one state to another. This class is instantiated only on the Admin Server, but we can use it to transition the states of all managed Coherence cache servers. To start Coherence cache servers, we must first configure a Node Manager on each Coherence cache server’s host machine. In order to start Coherence cache servers we can use the following script:

import socket;
admin_server_listen_address = socket.gethostname();
admin_server_url = 't3://' + admin_server_listen_address + ':' + admin_server_listen_port;

print 'CONNECT TO ADMIN SERVER';

connect(admin_username, admin_password, admin_server_url);

domainRuntime();
coherence_server_lifecycles = cmo.getCoherenceServerLifeCycleRuntimes();

for coherence_server_lifecycle in coherence_server_lifecycles:
	if (coherence_server_lifecycle.getState() != 'RUNNING'):
		print 'START COHERENCE SERVER ' + coherence_server_lifecycle.getName();
		task = coherence_server_lifecycle.start();
		while (task.isRunning() == 1):
			print 'STARTING COHERENCE SERVER ' + coherence_server_lifecycle.getName();
			java.lang.Thread.sleep(2000);

print 'DISCONNECT FROM THE ADMIN SERVER';
disconnect();

and the following bash script

#!/bin/sh

# SCRIPT_PATH=$(dirname $0)
SCRIPT=$(readlink -f $0)
SCRIPT_PATH=$(dirname $SCRIPT)

. ${SCRIPT_PATH}/SetEnvironment.sh

${WL_HOME}/common/bin/wlst.sh -loadProperties ${SCRIPT_PATH}/environment.properties ${SCRIPT_PATH}/startCoherence.py

When this script is run the following output is observed

[weblogic@middleware-magic scripts]$ ./CoherenceStartService.sh 

CLASSPATH=/home/weblogic/weblogic12.1.1/installation/patch_wls1211/profiles/default/sys_manifest_classpath/weblogic_patch.jar:/home/weblogic/weblogic12.1.1/installation/patch_ocp371/profiles/default/sys_manifest_classpath/weblogic_patch.jar:/home/weblogic/jrockit-jdk1.6.0_29-R28.2.2-4.1.0/lib/tools.jar:/home/weblogic/weblogic12.1.1/installation/wlserver_12.1/server/lib/weblogic_sp.jar:/home/weblogic/weblogic12.1.1/installation/wlserver_12.1/server/lib/weblogic.jar:/home/weblogic/weblogic12.1.1/installation/modules/features/weblogic.server.modules_12.1.1.0.jar:/home/weblogic/weblogic12.1.1/installation/wlserver_12.1/server/lib/webservices.jar:/home/weblogic/weblogic12.1.1/installation/modules/org.apache.ant_1.7.1/lib/ant-all.jar:/home/weblogic/weblogic12.1.1/installation/modules/net.sf.antcontrib_1.1.0.0_1-0b2/lib/ant-contrib.jar::/home/weblogic/weblogic12.1.1/installation/utils/config/10.3/config-launch.jar::/home/weblogic/weblogic12.1.1/installation/wlserver_12.1/common/derby/lib/derbynet.jar:/home/weblogic/weblogic12.1.1/installation/wlserver_12.1/common/derby/lib/derbyclient.jar:/home/weblogic/weblogic12.1.1/installation/wlserver_12.1/common/derby/lib/derbytools.jar::

Initializing WebLogic Scripting Tool (WLST) ...

Welcome to WebLogic Server Administration Scripting Shell

Type help() for help on available commands

CONNECT TO ADMIN SERVER
Connecting to t3://middleware-magic.com:7001 with userid weblogic ...
Successfully connected to Admin Server 'AdminServer' that belongs to domain 'base_domain'.

Warning: An insecure protocol was used to connect to the
server. To ensure on-the-wire security, the SSL port or
Admin port should be used instead.

Location changed to domainRuntime tree. This is a read-only tree with DomainMBean as the root.
For more help, use help(domainRuntime)

START COHERENCE SERVER coherence-server1
STARTING COHERENCE SERVER coherence-server1
STARTING COHERENCE SERVER coherence-server1
STARTING COHERENCE SERVER coherence-server1
STARTING COHERENCE SERVER coherence-server1
STARTING COHERENCE SERVER coherence-server1
STARTING COHERENCE SERVER coherence-server1
STARTING COHERENCE SERVER coherence-server1
STARTING COHERENCE SERVER coherence-server1
STARTING COHERENCE SERVER coherence-server1
STARTING COHERENCE SERVER coherence-server1
STARTING COHERENCE SERVER coherence-server1
STARTING COHERENCE SERVER coherence-server1
STARTING COHERENCE SERVER coherence-server1
STARTING COHERENCE SERVER coherence-server1
STARTING COHERENCE SERVER coherence-server1
STARTING COHERENCE SERVER coherence-server1
STARTING COHERENCE SERVER coherence-server1
STARTING COHERENCE SERVER coherence-server1
DISCONNECT FROM THE ADMIN SERVER
Disconnected from weblogic server: AdminServer

To stop Coherence cache servers we can use

import socket;
admin_server_listen_address = socket.gethostname();
admin_server_url = 't3://' + admin_server_listen_address + ':' + admin_server_listen_port;

print 'CONNECT TO ADMIN SERVER';

connect(admin_username, admin_password, admin_server_url);

domainRuntime();
coherence_server_lifecycles = cmo.getCoherenceServerLifeCycleRuntimes();

for coherence_server_lifecycle in coherence_server_lifecycles:
	if (coherence_server_lifecycle.getState() == 'RUNNING'):
		print 'SHUT DOWN COHERENCE SERVER ' + coherence_server_lifecycle.getName();
		task = coherence_server_lifecycle.forceShutdown();
		while (task.isRunning() == 1):
			print 'SHUTTING DOWN COHERENCE SERVER ' + coherence_server_lifecycle.getName();
			java.lang.Thread.sleep(2000);

print 'DISCONNECT FROM THE ADMIN SERVER';
disconnect();

with the following bash script

#!/bin/sh

# SCRIPT_PATH=$(dirname $0)
SCRIPT=$(readlink -f $0)
SCRIPT_PATH=$(dirname $SCRIPT)

. ${SCRIPT_PATH}/SetEnvironment.sh

${WL_HOME}/common/bin/wlst.sh -loadProperties ${SCRIPT_PATH}/environment.properties ${SCRIPT_PATH}/stopCoherence.py

When this script is run the following output is observed

[weblogic@middleware-magic scripts]$ ./CoherenceStopService.sh 

CLASSPATH=/home/weblogic/weblogic12.1.1/installation/patch_wls1211/profiles/default/sys_manifest_classpath/weblogic_patch.jar:/home/weblogic/weblogic12.1.1/installation/patch_ocp371/profiles/default/sys_manifest_classpath/weblogic_patch.jar:/home/weblogic/jrockit-jdk1.6.0_29-R28.2.2-4.1.0/lib/tools.jar:/home/weblogic/weblogic12.1.1/installation/wlserver_12.1/server/lib/weblogic_sp.jar:/home/weblogic/weblogic12.1.1/installation/wlserver_12.1/server/lib/weblogic.jar:/home/weblogic/weblogic12.1.1/installation/modules/features/weblogic.server.modules_12.1.1.0.jar:/home/weblogic/weblogic12.1.1/installation/wlserver_12.1/server/lib/webservices.jar:/home/weblogic/weblogic12.1.1/installation/modules/org.apache.ant_1.7.1/lib/ant-all.jar:/home/weblogic/weblogic12.1.1/installation/modules/net.sf.antcontrib_1.1.0.0_1-0b2/lib/ant-contrib.jar::/home/weblogic/weblogic12.1.1/installation/utils/config/10.3/config-launch.jar::/home/weblogic/weblogic12.1.1/installation/wlserver_12.1/common/derby/lib/derbynet.jar:/home/weblogic/weblogic12.1.1/installation/wlserver_12.1/common/derby/lib/derbyclient.jar:/home/weblogic/weblogic12.1.1/installation/wlserver_12.1/common/derby/lib/derbytools.jar::

Initializing WebLogic Scripting Tool (WLST) ...

Welcome to WebLogic Server Administration Scripting Shell

Type help() for help on available commands

CONNECT TO ADMIN SERVER
Connecting to t3://middleware-magic.com:7001 with userid weblogic ...
Successfully connected to Admin Server 'AdminServer' that belongs to domain 'base_domain'.

Warning: An insecure protocol was used to connect to the
server. To ensure on-the-wire security, the SSL port or
Admin port should be used instead.

Location changed to domainRuntime tree. This is a read-only tree with DomainMBean as the root.
For more help, use help(domainRuntime)

SHUT DOWN COHERENCE SERVER coherence-server1
SHUTTING DOWN COHERENCE SERVER coherence-server1
DISCONNECT FROM THE ADMIN SERVER
Disconnected from weblogic server: AdminServer

This is certainly a step in the right direction to integrate data-grids with application servers. Some more information on where it is going have a look at the Coherence Roadmap, or what do you think about this one: Grid Archive.

References

[1] Using ActiveCache.