Home > Coherence, Java, Oracle > How a member can use the existing cache in Coherence

How a member can use the existing cache in Coherence

In the previous post, I’ve explained how a member can join the existing cluster. Before read this post you should understand what was going on there.

At the final in previous post the new member joined the cluster. In this post I’ll explain how a member can use the existing cache ( customers cache which was created by the Eclipse project in this post )

Let’s go on from previous post.
Cluster Join
At the bottom of this screenshot you see that there is a prompt. To use existing cache ( this is the cache it has already created and it’s name is customers ) we type :

Map(?): cache customers

And it gives this output:

As you see the coherence was reading default cache configuration file instead of our cache config file. To force coherence to read our cache configuration file we should edit the JAVA_OPTS parameter in the coherence_join_cluster_test1.sh file ( it was created in previous post ) and add this clause by changing the real path :

-Dtangosol.coherence.cacheconfig=/home/oracle/labs/Coh_labs/workspace/CohExam_AFSungur/src/config/coherence-cache-config.xml -Dtangosol.pof.config=/home/oracle/labs/Coh_labs/workspace/CohExam_AFSungur/src/config/pof-config.xml

These xml files are under the src/config folder of the Eclipse project which has already been created.
And also you should change the classpath parameters because in the pof-config.xml file there is a class that should be specified in the classpath to use pof configuration.
To edit classpath parameters, edit the coherence_join_cluster_test1.sh file and go to the line which starts with JAVA_EXEC and change the -cp parameter as :

-cp "-classpath /home/oracle/labs/Coh_labs/workspace/CohExam_AFSungur/src/config:/labs/wls1211/coherence_3.7/lib/coherence.jar:/home/oracle/labs/Coh_labs/workspace/CohExam_AFSungur/bin" 

After editing coherence_join_cluster_test1.sh file save this file as coherence_join_cluster_test2.sh file. The coherence_join_cluster_test2.sh file is here:

Run this sh file.
Then type “cache customers” again in the prompt then you’ll see this output:

As shown in above loaded cache configuration file and pof configuration file is as we wanted. When querying the size of the cache it returns the correct answer:

Map (customers): size

Map (customers): 
  1. October 27, 2012 at 1:25 pm

    Since the admin of this site is working, no uncertainty very quickly it
    will be well-known, due to its feature contents.

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: