简体   繁体   English

Spring Data Gemfire定位器

[英]Spring Data Gemfire locator

I'm trying to set up a Gemfire cluster using Spring Data Gemfire. 我正在尝试使用Spring Data Gemfire设置Gemfire集群。

I can start a locator via gfsh and I can start a server via Spring. 我可以通过gfsh启动定位器 ,也可以通过Spring启动服务器

The problem is, I can't find a way to start a locator via Spring. 问题是,我找不到通过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. 当测试或启动带有1个或多个Spring配置的GemFire服务器的独立集群时,我经常使用这种技术。

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. 注意,两个相关的GemFire系统属性是“ locators”属性和“ start-locator”属性。 The "start-locator" GemFire System property is the configuration setting to start an "embedded" Locator in the GemFire Server. “ start-locator” GemFire系统属性是用于在GemFire服务器中启动“嵌入式” Locator的配置设置。 The "locators" GemFire System property just tells the Server which Locator to contact to join the cluster (as determined by the Locator of course). “定位器” GemFire System属性仅告诉服务器要联系哪个定位器以加入集群(当然是由定位器确定的)。

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

Not only that, with the "" element, the GemFire Server will also become a "Cache Server" listening for and serving cache clients. 不仅如此,借助“”元素,GemFire服务器还将成为侦听和服务缓存客户端的“缓存服务器”。

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... 一旦GemFire服务器启动“嵌入式”定位器(或可选地还有GemFire管理服务(管理器)),您就可以像这样在Gfsh中连接到它...

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. 请注意,从Gfsh向定位器的连接请求只是发送一个请求以“定位”集群中的Manager。 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. 如果集群中有一个Manager,则Locator发送回Manager的坐标(IP /端口),否则Locator将承担Manager的角色(默认情况下,Locator的jmx-manager = start设置)并将响应发送回Gfsh。 Gfsh will then form a new JMX-RMI connection directly to the Manager. 然后,Gfsh将直接建立到Manager的新JMX-RMI连接。 Therefore, using 'connect --jmx-manager' is more direct if you know the IP and PORT. 因此,如果您知道IP和PORT,则使用'connect --jmx-manager'更直接。

Also note, the GemFire "locators" System property can be a comma-delimited list of Locators like so... 还要注意,GemFire“定位器”系统属性可以是逗号分隔的定位器列表,例如...

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. 但是,“ start-locator” GemFire System属性只是一个host [port],因为您只能有1个“嵌入式” Locator。

Now, the other way in which you can start a Locator is using a Spring FactoryBean. 现在,启动定位器的另一种方法是使用Spring FactoryBean。 Awhile back, I created a LocatorLauncherFactoryBean based on GemFire's LocatorLauncher public, Java API class. 不久前,我基于GemFire的LocatorLauncher公共Java API类创建了LocatorLauncherFactoryBean。

This class was a prototype for a customer to demonstrate how a Locator could be configured and started in a Spring context. 此类是客户的原型,以演示如何在Spring上下文中配置和启动Locator。 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. 我计划最终在Spring上下文中引入正式的支持,以配置Locator,但是与其他票证相比,此JIRA票证的优先级较低。

See SGF-222 for further details. 有关更多详细信息,请参见SGF-222 You will also find the LocatorLauncherFactoryBean class attached to the JIRA ticket. 您还将找到JIRA票证附带的LocatorLauncherFactoryBean类。 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. 同样,LocatorLauncherFactoryBean是一个原型,并且在实际GemFire LocatorLauncher类上对广泛的配置设置的支持方面还不完善。

Hope this helps; 希望这可以帮助; cheers! 干杯!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM