I’ve just published a post on the Official Coherence Blog explaining how to programatically use and interact with the Reporter in Coherence 12.1.3. The post shows how you can directly run reports from Java and retrieve the output by using a new JMX operation called runTabularReport.
We have posted 4 new videos on the Oracle Coherence YouTube Channel explaining and demonstrating some of the new features in the recent Coherence 12.1.3 release.
Worth a look to get you up to speed on some of the new features!
As part of the wider Oracle Fusion Middleware 12c (18.104.22.168.0) release, Coherence 12.1.3 was released overnight.
The new version of Coherence has a number of cool new features, some of which I’ve outlined below:
- New memcached protocol support allowing a Coherence cluster to be used as a replacement for memcached servers. This allows memcached clients using the binary protocol to switch to using a Coherence cluster for storage. See here for details.
- Coherence JVisualVM Plug-in, originally part of the Coherence Incubator, is now released as part of the Coherence distribution. See the JMX documentation for more information.
- Support has been added for JCache (JSR-107) implementation within Coherence. See the Oracle JCache documentation.
- You can now submit asyncrhnonous entry processors which is very cool. See the com.tangosol.util.processor.AsynchronousProcessor API in the documentation.
- The NameService has been enhanced to run on all cluster members. This means you can connect to any member to look up a proxy service.
- In Managed Coherence Servers in WebLogic Server, you can now designate a node as a management proxy, which allows easier connection to Coherence MBean servers.
There has also been various index rebuild performance enhancements on failover as well as more forward and backward compatibility for Coherence*Extend clients and servers.
Please see here for the full list of new features and changes.
Coherence*Web is a great feature which allows you to store your HTTP sessions in a Coherence Cluster. Doing this allows your to de-couple the HTTP sessions from your JVM’s that are running your web apps, (which can free up JVM memory) and take advantage of the RASP (Reliability, Availability, Scalability and Performance) capabilities of Coherence for storage.
With this separation you can also more easily scale and manage and your HTTP session tier as well as utilise the wide array of session management options that Coherence*Web provides.
What I’d like to show you here is how to configure Coherence*Web in WebLogic Server 12.1.2 and deploy a basic web application that utilises this.
For more detailed information on Coherence*Web and the options available, see http://docs.oracle.com/middleware/1212/coherence/COHCW/start.htm#sthref11.
For this example, I’m assuming you already have installed WebLogic Server 12.1.2 and created a domain with node manager running.
We are going to create two WebLogic Server Clusters and a Coherence cluster into which we shall place both WLS clusters. This will ensure that the manages servers in both WLS clusters are associated with a common set of Coherence caching services
- StorageTier – 2 Coherence managed servers storage1 and storage2. This tierÂ will hold the HTTP session data.
- ClientTier – 2 regular application managed servers client1 and client2 – We will deploy our application to this tier.
Typically you would have multiple servers in each tier and have a load balancer in front, but for this example, we will just 2 which is the minimus to demonstrate session fail-over.
Once you have your AdminServer and node manager up and running, login to the console to carry out the following steps.
1. Create a Coherence Cluster
- Navigate to Domain Structure then Environment and click on Coherence Clusters.
- Give it a name and leave the defaults. Do not target it the AdminServer as we will target it in a moment.
2. Create the WebLogic Clusters, place both your WLS clusters in the Coherence cluster and configure Coherence storage for each WLS cluster
- Navigate to the Clusters link and create 2 clusters. StorageTier and ClientTier.
- Leave the defaults as is.
- Select the StorageTier cluster and click on the Coherence tab.
- Select your newly created Coherence cluster and click Save.
- Select Coherence Web Local Storage Enabled to ensure any managed servers in this cluster store Coherence*Web session data.
- Click Save to continue.
- Select the ClientTier cluster and click on the Coherence tab.
- Select your newly created Coherence cluster and click Save.
- De-select Local Storage Enabled and click Save. We don’t want to actually store HTTP sessions in the client tier, but we want to be able to access them.
3. Create Managed Servers to populate each WLS cluster.
Note the managed servers added to each cluster will inherit their Coherence config form the cluster wide values which you set above. This means the Coherence managed servers added to the Storage Tier WLS cluster will be providing session storage while the Regular managed servers in the Client Tier WLS cluster will be coherence clients.
- Navigate to the Servers link
- Create a new managed server called client1 and assign it to the ClientTier as well as the machine you created. Set the listener port to 7005.
- Create a new managed server called storage1 and assign it to the StorageTier as well as the machine you created. Set the listener port to 7007.
- Clone storage1 and name it storage2 and change the listener port to 7009.
- Start up you managed servers.
Now we need to Deploy applications which will demonstrate session fail-over and management features we have configured
- ClusterJSP – (optional) shows session failover.
- Sample-applications (optional) shows session management features
Deployment 1 ClusterJSP
Deploy ClusterJSP as a directory deployment rather than a archive deployment. This will make modifications of the deployment descriptors easier. You can download the file required from here.
Deploy the Application
- Unzip clusterjsp-ear.zip into your WLS domain applications directory (…/user_projects/applications)
- In the Admin. Console navigate to the Deployments page.
- Click the Install button and navigate to the applications directory where you should find the clusterjsp-ear directory.
- Click the select button to the left of the folder and click the Next button at the bottom of the page.
- Leave Install as application selected and click Next.
- Select ClientTier cluster and click Next.
- Leave the defaults and click Finish.
Test the application
- In a browser access the clusterjsp with the following url: http://yourhostname:7003/clusterjsp
- Follow the instructions at the bottom of the displayed page.
- To access the page from the other server in the client tier cluster change the the port number in the browser and hit enter. Notice the session attribute and value which you had added are not present because we have not yet enabled Coherence*Web.
Enable Coherence*Web Session Storage
- Create a WLS deployment descriptor to enable Coherence*Web sessions by saving the text below into a new file called:
<?xml version="1.0"?> <weblogic-web-app xmlns="http://www.bea.com/ns/weblogic/weblogic-web-app" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.bea.com/ns/weblogic/weblogic-web-app http://www.bea.com/ns/weblogic/weblogic-web-app/1.0/weblogic-web-app.xsd"> <session-descriptor> <persistent-store-type>coherence-web</persistent-store-type> </session-descriptor> </weblogic-web-app>
- In the Admin. Console navigate to the Deployments page.
- Update the deployment by click the Select button next to the clusterjsp-ear application and click the Update button.
- Repeat your previous test. This time you should see your Session attributes are present regardless of which client tier server you access.
- Stop the servers one at a time in each tier and notice when the session data is no longer available.
Deployment 2 Large session sample-application
Next, deploy the sample-application.war (available from here) to just the ClientTier WebLogic Cluster.
The only step required to configure a web application to use Coherence*Web, select coherence-web as the persistence-store-type in WEB-INF/weblogic.xml as shown above. It’s that simple!
Next, run the application using the URL: http://your-ip-address:7005/sample-application and choose ‘Create Session’, then ‘Display Session’. This is only a simple application with no real bells and whistles, to show you how to enable Coherence*Web for a web application.
You can see the output displays something similar to the following, which shows that Coherence is being used as the HTTP session store provider.
class: class weblogic.servlet.internal.session.CoherenceWebSessionData sessionid: Vqi9nQtgCjpfO2F6FBHieVZV2vEmXfqF8Tyx6QDaQddqRhyKrFQM!502625314!1400916309965
The create.jsp file contains the following. Here we are just using the HTTP session and no Coherence specific code is used. You can experiment with the other links in the sample application.
<%@ page import="java.util.*"%> <% session = request.getSession(true); out.println("class: " + session.getClass() + "<br/>"); out.println("sessionid: " + session.getId()); HashMap m = new HashMap(); m.put("a", 1); m.put("b", 1); session.setAttribute("test", m); %>
Your web application is now using Coherence to store your HTTP sessions!
It’s very easy to scale out your HTTP session tier, just add another managed server to your StorageTier.
You can skip to the Conclusion below, or continue with the next section where I’ll show you how to install the Coherence JVisualVM Plug-in to view what’s going on under the covers.
Use the JVisualVM Plug-in from the Coherence Incubator Project to monitor the Coherence*Web session data
I’m using the Coherence JVisualVM Plug-in from the Coherence Incubator for viewing MBean information for the rest of this demo. You could just as well browse the MBean tree, but the Plug-in shows this in a nicer format.
For detailed information on how to install and connect jvisualVM to a WebLogic Server environment please see the Coherence Incubator site.
Install the Coherence VisualVM plugin brief steps
- Download the latest pre-built plug-in module (NBM) from search.maven.org and save it to a local directory.
- Start JVisualVM by running jvisualvm or jvisualvm.exe (for Windows) from the bin directory under your Java home.
- Choose Tools -> Plugins.
- Click on the ‘Downloads’ tab.
- Click ‘Add Plugin’ and choose the file coherence-jvisualvm-12.2.0.nbm (from the location where you saved above).
- Click ‘Install’ and follow the prompts to install.
Once installed, connect to either a remote or local JMX enabled Coherence cache server process using JMX
- Restart jvisualvm with the following command (I have used UNIX style backslash for line continuation. If you are on Windows then please ensure the command is on one line.)
$JAVA_HOME/bin/jvisualvm --cp:a \ $WL_HOME/server/lib/wljmxclient.jar:$WL_HOME/server/lib/weblogic.jar \ -J-Djmx.remote.protocol.provider.pkgs=weblogic.management.remote \ -J-Dcom.oracle.coherence.jvisualvm.disable.mbean.check=true
- To create a connection right-click on either ‘Local’ or ‘Remote’ under the ‘Applications’ tree. Use the following for the connection URI and enter the credentials for the WebLogic Server Admin: (the following should contain no spaces)
- Once you have opened the newly created connection you will see the ‘Coherence Tab’.
- For troubleshooting, see the Coherence Incubator site.
After connecting to the domain runtime mbean server, you should see the ‘Coherence’ tab displayed, select this tab and then the ‘Coherence*Web’ tab and you will see that there is a session that has been created.
If you then choose ‘Heavy Session’ in the sample web application, you will see the session overflow count go up as Coherence will store large attributes in a separate cache for optimised performance.
If you look at the ‘Caches’ tab, you will see the size of the session-storage and session-overflow caches are updated.
Lastly, I used JMeter to create a load script that called the create.jsp and heavy.jsp to create sessions. You can see from the screenshot below, that you are able to view the number of sessions created and any session-reaping, which is cleaning up of old sessions.
It may have seemed that we went though a few steps above, but I wanted to show the evidence of the HTTP sessions begin stored Coherence*Web. The high-level steps to setup Coherence*Web are pretty straight forward:
- In your WebLogic domain, create a Coherence Cluster.
- Create a Client WebLogic Server Cluster and managed servers for your web apps and associate with the Coherence cluster as storage-disabled.
- Create a Storage WebLogic Server Cluster and managed servers for your data tier. Make this storage-enabled and also check ‘Coherence Web Local Storage Enabled‘.
- Update your WEB-INF/weblogic.xml to use coherence-web as persistence-store-type.
- Deploy your application and you are away.
Finally I get the chance to attend a conference and not have to present!
YOW! West is on in Perth for the first time on May 13-14 and there are some great developer focussed topics. Lets help support this conference and get it back for next year.
There is still enough time to get tickets: See http://west.yowconference.com.au