1 Installing Coherence and JDeveloper

This chapter describes how to install and set up your environment for running Oracle JDeveloper Studio Edition 11g and Oracle Coherence Release 3.5. This chapter contains the following sections:

This chapter assumes that you 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. It also assumes that you have a working installation of Java SE (JDK) version 1.6.

This chapter also assumes that you are running one of the following Microsoft Windows operating systems: XP, Vista, 2000, 2003, or 2008.

1.1 Downloading and Installing Coherence

To download and install Oracle Coherence:

  1. Download Oracle Coherence to your desktop.

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

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

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

    The zip file contains the coherence directory with these subdirectories:

    • bin—contains command scripts

    • lib—contains the required library files

    • examples— contains the example code

    • doc—contains the product documentation

1.2 Downloading and Installing JDeveloper

To download and Install Oracle JDeveloper Studio Edition 11g:

  1. Download Oracle JDeveloper Studio.

    You can obtain JDeveloper Studio 11g from the following URL:

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

  2. Run the JDeveloper Studio installer.

    Follow the prompts in the installation screens. If the installer asks for a Middleware Home, enter C:\oracle\product if it does not exist.

    If you are asked for a User Role when JDeveloper starts, select Default Role to enable all technologies.

1.3 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.

This exercise assumes that you have installed Oracle Coherence (Java Edition) Release 3.5 (See "Downloading and Installing Coherence").

Coherence uses a variety of network addresses and ports to enable communication between clustered processes. If these addresses and/or 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.3.3.1 / 33389 / Multicast

Cluster member discovery and broadcast

localhost / 8088+ / Unicast

Inter-process 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.

  • The "cache server," is a simple application that hosts and manages data on behalf of other applications in a cluster.

  • The "coherence shell," is a simple application that enables a developer to access, process, and update cached data within a cluster. It also provides informaiton about the cluster. By executing these applications on either a single host or several hosts, you can determine whether Coherence is operating correctly locally or across a network.

    When an application uses Coherence out-of-the-box, objects placed into Coherence caches are typically stored and managed in-process within the application. However, to increase the availability of the objects, Coherence may manage objects in-memory but out of the application process. This allows objects to survive possible application outages (either deliberate or accidental). To manage objects in this way, Coherence uses "cache servers". The purpose of a Coherence cache server is to manage application state in a cluster outside the application process. It is much like a database server, but without the requirement for storage.

