Skip Headers
Oracle® Coherence Tutorial for Oracle Coherence
Release 3.7.1

E22622-03
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Index
Index
Go to Feedback page
Contact Us

Go to previous page
Previous
Go to next page
Next
View PDF

1 Installing and Configuring Coherence

This chapter describes how to install and set up your environment for running Oracle Coherence Release 3.7.1 (Coherence).

Note:

This tutorial uses the Eclipse Helios 3.6.2 release with Oracle Enterprise Pack for Eclipse (OEPE) 11gR1 (11.1.1.7). For information about configuring Eclipse and OEPE for Coherence-based projects, see Chapter 2, "Installing and Configuring Eclipse and OEPE with Coherence"

The examples in this tutorial have been run with the 3.7 release of Coherence. Running the examples with the 3.7.1 release of Coherence will produce the same results.

You must have the privileges to install software and set system environment variables as the oracle user, an understanding of how to use a terminal window, including setting environment variables, and creating and moving between directories. You must have a working installation of Java SE (JDK) version 1.6 or higher. You must also be running one of the following Microsoft Windows operating systems: XP, Vista, 2000, 2003, or 2008.

This chapter contains the following sections:

1.1 Installing Coherence

To download and install Coherence:

  1. Download Coherence to your desktop.

    Coherence (Java edition) ships as a single zip file, typically called coherence-<version>.zip. You can download Coherence from the following URL:

    http://www.oracle.com/technology/products/coherence/index.html

  2. Extract the contents of the zip file to a folder named C:\oracle\product.

    The zip file contains the coherence folder with these subfolders:

    • bin, which contains command scripts

    • doc, which contains the product documentation

    • lib, which contains the required library files

1.2 Testing a Coherence Installation

In this exercise, you test whether your Coherence installation can cluster Java processes. This ensures that Coherence-based applications that ship with Coherence will run as expected. If Coherence is not capable of clustering on a single machine, then you must reconfigure your network and firewall settings.

To complete this exercise, you must have Oracle Coherence (Java Edition) Release 3.7.1 installed. See "Installing Coherence" for more information.

Coherence uses a variety of network addresses and ports to enable communication between clustered processes. If these addresses and ports are unavailable due to other applications using them, or because of a firewall, then Coherence may be unreliable, may fail to cluster, or may not work at all. By default, Coherence assumes that the network addresses and ports listed in Table 1-1 are available:

Table 1-1 Network Addresses and Ports Used by Coherence

Address / Port / Type Purpose

224.version / version / Multicast

Cluster member discovery and broadcast. The variable version represents the release version of Coherence. For example, the multicast address for the 3.7.0.0 release is 224.3.7.0. The port number also reflects the release version. For example, for the 3.7.0.0 release, the port number is 37000. Designing the address in this way ensures that different versions of Coherence do not cluster with each other by default.

localhost / 8088+ / Unicast

Interprocess communication between cluster members. (localhost is the local IP address and not the loop back address.)


Coherence ships with two simple command-line (shell-based) applications that can be used to determine whether Coherence operates correctly.

1.2.1 To Test a Coherence Installation—Main Steps

Follow these steps to test a Coherence Installation. The steps are described in detail in the following sections.

  1. Configure and Run the Sample Cache Server Application

  2. Configure and Run the Sample Cache Client Application

  3. Exercise the Sample Cache Client Application

  4. Troubleshooting Cache Server Clustering

1.2.2 Configure and Run the Sample Cache Server Application

To set up and run the sample cache server application:

  1. Open a terminal window and verify that the PATH environment variable is set to include the Java JDK (for example, \oracle\product\jdk160_14_R27.6.5-32\bin). If the PATH environment variable does not include the JDK \bin folder, then set it as follows:

    1. Set the JAVA_HOME environment variable to the base of the JDK installation.

      set JAVA_HOME=\oracle\product\jdk160_14_R27.6.5-32
      
    2. Include JAVA_HOME\bin in the PATH environment variable.

      set PATH=%JAVA_HOME%\bin;%PATH%
      
  2. Navigate to the folder where Coherence is installed. Edit the cache-server.cmd file and set the COHERENCE_HOME variable to point to the Coherence installation folder.

    cd C:\oracle\product\coherence\bin
    

    In the cache-server.cmd file, set the COHERENCE_HOME environment variable:

    COHERENCE_HOME=C:\oracle\product\coherence
    

    Example 1-1 illustrates the cache-server.cmd file with the edited value of the COHERENCE_HOME environment variable.

    Example 1-1 cache-server.cmd File with an Edited COHERENCE_HOME

    @echo off
    @
    @rem This will start a cache server
    @
    setlocal
    
    :config
    @rem specify the Coherence installation directory
    set coherence_home=c:\oracle\product\coherence
    
    @rem specify the JVM heap size
    set memory=512m
    
    :start
    if not exist "%coherence_home%\lib\coherence.jar" goto instructions
    
    if "%java_home%"=="" (set java_exec=java) else (set java_exec=%java_home%\bin\java)
    
    :launch
    
    set java_opts="-Xms%memory% -Xmx%memory%"
    
    "%java_exec%" -server -showversion "%java_opts%" -cp "%coherence_home%\lib\coherence.jar" com.tangosol.net.DefaultCacheServer %1
    
    goto exit
    
    :instructions
    
    echo Usage:
    echo   ^<coherence_home^>\bin\cache-server.cmd
    goto exit
    
    :exit
    endlocal
    @echo on
    
  3. Execute the cache server application that is located in the coherence\bin folder.

    C:\oracle\product\coherence\bin>cache-server.cmd
    

    When you start the first cache server, there is a slight delay because the cache server looks for an existing cluster. When the cache server determines that there are no clusters to join, it starts one. On start-up, the cache server produces output similar to the text in Example 1-2.

    Several important features are highlighted in the example:

    • The Java JDK version number.

    • Information about how configuration files are loaded. The default is to load from the coherence.jar file:

      Loaded operational configuration from resource "jar:file:/C:/oracle/product/coherence/lib/coherence.jar!/tangosol-coherence.xml"

    • The Coherence release number: Oracle Coherence 3.7.0.0...

    • The Coherence edition: Grid Edition: Development mode

    • The multicast address. This address changes with each Coherence version. Note the 3.7.0 in the address for Coherence Release 3.7.1: Group{Address=224.3.7.0, Port=37000, TTL=4}

    • The Member ID indicates the number of members in your cluster. For the purpose of this exercise, the value should be 1. ThisMember=Member(Id=1...

    Example 1-2 Output from Starting a Coherence Cache Server

    C:\oracle\product\coherence\bin>cache-server.cmd
    java version "1.6.0_14"
    Java(TM) SE Runtime Environment (build 1.6.0_14-b08)
    Java HotSpot(TM) Server VM (build 14.0-b16, mixed mode)
    
    2011-03-14 16:16:30.998/1.531 Oracle Coherence 3.7.0.0 <Info> (thread=main, member=n/a): Loaded operational configuration from "jar:file:/C:/oracle/product/coherence/lib/coherence.jar!/tangosol-coherence.xml"
    2011-03-14 16:16:31.342/1.875 Oracle Coherence 3.7.0.0 <Info> (thread=main, member=n/a): Loaded operational overrides from "jar:file:/C:/oracl
    e/product/coherence/lib/coherence.jar!/tangosol-coherence-override-dev.xml"
    2011-03-14 16:16:31.357/1.890 Oracle Coherence 3.7.0.0 <D5> (thread=main, member=n/a): Optional configuration override "/tangosol-coherence-override.xml" is not specified
    2011-03-14 16:16:31.373/1.906 Oracle Coherence 3.7.0.0 <D5> (thread=main, member=n/a): Optional configuration override "/custom-mbeans.xml" is not specified
    
    Oracle Coherence Version 3.7.0.0 Build 22913
     Grid Edition: Development mode
    Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
    
    2011-03-14 16:16:32.638/3.171 Oracle Coherence GE 3.7.0.0 <Info> (thread=main, member=n/a): Loaded cache configuration from "jar:file:/C:/oracle/product/coherence/lib/coherence.jar!/coherence-cache-config.xml"
    2011-03-14 16:16:33.295/3.828 Oracle Coherence GE 3.7.0.0 <D4> (thread=main, member=n/a): TCMP bound to /130.35.99.213:8088 using SystemSocketProvider
    2011-03-14 16:16:36.873/7.406 Oracle Coherence GE 3.7.0.0 <Info> (thread=Cluster, member=n/a): Created a new cluster "cluster:0x96AB" with Member(Id=1, Timestamp=2011-03-14 16:16:33.295, Address=130.35.99.213:8088, MachineId=49877, Location=site:URL, machine_name,process:1920, Role=CoherenceServer, Edition=Grid Edition, Mode=Development, CpuCount=2, SocketCount=1) UID=0x822363D50000012E4FDFD80FC2D51F98
    2011-03-14 16:16:36.873/7.406 Oracle Coherence GE 3.7.0.0 <Info> (thread=main, member=n/a): Started cluster Name=cluster:0x96AB
    
    Group{Address=224.3.7.0, Port=37000, TTL=4}
    
    MasterMemberSet
      (
      ThisMember=Member(Id=1, Timestamp=2011-03-14 16:16:33.295, Address=130.35.99.213:8088, MachineId=49877, Location=site:URL, machine_name,process:1920, Role=CoherenceServer)
      OldestMember=Member(Id=1, Timestamp=2011-03-14 16:16:33.295, Address=130.35.99.213:8088, MachineId=49877, Location=site:URL, machine_name,process:1920, Role=CoherenceServer)
      ActualMemberSet=MemberSet(Size=1, BitSetCount=2
        Member(Id=1, Timestamp=2011-03-14 16:16:33.295, Address=130.35.99.213:8088, MachineId=49877, Location=site:URL, machine_name,process:1920, Role=CoherenceServer)    )
      RecycleMillis=1200000
      RecycleSet=MemberSet(Size=0, BitSetCount=0
        )
      )
    
    TcpRing{Connections=[]}
    IpMonitor{AddressListSize=0}
    
    2011-03-14 16:16:36.935/7.468 Oracle Coherence GE 3.7.0.0 <D5> (thread=Invocation:Management, member=1): Service Management joined the cluster with senior service member 1
    2011-03-14 16:16:37.217/7.750 Oracle Coherence GE 3.7.0.0 <D5> (thread=DistributedCache, member=1): Service DistributedCache joined the cluster with senior service member 1
    2011-03-14 16:16:37.295/7.828 Oracle Coherence GE 3.7.0.0 <D5> (thread=ReplicatedCache, member=1): Service ReplicatedCache joined the cluster with senior service member 1
    2011-03-14 16:16:37.310/7.843 Oracle Coherence GE 3.7.0.0 <D5> (thread=OptimisticCache, member=1): Service OptimisticCache joined the cluster with senior service member 1
    2011-03-14 16:16:37.310/7.843 Oracle Coherence GE 3.7.0.0 <D5> (thread=Invocation:InvocationService, member=1): Service InvocationService joined the cluster with senior service member 1
    2011-03-14 16:16:37.326/7.859 Oracle Coherence GE 3.7.0.0 <Info> (thread=main, member=1):
    Services
      (
      ClusterService{Name=Cluster, State=(SERVICE_STARTED, STATE_JOINED), Id=0, Version=3.7, 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}
      ReplicatedCache{Name=ReplicatedCache, State=(SERVICE_STARTED), Id=3, Version=3.0, OldestMemberId=1}
      Optimistic{Name=OptimisticCache, State=(SERVICE_STARTED), Id=4, Version=3.0, OldestMemberId=1}
      InvocationService{Name=InvocationService, State=(SERVICE_STARTED), Id=5, Version=3.1, OldestMemberId=1}
      )
    
    Started DefaultCacheServer...
    

    Note:

    By default, Coherence is configured to use multicast to join a cluster and to distribute cluster events. Multicast can also be used to distribute a message efficiently to multiple nodes in the cluster. You can configure Coherence to disable multicast.

    The output of the cache-server.cmd file indicates whether you have one or more members in your cluster. The value of Member Id should be equal to 1:

    ...
    In MasterMemberSet
    ThisMember=Member(Id should be equal to 1)
    ...
    

    If ThisMember has an Id greater than one, it means that your cache server has joined a pre-existing cluster in your network. For the purposes of these exercises, the cluster should contain only one member. Follow the steps in "Restricting Coherence to Your Own Host" to restrict Coherence to your own host.

1.2.3 Configure and Run the Sample Cache Client Application

To set up and run the sample cache client application:

  1. Open another terminal window to start the cache client.

    Verify that the PATH environment variable is set to include the %JAVA_HOME%\bin folder. If the PATH environment variable does not include the %JAVA_HOME%\bin folder, then set the variable as described in "Configure and Run the Sample Cache Server Application".

  2. Navigate to the \oracle\product\coherence\bin folder. Edit the query.cmd file to set the COHERENCE_HOME variable to point to the Coherence installation folder.

    The query.cmd file includes a reference to the JLine JAR file (jline.jar). JLine is a Java library that simplifies working with console commands.

    Example 1-3 illustrates the query.cmd file, with COHERENCE_HOME=\oracle\product\coherence. JLINE_HOME is set to %jline_home%\lib.

    Example 1-3 query.cmd File with an Edited COHERENCE_HOME

    @echo off
    @
    @rem This will start a console application
    @rem demonstrating the functionality of the Coherence(tm) API
    @
    setlocal
     
    :config
    @rem specify the Coherence installation directory
    set coherence_home=c:\oracle\product\coherence 
     
    @rem specify the jline installation directory
    set jline_home=%coherence_home%\lib
     
    @rem specify if the console will also act as a server
    set storage_enabled=false
     
    @rem specify the JVM heap size
    set memory=64m
     
     
    :start
    if not exist "%coherence_home%\lib\coherence.jar" goto instructions
     
    if "%java_home%"=="" (set java_exec=java) else (set java_exec=%java_home%\bin\java)
     
     
    :launch
     
    if "%storage_enabled%"=="true" (echo ** Starting storage enabled console **) else (echo ** Starting storage disabled console **)
     
    set java_opts="-Xms%memory% -Xmx%memory% -Dtangosol.coherence.distributed.localstorage=%storage_enabled%"
     
    "%java_exec%" -server -showversion "%java_opts%" -cp "%coherence_home%\lib\coherence.jar;%jline_home%\jline.jar" com.tangosol.coherence.dslquery.QueryPlus %*
     
    goto exit
     
    :instructions
     
    echo Usage:
    echo   ^<coherence_home^>\bin\query.cmd
    goto exit
     
    :exit
    endlocal
    @echo on
    
  3. Execute the query.cmd file to start the cache client.

    query.cmd
    

    The output of starting the cache client, illustrated in Example 1-4, displays the basic distributed cache functionality that is built into Coherence. At the end of the output, the CohQL> prompt is displayed.

    Example 1-4 Output from Starting the Coherence Cache Client

    C:\coherence360\coherence\bin>query.cmd
    ** Starting storage disabled console **
    java version "1.6.0_14"
    Java(TM) SE Runtime Environment (build 1.6.0_14-b08)
    Java HotSpot(TM) Server VM (build 14.0-b16, mixed mode)
     
    Coherence Command Line Tool
     
    CohQL>
    

1.2.4 Exercise the Sample Cache Client Application

Exercise the cache client application by entering various commands and examining the output.

  1. Execute the following Coherence commands in the cache client:

    • Enter help to see the list of commands that are available.

    • Enter create cache "products" to create a cache named products.

      The cache products implements the com.tangosol.net.NamedCache interface. A cluster can have many named caches.

      Example 1-5 illustrates that by using the default configuration file (coherence-cache-config.xml) within the supplied coherence.jar file, a NamedCache called products is created using the distributed scheme.

      Example 1-5 Output from Starting a Coherence Cache

      CohQL> create cache "products"
      2011-03-14 16:49:09.217/109.469 Oracle Coherence 3.7.0.0 <Info> (thread=main, member=n/a): Loaded operational configuration from "jar:file:/C:/oracle/product/coherence/lib/coherence.jar!/tangosol-coherence.xml"2011-03-14 16:49:09.482/109.734 Oracle Coherence 3.7.0.0 <Info> (thread=main, member=n/a): Loaded operational overrides from "jar:file:/C:/oracle/product/coherence/lib/coherence.jar!/tangosol-coherence-override-dev.xml"
      2011-03-14 16:49:09.482/109.734 Oracle Coherence 3.7.0.0 <D5> (thread=main, member=n/a): Optional configuration override "/tangosol-coherence-override.xml" is not specified
      2011-03-14 16:49:09.482/109.734 Oracle Coherence 3.7.0.0 <D5> (thread=main, member=n/a): Optional configuration override "/custom-mbeans.xml" is not specified
      
      Oracle Coherence Version 3.7.0.0 Build 22913
       Grid Edition: Development mode
      Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
      
      2011-03-14 16:49:10.498/110.750 Oracle Coherence GE 3.7.0.0 <Info> (thread=main, member=n/a): Loaded cache configuration from "jar:file:/C:/oracle/product/coherence/lib/coherence.jar!/coherence-cache-config.xml"
      2011-03-14 16:49:11.185/111.437 Oracle Coherence GE 3.7.0.0 <D4> (thread=main, member=n/a): TCMP bound to /130.35.99.213:8090 using SystemSocketProvider
      2011-03-14 16:49:11.701/111.953 Oracle Coherence GE 3.7.0.0 <Info> (thread=Cluster, member=n/a): This Member(Id=2, Timestamp=2011-03-14 16:49:11.645, Address=130.35.99.213:8090, MachineId=49877, Location=site:URL, machine_name,process:4900, Role=TangosolCoherenceQueryPlus,Edition=Grid Edition, Mode=Development, CpuCount=2, SocketCount=1) joined cluster "cluster:0x96AB" with senior Member(Id=1, Timestamp=2011-03-14 16:16:33.295, Address=130.35.99.213:8088, MachineId=49877, Location=site:URL, machine_name,process:1920, Role=CoherenceServer, Edition=Grid Edition, Mode=Development, CpuCount=2, SocketCount=1)
      2011-03-14 16:49:11.732/111.984 Oracle Coherence GE 3.7.0.0 <D5> (thread=Cluster, member=n/a): Member 1 joined Service Cluster with senior member 1
      2011-03-14 16:49:11.732/111.984 Oracle Coherence GE 3.7.0.0 <D5> (thread=Cluster, member=n/a): Member 1 joined Service Management with senior member 1
      2011-03-14 16:49:11.732/111.984 Oracle Coherence GE 3.7.0.0 <D5> (thread=Cluster, member=n/a): Member 1 joined Service DistributedCache with senior member 1
      2011-03-14 16:49:11.732/111.984 Oracle Coherence GE 3.7.0.0 <D5> (thread=Cluster, member=n/a): Member 1 joined Service ReplicatedCache with senior member 1
      2011-03-14 16:49:11.732/111.984 Oracle Coherence GE 3.7.0.0 <D5> (thread=Cluster, member=n/a): Member 1 joined Service OptimisticCache with senior member 1
      2011-03-14 16:49:11.732/111.984 Oracle Coherence GE 3.7.0.0 <D5> (thread=Cluster, member=n/a): Member 1 joined Service InvocationService with senior member 12011-03-14 16:49:11.732/111.984 Oracle Coherence GE 3.7.0.0 <Info> (thread=main, member=n/a): Started cluster Name=cluster:0x96AB
      
      Group{Address=224.3.7.0, Port=37000, TTL=4}
      
      MasterMemberSet
        (
        ThisMember=Member(Id=2, Timestamp=2011-03-14 16:49:11.645, Address=130.35.99.213:8090, MachineId=49877, Location=site:URL, machine_name,process:4900, Role=TangosolCoherenceQueryPlus)
        OldestMember=Member(Id=1, Timestamp=2011-03-14 16:16:33.295, Address=130.35.99.213:8088, MachineId=49877, Location=site:URL, machine_name,process:1920, Role=CoherenceServer)
        ActualMemberSet=MemberSet(Size=2, BitSetCount=2
          Member(Id=1, Timestamp=2011-03-14 16:16:33.295, Address=130.35.99.213:8088, MachineId=49877, Location=site:URL, machine_name,process:1920, Role=CoherenceServer)
          Member(Id=2, Timestamp=2011-03-14 16:49:11.645, Address=130.35.99.213:8090, MachineId=49877, Location=site:URL, machine_name,process:4900, Role=TangosolCoherenceQueryPlus)
          )
        RecycleMillis=1200000
        RecycleSet=MemberSet(Size=0, BitSetCount=0
          )
        )
      
      TcpRing{Connections=[1]}
      IpMonitor{AddressListSize=0}
      
      2011-03-14 16:49:11.779/112.031 Oracle Coherence GE 3.7.0.0 <D5> (thread=Invocation:Management, member=2): Service Management joined the cluster with senior service member 1
      2011-03-14 16:49:12.060/112.312 Oracle Coherence GE 3.7.0.0 <D5> (thread=DistributedCache, member=2): Service DistributedCache joined the cluster with senior service member 1
      
      CohQL>
      
  2. Execute the following commands at the CohQL> prompt in the cache client. For definitions of these commands, see "Using Coherence Query Language" in Developer's Guide for Oracle Coherence.

    • Create a cache named products:

      create cache "products"  
      
    • Insert an entry (key-value pair) into the cache:

      insert into "products" key "television" value "ID-5070"
      
    • Change the value of the key:

      update "products" set value() = "ID-5080" where key() like "television
      
    • Retrieve the values in the cache:

      select * from "products" 
      
    • Retrieve the value of a key that does not exist. An empty result set will be returned:

      select key(), value() from "products" where key() is "radio" 
      
    • Delete an existing key in the cache. An empty result set will be returned:

      delete from "products" where key() = "television"
      
    • Delete the contents of the products cache. An empty result set will be returned:

      delete from "products"
      
    • Destroy the products cache:

      drop cache "products" 
      
    • Re-create the products cache:

      create cache "products" 
      
    • Insert more entries into the cache:

      insert into "products" key "television" value "ID-5080"
      insert into "products" key "radio" value "ID-5090"
      insert into "products" key "MP3 Player" value "ID-5100"
      insert into "products" key "laptop" value "ID-5110"
      
    • Retrieve the keys and values in the products cache:

      select key(), value() from "products" 
      
    • Save a serialized representation of the cache in a file:

      backup cache "products" to "products.bkup"
      
    • Delete a key from the cache:

      delete from "products" where key() = "television"  
      
    • Retrieve the cache contents again, notice that the deleted key and value will not be present:

      select key(), value() from "products" 
      
    • Delete the contents of the cache:

      delete from "products" 
      
    • Retrieve the contents of the cache. An empty result set will be returned:

      select * from "products"  
      
    • Restore the cache contents from the backup file:

      restore cache "products" from file "products.bkup" 
      
    • Retrieve the cache contents. Note that all of the entries will be restored and returned:

      select key(), value() from "products" 
      
    • Destroy the products cache:

      drop cache "products" 
      
    • Exit the command-line tool:

      bye 
      

    Example 1-6 illustrates the output of each of these commands.

    Example 1-6 Exercising Coherence Commands

    CohQL> create cache "products"
     
    CohQL> insert into "products" key "television" value "ID-5070"
     
    CohQL> update "products" set value() = "ID-5080" where key() like "television
    Results
    television: true
     
    CohQL> select * from "products"
    Results
    ID-5080
     
    CohQL> select key(), value() from "products" where key() is "radio"
    Results
     
    CohQL> delete from "products" where key() = "television"
    Results
     
    CohQL> delete from "products"
    Results
     
    CohQL> drop cache "products"
     
    CohQL> create cache "products"
     
    CohQL> insert into "products" key "television" value "ID-5080"
     
    CohQL> insert into "products" key "radio" value "ID-5090"
     
    CohQL> insert into "products" key "MP3 Player" value "ID-5100"
     
    CohQL> insert into "products" key "laptop" value "ID-5110"
    
    CohQL> select key(), value() from "products"
    Results
    "television", "ID-5080"
    "radio", "ID-5090"
    "MP3 Player", "ID-5100"
    "laptop", "ID-5110"
     
    CohQL> backup cache "products" to "products.bkup"
    WARNING: The backup command should not be used on active data set,
    as it makes no provisions that ensure data consistency during the backup.
    Please see the documentation for more detailed information.
     
    CohQL> delete from "products" where key() = "television"
    Results
     
    CohQL> select key(), value() from "products"
    Results
    "radio", "ID-5090"
    "MP3 Player", "ID-5100"
    "laptop", "ID-5110"
     
    CohQL> delete from "products"
    Results
     
    CohQL> select * from "products"
    Results
     
    CohQL> restore cache "products" from file "products.bkup"
     
    CohQL> select key(), value() from "products"
    Results
    "television", "ID-5080"
    "radio", "ID-5090"
    "MP3 Player", "ID-5100"
    "laptop", "ID-5110"
     
    CohQL> drop cache "products"
     
    CohQL> bye
    
    2011-03-14 16:54:41.638/441.890 Oracle Coherence GE 3.7.0.0 <D5> (thread=Invocation:Management, member=2): Service Management left the cluster
    2011-03-14 16:54:41.638/441.890 Oracle Coherence GE 3.7.0.0 <D5> (thread=DistributedCache, member=2): Service DistributedCache left the cluster
    2011-03-14 16:54:41.654/441.906 Oracle Coherence GE 3.7.0.0 <D5> (thread=Cluster, member=2): Service Cluster left the cluster
    
    C:\oracle\product\coherence\bin>
    
  3. Open another terminal window and set the PATH environment variable to include %JAVA_HOME% and %JAVA_HOME%\bin. Enter the query.cmd command in the new terminal window to start an instance of the cache client.

  4. Restart the first client with the query.cmd command. Enter the create cache "products" command. The terminal window displays a message similar to the following that describes where the first client is running. member 1 is the cache server and member 3 is the restarted first client.

    2011-03-14 17:51:26.701/17.688 Oracle Coherence GE 3.7.0.0 <D5> (thread=Invocation:Management, member=3): Service Management joined the cluster with senior service member 1
    2011-03-14 17:51:27.138/18.125 Oracle Coherence GE 3.7.0.0 <D5> (thread=DistributedCache, member=3): Service DistributedCache joined the cluster with senior service member 1
     
    CohQL> 
    
  5. Enter the create cache "products" command in the new terminal window to connect to the products cache. Try to get and put values in different sessions. Notice that each client can observe changes made by the other client.

  6. Terminate one of the query.cmd shells (bye). Note that the other shell displays a message indicating that the member has left the cluster, for example:

    2011-03-14 17:56:22.920/313.907 Oracle Coherence GE 3.7.0.0 <D5> (thread=Cluster, member=2): Member 3 left service Management with senior member 1
    2011-03-14 17:56:22.935/313.922 Oracle Coherence GE 3.7.0.0 <D5> (thread=Cluster, member=2): Member 3 left service DistributedCache with senior member 1
    2011-03-14 17:56:22.967/313.954 Oracle Coherence GE 3.7.0.0 <D5> (thread=Cluster, member=2): TcpRing disconnected from Member(Id=3, Timestamp=2011-03-14 17:55:21.803, Address=130.35.99.213:8092, MachineId=49877, Location=site:URL, machine_name,process:1008, Role=TangosolCoherenceQueryPlus) due to a peer departure; removing the member.
    2011-03-14 17:56:22.982/313.969 Oracle Coherence GE 3.7.0.0 <D5> (thread=Cluster, member=2): Member(Id=3, Timestamp=2011-03-14 17:56:22.982, Address=130.35.99.213:8092, MachineId=49877, Location=site:URL, machine_name,process:1008, Role=TangosolCoherenceQueryPlus) left Cluster with senior member 1
    
  7. If you terminate each of the cache clients (bye), and then restart them, note that data from the previous session is still available. This is because the data is held in the cache server.

  8. If you start another Coherence cache server, and then terminate the initial one that was started (using Ctrl+C or by closing the command window), note that the data is still available.

  9. Terminate both the query.cmd shells and cache-server.cmd shell. Restart query.cmd. Create a cache called test using the command create cache test. Try to put a value into the cache, as before. Because the cache client is configured to start in storage-disabled mode, you will receive a response similar to the following:

    com.tangosol.net.RequestPolicyException: No storage-enabled nodes exist for service DistributedCache
    
  10. Start a cache server by running the cache-server.cmd file. Try to insert a value again. This time, the value will be accepted.

  11. Terminate all cache servers.

1.2.5 Troubleshooting Cache Server Clustering

If the value of Member ID in the cache-server.cmd output is anything other than 1, then this indicates that the cache server has clustered with one or more other cache servers or processes running Coherence. These servers or processes can be running on the network or running locally on your host. Though this is the default behavior for Coherence—to cluster with other processes running Coherence locally or on a network—it is strongly advised that while you perform this tutorial, you restrict Coherence to your own host.

Note:

To restrict Coherence to a single host, the cache server and cache client executable files used in this tutorial use the tangosol.coherence.clusterport command line property set to 3155.

1.2.5.1 Restricting Coherence to Your Own Host

The value of the Member ID in the output of the cache-server.cmd cache server command indicates whether you have one or more members in your cluster. For the purpose of this tutorial, the value of Member ID must be equal to 1:

...
In MasterMemberSet
ThisMember=Member(Id should be equal to 1)
...

If the value of Member ID is greater than 1, it means that multiple clusters are being formed in your subnet.

There are several ways to restrict Coherence to your own host. The easiest way is to use the tangosol.coherence.clusterport system property to declare a unique cluster port value in your cache server startup file. For example, add the following Java option to your cache-server.cmd file. The value assigned to the system property can be any unique value, such as the last four digits of your telephone number.

-Dtangosol.coherence.clusterport=3155

1.2.5.2 Advanced Steps to Restrict Coherence to Your Own Host

If you follow the steps in "Restricting Coherence to Your Own Host" and the cache-server.cmd command still fails to return a Member Id value of 1, then there might be additional problems to resolve.

Disconnect from the network or disable networking on your host. If errors or exceptions occur when starting the cache server, your network settings might need to be modified. Try each of the following one at a time, restarting the cache server after each attempt:

  • If connected to a Virtual Private Network (VPN), then disconnect from it. By default, most VPN are not configured to permit multicast and some unicast traffic. In this environment, Coherence might not work, if left in the configuration in which it was shipped. Coherence can be configured to run across a VPN, but this requires some advanced settings.

  • If you run a firewall, configure it to enable the specified addresses and ports.

  • If you still experience problems, disconnect from all networks. This includes wireless and wired networks.

  • If all the preceding options fail, set up Coherence to run on a single host.