(Quick Reference)

3 Cache Servers - Reference Documentation

Authors: Jeff Brown, Graeme Rocher

Version: 1.0.0.BUILD-SNAPSHOT

Table of Contents

3 Cache Servers

Gemfire supports a client / server mode for caching which can unlock some of the nicer Gemfire features including:
  • Grid computing
  • Continuous querying
  • Advanced data partitioning

In order to use client/server mode you need to install gemfire as per the documentation.

This plugin provides scripts to start up cache servers and locators.

To startup cache servers you can use the start-cache-server command.

grails start-cache-server server1

You can stop a server again using the stop-cache-server command:

grails stop-cache-server server1

The port of the server is automatically assigned. If you want to specify the port, locator server or multicast options there are more advanced arguments:

grails start-cache-server server1 --locators=localhost[4111] --port=41112 --mcast-port=0

If the multicast port (mcast-port) option is set to 0 then multicast is disabled. If you disable multicast then you will need to setup a locator server.

You can setup a locator by running the start-locator command:

grails start-locator

This will start the locator on port 55221 by default. If you wish to start the locator service on a different port you can use:

grails start-locator --port=4111

A locator is responsible for looking up the location of cache servers. If you don't use a locator then the default multicast lookup will happen.

3.1 Cache Server Clients

Once you have some cache servers up and running you need to configure the Grails application to act as a client to the servers.

// grails-app/conf/Config.groovy
grails.gemfire.servers = {    
	myServer {
		properties = ['log-level': 'warning']
		pool {
			addServer "localhost", 4111
			setMinConnections 1
			setMaxConnections 20
			setRetryAttempts 10
			setSubscriptionEnabled true
		}
	}
}

The example above using a single cache server. If you plan to use multiple cache servers then you can specify one or many locators.

// grails-app/conf/Config.groovy
grails.gemfire.servers = {    
	myServer {
		properties = ['log-level': 'warning']
		pool {
			addLocator "localhost", 4111
			setMinConnections 1
			setMaxConnections 20
			setRetryAttempts 10
			setSubscriptionEnabled true
		}
	}
}

If you want to use continuous queries make sure that subscriptionEnabled is set to true on the pool. For all the configuration options see the PoolFactory API in the Gemfire documentation