Spring Data Gemfire定位器 [英] Spring Data Gemfire locator

查看:94
本文介绍了Spring Data Gemfire定位器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Spring Data Gemfire设置Gemfire集群.

I'm trying to set up a Gemfire cluster using Spring Data Gemfire.

我可以通过 gfsh 启动定位器,也可以通过Spring启动服务器.

I can start a locator via gfsh and I can start a server via Spring.

问题是,我找不到通过Spring启动 locator 的方法.

The problem is, I can't find a way to start a locator via Spring.

推荐答案

可能最简单,最简单的方法是在服务器中启动嵌入式"定位器.在测试或启动带有1个或多个Spring配置的GemFire服务器的独立集群时,我经常使用这种技术.

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.

配置如下所示...

<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"/>

...

请注意,两个相关的GemFire System属性是"locators"属性和"start-locator"属性. "start-locator" GemFire系统属性是用于在GemFire服务器中启动嵌入式" Locator的配置设置. 定位器" GemFire System属性仅告诉服务器要与哪个定位器联系以加入集群(这当然是由定位器确定的).

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}"/>

在此配置中,我告诉GemFire服务器启动一个嵌入式"定位器("start-locator")并连接到它(定位器"),以充当集群中的GemFire Manager("jmx-管理器"),然后启动管理服务("jmx-manager-start"),最后启动由Jetty实现的嵌入式" HTTP服务("http-service-port"),该服务将启动Pulse,即管理REST API以及Developer REST API.

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.

不仅如此,通过"元素,GemFire服务器还将成为侦听并为缓存客户端提供服务的缓存服务器".

Not only that, with the "" element, the GemFire Server will also become a "Cache Server" listening for and serving cache clients.

一旦GemFire服务器启动嵌入式"定位器(或可选的GemFire管理服务(管理器)),您就可以像这样在Gfsh中连接到它...

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]

或者,如果您启动了Management Service,则可以使用...直接连接到Manager.

Or, if you started the Management Service, you can connect directly to the Manager with...

gfsh>connect --jmx-manager=localhost[1199]

注意,从Gfsh到定位器的连接请求只是发送一个请求以定位"集群中的Manager.如果集群中有Manager,则Locator会发回Manager的坐标(IP/端口),否则Locator将承担Manager的角色(默认情况下,Locator的jmx-manager = start设置)并将响应发送回Gfsh. Gfsh随后将直接建立到Manager的新JMX-RMI连接.因此,如果您知道IP和PORT,则使用'connect --jmx-manager'更直接.

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.

还请注意,GemFire定位器"系统属性可以是逗号分隔的定位器列表,例如...

Also note, the GemFire "locators" System property can be a comma-delimited list of Locators like so...

locators=host1[port1],host2[port2],...,hostN[portN]

但是,"start-locator" GemFire System属性只是一个主机[端口],因为您只能有1个嵌入式" Locator.

However, the "start-locator" GemFire System property is just a host[port] as you can only have 1 "embedded" Locator.

现在,启动定位器的另一种方法是使用Spring FactoryBean.不久前,我基于GemFire的LocatorLauncher公共Java API类创建了LocatorLauncherFactoryBean.

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.

该类是客户的原型,以演示如何在Spring上下文中配置和启动Locator.我打算最终在Spring上下文中引入正式的支持,以配置Locator,但是与其他票证相比,此JIRA票证的优先级较低.

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.

有关更多详细信息,请参见 SGF-222 .您还将找到JIRA票证附带的LocatorLauncherFactoryBean类.随意使用和调整以达到您的目的.

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.

同样,LocatorLauncherFactoryBean是一个原型,并且在实际的GemFire LocatorLauncher类上对广泛的配置设置的支持方面还不够完善.

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!

这篇关于Spring Data Gemfire定位器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