在分布式模式

时间:2017-07-16 14:23:15

标签: java cluster-computing hazelcast vert.x

我们正在使用Vert.X库来开发REST服务层,以接收来自多个来源的消息。部分要求是在高可用性(HA)模式下运行REST Verticle。我们遵循vert.x核心手册来实现VertX集群,以便在分布式集群中运行(3个节点开始)。

根据文档我们做了以下

  1. 依赖项中包含的hazelcast库

        io.vertx     vertx-hazelcast     3.3.0

  2. 使用以下清单条目创建了一个胖jar,并在classpath中添加了资源文件夹,该文件夹需要加载所需的配置。我们从github

    中的vertx-examples中获取了hazelcast-default.xml

                              log4j.properties             config.json             hazelcast-default.xml中                                              io.vertx.core.Launcher             com.msg.verticles.RootVerticle             资源/                

  3. 创建一个脚本文件以触发启动器

    java -jar -Xmx2048m -Xms512m message-1.0-SNAPSHOT.jar -ha -D config = resources / config.json

  4. Launcher无法从resurce文件夹中拾取hazelcast-default.xml,并因以下异常而停止。不知道我在这里缺少什么。

    $> java -jar -Xmx2048m -Xms512m message-1.0-SNAPSHOT.jar -ha -D config = resources / config.json

    Jul 16, 2017 7:20:26 PM io.vertx.core.impl.launcher.commands.RunCommand
    INFO: Starting clustering...
    Jul 16, 2017 7:20:27 PM io.vertx.core.impl.launcher.commands.RunCommand
    INFO: No cluster-host specified so using address 127.0.0.1
    Jul 16, 2017 7:20:28 PM io.vertx.spi.cluster.hazelcast.HazelcastClusterManager
    WARNING: Cannot find cluster configuration on 'vertx.hazelcast.config' system property, on the classpath, or specified programmatically. Using default hazelcast configuration
    Jul 16, 2017 7:20:28 PM com.hazelcast.config.XmlConfigLocator
    INFO: Loading 'hazelcast-default.xml' from classpath.
    Jul 16, 2017 7:20:28 PM com.hazelcast.config.AbstractXmlConfigHelper
    WARNING: Name of the hazelcast schema location incorrect using default
    Jul 16, 2017 7:20:28 PM io.vertx.core.impl.VertxImpl
    SEVERE: Failed to join cluster
    com.hazelcast.core.HazelcastException: org.xml.sax.SAXParseException; schema_reference.4: Failed to read schema document 'null', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not <xsd:schema>.
            at com.hazelcast.util.ExceptionUtil.peel(ExceptionUtil.java:73)
    

2 个答案:

答案 0 :(得分:0)

根据documentation of Hazelcast cluster manager,您需要在类路径中名为cluster.xml的文件中指定Hazelcast配置(嵌入在fatjar的根目录中或类路径中的目录中)。

答案 1 :(得分:0)

通过将zookeeper配置为协调服务来解决此问题。这就像一个冠军!

https://github.com/vert-x3/vertx-zookeeper