基于Hazelcast的过程状态聚类

从2.7.0版开始,geoserver有一个新的WPS扩展点,允许同一集群中的geoserver节点共享当前WPS请求的状态。这对于异步节点尤其重要,因为客户端对进度/结果的轮询可能不会到达当前正在运行请求的同一节点。

基于Hazelcast的状态共享模块利用Hazelcast库使用复制的映射共享当前流程状态的信息。

安装

模块的安装遵循大多数扩展的常规过程:

  • 停止地理服务器

  • 将gs-wps-hazelcast-status.zip的内容解压缩到 geoserver/WEB-INF/lib 文件夹

  • 重新启动geoserver

配置

如果默认行为适合部署环境,则该模块不需要任何配置。

默认情况下,模块将使用多播消息定位同一集群中的其他节点,并自动开始与它们共享有关进程状态的信息。

如果这不令人满意,a hazelcast.xml 可以在geoserver数据目录的根目录中创建/编辑文件,以修改网络连接方法。

该文件没有使用特定于地理服务器的语法,而是使用常规的 Hazelcast configuration 带有简单分布式映射声明的文件:

<hazelcast xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://www.hazelcast.com/schema/config
                               http://www.hazelcast.com/schema/config/hazelcast-config-3.3.xsd"
  xmlns="http://www.hazelcast.com/schema/config">

  <!-- Protecting against accidental cluster joining -->
  <group>
    <name>geoserver</name>
    <password>geoserver</password>
  </group>

  <!--
     Make Hazelcast use log4j just like GeoServer. Remember to add:
       log4j.category.com.hazelcast=INFO
     in the geoserver logging configuration to see Hazelcast log messages
  -->
  <properties>
    <property name="hazelcast.logging.type">log4j</property>
  </properties>

  <!-- Network section, by default it enables multicast, tune it to use tcp in case
    multicast is not allowed, and list the nodes that make up a reasonable core of the
    cluster (e.g., machines that will never be all down at the same time) -->
  <network>
    <port auto-increment="true">5701</port>
    <join>
      <multicast enabled="true">
        <multicast-group>224.2.2.3</multicast-group>
        <multicast-port>54327</multicast-port>
      </multicast>
      <tcp-ip enabled="false">
        <interface>127.0.0.1</interface>
      </tcp-ip>
      <aws enabled="false">
        <access-key>my-access-key</access-key>
        <secret-key>my-secret-key</secret-key>
        <region>us-east-1</region>
      </aws>
    </join>
  </network>



  <!-- The WPS status map -->
  <map name="wpsExecutionStatusMap">
    <indexes>
      <!-- Add indexes to support the two most common queries -->
      <index ordered="false">executionId</index>
      <index ordered="true">completionTime</index>
    </indexes>
  </map>
</hazelcast>

如果需要基于TCP的配置,只需禁用多播配置,启用TCP IP配置,并在其中添加一个将构成集群核心的接口地址列表。并非集群中的所有节点都需要在所述部分中列出,而是一个足够长的列表,以确保并非列表中的所有节点都可能同时关闭:只要所述节点中至少有一个存在,集群将保持其完整性。