I'm trying to set up a Gemfire cluster using Spring Data Gemfire.
I can start a locator via gfsh and I can start a server via Spring.
The problem is, I can't find a way to start a locator via Spring.
I'm trying to set up a Gemfire cluster using Spring Data Gemfire.
I can start a locator via gfsh and I can start a server via Spring.
The problem is, I can't find a way to start a locator via Spring.
Probably the simplest, easiest way is to start an "embedded" Locator in a Server. I use this technique quite frequently when testing or starting a standalone cluster with 1 or more Spring-configured GemFire Servers.
The configuration looks like the following...
<util:properties id="gemfireProperties">
<prop key="name">GemFireServerWithEmbeddedLocator</prop>
<prop key="mcast-port">0</prop>
<prop key="locators">localhost[11235]</prop>
<prop key="log-level">config</prop>
<prop key="start-locator">localhost[11235]</prop>
</util:properties>
<gfe:cache properties-ref="gemfireProperties"/>
...
Note, the 2 pertinent GemFire System properties are the "locators" property and "start-locator" property. The "start-locator" GemFire System property is the configuration setting to start an "embedded" Locator in the GemFire Server. The "locators" GemFire System property just tells the Server which Locator to contact to join the cluster (as determined by the Locator of course).
You can even get more sophisticated with the following configuration...
<util:properties id="gemfireProperties">
<prop key="name">GemFireCacheServerManagerLocator</prop>
<prop key="mcast-port">0</prop>
<prop key="locators">localhost[11235]</prop>
<prop key="log-level">config</prop>
<prop key="http-service-port">8181</prop>
<prop key="jmx-manager">true</prop>
<prop key="jmx-manager-port">1199</prop>
<prop key="jmx-manager-start">true</prop>
<prop key="start-locator">localhost[11235]</prop>
</util:properties>
<gfe:cache properties-ref="gemfireProperties"/>
<gfe:cache-server auto-startup="true" bind-address="${server.bind.address}" port="${server.port}" host-name-for-clients="${server.hostname.for.clients}" max-connections="${server.max.connections}"/>
In this configuration, I have told the GemFire Server to start an "embedded" Locator ("start-locator") and connect to it ("locators"), to serve as a GemFire Manager in the cluster ("jmx-manager") then start up the management service ("jmx-manager-start") and finally to start the "embedded" HTTP service, implemented with Jetty ("http-service-port"), which will start Pulse, the Management REST API and as well as the Developer REST API.
Not only that, with the "" element, the GemFire Server will also become a "Cache Server" listening for and serving cache clients.
Once the GemFire Server starts an "embedded" Locator (or optionally the GemFire Management Service (a Manager) as well), you can connect to it in Gfsh like so...
gfsh>connect --locator=localhost[11235]
Or, if you started the Management Service, you can connect directly to the Manager with...
gfsh>connect --jmx-manager=localhost[1199]
Note, the connection request to a Locator from Gfsh just sends a request to "locate" the Manager in the cluster. If there is a Manager in the cluster, the Locator sends back the Manager's coordinates (IP/Port), otherwise the Locator will assume the role of a Manager (Locator's have jmx-manager=start set by default) and send back the response to Gfsh. Gfsh will then form a new JMX-RMI connection directly to the Manager. Therefore, using 'connect --jmx-manager' is more direct if you know the IP and PORT.
Also note, the GemFire "locators" System property can be a comma-delimited list of Locators like so...
locators=host1[port1],host2[port2],...,hostN[portN]
However, the "start-locator" GemFire System property is just a host[port] as you can only have 1 "embedded" Locator.
Now, the other way in which you can start a Locator is using a Spring FactoryBean. Awhile back, I created a LocatorLauncherFactoryBean based on GemFire's LocatorLauncher public, Java API class.
This class was a prototype for a customer to demonstrate how a Locator could be configured and started in a Spring context. I plan on introducing formal support for configuring Locators in a Spring context eventually, however the priority of this JIRA ticket is low compared to other tickets.
See SGF-222 for further details. You will also find the LocatorLauncherFactoryBean class attached to the JIRA ticket. Feel free to use and tweak for your purposes.
Again, the LocatorLauncherFactoryBean is a prototype and not nearly complete in it's support of the wide range of configuration settings on the actual GemFire LocatorLauncher class.
Hope this helps; cheers!