Code Monkey home page Code Monkey logo

hazelcast-consul-discovery-spi's Introduction

hazelcast-consul-discovery-spi

Build Status

Provides a Consul based discovery strategy for Hazlecast 3.6+ enabled applications. This is an easy to configure plug-and-play Hazlecast DiscoveryStrategy that will optionally register each of your Hazelcast instances with Consul and enable Hazelcast nodes to dynamically discover one another via Consul.

See "releases" below for important compatibility details with different version of Hazelcast.

Diagram of hazelcast consul discovery strategy

Status

This is release candidate code, tested against Hazelcast 3.6-EA+ through 3.9.x and 4.x stable releases, as well as Consul 0.7.x up to 1.0.x.

IMPORTANT:: Do not rely on JCenter/Bintray anymore! Update your gradle/maven dependencies to use Maven Central: https://search.maven.org/search?q=g:org.bitsofinfo

Releases

Hazelcast compatibility

Release history

  • MASTER - in progress, this README refers to what is in the master tag. Switch to relevant RELEASE tag above to see that versions README

  • 2.0-RC1-20210205: Same as 2.0-RC1 but made compliant for Maven Central due to JCenter/Bintray closure.

  • 2.0-RC1: PR #33 #34 Compat updates for Hazelcast 4.x thanks @amrsamii. REQUIRES HAZELCAST 4.x+, will not work with Hazelcast <= 3.x

  • 1.0-RC9-20210205: Same as 1.0-RC9 but made compliant for Maven Central due to JCenter/Bintray closure. Also explicity defined hazelcast dependency 3.10.4

  • 1.0-RC9: PR #28 #29 (consul health script fixes) for #27

  • 1.0-RC8: Tweaks for Consul 0.8+ (health check sample script change). consul-client upgrade to 0.17.1; build.gradle HZ 3.+ dependency. Address post Consul 0.8 ACL notes (in README) for [#26]

  • 1.0-RC7: consul-client 0.13.12; Fix [#17] with PR #18

  • 1.0-RC6: Fix [#12], consul-client 0.13.2 upgrade, fix base64 Java 8 issue. Tested against Hazelcast 3.6-EA+ through 3.7+ Stable releases

  • 1.0-RC5: Upgrade to latest consul-client #11 Tested against Hazelcast 3.6-EA+ through 3.6.4+ Stable releases

  • 1.0-RC4: Adds support for TCP/HTTP checks #3 Tested against Hazelcast 3.6-EA+ through 3.6 Stable releases

  • 1.0-RC3: Adds support for TLS #2 and Consul ACLs #4 Tested against Hazelcast 3.6-EA+ through 3.6 Stable releases

  • 1.0-RC2: Tested against Hazelcast 3.6-EA+ through 3.6 Stable releases

  • 1.0-RC1: Tested against Hazelcast 3.6-EA+ through 3.6-RC1 Stable releases

Requirements

Maven/Gradle

To use this discovery strategy in your Maven or Gradle project use the dependency samples below.

Gradle:

repositories {
    mavenCentral()
}

dependencies {
	compile 'org.bitsofinfo:hazelcast-consul-discovery-spi:2.0-RC1-20210205'

    // include your preferred javax.ws.rs-api implementation
    // (for the OrbitzWorldwide/consul-client dependency)
    // for example below:
    compile 'org.apache.cxf:cxf-rt-rs-client:3.0.3'
    compile 'org.apache.cxf:cxf-rt-transports-http-hc:3.0.3'
}

Maven:

<dependencies>
    <dependency>
        <groupId>org.bitsofinfo</groupId>
        <artifactId>hazelcast-consul-discovery-spi</artifactId>
        <version>2.0-RC1-20210205</version>
    </dependency>

    <!-- include your preferred javax.ws.rs-api
         (for the https://github.com/OrbitzWorldwide/consul-client dependency)
         implementation - see gradle example above
    -->
</dependencies>

Features

  • Supports two modes of operation:

    • Read-write: peer discovery and registration of a hazelcast instance without a local Consul agent (self registration)
    • Read-only: peer discovery only with an existing Consul agent setup (no registration by the strategy itself)
  • If you don't want to use the built in Consul registration, just specify the DoNothingRegistrator (see below) in your hazelcast discovery-strategy XML config. This will require you to run your own Consul agent that defines the hazelcast service.

  • If using self-registration, either LocalDiscoveryNodeRegistrator or ExplicitIpPortRegistrator which additionally support:

    • Automatic registration of the hazelcast instance with Consul
    • Custom Consul health-check script/interval to validate Hazelcast instance healthly
    • Control which IP is published as the service-address with Consul
    • Configurable discovery delay
    • Automatic Consul de-registration of instance via ShutdownHook

Usage

  • Ensure your project has the hazelcast-consul-discovery-spi artifact dependency declared in your maven pom or gradle build file as described above. Or build the jar yourself and ensure the jar is in your project's classpath.

  • Have Consul running and available somewhere on your network, start it such as:

consul agent -server -bootstrap-expect 1 -data-dir /tmp/consul -config-dir /path/to/consul.d/ -ui-dir /path/to/consul-web-ui [-enable-script-checks]
  • Configure your hazelcast.xml configuration file to use the ConsulDiscoveryStrategy (similar to the below): See hazelcast-consul-discovery-spi-example.xml for a full example with documentation of options.

  • Launch your hazelcast instances, configured with the Consul discovery-strategy similar to the below: see ManualRunner.java example.

<network>
  <port auto-increment="true">5701</port>

  <join>
    <multicast enabled="false"/>
    <aws enabled="false"/>
    <tcp-ip enabled="false" />

     <discovery-strategies>
       <discovery-strategy enabled="true"
           class="org.bitsofinfo.hazelcast.discovery.consul.ConsulDiscoveryStrategy">

         <properties>
              <property name="consul-host">localhost</property>
              <property name="consul-port">8500</property>
              <property name="consul-service-name">hz-discovery-test-cluster</property>
              <property name="consul-healthy-only">true</property>
              <property name="consul-service-tags">hazelcast, test1</property>
              <property name="consul-discovery-delay-ms">10000</property>

              <property name="consul-acl-token"></property>
              <property name="consul-ssl-enabled">false</property>
              <property name="consul-ssl-server-cert-file-path"></property>
              <property name="consul-ssl-server-cert-base64"></property>
              <property name="consul-ssl-server-hostname-verify">true</property>

              <property name="consul-registrator">org.bitsofinfo.hazelcast.discovery.consul.LocalDiscoveryNodeRegistrator</property>
              <property name="consul-registrator-config"><![CDATA[
    					{
    					  "preferPublicAddress":false,
    					  "healthCheckProvider":"org.bitsofinfo.hazelcast.discovery.consul.ScriptHealthCheckBuilder",
    					  "healthCheckScript":"nc -z #MYIP #MYPORT",
    					  "healthCheckScriptIntervalSeconds":30,
    					}
                  ]]></property>
        </properties>
      </discovery-strategy>
    </discovery-strategies>

  </join>
</network>
  • The above example uses a script health check, so don't forget to enable it in consul (see Consul checks definition). You can also make use of a simple network TCP check, substituting the healthChek properties about with the following:
                "healthCheckProvider":"org.bitsofinfo.hazelcast.discovery.consul.TcpHealthCheckBuilder",
                "healthCheckTcp":"#MYIP:#MYPORT",
                "healthCheckTcpIntervalSeconds":30
  • An you can also use the HTTP healthcheck that Hazelcast provides, don't forget to set Hazelcast property 'hazelcast.http.healthcheck.enabled' to true. (see Hazelcast's Simple HTTP based healthcheck implementation), substituting the healthChek properties about with the following:
 <property name="hazelcast.http.healthcheck.enabled">true</property>
 ...
                "healthCheckProvider":"org.bitsofinfo.hazelcast.discovery.consul.HttpHealthCheckBuilder",
                "healthCheckHttp":"http://#MYIP:#MYPORT/hazelcast/health",
                "healthCheckHttpIntervalSeconds":30,
  • Once nodes are joined you can query Consul to see the auto-registration of hazelcast instances works, the service-id's generated etc

curl http://localhost:8500/v1/catalog/services

{
  "consul":[],
  "hz-discovery-test-cluster":["hazelcast","test1"],
  "web":["rails"]
}

curl http://localhost:8500/v1/catalog/service/hz-discovery-test-cluster

[
  {
    "Node":"myhost1",
    "Address":"192.168.0.208",
    "ServiceID":"hz-discovery-test-cluster-192.168.0.208-192.168.0.208-5701",
    "ServiceName":"hz-discovery-test-cluster",
    "ServiceTags":[
      "hazelcast",
      "test1"
    ],
    "ServiceAddress":"192.168.0.208",
    "ServicePort":5701
  },
  {
    "Node":"myhost1",
    "Address":"192.168.0.208",
    "ServiceID":"hz-discovery-test-cluster-192.168.0.208-192.168.0.208-5702",
    "ServiceName":"hz-discovery-test-cluster",
    "ServiceTags":[
      "hazelcast",
      "test1"
    ],
    "ServiceAddress":"192.168.0.208",
    "ServicePort":5702
  }
]

Building from source

  • From the root of this project, build a Jar : ./gradlew assemble

  • Include the built jar artifact located at build/libs/hazelcast-consul-discovery-spi-[VERSION].jar in your hazelcast project

  • If not already present in your hazelcast application's Maven (pom.xml) or Gradle (build.gradle) dependencies section; ensure that these dependencies are present (versions may vary as appropriate):

compile group: 'com.orbitz.consul', name: 'consul-client', version:'1.2.3'
compile group: 'org.apache.cxf', name:'cxf-rt-rs-client', version:'3.0.3'
compile group: 'org.apache.cxf', name:'cxf-rt-transports-http-hc', version:'3.0.3'

Consul UI example

Showing LocalDiscoveryNodeRegistrator configured hazelcast services with health-checks

Diagram of consul ui

Unit-tests

It may also help you to understand the functionality by checking out and running the unit-tests located at src/test/java. BE SURE TO READ the comments in the test source files as some of the tests require you to setup your local Consul and edit certain files.

From the command line you can run TestExplicitIpPortRegistrator and TestLocalDiscoveryNodeRegistrator unit-tests by invoking the runTests task using gradlew that runs both tests and displays the result on the console.

$ ./gradlew runTests

The task above will display output indicating the test has started and whether the test has passed or failed.

Sample output for passing test:
org.bitsofinfo.hazelcast.discovery.consul.TestExplicitIpPortRegistrator > testExplicitIpPortRegistrator STARTED

org.bitsofinfo.hazelcast.discovery.consul.TestExplicitIpPortRegistrator > testExplicitIpPortRegistrator PASSED
Sample output for failing test:
org.bitsofinfo.hazelcast.discovery.consul.TestDoNothingRegistrator > testDoNothingRegistrator STARTED

org.bitsofinfo.hazelcast.discovery.consul.TestDoNothingRegistrator > testDoNothingRegistrator FAILED
    java.lang.AssertionError at TestDoNothingRegistrator.java:85

To run individual unit-test, use the unitTest.single argument to provide the unit-test you would like to run. The command below runs the unit test for TestDoNothingRegistrator

$ ./gradlew -DunitTest.single=TestDoNothingRegistrator unitTest
Note on running TestDoNothingRegistrator unit-test

The TestDoNothingRegistrator unit-test should be run separately using the unitTest.single argument as demonstrated above as it requires you to register a service with your local consul with 5 nodes/instances. Please CAREFULLY READ the comments in TestDoNothingRegistrator.java to see how this test should be run.

Passing optional parameters to unit-tests

The following parameters can be passed with the -D option when invoking the tests

-DconsulPort=(some port)
-DconsulHost=(some host)
-DconsulAclToken=(some ACL token if the server requires it)
-DconsulSslEnabled=(true | false)
-DconsulSslServerCertFilePath=(/path/to/ca.cert)
-DconsulSslServerCertBase64=(base64 encoded cert string)
-DconsulSslServerHostnameVerify=(false|True)
-DconsulHealthCheckProvider=(org.bitsofinfo.hazelcast.discovery.consul.ScriptHealthCheckBuilder | org.bitsofinfo.hazelcast.discovery.consul.HttpHealthCheckBuilder)

Related info

Todo

  • Ensure all configuration tweakable via -D system properties

Notes

Containerization (Docker) notes

This library may also be helpful to you: docker-discovery-registrator-consul

One of the main drivers for coding this module was for Hazelcast applications that were deployed as Docker containers that would need to automatically register themselves with Consul for higher level cluster orchestration of the cluster.

If you are deploying your Hazelcast application as a Docker container, one helpful tip is that you will want to avoid hardwired configuration in the hazelcast XML config, but rather have your Docker container take startup arguments that would be translated to -D system properties on startup. Convienently Hazelcast can consume these JVM system properties and replace variable placeholders in the XML config. See this documentation for examples: http://docs.hazelcast.org/docs/3.6/manual/html-single/index.html#using-variables

Specifically when using this discovery strategy and Docker, it may be useful for you to use the ExplicitIpPortRegistrator ConsulRegistrator instead of the LocalDiscoveryNodeRegistrator as the latter relies on hazelcast to determine its IP/PORT and this may end up being the local container IP, and not the Docker host IP, leading to a situation where a unreachable IP/PORT combination is published to Consul.

Example: excerpt from explicitIpPortRegistrator-example.xml

Start your hazelcast app such as with the below, this would assume that hazelcast is actually reachable via this configuration via your Docker host and the port mappings that were specified on docker run. (i.e. the IP below would be your docker host/port that is mapped to the actual hazelcast app container and port it exposes for hazelcast).

See this Docker issue for related info on detecting mapped ports/ip from within a container

java -jar myHzApp.jar -DregisterWithIpAddress=<dockerHostIp> -DregisterWithPort=<mappedContainerPortOnDockerHost> ....

<property name="consul-registrator-config"><![CDATA[
      {
        "registerWithIpAddress":"${registerWithIpAddress}",
        "registerWithPort":${registerWithPort},
        "healthCheckScript":"nc -z #MYIP #MYPORT",
        "healthCheckScriptIntervalSeconds":30
      }
  ]]></property>

Until hazelcast fixes the numerous issues around interfaces/binding etc, you may be better off just running your hz app in a docker swarm and use: https://github.com/bitsofinfo/hazelcast-docker-swarm-discovery-spi for peer to peer hazelcast cluster discovery.

Consul health-check notes

Depending on the health check script you are using: (nc -z #MYIP #MYPORT OR /bin/sh exec 6<>/dev/tcp/#MYIP/#MYPORT || (exit 3) should see something like in your Consul agent monitor when the health-check scripts are running:

> consul monitor --log-level trace

2015/11/20 11:21:39 [DEBUG] agent: check 'service:hz-discovery-test-cluster-192.168.0.208-192.168.0.208-5701' script 'exec 6<>/dev/tcp/192.168.0.208/5701 || (exit 3)' output:
2015/11/20 11:21:39 [DEBUG] agent: Check 'service:hz-discovery-test-cluster-192.168.0.208-192.168.0.208-5701' is passing

Depending on the version of Hazelcast you are using, you may see something like these warnings logged when the health-check script interrogates the hazelcast port and does nothing. You are free to monitor the services any way you wish, or not at all by omitting the healthCheckScript JSON property; see See hazelcast-consul-discovery-spi-example.xml for an example.

Dec 13, 2017 10:25:40 AM com.hazelcast.nio.tcp.TcpIpConnection
INFO: [172.20.10.2]:5702 [hazelcast-consul-discovery-spi] [3.9.1] Connection[id=3, /172.20.10.2:5702->/172.20.10.2:57436, endpoint=null, alive=false, type=NONE] closed. Reason: Connection closed by the other side

Dec 13, 2017 10:25:40 AM com.hazelcast.nio.tcp.TcpIpConnection
INFO: [172.20.10.2]:5702 [hazelcast-consul-discovery-spi] [3.9.1] Connection[id=3, /172.20.10.2:5702->/172.20.10.2:57436, endpoint=null, alive=false, type=NONE] closed. Reason: Connection closed by the other side

OR

Nov 20, 2015 6:57:50 PM com.hazelcast.nio.tcp.SocketAcceptorThread
INFO: [192.168.0.208]:5701 [hazelcast-consul-discovery] [3.6] Accepting socket connection from /192.168.0.208:53495
Nov 20, 2015 6:57:50 PM com.hazelcast.nio.tcp.TcpIpConnectionManager
INFO: [192.168.0.208]:5701 [hazelcast-consul-discovery] [3.6] Established socket connection between /192.168.0.208:5701 and /192.168.0.208:53495
Nov 20, 2015 6:57:50 PM com.hazelcast.nio.tcp.nonblocking.NonBlockingSocketWriter
WARNING: [192.168.0.208]:5701 [hazelcast-consul-discovery] [3.6] SocketWriter is not set, creating SocketWriter with CLUSTER protocol!
Nov 20, 2015 6:57:50 PM com.hazelcast.nio.tcp.TcpIpConnection
INFO: [192.168.0.208]:5701 [hazelcast-consul-discovery] [3.6] Connection [/192.168.0.208:53495] lost. Reason: java.io.EOFException[Could not read protocol type!]

Consul ACL issues

This library was originally developed prior to Consul 0.8, as of 0.8+, changes to the ACL system were made which may require you to grant additional access if your target consul is in default deny mode

See:

For examples: For the unit tests to work, create a new client token w/ the following policy, then assign the token to the consul-acl-token setting for this SPI's XML config:

service "" { policy = "write" },
node "" { policy = "write" },
agent "" { policy = "read" }

NOTE! The above sample is just that (a simple sample), in production you may want to re-evaluate and lock down further as needed.

push

./gradlew -PbintrayUser= -PbintrayApiKey= bintray 

hazelcast-consul-discovery-spi's People

Contributors

amrsamii avatar bitsofinfo avatar bmudda-wpp avatar verdoso avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hazelcast-consul-discovery-spi's Issues

add options for Consul SSL enabled backends

Add options for Consul SSL enabled backends, these options should be available regardless of registrator strategy used

<property name="consul-ssl-enabled">true | false</property>
<property name="consul-ssl-server-cert-file-path">pathToCustomSelfSigned consul cert we want to trust</property>
<property name="consul-ssl-server-cert-base64">base64 encoded self-signed consul ssl certificate to trust</property>
<property name="consul-ssl-server-hostname-verify">true | false</property>

Update all examples/unit-tests

Unable connect to consul agent with tls enabled

I have consul cluster with tls enabled. I've also some agents with disabled incoming verify and i am trying to setup cluster with consul discovery. I've added this jars to my hazelcast CLASSPATH:

consul-client-1.4.2.jar
converter-jackson-2.8.1.jar
guava-28.2-jre.jar
hazelcast-consul-discovery-spi-1.0-RC9.jar
jackson-annotations-2.9.10.jar
jackson-core-2.9.10.jar
jackson-databind-2.9.10.jar
jackson-datatype-guava-2.10.3.jar
jackson-datatype-jdk8-2.10.3.jar
kotlin-stdlib-1.3.71.jar
okhttp-4.4.0.jar
okio-2.5.0.jar
retrofit-2.8.1.jar
slf4j-api-1.7.30.jar

Next I've adjust hazelcast-consul-discovery-spi-example.xml and run hazelcast, but got some TLS errors:

Apr 07, 2020 6:35:08 AM com.hazelcast.spi.discovery.integration.DiscoveryService
SEVERE: [10.222.0.2]:5701 [hazelcast-consul-discovery-spi] [3.9.1] Unexpected error in configuring discovery: Error connecting to Consul
com.orbitz.consul.ConsulException: Error connecting to Consul
	at com.orbitz.consul.AgentClient.ping(AgentClient.java:69)
	at com.orbitz.consul.Consul$Builder.build(Consul.java:731)
	at org.bitsofinfo.hazelcast.discovery.consul.ConsulClientBuilder.buildConsul(ConsulClientBuilder.java:76)
	at org.bitsofinfo.hazelcast.discovery.consul.ConsulDiscoveryStrategy.<init>(ConsulDiscoveryStrategy.java:146)
	at org.bitsofinfo.hazelcast.discovery.consul.ConsulDiscoveryStrategyFactory.newDiscoveryStrategy(ConsulDiscoveryStrategyFactory.java:46)
	at com.hazelcast.spi.discovery.impl.DefaultDiscoveryService.buildDiscoveryStrategy(DefaultDiscoveryService.java:185)
	at com.hazelcast.spi.discovery.impl.DefaultDiscoveryService.loadDiscoveryStrategies(DefaultDiscoveryService.java:145)
	at com.hazelcast.spi.discovery.impl.DefaultDiscoveryService.<init>(DefaultDiscoveryService.java:60)
	at com.hazelcast.spi.discovery.impl.DefaultDiscoveryServiceProvider.newDiscoveryService(DefaultDiscoveryServiceProvider.java:29)
	at com.hazelcast.instance.Node.createDiscoveryService(Node.java:265)
	at com.hazelcast.instance.Node.<init>(Node.java:216)
	at com.hazelcast.instance.HazelcastInstanceImpl.createNode(HazelcastInstanceImpl.java:160)
	at com.hazelcast.instance.HazelcastInstanceImpl.<init>(HazelcastInstanceImpl.java:128)
	at com.hazelcast.instance.HazelcastInstanceFactory.constructHazelcastInstance(HazelcastInstanceFactory.java:195)
	at com.hazelcast.instance.HazelcastInstanceFactory.newHazelcastInstance(HazelcastInstanceFactory.java:174)
	at com.hazelcast.instance.HazelcastInstanceFactory.newHazelcastInstance(HazelcastInstanceFactory.java:124)
	at com.hazelcast.core.Hazelcast.newHazelcastInstance(Hazelcast.java:58)
	at com.hazelcast.core.server.StartServer.main(StartServer.java:46)
Caused by: java.net.UnknownServiceException: Unable to find acceptable protocols. isFallback=false, modes=[ConnectionSpec(cipherSuites=[TLS_AES_128_GCM_SHA256, TLS_AES_256_GCM_SHA384, TLS_CHACHA20_POLY1305_SHA256, TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384, TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256, TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, TLS_RSA_WITH_AES_128_GCM_SHA256, TLS_RSA_WITH_AES_256_GCM_SHA384, TLS_RSA_WITH_AES_128_CBC_SHA, TLS_RSA_WITH_AES_256_CBC_SHA, SSL_RSA_WITH_3DES_EDE_CBC_SHA], tlsVersions=[TLS_1_3, TLS_1_2], supportsTlsExtensions=true), ConnectionSpec()], supported protocols=[TLSv1]
	at okhttp3.internal.connection.ConnectionSpecSelector.configureSecureSocket(ConnectionSpecSelector.kt:63)
	at okhttp3.internal.connection.RealConnection.connectTls(RealConnection.kt:361)
	at okhttp3.internal.connection.RealConnection.establishProtocol(RealConnection.kt:325)
	at okhttp3.internal.connection.RealConnection.connect(RealConnection.kt:197)
	at okhttp3.internal.connection.ExchangeFinder.findConnection(ExchangeFinder.kt:233)
	at okhttp3.internal.connection.ExchangeFinder.findHealthyConnection(ExchangeFinder.kt:107)
	at okhttp3.internal.connection.ExchangeFinder.find(ExchangeFinder.kt:75)
	at okhttp3.internal.connection.RealCall.initExchange$okhttp(RealCall.kt:245)
	at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.kt:32)
	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:100)
	at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.kt:82)
	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:100)
	at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.kt:83)
	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:100)
	at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.kt:74)
	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:100)
	at com.orbitz.consul.cache.TimeoutInterceptor.intercept(TimeoutInterceptor.java:53)
	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:100)
	at com.orbitz.consul.Consul$Builder.lambda$withAclToken$2(Consul.java:419)
	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:100)
	at okhttp3.internal.connection.RealCall.getResponseWithInterceptorChain$okhttp(RealCall.kt:197)
	at okhttp3.internal.connection.RealCall.execute(RealCall.kt:148)
	at retrofit2.OkHttpCall.execute(OkHttpCall.java:190)
	at com.orbitz.consul.AgentClient.ping(AgentClient.java:62)
	... 17 more

