Skip Headers
Oracle® Coherence Developer's Guide
Release 3.6.1

Part Number E15723-03
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Feedback page
Contact Us

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

7 Setting Single Server Mode

If you want to perform unit testing or quick restarts, you might find it more convenient to avoid the network and run in single-server mode. To constrain Coherence to run on a single server, set the multicast packet time-to-live to 0, and set the unicast IP address.

You can configure these properties either by declaring system properties on the command line or by editing the values in the operational configuration descriptor, tangosol-coherence.xml file.

Setting Single Server Mode in the Operation Configuration Descriptor

In the tangosol-coherence.xml file, the multicast packet time to live value is defined by the <time-to-live> subelement of the <multicast-listener> element. The <time-to-live> value determines the maximum number of "hops" a packet may traverse between network segments. Setting this subelement to 0 keeps the packets from leaving the originating machine.

The unicast IP address is defined by the <address> subelement of the <unicast-listener> element. This subelement specifies the IP address that a Socket will listen or publish on and must be routed to loopback as well. Setting this subelement to an IP address that is never used will prevent Coherence from joining the network.

Note:

The "localhost" setting may not work on systems that define localhost as the loopback address; in that case, specify the machine name or the specific IP address.

The following XML code fragment illustrates a single server mode configuration in the tangosol-coherence.xml file.

Example 7-1 Single Server Mode Configuration

<coherence>
    <cluster-config>
        ...
        <multicast-listener>
            <time-to-live>0<\time-to-live>
            ...
        <mulitcast-listener>
        ...
        <unicast-listener>
            <address>127.0.0.1<\address>
            ...
        <\unicast-listener>
        ...
   <\cluster-config>
<\coherence>

Setting Single Server Mode on the Command Line

Coherence defines system properties that allow you to set the multicast packet time-to-live and the unicast IP address for single server mode on the command line. This feature is useful when you need to change the settings for a single JVM, or if you want to start an application with settings that differ from those in the descriptor files.

The following system properties can be used to define single server mode.

The sample command line in Example 7-2 illustrates starting coherence in single server mode:

Example 7-2 Command to Start Coherence in Single Server Mode

java -Dtangosol.coherence.localhost=127.0.0.1 -Dtangosol.coherence.ttl=0 -jar coherence.jar

See Appendix C, "Command Line Overrides" for more information on system properties defined by Coherence.