o.hazelcast-consul-discovery-spi.2.0-RC1-20210205.source-code.hazelcast-consul-discovery-spi-example.xml Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of hazelcast-consul-discovery-spi Show documentation
Show all versions of hazelcast-consul-discovery-spi Show documentation
hazelcast-consul-discovery-spi - Consul based discovery strategy SPI for Hazelcast enabled applications
The newest version!
<?xml version="1.0" encoding="UTF-8"?> <hazelcast id="hazelcast-consul-discovery" xsi:schemaLocation="http://www.hazelcast.com/schema/config hazelcast-config-4.0.xsd" xmlns="http://www.hazelcast.com/schema/config" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <cluster-name>hazelcast-consul-discovery-spi</cluster-name> <properties> <property name="hazelcast.discovery.enabled">true</property> <property name="hazelcast.shutdownhook.enabled">false</property> </properties> <network> <port auto-increment="true">5701</port> <join> <multicast enabled="false"/> <aws enabled="false"/> <tcp-ip enabled="false" /> <!-- Enable a Consul based discovery strategy --> <discovery-strategies> <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> <!-- Name of the Consul service that will be used to discover peer hazelcast services in Consul IF a ConsulRegistrator is configured below: this node will be registered under this same service name. This name should be UNIQUE to your hazelcast cluster! (i.e. like your group name above..) --> <property name="consul-service-name">hz-discovery-test-cluster</property> <!-- When discovering peer nodes, only return those that are healthy (true) If false, all nodes, regardless of health (from Consul's perspective) will be returned This DOES NOT apply to the first call to discoverNodes() but only subsequent calls (if any) to account for any Consul service health-check you have, who's interval might be longer than the period of time which the service is registered and the first health check runs. --> <property name="consul-healthy-only">true</property> <!-- Comma separated list of Consul service tags that will be used when registering services in Consul who are part of the same cluster and will be discovered and treated as peer members of the hazelcast cluster. --> <property name="consul-service-tags">hazelcast,test1</property> <!-- If you quickly start an entire hz cluster at the exact same time, and all hazelcast services are registered with Consul at the same time, its possible they may all discover ONLY themselves as members, leading to a cluster that can never be fully discovered. This small delay can assist with avoiding that problem. @see https://github.com/hazelcast/hazelcast/issues/6813 --> <property name="consul-discovery-delay-ms">10000</property> <!-- An optional Access Control List (ACL) token that can be used to control access to data and API. this is passed as query parameter (token) when using Consul clients. You can use the uuidgen to pre-generate the UUID on any *nix machines and create the ACL by providing that in the ID field of the json body of the ACL create request. If you don't provide an ID, then a random generated UUID will be returned in the response, which you can use here. @see https://www.consul.io/docs/agent/http/acl.html#acl_create You would also need a acl_master_token setup on your server configuration json, or create a management token using the acl/create API above using "type":"management" in the body of the json to get a new acl_master_token UUID. Once you have the acl_master_token, you can create a client token using the following curl command for example, that creates an acl_token of type: client that gives read and write permission to all services: curl -X PUT -d @client_acl.json "http://localhost:8500/v1/acl/create?token=D4289F4C-19C1-4A9B-AC7A-A46D9CFA78BF&pretty=true";echo You can find the client_acl.json under docs/sample_data folder --> <property name="consul-acl-token">23f4e655-5ff2-89f8-497a-bbc73a4e6e47</property> <!-- If you want to enable TLS, you can set this option to "true". If you enable TLS, then the "consul-port" property above needs to be set to the correct https port that is configured on the Consul server. OPTIONALLY: In addition, either "consul-ssl-server-cert-file-path" or "consul-ssl-server-cert-base64" properties below would have to be provided if TLS is enabled and your consul server(s) present a self-signed non-JRE trusted certificate. --> <property name="consul-ssl-enabled">false</property> <!-- OPTIONAL: only necessary if your consul server presents a self-signed certificate Path to a self signed CA cert file that will be used if TLS is enabled. You need to provide the full path to the certificate file. You can alternatively provide the "consul-ssl-server-cert-base64" property below. --> <property name="consul-ssl-server-cert-file-path">/path/to/ca.cert</property> <!-- OPTIONAL: only necessary if your consul server presents a self-signed certificate A base64 encoded CA cert string that can be used for TLS connection. You can alternatively provide the "consul-ssl-server-cert-file-path" property above. --> <property name="consul-ssl-server-cert-base64"></property> <!-- If this set to false, it will override the hostnameVerifier to be used by the client to verify the endpoint's hostname against it's identification information and always mark it as verified. You can set this to true, to use the default hostnameVerifier that will strict match the endpoint's hostname against the client identification. --> <property name="consul-ssl-server-hostname-verify">false</property> <!-- ConsulRegistrator: This (optionally) enables the DiscoveryStrategy to register this hazelcast instance as a service with Consul directly and deregister it on shutdown. LocalDiscoveryNodeRegistrator: Uses the private/public IP:PORT determined by this Hazelcast instance (and tags above) as the identifiers for registering itself with Consul as a unique service. ExplicitIpPortRegistrator: Uses an explicit IP:PORT specified by you in the 'consul-registrator-config' below (and tags above) as the identifiers for registering itself with Consul as a unique service. DoNothingRegistrator: Does NOTHING in regards to registration or deregistration of this node as a service with Consul. This should be used if you are running a local Consul agent yourself and managing the registration of this Hazelcast node manually via standard Consul configs on the agent. --> <property name="consul-registrator">org.bitsofinfo.hazelcast.discovery.consul.LocalDiscoveryNodeRegistrator</property> <!-- Custom properties for the ConsulRegistrator class you are using, JSON. @see ConsulRegistrator implementation class for details on the configuration unique to it. The configuration below is for LocalDiscoveryNodeRegistrator: - preferPublicAddress (true|false) : use the public IP determined by hazelcast (if not null) over the private IP - healthCheckProvider: the type of health check to use (script, http or tcp). It defaults to "org.bitsofinfo.hazelcast.discovery.consul.ScriptHealthCheckBuilder" if this property is not provided. Properties consumed by: org.bitsofinfo.hazelcast.discovery.consul.ScriptHealthCheckBuilder - healthCheckScript: can be anything you want Consul to do to determine health. Variables #MYIP/#MYPORT will be replaced with this node's IP/PORT @see https://www.consul.io/docs/agent/checks.html - healthCheckScriptIntervalSeconds: self explanatory Properties consumed by: org.bitsofinfo.hazelcast.discovery.consul.HttpHealthCheckBuilder - healthCheckHttp: valid hostname and port to use for health check. You can provide optional path to a specific script. Variables #MYIP/#MYPORT will be replaced with this node's IP/PORT - healthCheckHttpIntervalSeconds: self explanatory Properties consumed by: org.bitsofinfo.hazelcast.discovery.consul.TcpHealthCheckBuilder - healthCheckTcp: valid IP and port to use for health check. Variables #MYIP/#MYPORT will be replaced with this node's IP/PORT - healthCheckTcpIntervalSeconds: self explanatory --> <property name="consul-registrator-config"><![CDATA[ { "preferPublicAddress":false, "healthCheckProvider":"org.bitsofinfo.hazelcast.discovery.consul.ScriptHealthCheckBuilder", "healthCheckScript":"nc -z #MYIP #MYPORT", "healthCheckScriptIntervalSeconds":30, "healthCheckHttp":"http://some.endpoint.on.this.app:80", "healthCheckHttpIntervalSeconds":30, "healthCheckTcp":"ip:port", "healthCheckTcpIntervalSeconds":30 } ]]></property> <!-- The configuration below is for ExplicitIpPortRegistrator: - registerWithIpAddress: register with this IP in Consul - registerWithPort: register with this PORT in Consul - healthCheckProvider: the type of health check to use (script or http). It defaults to "org.bitsofinfo.hazelcast.discovery.consul.ScriptHealthCheckBuilder" if this property is not provided. Properties consumed by: org.bitsofinfo.hazelcast.discovery.consul.ScriptHealthCheckBuilder - healthCheckScript: can be anything you want Consul to do to determine health. Variables #MYIP/#MYPORT will be replaced with this node's IP/PORT @see https://www.consul.io/docs/agent/checks.html - healthCheckScriptIntervalSeconds: self explanatory Properties consumed by: org.bitsofinfo.hazelcast.discovery.consul.HttpHealthCheckBuilder - healthCheckHttp: valid hostname and port to use for health check. You can provide optional path to a specific script. Variables #MYIP/#MYPORT will be replaced with this node's IP/PORT (port being hazelcast port, but you likely would not want to use that for an http check) - healthCheckHttpIntervalSeconds: self explanatory Properties consumed by: org.bitsofinfo.hazelcast.discovery.consul.TcpHealthCheckBuilder - healthCheckTcp: valid IP and port to use for health check. Variables #MYIP/#MYPORT will be replaced with this node's IP/PORT (port being hazelcast port) - healthCheckTcpIntervalSeconds: self explanatory <property name="consul-registrator-config"><![CDATA[ { "registerWithIpAddress":"192.168.1.102", "registerWithPort":5701, "healthCheckProvider":"org.bitsofinfo.hazelcast.discovery.consul.HttpHealthCheckBuilder", "healthCheckScript":"nc -z #MYIP #MYPORT", "healthCheckScriptIntervalSeconds":30, "healthCheckHttp":"http://#MYIP:80", "healthCheckHttpIntervalSeconds":30, "healthCheckTcp":"#MYIP:#MYPORT", "healthCheckTcpIntervalSeconds":30 } ]]></property> --> </properties> </discovery-strategy> </discovery-strategies> </join> </network> </hazelcast>
© 2015 - 2025 Weber Informatics LLC | Privacy Policy