Apr 07, 2020 6:35:08 AM com.hazelcast.spi.discovery.integration.DiscoveryService
INFO: [10.222.0.2]:5701 [hazelcast-consul-discovery-spi] [3.9.1] Registered our service instance w/ Consul OK.. delaying Hazelcast discovery, sleeping: 10000ms

Is the project still being maintained?

Hi
I was wondering if this project was still being maintained and if a non-RC version is planned for anytime in the future?
Just curious because seeing the last commit if from a year ago.

Would you advise to use it for production?

Thank you!

null service address on initial discovery

Hello,

At discovery time the healthy nodes are found however the host (service.getServiceAddress()) is missing. This seems to be causing the registration to fail.

I am running the master branch of this repo and Consul v0.7.5.

Problem area seems to be here. Note that port 5701 shows up but there is no host which results in a null a little later:

Mar 24, 2017 4:25:55 AM com.hazelcast.spi.discovery.integration.DiscoveryService
INFO: [10.250.130.160]:5701 [dev] [3.6.7] Discovered healthy node: :5701
Mar 24, 2017 4:25:55 AM com.hazelcast.spi.discovery.integration.DiscoveryService
INFO: [10.250.130.160]:5701 [dev] [3.6.7] Discovered healthy node: :5701

...

WARNING: [10.250.130.160]:5701 [dev] [3.6.7] Wrong bind request from Address[10.250.130.160]:5701! This node is not requested endpoint: Address[null]:5701
Mar 24, 2017 4:25:55 AM com.hazelcast.nio.tcp.TcpIpConnection