To set up and run the cache server and client:

  1. Open a terminal window and verify that the PATH environment variable is set to include the Java JDK (for example, \oracle\product\jdk160_05\bin). If the PATH environment variable does not include jdk\jdk160_05\bin directory, then set the variable as follows:

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

      set JAVA_HOME=\oracle\product\jdk160_05
      
    2. Include JAVA_HOME\bin in the PATH environment variable.

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

    cd C:\oracle\product\coherence\bin
    

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

    COHERENCE_HOME=C:\oracle\product\coherence
    

    Save cache-server.cmd and close the file.

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

    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 directory.

    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 it determines that there are no clusters to join, it starts one. On startup, 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: java version "1.6.0_05"

    • information about how configuration files are loaded. The default is to load from JAR: Loaded operational configuration from resource "jar:file:/C:/oracle/product/coherence/lib/coherence.jar!/tangosol-coherence.xml"

    • the Coherence release number: Oracle Coherence Version 3.5/453

    • the multicast address. This address changes with each Coherence version. Note the 3.5.0 in the address for Coherence Release 3.5: Group{Address=224.3.5.0, Port=35450, TTL=4}

    • the Member Id indicates the number of members in your cluster. For the purposes 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_05"
    Java(TM) SE Runtime Environment (build 1.6.0_05-b13)
    Java HotSpot(TM) Server VM (build 10.0-b19, mixed mode)
    
    2009-04-20 17:49:40.179/0.703 Oracle Coherence 3.5/453 (Pre-release) <Info> (thread=main, member=n/a): Loaded operational configuration from resource "jar:file:/C:/oracle/product/coherence/lib/coherence.jar!/tangosol-coherence.xml"  
    2009-04-20 17:49:40.195/0.719 Oracle Coherence 3.5/453 (Pre-release) <Info> (thread=main, member=n/a): Loaded operational overrides from resource "jar :file:/C:/oracle/product/coherence/lib/coherence.jar!/tangosol-coherence-override-dev.xml" 2009-04-20 17:49:40.195/0.719 Oracle Coherence 3.5/453 (Pre-release) <D5> (thread=main, member=n/a): Optional configuration override "/tangosol-coherence-override.xml" is not specified
    2009-04-20 17:49:40.210/0.734 Oracle Coherence 3.5/453 (Pre-release) <D5> (thread=main, member=n/a): Optional configuration override "/custom-mbeans.xml" is not specified
    
    Oracle Coherence Version 3.5/453 (Pre-release) 
     Grid Edition: Development mode
    Copyright (c) 2000, 2009, Oracle and/or its affiliates. All rights reserved.
    
    2009-04-20 17:49:40.898/1.422 Oracle Coherence GE 3.5/453 (Pre-release) <Info> (thread=main, member=n/a): Loaded cache configuration from resource "jar:file:/C:/oracle/product/coherence/lib/coherence.jar!/coherence-cache-config.xml"
    2009-04-20 17:49:42.054/2.578 Oracle Coherence GE 3.5/453 (Pre-release) <D5> (thread=Cluster, member=n/a): Service Cluster joined the cluster with senior service member n/a
    2009-04-20 17:49:45.304/5.828 Oracle Coherence GE 3.5/453 (Pre-release) <Info> (thread=Cluster, member=n/a): Created a new cluster "cluster:0x29DB" with Member(Id=1, Timestamp=2009-04-20 17:49:41.648, Address=130.35.99.50:8088, MachineId=49714, Location=site:us.oracle.com,machine:tpfaeffl-pc,process:2208, Role=CoherenceServer, Edition=Grid Edition, Mode=Development, CpuCount=1, SocketCount=1) UID=0x8223633200000120C6265310C2321F98
    2009-04-20 17:49:45.335/5.859 Oracle Coherence GE 3.5/453 (Pre-release) <D5> (thread=Invocation:Management, member=1): Service Management joined the cluster with senior service member 1
    2009-04-20 17:49:45.898/6.422 Oracle Coherence GE 3.5/453 (Pre-release) <D5> (thread=DistributedCache, member=1): Service DistributedCache joined the cluster with senior service member 1
    2009-04-20 17:49:46.007/6.531 Oracle Coherence GE 3.5/453 (Pre-release) <D5> (thread=ReplicatedCache, member=1): Service ReplicatedCache joined the cluster with senior service member 1
    2009-04-20 17:49:46.023/6.547 Oracle Coherence GE 3.5/453 (Pre-release) <D5> (thread=OptimisticCache, member=1): Service OptimisticCache joined the cluster with senior service member 1
    2009-04-20 17:49:46.023/6.547 Oracle Coherence GE 3.5/453 (Pre-release) <D5> (thread=Invocation:InvocationService, member=1): Service InvocationService joined the cluster with senior service member 1
    2009-04-20 17:49:46.023/6.547 Oracle Coherence GE 3.5/453 (Pre-release) <Info> (thread=main, member=1): Started DefaultCacheServer...
    
    SafeCluster: Name=cluster:0x29DB
    
    Group{Address=224.3.5.0, Port=35453, TTL=4}  
    
    MasterMemberSet  
      (
      ThisMember=Member(Id=1, Timestamp=2009-04-20 17:49:41.648, Address=130.35.99.50:8088, MachineId=49714, Location=site:us.oracle.com,machine:tpfaeffl-pc,process:2208, Role=CoherenceServer)
      OldestMember=Member(Id=1, Timestamp=2009-04-20 17:49:41.648, Address=130.35.99.50:8088, MachineId=49714, Location=site:us.oracle.com,machine:tpfaeffl-pc,process:2208, Role=CoherenceServer)
      ActualMemberSet=MemberSet(Size=1, BitSetCount=2
        Member(Id=1, Timestamp=2009-04-20 17:49:41.648, Address=130.35.99.50:8088, MachineId=49714, Location=site:us.oracle.com,machine:tpfaeffl-pc,proces
    s:2208, Role=CoherenceServer)
        )
      RecycleMillis=120000
      RecycleSet=MemberSet(Size=0, BitSetCount=0
        )
      )
    
    Services
      (
      TcpRing{TcpSocketAccepter{State=STATE_OPEN, ServerSocket=130.35.99.50:8088}, Connections=[]}
      ClusterService{Name=Cluster, State=(SERVICE_STARTED, STATE_JOINED), Id=0, Version=3.4, OldestMemberId=1}
      InvocationService{Name=Management, State=(SERVICE_STARTED), Id=1, Version=3.1, OldestMemberId=1}
      DistributedCache{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}
      )
    

    Note:

    By default, Coherence is configured to use multicast to attempt to join a cluster and to distribute cluster events. Multicast can also be used to distribute a message efficiently to more than one other node of the cluster. Coherence can be configured so that it does not use multicast.

    The output of cache-server.cmd 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 Member Id is greater than 1, then multiple clusters are being formed in your subnet. For the purposes of these exercises, there should only be one member in the cluster. Follow the steps in "Restricting Coherence to Your Own Host" to restrict Coherence to your own host.

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

    Verify that the PATH environment variable is set to include \oracle\product\jdk160_05\bin. If the PATH environment variable does not include the jdk160_05\bin directory, then set the variable as follows:

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

      set JAVA_HOME=\oracle\product\jdk160_05
      
    2. Include JAVA_HOME\bin in the PATH environment variable.

      set PATH=%JAVA_HOME%\bin;%PATH%
      
  5. Navigate to the \oracle\product\coherence\bin directory. Edit coherence.cmd and set the COHERENCE_HOME variable to point to the Coherence installation directory. Save and close the file.

    Example 1-3 illustrates the coherence.cmd file, with COHERENCE_HOME=\oracle\product\coherence.

    Example 1-3 coherence.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 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" com.tangosol.net.CacheFactory %1
    
    goto exit
    
    :instructions
    
    echo Usage:
    echo   ^<coherence_home^>\bin\coherence.cmd
    goto exit
    
    :exit
    endlocal
    @echo on
    
  6. Execute the coherence.cmd file to start the cache client. This application shows you the basic distributed cache functionality that is built within Coherence.

    coherence.cmd
    

    Example 1-4 illustrates the output from starting the cache client. Note the following features of the output:

    • the client is the second member of the cluster (the server is the first member): ThisMember=Member(Id=2,...

    • at the end of the output, you should see the Map(?) prompt

    Example 1-4 Output from Starting the Coherence Cache Client

    C:\oracle\product\coherence\bin>coherence.cmd
    ** Starting storage disabled console **
    java version "1.6.0_05"
    Java(TM) SE Runtime Environment (build 1.6.0_05-b13)
    Java HotSpot(TM) Server VM (build 10.0-b19, mixed mode)
    
    2009-04-20 18:01:27.632/0.750 Oracle Coherence 3.5/453 (Pre-release) <Info> (thread=main, member=n/a): Loaded operational configuration from resource "jar:file:/C:/oracle/product/coherence/lib/coherence.jar!/tangosol-coherence.xml"
    2009-04-20 18:01:27.648/0.766 Oracle Coherence 3.5/453 (Pre-release) <Info> (thread=main, member=n/a): Loaded operational overrides from resource "jar:file:/C:/oracle/product/coherence/lib/coherence.jar!/tangosol-coherence-override-dev.xml"
    2009-04-20 18:01:27.648/0.766 Oracle Coherence 3.5/453 (Pre-release) <D5> (thread=main, member=n/a): Optional configuration override "/tangosol-coherence-override.xml" is not specified
    2009-04-20 18:01:27.663/0.781 Oracle Coherence 3.5/453 (Pre-release) <D5> (thread=main, member=n/a): Optional configuration override "/custom-mbeans.xml" is not specified
    
    Oracle Coherence Version 3.5/453 (Pre-release)
     Grid Edition: Development mode
    Copyright (c) 2000, 2009, Oracle and/or its affiliates. All rights reserved.
    
    2009-04-20 18:01:29.429/2.547 Oracle Coherence GE 3.5/453 (Pre-release) <D5> (thread=Cluster, member=n/a): Service Cluster joined the cluster with senior service member n/a
    2009-04-20 18:01:29.538/2.656 Oracle Coherence GE 3.5/453 (Pre-release) <Info> (thread=Cluster, member=n/a): Failed to satisfy the variance: allowed=16, actual=47
    2009-04-20 18:01:29.538/2.656 Oracle Coherence GE 3.5/453 (Pre-release) <Info> (thread=Cluster, member=n/a): Increasing allowable variance to 19
    2009-04-20 18:01:29.882/3.000 Oracle Coherence GE 3.5/453 (Pre-release) <Info> (thread=Cluster, member=n/a): This Member(Id=2, Timestamp=2009-04-20 18:01:29.64, Address=130.35.99.50:8089, MachineId=49714, Location=site:us.oracle.com,machine:tpfaeffl-pc,process:1760, Role=CoherenceConsole, Edition=Grid Edition, Mode=Development, CpuCount=1, SocketCount=1) joined cluster "cluster:0x29DB" with senior Member(Id=1, Timestamp=2009-04-20 17:49:41.648, Address=130.35.99.50:8088, MachineId=49714, Location=site:us.oracle.com,machine:tpfaeffl-pc,process:2208, Role=CoherenceServer, Edition=Grid Edition, Mode=Development, CpuCount=1, SocketCount=1)
    2009-04-20 18:01:29.913/3.031 Oracle Coherence GE 3.5/453 (Pre-release) <D5> (thread=Cluster, member=n/a): Member 1 joined Service Management with senior member 1
    2009-04-20 18:01:29.913/3.031 Oracle Coherence GE 3.5/453 (Pre-release) <D5> (thread=Cluster, member=n/a): Member 1 joined Service DistributedCache with senior member 1
    2009-04-20 18:01:29.913/3.031 Oracle Coherence GE 3.5/453 (Pre-release) <D5> (thread=Cluster, member=n/a): Member 1 joined Service ReplicatedCache with senior member 1
    2009-04-20 18:01:29.913/3.031 Oracle Coherence GE 3.5/453 (Pre-release) <D5> (thread=Cluster, member=n/a): Member 1 joined Service OptimisticCache with senior member 1
    2009-04-20 18:01:29.913/3.031 Oracle Coherence GE 3.5/453 (Pre-release) <D5> (thread=Cluster, member=n/a): Member 1 joined Service InvocationService with senior member 1
    2009-04-20 18:01:30.101/3.219 Oracle Coherence GE 3.5/453 (Pre-release) <D5> (thread=Invocation:Management, member=2): Service Management joined the cluster with senior service member 1 SafeCluster: Name=cluster:0x29DB
    
    Group{Address=224.3.5.0, Port=35453, TTL=4}
    
    MasterMemberSet
      (
      ThisMember=Member(Id=2, Timestamp=2009-04-20 18:01:29.64, Address=130.35.99.50:8089, MachineId=49714, Location=site:us.oracle.com,machine:tpfaeffl-pc,process:1760, Role=CoherenceConsole)
      OldestMember=Member(Id=1, Timestamp=2009-04-20 17:49:41.648, Address=130.35.99.50:8088, MachineId=49714, Location=site:us.oracle.com,machine:tpfaeffl-pc,process:2208, Role=CoherenceServer)
      ActualMemberSet=MemberSet(Size=2, BitSetCount=2
        Member(Id=1, Timestamp=2009-04-20 17:49:41.648, Address=130.35.99.50:8088, MachineId=49714, Location=site:us.oracle.com,machine:tpfaeffl-pc,process:2208, Role=CoherenceServer)
        Member(Id=2, Timestamp=2009-04-20 18:01:29.64, Address=130.35.99.50:8089, MachineId=49714, Location=site:us.oracle.com,machine:tpfaeffl-pc,process:1760, Role=CoherenceConsole)
        )
      RecycleMillis=120000
      RecycleSet=MemberSet(Size=0, BitSetCount=0
        )
      )
    Services
      (
      TcpRing{TcpSocketAccepter{State=STATE_OPEN, ServerSocket=130.35.99.50:8089}, Connections=[]}
      ClusterService{Name=Cluster, State=(SERVICE_STARTED, STATE_JOINED), Id=0, Version=3.4, OldestMemberId=1}
      InvocationService{Name=Management, State=(SERVICE_STARTED), Id=1, Version=3.1, OldestMemberId=1}
      )
    
    Map (?):
    2009-04-20 18:01:30.929/4.047 Oracle Coherence GE 3.5/453 (Pre-release) <D5> (thread=TcpRingListener, member=2): TcpRing: connecting to member 1 using
     TcpSocket{State=STATE_OPEN, Socket=Socket[addr=/130.35.99.50,port=3609,localport=8089]}
    
    Map (?):
    
  7. Exercise the client application by executing the following Coherence commands in the Coherence shell:

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

    • Enter cache mycache.

      The cache mycache implements the com.tangosol.net.NamedCache interface. Each NamedCache can be thought of as a table. A cluster can have many named caches. Each NamedCache holds one type of object. It can be a simple object, such as a String, or a complex object that you define.

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

      Example 1-5 Output from Starting a Coherence Cache

      Map (?): cache myCache
      2009-04-20 18:08:16.773/409.891 Oracle Coherence GE 3.5/453 (Pre-release) <Info> (thread=main, member=2): Loaded cache configuration from resource "jar:file:/C:/oracle/product/coherence/lib/coherence.jar!/coherence-cache-config.xml"
      2009-04-20 18:08:17.132/410.250 Oracle Coherence GE 3.5/453 (Pre-release) <D5> (thread=DistributedCache, member=2): Service DistributedCache joined the cluster with senior service member 1
      2009-04-20 18:08:17.163/410.281 Oracle Coherence GE 3.5/453 (Pre-release) <D5> (thread=DistributedCache, member=2): Service DistributedCache: received ServiceConfigSync containing 258 entries
      <distributed-scheme>
        <!--
        To use POF serialization for this partitioned service,
        uncomment the following section
        <serializer>
        <class-name>com.tangosol.io.pof.ConfigurablePofContext</class-name>
        </serializer>
        -->
        <scheme-name>example-distributed</scheme-name>
        <service-name>DistributedCache</service-name>
        <backing-map-scheme>
          <local-scheme>
            <scheme-ref>example-binary-backing-map</scheme-ref>
          </local-scheme>
        </backing-map-scheme>
        <autostart>true</autostart>
      </distributed-scheme>
      
      Map (myCache):
      

      Execute the following commands at the Map(myCache) prompt in the Coherence shell. For definitions of these commands, see Appendix A, "Coherence Client Application Commands."

    • get message

    • put message "hello"

    • list

    • size

    • get message

    • put message "second message"

    • get message

    • remove message

    • size

    • get message

    • put message "hi"

    • bye

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

    Example 1-6 Exercising Coherence Commands

    Map (mycache): get message
    null
    
    Map (mycache): put message "hello"
    null
    
    Map (mycache): list
    message = hello
    
    Map (mycache): size
    1
    
    Map (mycache): get message
    hello
    
    Map (mycache): put message "second message"
    hello
    
    Map (mycache): get message
    second message
    
    Map (mycache): remove message
    second message
    
    Map (mycache): size
    0
    
    Map (mycache): get message
    null
    
    Map (mycache): put message "hi"
    null
    
    Map (mycache): bye
    Map (mycache): bye2009-04-20 18:16:35.898/909.016 Oracle Coherence GE 3.5/453 (Pre-release) <D5> (thread=Invocation:Management, member=2): Service Management left the cluster
    2009-04-20 18:16:35.913/909.031 Oracle Coherence GE 3.5/453 (Pre-release) <D5> (thread=DistributedCache, member=2): Service DistributedCache left the cluster
    2009-04-20 18:16:36.007/909.125 Oracle Coherence GE 3.5/453 (Pre-release) <D5> (thread=Cluster, member=2): Service Cluster left the cluster
    
    C:\oracle\product\coherence\bin>
    
  8. Open another terminal window and set the PATH environment variable to include \oracle\product\jdk160_05\bin. and the JAVA_HOME variable to \oracle\product\jdk160_05 (See Step 4).

  9. Start a second instance of coherence.cmd in the new terminal window. Note that the terminal window displays a message similar to the following that describes where the first client is running:

    Map (mycache):
    2009-04-20 18:18:15.468/66.407 Oracle Coherence GE 3.5/453 (Pre-release) (thread=Cluster, member=3): Member 4 joined Service DistributedCache with senior member 1
    
  10. Use the cache mycache command in the new terminal to connect to the NamedCache called mycache. Try to get and put values in different sessions. notice that each client can observe changes made by the other client.

  11. Terminate one of the coherence.cmd shells (bye). Note that the other shell displays a message indicating that the member has left the cluster. For example:

    Map (mycache):
    2009-04-20 18:18:50.835/878.204 Oracle Coherence GE 3.5/453 (Pre-release) <D5> (thread=Cluster, member=3): Member 4 left service DistributedCache with senior member 1
    
    Map (mycache):
    2009-04-20 18:18:50.835/878.204 Oracle Coherence GE 3.5/453 (Pre-release)<D5> (thread=Cluster, member=3): MemberLeft notification for Member 4 received from Member(Id=4, Timestamp=2008-12-10 11:50:51.601, Address=130.35.99.248:8090, MachineId=49912, Location=site:us.oracle.com,machine:tpfaeffl-pc,process:5356, Role=CoherenceConsole)
    2009-04-20 18:19:50.835/878.204 Oracle Coherence GE 3.5/453 (Pre-release) <D5> (thread=Cluster, member=3): Member(Id=4, Timestamp=2008-12-10 12:00:09.249, Address=130.35.99.248:8090, MachineId=49912, Location=site:us.oracle.com,machine:tpfaeffl-pc,process:5356, Role=CoherenceConsole) left Cluster with senior member 1
    
  12. If you terminate each of the Coherence shells (bye), and then restart them, note that data from the previous session still available. This is because the data is held in the cache server.

  13. 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.

  14. Terminate both the coherence.cmd shells and cache-server.cmd. Start coherence.cmd. Create a NamedCache called test using cachetest. Try to put in a value as before and note the results.

  15. Start a cache server by running the cache-server.cmd file from the coherence\bin directory. Try to put in a value again and note the results.

  16. Terminate all the cache servers.

1.3.1 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 may 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, while you perform this tutorial, that you restrict Coherence to your own host.

1.3.1.1 Restricting Coherence to Your Own Host

The output of cache-server.cmd indicates whether you have just one member in your cluster. The value of Member ID should be equal to 1:

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

If Member ID is greater than 1, it means that multiple clusters are being formed in your subnet. For the purposes of the exercises in this document, there should only be one member in the cluster.

To restrict Coherence to your own host:

  1. Stop cache server by pressing Ctrl+C.

  2. Create a directory called backup under oracle\product\coherence\lib.

    cd C:\oracle\product\coherence\lib
    mkdir backup
    
  3. Copy coherence.jar from the oracle\product\coherence\lib directory to the backup directory.

    cp coherence.jar C:\oracle\product\coherence\lib\backup\coherence.jar
    
  4. Navigate to the oracle\product\coherence\lib\backup directory.

  5. Extract tangosol-coherence.xml from coherence.jar.

    jar -xvf coherence.jar tangosol-coherence.xml
    
  6. Edit the tangosol-coherence.xml file.

    Change the multicast listener port to a unique value, for example, 34408. Be sure that your multicast listener port value that you are setting is unique. For example, if you share the port value 34407 with another user, then change your port value to 34408 and the other user can change to 34409. When you are finished, save the file and quit the editor.

    Example 1-7 illustrates the multicast-listener fragment of tangosol-coherence.xml with its original port value of 34407.

    Example 1-7 Multicast-Listener Fragment of tangosol-coherence.xml File

    ...
        <multicast-listener>
          <address system-property="tangosol.coherence.clusteraddress">224.3.4.1</address>
          <port system-property="tangosol.coherence.clusterport">34407</port>
    
          <!--
          Note: For production use, this value should be set to the lowest integer
          value that works. On a single server cluster, it should work at "0"; on
          a simple switched backbone, it should work at "1"; on an advanced backbone
          with intelligent switching, it may require a value of "2" or more. Setting
          the value too high can utilize unnecessary bandwidth on other LAN segments
          and can even cause the OS or network devices to disable multicast traffic.
          -->
          <time-to-live system-property="tangosol.coherence.ttl">4</time-to-live>
    
  7. Append the modified tangosol-coherence.xml file to coherence.jar in the backup directory. Replace coherence.jar in the lib directory with the one in the backup directory.

    jar -uvf coherence.jar tangosol-coherence.xml
    cp coherence.jar \oracle\product\coherence\lib\coherence.jar
    

    When you execute cache-server.cmd, you should be able to view the modified port. Also, your cluster should now be restricted to your own host. If Membership ID still displays something other than 1, then there may be additional issues with the installation. See "Advanced Steps to Restrict Coherence to Your Own Host" for more information.

1.3.1.2 Advanced Steps to Restrict Coherence to Your Own Host

If you follow the steps in the previous section and cache-server.cmd still fails to return a Member Id value of 1, then there may be additional issues you must 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 between each attempt:

  • If connected to a VPN, disconnect from it. By default, most VPN networks are not configured to permit multicast and some unicast traffic. In this environment, Coherence may not work as it is configured out-of-the-box. Coherence can be configured to run across a VPN, but this requires some advanced settings.

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

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

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