Full log output

Java HotSpot(TM) 64-Bit Server VM warning: ignoring option PermSize=256m; support was removed in 8.0
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=512m; support was removed in 8.0
Mar 24, 2017 4:30:08 AM com.hazelcast.config.XmlConfigLocator
INFO: Loading configuration /opt/idam/orchis-sessionstore/bin/hazelcast.xml from System property 'hazelcast.config'
Mar 24, 2017 4:30:08 AM com.hazelcast.config.XmlConfigLocator
INFO: Using configuration file at /opt/idam/orchis-sessionstore/bin/hazelcast.xml
Mar 24, 2017 4:30:09 AM com.hazelcast.instance.DefaultAddressPicker
INFO: [LOCAL] [dev] [3.6.7] Prefer IPv4 stack is true.
Mar 24, 2017 4:30:10 AM com.hazelcast.instance.DefaultAddressPicker
INFO: [LOCAL] [dev] [3.6.7] Picked Address[10.250.130.160]:5701, using socket ServerSocket[addr=/0:0:0:0:0:0:0:0,localport=5701], bind any local is true
Mar 24, 2017 4:30:10 AM com.hazelcast.system
INFO: [10.250.130.160]:5701 [dev] [3.6.7] Hazelcast 3.6.7 (20161208 - 3eec5a1) starting at Address[10.250.130.160]:5701
Mar 24, 2017 4:30:10 AM com.hazelcast.system
INFO: [10.250.130.160]:5701 [dev] [3.6.7] Copyright (c) 2008-2016, Hazelcast, Inc. All Rights Reserved.
Mar 24, 2017 4:30:10 AM com.hazelcast.system
INFO: [10.250.130.160]:5701 [dev] [3.6.7] Configured Hazelcast Serialization version : 1
Mar 24, 2017 4:30:10 AM com.hazelcast.spi.OperationService
INFO: [10.250.130.160]:5701 [dev] [3.6.7] Backpressure is disabled
Mar 24, 2017 4:30:10 AM com.hazelcast.spi.impl.operationexecutor.classic.ClassicOperationExecutor
INFO: [10.250.130.160]:5701 [dev] [3.6.7] Starting with 2 generic operation threads and 2 partition operation threads.
Mar 24, 2017 4:30:11 AM com.hazelcast.spi.discovery.integration.DiscoveryService
INFO: [10.250.130.160]:5701 [dev] [3.6.7] Using ConsulRegistrator: org.bitsofinfo.hazelcast.discovery.consul.DoNothingRegistrator
Mar 24, 2017 4:30:13 AM com.hazelcast.spi.discovery.integration.DiscoveryService
INFO: [10.250.130.160]:5701 [dev] [3.6.7] Registered our service instance w/ Consul OK.. delaying Hazelcast discovery, sleeping: 10000ms
Mar 24, 2017 4:30:23 AM com.hazelcast.instance.Node
INFO: [10.250.130.160]:5701 [dev] [3.6.7] Activating Discovery SPI Joiner
Mar 24, 2017 4:30:23 AM com.hazelcast.core.LifecycleService
INFO: [10.250.130.160]:5701 [dev] [3.6.7] Address[10.250.130.160]:5701 is STARTING
Mar 24, 2017 4:30:23 AM com.hazelcast.nio.tcp.nonblocking.NonBlockingIOThreadingModel
INFO: [10.250.130.160]:5701 [dev] [3.6.7] TcpIpConnectionManager configured with Non Blocking IO-threading model: 3 input threads and 3 output threads
Mar 24, 2017 4:30:24 AM com.hazelcast.spi.discovery.integration.DiscoveryService
INFO: [10.250.130.160]:5701 [dev] [3.6.7] Discovered healthy node: :5701
Mar 24, 2017 4:30:24 AM com.hazelcast.spi.discovery.integration.DiscoveryService
INFO: [10.250.130.160]:5701 [dev] [3.6.7] Discovered healthy node: :5701
Mar 24, 2017 4:30:24 AM com.hazelcast.nio.tcp.InitConnectionTask
INFO: [10.250.130.160]:5701 [dev] [3.6.7] Connecting to localhost/127.0.0.1:5701, timeout: 0, bind-any: true
Mar 24, 2017 4:30:24 AM com.hazelcast.nio.tcp.SocketAcceptorThread
INFO: [10.250.130.160]:5701 [dev] [3.6.7] Accepting socket connection from /127.0.0.1:51051
Mar 24, 2017 4:30:24 AM com.hazelcast.nio.tcp.TcpIpConnectionManager
INFO: [10.250.130.160]:5701 [dev] [3.6.7] Established socket connection between /127.0.0.1:51051 and localhost/127.0.0.1:5701
Mar 24, 2017 4:30:24 AM com.hazelcast.nio.tcp.TcpIpConnectionManager
INFO: [10.250.130.160]:5701 [dev] [3.6.7] Established socket connection between /127.0.0.1:5701 and /127.0.0.1:51051
Mar 24, 2017 4:30:24 AM com.hazelcast.nio.tcp.TcpIpConnectionManager
WARNING: [10.250.130.160]:5701 [dev] [3.6.7] Wrong bind request from Address[10.250.130.160]:5701! This node is not requested endpoint: Address[null]:5701
Mar 24, 2017 4:30:24 AM com.hazelcast.nio.tcp.TcpIpConnection
NFO: [10.250.130.160]:5701 [dev] [3.6.7] Connection [/127.0.0.1:51051] lost. Reason: Socket explicitly closed
Mar 24, 2017 4:30:24 AM com.hazelcast.nio.tcp.nonblocking.NonBlockingSocketWriter
WARNING: [10.250.130.160]:5701 [dev] [3.6.7] hz._hzInstance_1_dev.IO.thread-out-1 Closing socket to endpoint Address[]:5701, Cause:java.nio.channels.CancelledKeyException
java.nio.channels.CancelledKeyException
	at sun.nio.ch.SelectionKeyImpl.ensureValid(SelectionKeyImpl.java:73)
	at sun.nio.ch.SelectionKeyImpl.interestOps(SelectionKeyImpl.java:77)
	at com.hazelcast.nio.tcp.nonblocking.AbstractHandler.unregisterOp(AbstractHandler.java:74)
	at com.hazelcast.nio.tcp.nonblocking.NonBlockingSocketWriter.unschedule(NonBlockingSocketWriter.java:295)
	at com.hazelcast.nio.tcp.nonblocking.NonBlockingSocketWriter.handle(NonBlockingSocketWriter.java:344)
	at com.hazelcast.nio.tcp.nonblocking.NonBlockingSocketWriter.run(NonBlockingSocketWriter.java:423)
	at com.hazelcast.nio.tcp.nonblocking.NonBlockingIOThread.executeTask(NonBlockingIOThread.java:293)
	at com.hazelcast.nio.tcp.nonblocking.NonBlockingIOThread.processTaskQueue(NonBlockingIOThread.java:286)
	at com.hazelcast.nio.tcp.nonblocking.NonBlockingIOThread.selectLoop(NonBlockingIOThread.java:230)
	at com.hazelcast.nio.tcp.nonblocking.NonBlockingIOThread.run(NonBlockingIOThread.java:187)

Mar 24, 2017 4:30:24 AM com.hazelcast.nio.tcp.TcpIpConnection
INFO: [10.250.130.160]:5701 [dev] [3.6.7] Connection [Address[]:5701] lost. Reason: java.io.EOFException[Remote socket closed!]
Mar 24, 2017 4:30:24 AM com.hazelcast.nio.tcp.nonblocking.NonBlockingSocketReader
WARNING: [10.250.130.160]:5701 [dev] [3.6.7] hz._hzInstance_1_dev.IO.thread-in-1 Closing socket to endpoint Address[]:5701, Cause:java.io.EOFException: Remote socket closed!

Any guess as to what is going on or what I should do to debug further?

Thanks!

Validate and integrate support for consul ACLs

Add support/config options ACL token auth options to consul. This token would be appended to all API operations requests (agent, health, catalog)

<property name="consul-acl-token">token-generated-by-consul-uuidgen</property>

Update all examples and unit-tests

Non-passing members not being removed from Members list

I have 4 systems running hazelcast (each of which is running the hazelcast-consul-discovery-spi). Consul is reachable on localhost on each system. On one of the systems I kill consul with kill -9. On another system I run

curl http://localhost:8500/v1/health/service/hazelcast?passing

and see that the system without consul is not reported. However, the Members list in that system still shows the system without consul. It appears that the consul-healthy-only flag isn't being honored. Any ideas?

Any chance for an RC5 that uses the most recent consul-client?

When I try to use RC4 of hazelcast-consul-discovery-spi with wildfly 8.2.0.Final, I get into a jar conflict with the com.fasterxml.jackson.core jars. This seems to happen because RC4 uses version 0.10.0 of consul-client which depended on specific versions of those jar files. Resteasy from jboss uses different versions. Versions of consul-client later than 0.11.X addressed this by including the classes within the jar in such a way that the dependencies were resolved locally instead of using the class loader to load them.

I did a test where I changed the pom file hazelcast-consul-discovery-spi-1.0-RC4.pom, changing the dependency for consul-client to be version 0.12.4 from 0.10.0. AFAICT the hazelcast-discovery functionality worked fine and my problems with jar conflicts disappeared.

Is there any chance that an RC5 could be published that changed the dependency for consul-client to make this "official"?

Hazelcast version

Hi,

Is it possible to upgrade your hazelcast dependency to the latest stable version? (3.8+)

Thanks

Multiple Docker Hosts discovery

Hi,

We have 2 hosts running several docker instances, we are trying to leverage consul to assist us in Hazelcast discovery.

I managed to get Hazelcast nodes listed In consul but seems as if HC refuses to connect:

12-Jul-2017 19:28:38.353 INFO [hz._hzInstance_1_docker_int.IO.thread-in-0] com.hazelcast.nio.tcp.TcpIpConnection.null [172.17.0.3]:5701 [docker_int] [3.8.3] Connect
ion[id=1, /172.17.0.3:42637->/172.17.0.6:5701, endpoint=[172.17.0.6]:5701, alive=false, type=MEMBER] closed. Reason: Connection closed by the other side

This somewhat makes sense - we have 2 hosts running at 10.0.1.160 and 10.0.2.71, our HC nodes are set to listen on port 5701 and map to a random port on the host, i.e 10.0.1.160:42637 -> 172.17.0.3:5701.

Not really sure why the nodes are trying to connect in their internal IP, this obviously wont work, each docker container is running on a different hosts and they cannot communicate between 172.17.0.3 to 172.17.0.6, they can only communicate between 10.0.1.160 to 10.0.2.71 which is the real host IP.

I switched org.bitsofinfo.hazelcast.discovery.consul.LocalDiscoveryNodeRegistrator to DoNothingRegistrator and used Regisrator to automatically register my nodes in Consul, this worked fine and got the correct IP and Port from consul but now HC is refusing to connect stating 'This node is not requested endpoint' since it's looking for 172.17.0.3:5701 but consul returned 10.0.1.160:randomport.

Is it even possible to make this work on 2 different hosts with random ports ?

Thanks for the help!

here is my configuration:

     <properties>
          <property name="consul-host">10.0.1.160</property>
          <property name="consul-port">8500</property>
          <property name="consul-service-name">hz-cluster</property>
          <property name="consul-healthy-only">true</property>
          <property name="consul-service-tags">hazelcast, test1</property>
          <property name="consul-discovery-delay-ms">10000</property>

          <property name="consul-acl-token"></property>
          <property name="consul-ssl-enabled">false</property>
          <property name="consul-ssl-server-cert-file-path"></property>
          <property name="consul-ssl-server-cert-base64"></property>
          <property name="consul-ssl-server-hostname-verify">false</property>

          <property name="consul-registrator">org.bitsofinfo.hazelcast.discovery.consul.LocalDiscoveryNodeRegistrator</property>
          <property name="consul-registrator-config"><![CDATA[
                                    {
                                      "preferPublicAddress":true,
                                      "healthCheckProvider":"org.bitsofinfo.hazelcast.discovery.consul.TcpHealthCheckBuilder",
                                      "healthCheckTcp":"#MYIP:8080",
                                      "healthCheckTcpIntervalSeconds":30
                                    }
              ]]></property>
    </properties>
  </discovery-strategy>
</discovery-strategies>

Add support for different kinds of checks in registrator

Should be able to do more than just "script", i.e. TCP/HTTP, which won't rely on something being available such as bash/curl etc. Add additional support for these checks in the consul-registrator-config JSON block such as:

"healthCheckType":"tcp",
"healthCheckTcp":"ip:port",
"healthCheckTcpIntervalSeconds":30
"healthCheckTcpTimeoutSeconds":30
"healthCheckType":"http",
"healthCheckHttp":"http://hostToCheck:port/whatever",
"healthCheckHttpIntervalSeconds":30
"healthCheckHttpTimeoutSeconds":30

https://www.consul.io/docs/agent/checks.html

hazelcast/hazelcast#7381

com.orbitz.consul.ConsulException: Error pinging Consul: Forbidden

Unit as of RC7 tests go against consul 0.7.5, with latest consul the following occurs

SEVERE: [169.254.222.176]:5701 [hazelcast-consul-discovery-spi] [3.7.8] Unexpected error in configuring discovery: Error connecting to Consul
com.orbitz.consul.ConsulException: Error connecting to Consul
	at com.orbitz.consul.AgentClient.ping(AgentClient.java:65)
	at com.orbitz.consul.Consul$Builder.build(Consul.java:533)
	at org.bitsofinfo.hazelcast.discovery.consul.ConsulClientBuilder.buildConsul(ConsulClientBuilder.java:71)
	at org.bitsofinfo.hazelcast.discovery.consul.ConsulDiscoveryStrategy.<init>(ConsulDiscoveryStrategy.java:146)
	at org.bitsofinfo.hazelcast.discovery.consul.ConsulDiscoveryStrategyFactory.newDiscoveryStrategy(ConsulDiscoveryStrategyFactory.java:46)
	at com.hazelcast.spi.discovery.impl.DefaultDiscoveryService.buildDiscoveryStrategy(DefaultDiscoveryService.java:217)
	at com.hazelcast.spi.discovery.impl.DefaultDiscoveryService.loadDiscoveryStrategies(DefaultDiscoveryService.java:158)
	at com.hazelcast.spi.discovery.impl.DefaultDiscoveryService.<init>(DefaultDiscoveryService.java:60)
	at com.hazelcast.spi.discovery.impl.DefaultDiscoveryServiceProvider.newDiscoveryService(DefaultDiscoveryServiceProvider.java:29)
	at com.hazelcast.instance.Node.createDiscoveryService(Node.java:226)
	at com.hazelcast.instance.Node.<init>(Node.java:193)
	at com.hazelcast.instance.HazelcastInstanceImpl.createNode(HazelcastInstanceImpl.java:153)
	at com.hazelcast.instance.HazelcastInstanceImpl.<init>(HazelcastInstanceImpl.java:125)
	at com.hazelcast.instance.HazelcastInstanceFactory.constructHazelcastInstance(HazelcastInstanceFactory.java:218)
	at com.hazelcast.instance.HazelcastInstanceFactory.newHazelcastInstance(HazelcastInstanceFactory.java:176)
	at com.hazelcast.instance.HazelcastInstanceFactory.newHazelcastInstance(HazelcastInstanceFactory.java:126)
	at com.hazelcast.core.Hazelcast.newHazelcastInstance(Hazelcast.java:58)
	at org.bitsofinfo.hazelcast.discovery.consul.ManualRunner.main(ManualRunner.java:21)
Caused by: com.orbitz.consul.ConsulException: Error pinging Consul: Forbidden
	at com.orbitz.consul.AgentClient.ping(AgentClient.java:61)
	... 17 more

Question: regarding dynamic discovery strategy changing at runtime/startup

author:@pheitman

This looks like exactly what I need โ€“ but Iโ€™m having one key problem. Our application is Spring-based and I want to make this network strategy conditional on being in a deployment using consul. The spring xsd does not have the โ€œenabledโ€ attribute for the discovery strategy, unlike the other three options for the network join. Is there any examples that describe how to support conditionally enabling the discovery strategy? Possibly extending the class to look for an enabled property?

TTL parameter is required for registering script Consul health check

I'm trying to register script health check with such config:

        String discoveryHostname = "localhost";
        int discoveryPort = 8500;
        String hazelcastAddress = "localhost";
        String hazelcastPassword = "password";

        Config config = new Config();

        config.getProperties().setProperty("hazelcast.discovery.enabled", "true");

        config.getNetworkConfig().getJoin().getMulticastConfig().setEnabled(false);
        config.getNetworkConfig().getJoin().getAwsConfig().setEnabled(false);
        config.getNetworkConfig().getJoin().getTcpIpConfig().setEnabled(false);

        config.getNetworkConfig().setPortAutoIncrement(true);
        config.getNetworkConfig().setPort(port);

        Map<String, Comparable> properties = new HashMap<>();

        properties.put("consul-host", discoveryHostname);
        properties.put("consul-port", String.valueOf(discoveryPort));
        properties.put("consul-service-name", "hazelcast");
        properties.put("consul-healthy-only", "true");
        properties.put("consul-service-tags", "hazelcast");
        properties.put("consul-discovery-delay-ms", "0");
        properties.put("consul-registrator", LocalDiscoveryNodeRegistrator.class.getName());

        properties.put("consul-registrator-config", format("{\n" +
          "\"preferPublicAddress\": false,\n" +
          "\"healthCheckProvider\": \"%s\",\n" +
          "\"healthCheckScript\": \"nc -z %s %s\",\n" +
          "\"healthCheckScriptIntervalSeconds\": 30\n" +
          "}", ScriptHealthCheckBuilder.class.getName(), hazelcastAddress, port));

        DiscoveryStrategyConfig strategy = new DiscoveryStrategyConfig(ConsulDiscoveryStrategy.class.getName(), properties);
     
   config.getNetworkConfig().getJoin().getDiscoveryConfig().addDiscoveryStrategyConfig(strategy);

        return config;

and get error:

Caused by: com.orbitz.consul.ConsulException: Consul request failed with status [400]: Invalid check: TTL must be > 0 for TTL checks
```.

instanceName must contain text

Hello,

I have consul running on my localhost and below is how i have configured this plugin in my spring boot application.

@bean
public HazelcastInstance hazelcastInstance() throws Exception{
return Hazelcast.getOrCreateHazelcastInstance(buildHzConfig());
}
private Config buildHzConfig() throws Exception {

	Config config = new Config();

   // Use Consul for discovery instead of multicast with the help of this:
   // https://github.com/bitsofinfo/hazelcast-consul-discovery-spi

	config.setProperty("hazelcast.discovery.enabled", "true");
	config.setProperty("hazelcast.http.healthcheck.enabled", "true");

	config.getNetworkConfig().getJoin().getMulticastConfig().setEnabled(false);
	String myIP = InetAddress.getLocalHost().getHostAddress();
	DiscoveryStrategyConfig discoveryStrategyConfig = new DiscoveryStrategyConfig(new ConsulDiscoveryStrategyFactory());
	discoveryStrategyConfig.addProperty(ConsulDiscoveryConfiguration.CONSUL_HOST.key(), myIP);
	discoveryStrategyConfig.addProperty(ConsulDiscoveryConfiguration.CONSUL_PORT.key(), "8500");
	discoveryStrategyConfig.addProperty(ConsulDiscoveryConfiguration.CONSUL_SERVICE_TAGS.key(), "");
	discoveryStrategyConfig.addProperty(ConsulDiscoveryConfiguration.CONSUL_SERVICE_NAME.key(), "hz-cluster");
	discoveryStrategyConfig.addProperty(ConsulDiscoveryConfiguration.CONSUL_HEALTHY_ONLY.key(), true);
	discoveryStrategyConfig.addProperty(ConsulDiscoveryConfiguration.CONSUL_DISCOVERY_DELAY_MS.key(), "3000");
	discoveryStrategyConfig.addProperty(ConsulDiscoveryConfiguration.CONSUL_REGISTRATOR.key(), LocalDiscoveryNodeRegistrator.class.getName());

	ObjectNode jsonRegistratorConfig = JsonNodeFactory.instance.objectNode();

	jsonRegistratorConfig.put("preferPublicAddress", false);
	jsonRegistratorConfig.put("healthCheckProvider", HttpHealthCheckBuilder.class.getName());
	jsonRegistratorConfig.put("healthCheckHttp", String.format("http://"+myIP+":%s%s", "8891", "/hazelcast/health"));
	jsonRegistratorConfig.put("healthCheckHttpIntervalSeconds", 3);

	discoveryStrategyConfig.addProperty(ConsulDiscoveryConfiguration.CONSUL_REGISTRATOR_CONFIG.key(), jsonRegistratorConfig.toString());

	config.getNetworkConfig().getJoin().getDiscoveryConfig().getDiscoveryStrategyConfigs().add(discoveryStrategyConfig);

	return config;
}

When i start the application, below is the error i am getting. Can someone help with this. I am just wondering what this "instanceName must contain text" in the logs. I couldn't figure out anything by starting the application in debug mode (the frames doesn't link to the exact class)

ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hazelcastInstance' defined in class path resource [/com/api/SpringConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.hazelcast.core.HazelcastInstance]: Factory method 'hazelcastInstance' threw exception; nested exception is java.lang.IllegalArgumentException: instanceName must contain text

Thanks

Add support for configurable consul API client library plugins w/ resiliency

Need to add an plugin/abstraction for what underlying consul API library we utilize.

Plugin based feature

For now create 3 interfaces for the consul APIs we currently use

CatalogAPIClient
HealthAPIClient
AgentAPIClient

The initial set of methods on each of these 3 interfaces should be compatible with the existing orbitz methods.

Create an initial orbitz consul client implementation of all 3.

<!-- Which consul API client library plugin to use -->
<property name="consul-default-client-provider">orbitz</property>

<!-- specific functional domain override -->
<property name="consul-catalog-client-provider">orbitz</property>
<property name="consul-health-client-provider">orbitz</property>
<property name="consul-agent-client-provider">orbitz</property>

Resiliancy feature

  1. Add an option that is globally obeyed to define the timeout for all API requests (both connect and socket timeouts)
<property name="consul-api-client-timeout-seconds">30</property>
  1. We need the ability to define more than one consul host/port to talk to, specifically define which consul endpoints to use for each different API we utilize, add a new configuration properties such as:
<!-- comma separated list of host:ports to use for all API clients-->
<property name="consul-hosts">localhost:port,host2:port</property>

<!-- Permit specific overrides of hosts to uses for specific APIs -->
<property name="consul-agent-hosts">localhost:port,host2:port</property>
<property name="consul-health-hosts">localhost:port,host2:port</property>
<property name="consul-catalog-hosts">localhost:port,host2:port</property>

<!-- still support this backwards compatible method, which would seed consul-hosts -->
<property name="consul-host">localhost</property>
<property name="consul-port">8500</property>

Behavior when multiple hosts are specified

Agent / Health

If more than one agent host is configured, register against each specified agent host (both register the node and a health check)

Catalog

If more than one catalog host is configured, attempt to talk to the first one, if a transient connectivity error occurs, revert to the second host and so on

Unable to discover cluster members

Hi,

I am trying to get Hazelcast to discover its cluster members via consul using this plugin.

Hazelcast version : 3.7.5
hazelcast-consul-discovery-spi : 1.0-RC7
com.orbitz.consul.consul-client : 0.13.11-shaded.jar

I have two vms reachable from one another 10.78.106.136 and 10.78.106.137. I am running consul server on 136 and an agent on 137. Here is the output of consul members

Node Address Status Type Build Protocol DC
agent-one 10.78.106.136:8301 alive server 0.8.3 2 dc1
agent-two 10.78.106.137:8301 alive client 0.8.3 2 dc1

I however am not able to see both the cluster members when I do a hazelcastInstance.getCluster().getMembers(). It always only shows the node on which the call is made.

Here is my cluster.xml
cluster.txt

I see these messages in the logs

[10.78.106.137]:5801 [host_telemetry_cluster_229] [3.7.5] Connection[id=30, /10.78.106.137:5801->/10.78.106.137:47788, endpoint=null, alive=false, type=NONE] closed. Reason: Connection closed by the other side
2017-06-01 13:55:06,417 WARN [hz._hzInstance_1_host_telemetry_cluster_229.IO.thread-out-2] Slf4jFactory$Slf4jLogger - [10.78.106.137]:5801 [host_telemetry_cluster_229] [3.7.5] SocketWriter is not set, creating SocketWriter with CLUSTER protocol!

and hence turned off auto-increment on cluster.xml. The logs continue to show up the error though.

I also see these exceptions from the consul client

Caused by: java.io.EOFException: \n not found: size=0 content=โ€ฆ
at com.orbitz.okio.RealBufferedSource.readUtf8LineStrict(RealBufferedSource.java:215) ~[consul-client-0.13.11-shaded.jar:?]

Caused by: java.io.IOException: unexpected end of stream on com.orbitz.okhttp3.Address@145f72d1
Unexpected error in configuring discovery: Error connecting to Consul
com.orbitz.consul.ConsulException: Error connecting to Consul
at com.orbitz.consul.AgentClient.ping(AgentClient.java:65) ~[consul-client-0.13.11-shaded.jar:?]

I am configuring the consul server address in the cluster.xml on both vms. Using 127.0.0.1 does not help either.

What could I be doing wrong ? It appears I am only trying the most basic use case here.

Thanks,
Rajesh

Question on configuration

Sorry in advance as I think this is a very basic question. I'm experienced with Consul but not so much with Hazelcast.

I have consul stood up and running and have setup an agent on some instances with this the service configuration done manually. I can see the services in consul. I'm using the DoNothingRegistrator however Hazelcast doesn't seem to detect the configuration at all in my hazelcast.xml. I am using the hazelcast.xml example from the resources folder for that registrator.

To set this up I built this project and took the built jar and put it into my hazelcastfolder/libs/ directory. I also made the change to the hazelcast.xml file.

When Hazelcast comes up it just uses the local IP and there isn't any reference to the consul discovery spi in the logs.

This is just a standard install of Hazelcast. No customization is done on top of it. Is dropping the built and dependent jars into hazelcastfolder/libs/, updating the hazelcast.xml, and restarting sufficient to get Hazelcast to recognize the consul discovery spi?

Again, sorry for the noob question. I certainly understand if I should be looking elsewhere.

unable to connect to consul, NullPointerException

H
ello,
hitting an issue with hazelcast 3.6.2, see trace below.

My context:

  • hazelcast 3.6.2 oss
  • jdk 1.8.0
  • hazelcast-consul-discovery-spi, 1.0.RC4
  • i built an uberjar with hazelcast-consul-discovery-spi, and cfx jax-rs client (as suggested in the README).

Here is my hazelcast.xml discovery snippet

...
               <discovery-strategy enabled="true"
                   class="org.bitsofinfo.hazelcast.discovery.consul.ConsulDiscoveryStrategy">

                 <properties>
                       <!--  hostname or IP of the consul server -->
                      <property name="consul-host">localhost</property>

                      <!--  port of the consul server -->
                      <property name="consul-port">8500</property>
...
                      <property name="consul-registrator-config"><![CDATA[
                                                                      {
                                                                        "preferPublicAddress":false,
                                                                        "healthCheckProvider":"org.bitsofinfo.hazelcast.discovery.consul.ScriptHealthCheckBuilder",
                                                                        "healthCheckScript":"exec 6<>/dev/tcp/#MYIP/#MYPORT || (exit 3)",
                                                                        "healthCheckScriptIntervalSeconds":30,
                                                                                                                                                "healthCheckTcp":"ip:port",
                                                                                                                                                "healthCheckTcpIntervalSeconds":30
                                                                      }
                                                                  ]]></property>




The exception below happens before connecting to consul (exact same trace with consul up, or down on localhost).

I suspect a classloader issue or incompatibility with cxf 3.0.3 (which is quite old).
Any hint ?
Other jax-rs compatible lib suggestion ?
thx

19:57:12.315 [main] INFO  c.h.s.d.integration.DiscoveryService - [192.168.122.1]:5703 [test] [3.6.2] Using ConsulRegistrator: org.bitsofinfo.hazelcast.discovery.consul.LocalDiscoveryNodeRegistrator                                                                                                                                           
19:57:12.315 [main] INFO  c.h.s.d.integration.DiscoveryService - [192.168.122.1]:5703 [test] [3.6.2] Determined local DiscoveryNode address to use: Address[192.168.122.1]:5703                                                                                                                                                                 
19:57:12.453 [main] DEBUG o.apache.cxf.common.logging.LogUtils - Using org.apache.cxf.common.logging.Slf4jLogger for logging.                                           
19:57:12.705 [main] DEBUG o.a.c.jaxrs.provider.ProviderFactory - Problem with creating the default provider org.apache.cxf.jaxrs.provider.json.JSONProvider: org.apache.cxf.jaxrs.provider.json.JSONProvider                                                                                                                                    
19:57:12.715 [main] DEBUG o.a.c.j.model.AbstractResourceInfo - Injecting a custom context org.apache.cxf.jaxrs.ext.MessageContext, ContextProvider is required for this type                                                                                                                                                                    
19:57:12.726 [main] DEBUG o.a.c.j.model.AbstractResourceInfo - Injecting a custom context org.apache.cxf.jaxrs.ext.MessageContext, ContextProvider is required for this type                                                                                                                                                                    
19:57:12.730 [main] DEBUG o.a.c.j.model.AbstractResourceInfo - Injecting a custom context org.apache.cxf.jaxrs.ext.MessageContext, ContextProvider is required for this type                                                                                                                                                                    
19:57:12.732 [main] DEBUG o.a.c.j.model.AbstractResourceInfo - Injecting a custom context org.apache.cxf.jaxrs.ext.MessageContext, ContextProvider is required for this type                                                                                                                                                                    
Apr 27, 2016 7:57:12 PM org.bitsofinfo.hazelcast.discovery.consul.ConsulClientBuilder                                                                                   
SEVERE: Unexpected Error occured while buildConsul() - Error connecting to Consul                                                                                       
com.orbitz.consul.ConsulException: Error connecting to Consul                                                                                                           
        at com.orbitz.consul.AgentClient.ping(AgentClient.java:74)                                                                                                      
        at com.orbitz.consul.Consul.<init>(Consul.java:73)                                                                                                              
        at com.orbitz.consul.Consul.<init>(Consul.java:24)                                                                                                              
        at com.orbitz.consul.Consul$Builder.build(Consul.java:337)                                                                                                      
        at org.bitsofinfo.hazelcast.discovery.consul.ConsulClientBuilder.buildConsul(ConsulClientBuilder.java:71)                                                       
        at org.bitsofinfo.hazelcast.discovery.consul.BaseRegistrator.init(BaseRegistrator.java:96)                                                                      
        at org.bitsofinfo.hazelcast.discovery.consul.ConsulDiscoveryStrategy.<init>(ConsulDiscoveryStrategy.java:122)                                                   
        at org.bitsofinfo.hazelcast.discovery.consul.ConsulDiscoveryStrategyFactory.newDiscoveryStrategy(ConsulDiscoveryStrategyFactory.java:46)                        
        at com.hazelcast.spi.discovery.impl.DefaultDiscoveryService.buildDiscoveryProvider(DefaultDiscoveryService.java:204)                                            
        at com.hazelcast.spi.discovery.impl.DefaultDiscoveryService.loadDiscoveryProviders(DefaultDiscoveryService.java:145)                                            
        at com.hazelcast.spi.discovery.impl.DefaultDiscoveryService.<init>(DefaultDiscoveryService.java:60)                                                             
        at com.hazelcast.spi.discovery.impl.DefaultDiscoveryServiceProvider.newDiscoveryService(DefaultDiscoveryServiceProvider.java:29)                                
        at com.hazelcast.instance.Node.createDiscoveryService(Node.java:217)                                                                                            
        at com.hazelcast.instance.Node.<init>(Node.java:185)                                                                                                            
        at com.hazelcast.instance.HazelcastInstanceImpl.<init>(HazelcastInstanceImpl.java:125)                                                                          
        at com.hazelcast.instance.HazelcastInstanceFactory.constructHazelcastInstance(HazelcastInstanceFactory.java:160)                                                
        at com.hazelcast.instance.HazelcastInstanceFactory.newHazelcastInstance(HazelcastInstanceFactory.java:143)                                                      
        at com.hazelcast.instance.HazelcastInstanceFactory.newHazelcastInstance(HazelcastInstanceFactory.java:111)                                                      
        at com.hazelcast.core.Hazelcast.newHazelcastInstance(Hazelcast.java:58)                                                                                         
        at com.hazelcast.core.server.StartServer.main(StartServer.java:36)                                                                                              
Caused by: java.lang.NullPointerException                                                                                                                               
        at org.apache.cxf.jaxrs.client.AbstractClient.setupOutInterceptorChain(AbstractClient.java:847)                                                                 
        at org.apache.cxf.jaxrs.client.AbstractClient.createMessage(AbstractClient.java:924)                                                                            
        at org.apache.cxf.jaxrs.client.WebClient.finalizeMessage(WebClient.java:1109)                                                                                   
        at org.apache.cxf.jaxrs.client.WebClient.doChainedInvocation(WebClient.java:1082)                                                                               
        at org.apache.cxf.jaxrs.client.WebClient.doInvoke(WebClient.java:883)                                                                                           
        at org.apache.cxf.jaxrs.client.WebClient.doInvoke(WebClient.java:854)                                                                                           
        at org.apache.cxf.jaxrs.client.WebClient.invoke(WebClient.java:417)                                                                                             
        at org.apache.cxf.jaxrs.client.WebClient$SyncInvokerImpl.method(WebClient.java:1609)                                                                            
        at org.apache.cxf.jaxrs.client.WebClient$SyncInvokerImpl.method(WebClient.java:1604)                                                                            
        at org.apache.cxf.jaxrs.client.WebClient$SyncInvokerImpl.get(WebClient.java:1524)                                                                               
        at org.apache.cxf.jaxrs.client.spec.InvocationBuilderImpl.get(InvocationBuilderImpl.java:80)                                                                    
        at com.orbitz.consul.AgentClient.ping(AgentClient.java:66)                                                                                                      
        ... 19 more                                                                                                                                                     

19:57:12.775 [main] ERROR c.h.s.d.integration.DiscoveryService - [192.168.122.1]:5703 [test] [3.6.2] Unexpected error in configuring LocalDiscoveryNodeRegistration: Error connecting to Consul                                                                                                                                                 
com.orbitz.consul.ConsulException: Error connecting to Consul                                                                                                           
        at com.orbitz.consul.AgentClient.ping(AgentClient.java:74) ~[hazelcast-bosh-uberjar-0.0.1-SNAPSHOT-jar-with-dependencies.jar:na]                                
        at com.orbitz.consul.Consul.<init>(Consul.java:73) ~[hazelcast-bosh-uberjar-0.0.1-SNAPSHOT-jar-with-dependencies.jar:na]                                        
        at com.orbitz.consul.Consul.<init>(Consul.java:24) ~[hazelcast-bosh-uberjar-0.0.1-SNAPSHOT-jar-with-dependencies.jar:na]                                        
        at com.orbitz.consul.Consul$Builder.build(Consul.java:337) ~[hazelcast-bosh-uberjar-0.0.1-SNAPSHOT-jar-with-dependencies.jar:na]                                
        at org.bitsofinfo.hazelcast.discovery.consul.ConsulClientBuilder.buildConsul(ConsulClientBuilder.java:71) ~[hazelcast-bosh-uberjar-0.0.1-SNAPSHOT-jar-with-dependencies.jar:na]                                                                                                                                                         
        at org.bitsofinfo.hazelcast.discovery.consul.BaseRegistrator.init(BaseRegistrator.java:96) ~[hazelcast-bosh-uberjar-0.0.1-SNAPSHOT-jar-with-dependencies.jar:na]
        at org.bitsofinfo.hazelcast.discovery.consul.ConsulDiscoveryStrategy.<init>(ConsulDiscoveryStrategy.java:122) [hazelcast-bosh-uberjar-0.0.1-SNAPSHOT-jar-with-dependencies.jar:na]                                                                                                                                                      
        at org.bitsofinfo.hazelcast.discovery.consul.ConsulDiscoveryStrategyFactory.newDiscoveryStrategy(ConsulDiscoveryStrategyFactory.java:46) [hazelcast-bosh-uberjar-0.0.1-SNAPSHOT-jar-with-dependencies.jar:na]                                                                                                                           
        at com.hazelcast.spi.discovery.impl.DefaultDiscoveryService.buildDiscoveryProvider(DefaultDiscoveryService.java:204) [hazelcast-bosh-uberjar-0.0.1-SNAPSHOT-jar-with-dependencies.jar:na]                                                                                                                                               
        at com.hazelcast.spi.discovery.impl.DefaultDiscoveryService.loadDiscoveryProviders(DefaultDiscoveryService.java:145) [hazelcast-bosh-uberjar-0.0.1-SNAPSHOT-jar-with-dependencies.jar:na]                                                                                                                                               
        at com.hazelcast.spi.discovery.impl.DefaultDiscoveryService.<init>(DefaultDiscoveryService.java:60) [hazelcast-bosh-uberjar-0.0.1-SNAPSHOT-jar-with-dependencies.jar:na]                                                                                                                                                                
        at com.hazelcast.spi.discovery.impl.DefaultDiscoveryServiceProvider.newDiscoveryService(DefaultDiscoveryServiceProvider.java:29) [hazelcast-bosh-uberjar-0.0.1-SNAPSHOT-jar-with-dependencies.jar:na]                                                                                                                                   
        at com.hazelcast.instance.Node.createDiscoveryService(Node.java:217) [hazelcast-bosh-uberjar-0.0.1-SNAPSHOT-jar-with-dependencies.jar:na]                       
        at com.hazelcast.instance.Node.<init>(Node.java:185) [hazelcast-bosh-uberjar-0.0.1-SNAPSHOT-jar-with-dependencies.jar:na]                                       
        at com.hazelcast.instance.HazelcastInstanceImpl.<init>(HazelcastInstanceImpl.java:125) [hazelcast-bosh-uberjar-0.0.1-SNAPSHOT-jar-with-dependencies.jar:na]     
        at com.hazelcast.instance.HazelcastInstanceFactory.constructHazelcastInstance(HazelcastInstanceFactory.java:160) [hazelcast-bosh-uberjar-0.0.1-SNAPSHOT-jar-with-dependencies.jar:na]                                                                                                                                                   
        at com.hazelcast.instance.HazelcastInstanceFactory.newHazelcastInstance(HazelcastInstanceFactory.java:143) [hazelcast-bosh-uberjar-0.0.1-SNAPSHOT-jar-with-dependencies.jar:na]                                                                                                                                                         
        at com.hazelcast.instance.HazelcastInstanceFactory.newHazelcastInstance(HazelcastInstanceFactory.java:111) [hazelcast-bosh-uberjar-0.0.1-SNAPSHOT-jar-with-dependencies.jar:na]                                                                                                                                                         
        at com.hazelcast.core.Hazelcast.newHazelcastInstance(Hazelcast.java:58) [hazelcast-bosh-uberjar-0.0.1-SNAPSHOT-jar-with-dependencies.jar:na]                    
        at com.hazelcast.core.server.StartServer.main(StartServer.java:36) [hazelcast-bosh-uberjar-0.0.1-SNAPSHOT-jar-with-dependencies.jar:na]                         
Caused by: java.lang.NullPointerException: null                                                                                                                         
        at org.apache.cxf.jaxrs.client.AbstractClient.setupOutInterceptorChain(AbstractClient.java:847) ~[hazelcast-bosh-uberjar-0.0.1-SNAPSHOT-jar-with-dependencies.jar:na]                                                                                                                                                                   
        at org.apache.cxf.jaxrs.client.AbstractClient.createMessage(AbstractClient.java:924) ~[hazelcast-bosh-uberjar-0.0.1-SNAPSHOT-jar-with-dependencies.jar:na]      
        at org.apache.cxf.jaxrs.client.WebClient.finalizeMessage(WebClient.java:1109) ~[hazelcast-bosh-uberjar-0.0.1-SNAPSHOT-jar-with-dependencies.jar:na]             
        at org.apache.cxf.jaxrs.client.WebClient.doChainedInvocation(WebClient.java:1082) ~[hazelcast-bosh-uberjar-0.0.1-SNAPSHOT-jar-with-dependencies.jar:na]         
        at org.apache.cxf.jaxrs.client.WebClient.doInvoke(WebClient.java:883) ~[hazelcast-bosh-uberjar-0.0.1-SNAPSHOT-jar-with-dependencies.jar:na]                     
        at org.apache.cxf.jaxrs.client.WebClient.doInvoke(WebClient.java:854) ~[hazelcast-bosh-uberjar-0.0.1-SNAPSHOT-jar-with-dependencies.jar:na]                     
        at org.apache.cxf.jaxrs.client.WebClient.invoke(WebClient.java:417) ~[hazelcast-bosh-uberjar-0.0.1-SNAPSHOT-jar-with-dependencies.jar:na]                       
        at org.apache.cxf.jaxrs.client.WebClient$SyncInvokerImpl.method(WebClient.java:1609) ~[hazelcast-bosh-uberjar-0.0.1-SNAPSHOT-jar-with-dependencies.jar:na]      
        at org.apache.cxf.jaxrs.client.WebClient$SyncInvokerImpl.method(WebClient.java:1604) ~[hazelcast-bosh-uberjar-0.0.1-SNAPSHOT-jar-with-dependencies.jar:na]      
        at org.apache.cxf.jaxrs.client.WebClient$SyncInvokerImpl.get(WebClient.java:1524) ~[hazelcast-bosh-uberjar-0.0.1-SNAPSHOT-jar-with-dependencies.jar:na]         
        at org.apache.cxf.jaxrs.client.spec.InvocationBuilderImpl.get(InvocationBuilderImpl.java:80) ~[hazelcast-bosh-uberjar-0.0.1-SNAPSHOT-jar-with-dependencies.jar:na]                                                                                                                                                                      
        at com.orbitz.consul.AgentClient.ping(AgentClient.java:66) ~[hazelcast-bosh-uberjar-0.0.1-SNAPSHOT-jar-with-dependencies.jar:na]                                
        ... 19 common frames omitted                                                                                                                                    
19:57:12.777 [main] ERROR c.h.s.d.integration.DiscoveryService - [192.168.122.1]:5703 [test] [3.6.2] Unexpected error attempting to init() ConsulRegistrator and register(): Unexpected error in configuring LocalDiscoveryNodeRegistration: Error connecting to Consul                                                                         

consul-acl-token isn't optional

I'm trying to configure Hazelcast usin the following code:

        Map<String, Comparable> properties = new HashMap<>();
        properties.put("consul-host", "localhost");
        properties.put("consul-port", "8500");
        properties.put("consul-service-name", "abc");
        properties.put("consul-healthy-only", "true");
        properties.put("consul-service-tags", "LocalDiscoveryNodeRegistrator");
        properties.put("consul-discovery-delay-ms", "10000");
        properties.put("consul-registrator", "org.bitsofinfo.hazelcast.discovery.consul.LocalDiscoveryNodeRegistrator");
        properties.put("consul-registrator-config", consulRegistratorConfig);

        DiscoveryStrategyConfig discoveryStrategyConfig = new DiscoveryStrategyConfig(
                "org.bitsofinfo.hazelcast.discovery.consul.ConsulDiscoveryStrategy", properties);
        discoveryConfig.addDiscoveryStrategyConfig(discoveryStrategyConfig);

When I run it though it tells me that the consul-acl-token property is mandatlry. It should be optional according to https://github.com/bitsofinfo/hazelcast-consul-discovery-spi/blob/master/src/main/resources/hazelcast-consul-discovery-spi-example.xml.

Any idea what I'm doing wrong here?

Thanks

Nick

Not able to get ExplicitIpPortRegistrator working

I am using "ExplicitIpPortRegistrator"

My hazelcast.xml looks like this



hazelcast-consul-discovery-spi
haz3lcast1

<properties>
    <property name="hazelcast.discovery.enabled">true</property>
    <property name="hazelcast.shutdownhook.enabled">false</property>
    <property name="hazelcast.phone.home.enabled">false</property>
    <property name="hazelcast.mancenter.enabled">false</property>
    <property name="hazelcast.memcache.enabled">false</property>
    <property name="hazelcast.rest.enabled">false</property>
    <property name="hazelcast.wait.seconds.before.join">5</property>
    <property name="hazelcast.operation.thread.count">1</property>
    <property name="hazelcast.operation.generic.thread.count">1</property>
    <property name="hazelcast.client.event.thread.count">1</property>
    <property name="hazelcast.event.thread.count">1</property>
    <property name="hazelcast.heartbeat.interval.seconds">5</property>
    <property name="hazelcast.max.no.heartbeat.seconds">30</property>
    <property name="hazelcast.icmp.enabled">true</property>
    <property name="hazelcast.icmp.timeout">5000</property>
    <property name="hazelcast.icmp.ttl">3</property>
    <property name="hazelcast.merge.next.run.delay.seconds">15</property>       
</properties>

<network>
    <port auto-increment="true">2434</port>
    
    <join>
        <multicast enabled="false"/>
        <aws enabled="false"/>
        <tcp-ip enabled="false" />
          
         <discovery-strategies>
    
           <discovery-strategy enabled="true"
               class="org.bitsofinfo.hazelcast.discovery.consul.ConsulDiscoveryStrategy">
    
             <properties>
                  <property name="consul-host">172.17.0.1</property>
                  <property name="consul-port">8500</property>
                  <property name="consul-service-name">orientdb</property>
                  <property name="consul-healthy-only">true</property>
                  <property name="consul-discovery-delay-ms">0</property>
                  
                  <property name="consul-acl-token"></property>
			              <property name="consul-ssl-enabled">false</property>
				            <property name="consul-ssl-server-cert-file-path"></property>
				            <property name="consul-ssl-server-cert-base64"></property>
				            <property name="consul-ssl-server-hostname-verify">false</property>					  
                  <property name="consul-registrator">org.bitsofinfo.hazelcast.discovery.consul.ExplicitIpPortRegistrator</property>
                  <property name="consul-registrator-config"><![CDATA[
                      {
                          "registerWithIpAddress":"MYIP",
                          "registerWithPort":2434, 
                          "healthCheckProvider":"org.bitsofinfo.hazelcast.discovery.consul.ScriptHealthCheckBuilder",
                          "healthCheckScript":"exec 6<>/dev/tcp/MYIP/SERVICE_PORT || (exit 3)",
                          "healthCheckScriptIntervalSeconds":30,
                          "healthCheckHttp":"http://MYIP:80",
                          "healthCheckHttpIntervalSeconds":30,
                          "healthCheckTcp":"MYIP:SERVICE_PORT",
                          "healthCheckTcpIntervalSeconds":30
                      }]]>
                  </property>                            
             </properties>
           </discovery-strategy>
         </discovery-strategies>
          
    </join>
</network>

I got the following error when i start up orient db which uses hazelcast:

2017-09-18 16:49:59:230 INFO [172.17.0.1]:2434 [hazelcast-consul-discovery-spi] [3.8.4] Determined local DiscoveryNode address to use: [10.210.56.20]:2434 [DiscoveryService]Exception in thread "Thread-0" java.lang.NoSuchMethodError: com.fasterxml.jackson.databind.type.ReferenceType.upgradeFrom(Lcom/fasterxml/jackson/databind/JavaType;Lcom/fasterxml/jackson/databind/JavaType;)Lcom/fasterxml/jackson/databind/type/ReferenceType;

Strange exception

Hi,

Whilst running 2 instances of an app we saw this odd exception. Any ideas what taggedAddresses are?

Thanks

Nick

flex-mam-app_1       | 2016-08-11 04:20:07 ERROR [flex-mam-app,,,] 1 ---[        cached2]c.h.s.d.integration.DiscoveryService     : [10.9.16.112]:5701 [flex-mam-app] [3.6.3]
 discoverNodes() unexpected error: Consul request failed                                                                                                                     
flex-mam-app_1       | com.orbitz.consul.ConsulException: Consul request failed                                                                                              
flex-mam-app_1       |  at com.orbitz.consul.util.Http.extractConsulResponse(Http.java:49)                                                                                   
flex-mam-app_1       |  at com.orbitz.consul.HealthClient.getHealthyServiceInstances(HealthClient.java:317)                                                                  
flex-mam-app_1       |  at com.orbitz.consul.HealthClient.getHealthyServiceInstances(HealthClient.java:300)                                                                  
flex-mam-app_1       |  at org.bitsofinfo.hazelcast.discovery.consul.ConsulDiscoveryStrategy.discoverNodes(ConsulDiscoveryStrategy.java:185)                                 
flex-mam-app_1       |  at com.hazelcast.spi.discovery.impl.DefaultDiscoveryService.discoverNodes(DefaultDiscoveryService.java:74)                                           
flex-mam-app_1       |  at com.hazelcast.cluster.impl.DiscoveryJoiner.getPossibleAddresses(DiscoveryJoiner.java:42)                                                          
flex-mam-app_1       |  at com.hazelcast.cluster.impl.TcpIpJoiner.searchForOtherClusters(TcpIpJoiner.java:501)                                                               
flex-mam-app_1       |  at com.hazelcast.cluster.impl.SplitBrainHandler.searchForOtherClusters(SplitBrainHandler.java:75)                                                    
flex-mam-app_1       |  at com.hazelcast.cluster.impl.SplitBrainHandler.run(SplitBrainHandler.java:42)                                                                       
flex-mam-app_1       |  at com.hazelcast.util.executor.CachedExecutorServiceDelegate$Worker.run(CachedExecutorServiceDelegate.java:212)                                      
flex-mam-app_1       |  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)                                                                   
flex-mam-app_1       |  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)                                                                   
flex-mam-app_1       |  at java.lang.Thread.run(Thread.java:745)                                                                                                             
flex-mam-app_1       |  at com.hazelcast.util.executor.HazelcastManagedThread.executeRun(HazelcastManagedThread.java:76)                                                     
flex-mam-app_1       |  at com.hazelcast.util.executor.HazelcastManagedThread.run(HazelcastManagedThread.java:92)                                                            
flex-mam-app_1       | Caused by: com.orbitz.fasterxml.jackson.databind.JsonMappingException: Instantiation of [simple type, class com.orbitz.consul.model.health.ImmutableNo
de] value failed (java.lang.IllegalStateException): Cannot build Node, some of required attributes are not set [taggedAddresses]                                             
flex-mam-app_1       |  at [Source: java.io.InputStreamReader@103f8b67; line: 1, column: 121] (through reference chain: java.util.ArrayList[0]->com.orbitz.consul.model.healt
h.Json["Node"])                                                                                                                                                              
flex-mam-app_1       |  at com.orbitz.fasterxml.jackson.databind.JsonMappingException.from(JsonMappingException.java:262)                                                    
flex-mam-app_1       |  at com.orbitz.fasterxml.jackson.databind.deser.std.StdValueInstantiator.wrapAsJsonMappingException(StdValueInstantiator.java:445)                    
flex-mam-app_1       |  at com.orbitz.fasterxml.jackson.databind.deser.std.StdValueInstantiator.rewrapCtorProblem(StdValueInstantiator.java:464)                             
flex-mam-app_1       |  at com.orbitz.fasterxml.jackson.databind.deser.std.StdValueInstantiator._createUsingDelegate(StdValueInstantiator.java:502)                          
flex-mam-app_1       |  at com.orbitz.fasterxml.jackson.databind.deser.std.StdValueInstantiator.createUsingDelegate(StdValueInstantiator.java:265)                           
flex-mam-app_1       |  at com.orbitz.fasterxml.jackson.databind.deser.BeanDeserializerBase.deserializeFromObjectUsingNonDefault(BeanDeserializerBase.java:1119)             
flex-mam-app_1       |  at com.orbitz.fasterxml.jackson.databind.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:298)                                     
flex-mam-app_1       |  at com.orbitz.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:133)                                               
flex-mam-app_1       |  at com.orbitz.fasterxml.jackson.databind.deser.SettableBeanProperty.deserialize(SettableBeanProperty.java:490)                                       
flex-mam-app_1       |  at com.orbitz.fasterxml.jackson.databind.deser.impl.MethodProperty.deserializeAndSet(MethodProperty.java:95)                                         
flex-mam-app_1       |  at com.orbitz.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:260)                                        
flex-mam-app_1       |  at com.orbitz.fasterxml.jackson.databind.deser.BeanDeserializer._deserializeOther(BeanDeserializer.java:163)                                         
flex-mam-app_1       |  at com.orbitz.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:135)                                               
flex-mam-app_1       |  at com.orbitz.fasterxml.jackson.databind.deser.BeanDeserializerBase.deserializeFromObjectUsingNonDefault(BeanDeserializerBase.java:1119)             
flex-mam-app_1       |  at com.orbitz.fasterxml.jackson.databind.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:298)                                     
flex-mam-app_1       |  at com.orbitz.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:133)                                               
flex-mam-app_1       |  at com.orbitz.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:277)                               
flex-mam-app_1       |  at com.orbitz.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:249)                               
flex-mam-app_1       |  at com.orbitz.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:26)                                
flex-mam-app_1       |  at com.orbitz.fasterxml.jackson.databind.ObjectReader._bindAndClose(ObjectReader.java:1578)                                                          
flex-mam-app_1       |  at com.orbitz.fasterxml.jackson.databind.ObjectReader.readValue(ObjectReader.java:1183)                                                              
flex-mam-app_1       |  at com.orbitz.retrofit.converter.jackson.JacksonResponseBodyConverter.convert(JacksonResponseBodyConverter.java:32)                                  
flex-mam-app_1       |  at com.orbitz.retrofit.converter.jackson.JacksonResponseBodyConverter.convert(JacksonResponseBodyConverter.java:23)                                  
flex-mam-app_1       |  at com.orbitz.retrofit.ServiceMethod.toResponse(ServiceMethod.java:117)                                                                              
flex-mam-app_1       |  at com.orbitz.retrofit.OkHttpCall.parseResponse(OkHttpCall.java:211)                                                                                 
flex-mam-app_1       |  at com.orbitz.retrofit.OkHttpCall.execute(OkHttpCall.java:174)                                                                                       
flex-mam-app_1       |  at com.orbitz.consul.util.Http.extractConsulResponse(Http.java:47)                                                                                   
flex-mam-app_1       |  ... 14 common frames omitted                                                                                                                         
flex-mam-app_1       | Caused by: java.lang.IllegalStateException: Cannot build Node, some of required attributes are not set [taggedAddresses]                              
flex-mam-app_1       |  at com.orbitz.consul.model.health.ImmutableNode$Builder.build(ImmutableNode.java:300)                                                                
flex-mam-app_1       |  at com.orbitz.consul.model.health.ImmutableNode.fromJson(ImmutableNode.java:198)                                                                     
flex-mam-app_1       |  at sun.reflect.GeneratedMethodAccessor155.invoke(Unknown Source)                                                                                     
flex-mam-app_1       |  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)                                                             
flex-mam-app_1       |  at java.lang.reflect.Method.invoke(Method.java:498)                                                                                                  
flex-mam-app_1       |  at com.orbitz.fasterxml.jackson.databind.introspect.AnnotatedMethod.call1(AnnotatedMethod.java:115)                                                  
flex-mam-app_1       |  at com.orbitz.fasterxml.jackson.databind.deser.std.StdValueInstantiator._createUsingDelegate(StdValueInstantiator.java:486)                          
flex-mam-app_1       |  ... 37 common frames omitted    

I am having issues with starting the hazelcast consul discovery

So here is the scenario i am trying.

I have orientdb which uses hazelcast. So i have a hazelcast.xml which looks



hazelcast-consul-discovery-spi
haz3lcast1

<properties>
    <property name="hazelcast.discovery.enabled">true</property>
    <property name="hazelcast.shutdownhook.enabled">false</property>
    <property name="hazelcast.phone.home.enabled">false</property>
    <property name="hazelcast.mancenter.enabled">false</property>
    <property name="hazelcast.memcache.enabled">false</property>
    <property name="hazelcast.rest.enabled">false</property>
    <property name="hazelcast.wait.seconds.before.join">5</property>
    <property name="hazelcast.operation.thread.count">1</property>
    <property name="hazelcast.operation.generic.thread.count">1</property>
    <property name="hazelcast.client.event.thread.count">1</property>
    <property name="hazelcast.event.thread.count">1</property>
    <property name="hazelcast.heartbeat.interval.seconds">5</property>
    <property name="hazelcast.max.no.heartbeat.seconds">30</property>
    <property name="hazelcast.icmp.enabled">true</property>
    <property name="hazelcast.icmp.timeout">5000</property>
    <property name="hazelcast.icmp.ttl">3</property>
    <property name="hazelcast.merge.next.run.delay.seconds">15</property>       
</properties>

<network>
    <port auto-increment="true">2434</port>
    
    <join>
        <multicast enabled="false"/>
          <aws enabled="false"/>
          <tcp-ip enabled="false" />
          
         <discovery-strategies>
    
           <discovery-strategy enabled="true"
               class="org.bitsofinfo.hazelcast.discovery.consul.ConsulDiscoveryStrategy">
    
             <properties>
                <property name="consul-host">localhost</property>
                <property name="consul-port">8500</property>
                <property name="consul-service-name">hz-discovery-test-cluster</property>
                <property name="consul-healthy-only">true</property>
                <property name="consul-discovery-delay-ms">0</property>
                <property name="consul-ssl-enabled">false</property>
                <property name="consul-ssl-server-cert-file-path"></property>
                <property name="consul-ssl-server-cert-base64"></property>
                <property name="consul-ssl-server-hostname-verify">false</property>
                <property name="consul-registrator">org.bitsofinfo.hazelcast.discovery.consul.DoNothingRegistrator</property>
             </properties>
           </discovery-strategy>
         </discovery-strategies>
          
    </join>
</network>

This hazelcast.xml exists in the container and i have a local consul agent running. when i start the container i get the following error:

2017-09-15 19:22:27:345 INFO [172.17.0.2]:2434 [hazelcast-consul-discovery-spi] [3.7.8] Using ConsulRegistrator: org.bitsofinfo.hazelcast.discovery.consul.DoNothingRegistrator [DiscoveryService]Exception in thread "Thread-0" java.lang.NoClassDefFoundError: com/google/common/net/HostAndPort
at org.bitsofinfo.hazelcast.discovery.consul.ConsulClientBuilder.buildConsul(ConsulClientBuilder.java:68)
at org.bitsofinfo.hazelcast.discovery.consul.ConsulDiscoveryStrategy.(ConsulDiscoveryStrategy.java:146)
at org.bitsofinfo.hazelcast.discovery.consul.ConsulDiscoveryStrategyFactory.newDiscoveryStrategy(ConsulDiscoveryStrategyFactory.java:46)
at com.hazelcast.spi.discovery.impl.DefaultDiscoveryService.buildDiscoveryStrategy(DefaultDiscoveryService.java:217)
at com.hazelcast.spi.discovery.impl.DefaultDiscoveryService.loadDiscoveryStrategies(DefaultDiscoveryService.java:158)
at com.hazelcast.spi.discovery.impl.DefaultDiscoveryService.(DefaultDiscoveryService.java:60)
at com.hazelcast.spi.discovery.impl.DefaultDiscoveryServiceProvider.newDiscoveryService(DefaultDiscoveryServiceProvider.java:29)
at com.hazelcast.instance.Node.createDiscoveryService(Node.java:226)
at com.hazelcast.instance.Node.(Node.java:193)
at com.hazelcast.instance.HazelcastInstanceImpl.createNode(HazelcastInstanceImpl.java:153)
at com.hazelcast.instance.HazelcastInstanceImpl.(HazelcastInstanceImpl.java:125)
at com.hazelcast.instance.HazelcastInstanceFactory.constructHazelcastInstance(HazelcastInstanceFactory.java:218)
at com.hazelcast.instance.HazelcastInstanceFactory.newHazelcastInstance(HazelcastInstanceFactory.java:176)
at com.hazelcast.instance.HazelcastInstanceFactory.newHazelcastInstance(HazelcastInstanceFactory.java:126)
at com.hazelcast.core.Hazelcast.newHazelcastInstance(Hazelcast.java:58)
at com.orientechnologies.orient.server.hazelcast.OHazelcastPlugin.configureHazelcast(OHazelcastPlugin.java:726)
at com.orientechnologies.orient.server.hazelcast.OHazelcastPlugin.startup(OHazelcastPlugin.java:154)
at com.orientechnologies.orient.server.OServer.registerPlugins(OServer.java:1249)
at com.orientechnologies.orient.server.OServer.activate(OServer.java:399)
at com.orientechnologies.orient.server.OServerMain$1.run(OServerMain.java:46)
Caused by: java.lang.ClassNotFoundException: com.google.common.net.HostAndPort
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 20 more

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.