{"id":17132193,"url":"https://github.com/bitsofinfo/hazelcast-docker-swarm-discovery-spi","last_synced_at":"2025-10-09T02:43:16.225Z","repository":{"id":57744946,"uuid":"94909281","full_name":"bitsofinfo/hazelcast-docker-swarm-discovery-spi","owner":"bitsofinfo","description":"Docker Swarm based discovery strategy SPI for Hazelcast enabled applications ","archived":false,"fork":false,"pushed_at":"2021-02-09T19:20:06.000Z","size":646,"stargazers_count":39,"open_issues_count":7,"forks_count":33,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-03-26T23:05:04.803Z","etag":null,"topics":["docker","hazelcast","service-discovery","swarm"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bitsofinfo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-06-20T15:53:32.000Z","updated_at":"2024-06-26T11:06:27.000Z","dependencies_parsed_at":"2022-08-30T11:32:01.048Z","dependency_job_id":null,"html_url":"https://github.com/bitsofinfo/hazelcast-docker-swarm-discovery-spi","commit_stats":null,"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitsofinfo%2Fhazelcast-docker-swarm-discovery-spi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitsofinfo%2Fhazelcast-docker-swarm-discovery-spi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitsofinfo%2Fhazelcast-docker-swarm-discovery-spi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitsofinfo%2Fhazelcast-docker-swarm-discovery-spi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bitsofinfo","download_url":"https://codeload.github.com/bitsofinfo/hazelcast-docker-swarm-discovery-spi/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248674658,"owners_count":21143760,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docker","hazelcast","service-discovery","swarm"],"created_at":"2024-10-14T19:26:19.823Z","updated_at":"2025-10-09T02:43:11.200Z","avatar_url":"https://github.com/bitsofinfo.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# hazelcast-docker-swarm-discovery-spi\n\n[![Build Status](https://travis-ci.org/bitsofinfo/hazelcast-docker-swarm-discovery-spi.svg?branch=master)](https://travis-ci.org/bitsofinfo/hazelcast-docker-swarm-discovery-spi)\n\nProvides a Docker Swarm mode based discovery strategy for Hazlecast 3.6+ enabled applications.\nThis is an easy to configure plug-and-play Hazlecast DiscoveryStrategy that will enable Hazelcast applications to dynamically discover one another when deployed as Docker Swarm services.\n\n* [Status](#status)\n* [Releases](#releases)\n* [Requirements](#requirements)\n* [Maven/Gradle install](#mavengradle)\n* [How it works](#howitworks)\n* [Features](#features)\n* [Usage](#usage)\n* [Build from source](#building)\n* [Unit tests](#tests)\n* [Related Info](#related)\n* [Todo](#todo)\n* [Troubleshooting](#troubleshooting)\n\n![Diagram of hazelcast docker swarm discovery strategy](/docs/diag1.png \"Diagram1\")\n\n## \u003ca id=\"status\"\u003e\u003c/a\u003eStatus\n\nThis is release candidate code, tested against Hazelcast 3.6-EA+ through 3.9.x Stable releases. See **Releases** below for compatible jars. For use only on Docker 1.12+ \"swarm mode\" environments.\n\n**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\n\n## \u003ca id=\"releases\"\u003e\u003c/a\u003eReleases\n\n### For Hazelcast 3.9+ only (see below for \u003c= 3.8)\n\n* MASTER - in progress, this README refers to what is in the master tag. **Switch to relevant RELEASE tag above to see that version's README**\n\n* **1.0-RC14-20210205**: Same as `1.0-RC14` but made compliant for Maven Central due to JCenter/Bintray closure. \n\n* [1.0-RC14](https://github.com/bitsofinfo/hazelcast-docker-swarm-discovery-spi/releases/tag/1.0-RC14) Additional configurable properties (`strict-docker-service-name-comparison / strictDockerServiceNameComparison`) to optionally add a strict \"equals\" check against names of services returned from docker; docker itself returns services based on a \"startsWith\" check.\n\n* [1.0-RC13](https://github.com/bitsofinfo/hazelcast-docker-swarm-discovery-spi/releases/tag/1.0-RC13) Additional configurable properties (`log-all-service-names-on-failed-discovery / logAllServiceNamesOnFailedDiscovery`) to optionally log (FINE) all available docker service names if no containers can be discovered via configured criteria. Better logging to provide the context by which `SwarmDiscoveryUtil` is being utilized.\n\n* [1.0-RC12](https://github.com/bitsofinfo/hazelcast-docker-swarm-discovery-spi/releases/tag/1.0-RC12) Additional debug logging\n\n* [1.0-RC11](https://github.com/bitsofinfo/hazelcast-docker-swarm-discovery-spi/releases/tag/1.0-RC11) Added `java.util.Properties` based constructor for `SwarmMemberAddressProvider`\n\n* [1.0-RC10](https://github.com/bitsofinfo/hazelcast-docker-swarm-discovery-spi/releases/tag/1.0-RC10) Better logging in: `DockerDNSRRMemberAddressProvider` for https://github.com/bitsofinfo/hazelcast-docker-swarm-discovery-spi/issues/25\n\n* [1.0-RC9](https://github.com/bitsofinfo/hazelcast-docker-swarm-discovery-spi/releases/tag/1.0-RC9) Better NPE handling for invalid/null Tasks returned from service spec or no network attachments\n\n* [1.0-RC8](https://github.com/bitsofinfo/hazelcast-docker-swarm-discovery-spi/releases/tag/1.0-RC8): Incorporated PRs #18 (adjust depedencies declaration), #17\n\n* [1.0-RC7](https://github.com/bitsofinfo/hazelcast-docker-swarm-discovery-spi/releases/tag/1.0-RC7): Incorporated PRs #14 (initial scan self check), #15 (docker service names optional)\n\n* [1.0-RC6](https://github.com/bitsofinfo/hazelcast-docker-swarm-discovery-spi/releases/tag/1.0-RC6): Added support for swarm dnsrr based discovery, thanks [Cardds](https://github.com/Cardds), https://github.com/bitsofinfo/hazelcast-docker-swarm-discovery-spi/pull/10\n\n* [1.0-RC5](https://github.com/bitsofinfo/hazelcast-docker-swarm-discovery-spi/releases/tag/1.0-RC5): Added support for SSL swarm manager URIs and skip verify for SSL.\n\n* [1.0-RC4](https://github.com/bitsofinfo/hazelcast-docker-swarm-discovery-spi/releases/tag/1.0-RC4): Changed gradle dependencies for HZ `3.9.+` \u0026 spotify docker-client for `8.+`. Implemented new `MemberAddressProvider` SPI, as alternative option to using `SwarmAddressPicker`\n\n### For Hazelcast 3.8 and below\n\n* [1.0-RC3](https://github.com/bitsofinfo/hazelcast-docker-swarm-discovery-spi/releases/tag/1.0-RC3): Improved SwarmAddressPicker constructor [PR #6](https://github.com/bitsofinfo/hazelcast-docker-swarm-discovery-spi/pull/6)\n\n* [1.0-RC2](https://github.com/bitsofinfo/hazelcast-docker-swarm-discovery-spi/releases/tag/1.0-RC2): Excludes stopped tasks [#2](https://github.com/bitsofinfo/hazelcast-docker-swarm-discovery-spi/issues/2)\n\n* [1.0-RC1](https://github.com/bitsofinfo/hazelcast-docker-swarm-discovery-spi/releases/tag/1.0-RC1): Initial release\n\n## \u003ca id=\"requirements\"\u003e\u003c/a\u003eRequirements\n\n* Java 7+\n* [Hazelcast 3.6+](https://hazelcast.org/)\n* [Docker 1.12+ Swarm Mode](https://docs.docker.com/engine/swarm/) with one or more swarm manager nodes listening on a `tcp://` socket\n\n## \u003ca id=\"mavengradle\"\u003e\u003c/a\u003eMaven/Gradle\n\nTo use this discovery strategy in your Maven or Gradle project use the dependency samples below.\n\n### Gradle:\n\n```\nrepositories {\n    mavenCentral()\n}\n\ndependencies {\n  // \u003c!-- Use 1.0.RC3 for Hazelcast \u003c 3.8.x --\u003e\n  compile 'org.bitsofinfo:hazelcast-docker-swarm-discovery-spi:1.0-RC14-20210205'\n}\n```\n\n### Maven:\n\n```\n\u003cdependencies\u003e\n    \u003cdependency\u003e\n        \u003cgroupId\u003eorg.bitsofinfo\u003c/groupId\u003e\n        \u003cartifactId\u003ehazelcast-docker-swarm-discovery-spi\u003c/artifactId\u003e\n        \u003cversion\u003e1.0-RC14-20210205\u003c/version\u003e \n    \u003c/dependency\u003e\n\u003c/dependencies\u003e\n```\n\n## \u003ca id=\"features\"\u003e\u003c/a\u003eFeatures\n\n* Will permit Hazelcast instances deployed on a Docker 1.12+ Swarm to automatically discover and connect with one another\n\n## \u003ca id=\"howitworks\"\u003e\u003c/a\u003eHow it works\n\nHazelcast applications that use this discovery SPI will discover one another when deployed as Docker services in the following way.\n\n* Launch your docker service with its target overlay network name and either its service name or service labels. In addition, specify additional ENVIRONMENT variables via `-e` named `dockerNetworkNames` and optionally `dockerServiceNames` and `dockerServiceLabels`. You should have at least one of `dockerServiceNames` or `dockerServiceLabels` defined. These variables will be consumed by the discovery SPI. The `DOCKER_HOST` environment variable for the container should also be set to a name that resolves to one or more swarm manager nodes, via the format `tcp://`, `http://` or `https://`\n\n* The Docker Swarm Discovery SPI consumes from the `DOCKER_HOST`, `dockerNetworkNames`, optionally `dockerServiceNames`, `dockerServiceLabels` and `hazelcastPeerPort` and begins the following process.\n\n    1. Leverages the custom `MemberAddressProvider` SPI implementation (`SwarmMemberAddressProvider`) or `SwarmAddressPicker` hack (read below!) to talk to the *$DOCKER_HOST* `/networks`, `/services` and `/tasks` APIs to determine the current node's IP address on the docker network, and bind hazelcast on `hazelcastPeerPort` to that address.\n\n    2. Next hazelcast invokes the SPI `discoverMembers()` to determine all peer docker service tasks (containers) ip addresses and attempts to connect to them to form the cluster connecting to the configured `hazelcastPeerPort` (default 5701)\n\nAlternatively, discovery can be limited to the bounds of the docker cluster using [docker endpoint_mode dnsrr](https://docs.docker.com/engine/swarm/networking/#configure-service-discovery).\n\n* Launch your docker service with its service name and target overlay network name with `endpoint_mode` set to `dnsrr`. In addition, specify additional ENVIRONMENT variables via `-e` named `serviceName`, `servicePort`, and `peerServicesCsv`\n\n    1. Leverages the custom `MemberAddressProvider` SPI implementation (`DockerDNSRRMemberAddressProvider`) to resolve the DNS entries for its own service, `serviceName`, and port, `servicePort`, to IP addresses within the docker network.\n\n    2. Next, hazelcast invokes the SPI DiscoveryStrategy to resolve the internal docker DNS entries for all services that the hazelcast instance should consider its peers, and connects to them over the ports specified in `peerServicesCsv` (default 5701)\n\n    *Note: `peerServicesCsv` must contain a reference to the `serviceName` and `servicePort`, if the service is meant to cluster with itself*\n\n## \u003ca id=\"usage\"\u003e\u003c/a\u003eUsage\n\nEnsure your project has the `hazelcast-docker-swarm-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.\n\n### Option 1: Local network binding via  SwarmMemberAddressProvider\n\n*Note this is only available in RC4+ and only for Hazelcast 3.9+. apps*\n\nConfigure your hazelcast.xml configuration file to use the `DockerSwarmDiscoveryStrategy` and `SwarmMemberAddressProvider` (similar to the below): [See hazelcast-docker-swarm-discovery-spi-example-member-address-provider.xml](src/main/resources/hazelcast-docker-swarm-discovery-spi-example-member-address-provider.xml) for an example with documentation of options.\n\n\n```\nConfig conf =new ClasspathXmlConfig(\"yourHzConfig.xml\");\n\nHazelcastInstance hazelcastInstance = HazelcastInstanceFactory\n        .newHazelcastInstance(conf,\"myAppName\",new DefaultNodeContext());\n\n```\n\n### Option 2: Swarm DNSRR network binding via DockerDNSRRMemberAddressProvider\n\n*Note this is only available in RC6+ and only for Hazelcast 3.9+. apps*\n\nConfigure your hazelcast.xml configuration file to use the `DockerDNSRRDiscoveryStrategy` and `DockerDNSRRMemberAddressProvider` (similar to the below): [See hazelcast-docker-swarm-dnsrr-discovery-spi-example.xml](src/main/resources/hazelcast-docker-swarm-dnsrr-discovery-spi-example.xml) for an example with documentation of options.\n\n```\nConfig conf =new ClasspathXmlConfig(\"yourHzConfig.xml\");\n\nHazelcastInstance hazelcastInstance = HazelcastInstanceFactory\n        .newHazelcastInstance(conf,\"myAppName\",new DefaultNodeContext());\n\n```\n\n### Option 3: Local network binding via SwarmAddressPicker\n\n*Note this the preferred method for Hazecast \u003c= 3.8.x apps*\n\nConfigure your hazelcast.xml configuration file to use the `DockerSwarmDiscoveryStrategy` (similar to the below): [See hazelcast-docker-swarm-discovery-spi-example-address-picker.xml](src/main/resources/hazelcast-docker-swarm-discovery-spi-example-address-picker.xml) for an example with documentation of options.\n\n\n```\nimport org.bitsofinfo.hazelcast.discovery.docker.swarm.SwarmAddressPicker;\n...\n\nConfig conf =new ClasspathXmlConfig(\"yourHzConfig.xml\");\n\nNodeContext nodeContext = new DefaultNodeContext() {\n    @Override\n    public AddressPicker createAddressPicker(Node node) {\n        return new SwarmAddressPicker(new ILogger() {\n            // you provide the impl... or use provided \"SystemPrintLogger\"\n        });\n    }\n};\n\nHazelcastInstance hazelcastInstance = HazelcastInstanceFactory\n        .newHazelcastInstance(conf,\"myAppName\",nodeContext);\n\n```\n\n### If a local network binding option is chosen, proceed with the below:\n\n* Create a Docker image for your application that uses Hazelcast\n\n* Create an overlay network for your service, `docker network create -d overlay [name]`\n\n* Launch your services via `docker service create` against your Docker Swarm cluster:\n\nNote this example command assumes an entrypoint script exists that execs the `java` command. Your *DOCKER_HOST* must be accessible over http (i.e. daemons listening on the *tcp://* socket\n\nNOTE! All `-D` java System properties below can be omitted and alternatively defined within the `\u003cmember-address-provider\u003e` Hazelcast XML configuration stanza itself. You can mix/match combination of -D defined properties and those defined in Hazelcast XML. Properties defined in Hazelcast XMl take priority.\n\n\n**DOCKER_HOST non-tls**\n```\ndocker service create \\\n    --network [mynet] \\\n    --name myHzService1 \\\n    -l myLabel1=value1 \\\n    -l myLabel2=value2 \\\n    -e \"DOCKER_HOST=http://[swarmmgr]:[port]\" \\\n    [yourappimage] \\\n    java \\\n    -DdockerNetworkNames=[mynet] \\\n    -DdockerServiceNames=myHzService1 \\\n    -DdockerServiceLabels=\"myLabel1=value1,myLabel2=value2\" \\\n    -DhazelcastPeerPort=5701 \\\n    -jar /test.jar\n```\n\n**1.0-RC5+ ONLY: DOCKER_HOST SSL w/ optional skip verify**\n\n**1.0-RC13+ ONLY: Optionally, logAllServiceNamesOnFailedDiscovery, FINE logging only**\n```\ndocker service create \\\n    --network [mynet] \\\n    --name myHzService1 \\\n    -l myLabel1=value1 \\\n    -l myLabel2=value2 \\\n    [yourappimage] \\\n    java \\\n    -DdockerNetworkNames=[mynet] \\\n    -DdockerServiceNames=myHzService1 \\\n    -DdockerServiceLabels=\"myLabel1=value1,myLabel2=value2\" \\\n    -DhazelcastPeerPort=5701 \\\n    -DswarmMgrUri=http(s)://[swarmmgr]:[port] \\\n    -DskipVerifySsl=[true|false] \\\n    -DlogAllServiceNamesOnFailedDiscovery=[true|false] \\\n    -jar /test.jar\n```\n\n**1.0-RC14+ ONLY: Optionally, strictDockerServiceNameComparison\n```\ndocker service create \\\n    --network [mynet] \\\n    --name myHzService1 \\\n    -l myLabel1=value1 \\\n    -l myLabel2=value2 \\\n    [yourappimage] \\\n    java \\\n    -DdockerNetworkNames=[mynet] \\\n    -DdockerServiceNames=myHzService1 \\\n    -DdockerServiceLabels=\"myLabel1=value1,myLabel2=value2\" \\\n    -DhazelcastPeerPort=5701 \\\n    -DswarmMgrUri=http(s)://[swarmmgr]:[port] \\\n    -DskipVerifySsl=[true|false] \\\n    -DlogAllServiceNamesOnFailedDiscovery=[true|false] \\\n    -DstrictDockerServiceNameComparison=[true|false] \\\n    -jar /test.jar\n```\n\nNOTE! All `-D` java System properties above can be omitted and alternatively defined within the `\u003cmember-address-provider\u003e` Hazelcast XML configuration stanza itself. You can mix/match combination of -D defined properties and those defined in Hazelcast XML. Properties defined in Hazelcast XMl take priority.\n\nNOTE! Use the optional `logAllServiceNamesOnFailedDiscovery` property with caution. If your target swarm cluster contains many services this call may result in logging a considerable amount of un-related docker service names.\n\nExample configuration (using MemberAddressProvider for Hazelcast 3.9+): see the example: (hazelcast-docker-swarm-discovery-spi-example-member-address-provider.xml)[src/main/resources/META-INF/hazelcast-docker-swarm-discovery-spi-example-member-address-provider.xml]\n\nFor Hazelcast \u003c= 3.8.x apps: see the example: (hazelcast-docker-swarm-discovery-spi-example-address-picker.xml)[src/main/resources/META-INF/hazelcast-docker-swarm-discovery-spi-example-address-picker.xml]\n```\n\u003cnetwork\u003e\n    \u003cport auto-increment=\"true\"\u003e5701\u003c/port\u003e\n\n    \u003cinterfaces enabled=\"false\"\u003e\n    \u003c/interfaces\u003e\n\n    \u003cjoin\u003e\n\n        \u003cmulticast enabled=\"false\"/\u003e\n        \u003caws enabled=\"false\"/\u003e\n        \u003ctcp-ip enabled=\"false\" /\u003e\n\n        \u003c!-- for Hazelcast 3.9+ apps only, comment out for \u003c= 3.8.x apps)\n        \u003cmember-address-provider enabled=\"true\"\u003e\n            \u003cclass-name\u003eorg.bitsofinfo.hazelcast.discovery.docker.swarm.SwarmMemberAddressProvider\u003c/class-name\u003e\n\n            \u003c!--\n                OPTIONAL:\n\n                The following will be passed as a java.util.Properties to\n                the SwarmMemberAddressProvider(java.util.Properties) constructor.\n\n                If you do not defined these here in XML, by default they will be fetched via\n                -D java System.properties by the same names via the default no-arg constructor\n                of SwarmMemberAddressProvider\n\n                \u003cproperties\u003e\n                \u003cproperty name=\"dockerNetworkNames\"\u003e...\u003c/property\u003e\n                \u003cproperty name=\"dockerServiceLabels\"\u003e...\u003c/property\u003e\n                \u003cproperty name=\"dockerServiceNames\"\u003e...\u003c/property\u003e\n                \u003cproperty name=\"hazelcastPeerPort\"\u003e...\u003c/property\u003e\n                \u003cproperty name=\"swarmMgrUri\"\u003e...\u003c/property\u003e\n                \u003cproperty name=\"skipVerifySsl\"\u003etrue|false\u003c/property\u003e\n                \u003cproperty name=\"logAllServiceNamesOnFailedDiscovery\"\u003etrue|false\u003c/property\u003e\n                \u003cproperty name=\"strictDockerServiceNameComparison\"\u003etrue|false\u003c/property\u003e\n                \u003c/properties\u003e\n            --\u003e\n        \u003c/member-address-provider\u003e\n\n         \u003c!-- Enable a Docker Swarm based discovery strategy --\u003e\n         \u003cdiscovery-strategies\u003e\n\n           \u003cdiscovery-strategy enabled=\"true\"\n               class=\"org.bitsofinfo.hazelcast.discovery.docker.swarm.DockerSwarmDiscoveryStrategy\"\u003e\n\n             \u003cproperties\u003e\n                  \u003c!-- Comma delimited list of Docker network names to discover matching services on --\u003e\n                  \u003cproperty name=\"docker-network-names\"\u003e${dockerNetworkNames}\u003c/property\u003e\n\n                  \u003c!-- Comma delimited list of relevant Docker service names\n                       to find tasks/containers on the above networks --\u003e\n                  \u003cproperty name=\"docker-service-names\"\u003e${dockerServiceNames}\u003c/property\u003e\n\n                  \u003c!-- Comma delimited list of relevant Docker service label=values\n                       to find tasks/containers on the above networks --\u003e\n                  \u003cproperty name=\"docker-service-labels\"\u003e${dockerServiceLabels}\u003c/property\u003e\n\n                  \u003c!-- 1.0-RC5+ ONLY: Swarm Manager URI (overrides DOCKER_HOST) --\u003e\n                  \u003cproperty name=\"swarm-mgr-uri\"\u003e${swarmMgrUri}\u003c/property\u003e\n\n                  \u003c!-- 1.0-RC5+ ONLY: If Swarm Mgr URI is SSL, to enable skip-verify for it --\u003e\n                  \u003cproperty name=\"skip-verify-ssl\"\u003e${skipVerifySsl}\u003c/property\u003e\n                  \n                  \u003c!-- 1.0-RC13+ ONLY! \n                       If enabled logged w/ severity FINE.\n                       Use with caution. If your target swarm cluster contains many services this call \n                       may result in logging a considerable amount of un-related docker service names.\n                  --\u003e\n                  \u003cproperty name=\"log-all-service-names-on-failed-discovery\"\u003e${logAllServiceNamesOnFailedDiscovery}\u003c/property\u003e\n\n                  \u003c!-- 1.0-RC14+ ONLY: If enabled, perform strict \"equals\" name check of services returned from Docker --\u003e\n                  \u003cproperty name=\"strict-docker-service-name-comparison\"\u003e${strictDockerServiceNameComparison}\u003c/property\u003e\n\n                  \u003c!-- The raw port that hazelcast is listening on\n\n                       IMPORTANT: this is NOT a docker \"published\" port, nor is it necessarily\n                       a EXPOSEd port... it is simply the hazelcast port that the service\n                       is configured with, this must be the same for all matched containers\n                       in order to work, and just using the default of 5701 is the simplist\n                       way to go.\n                   --\u003e\n                  \u003cproperty name=\"hazelcast-peer-port\"\u003e${hazelcastPeerPort}\u003c/property\u003e\n             \u003c/properties\u003e\n\n           \u003c/discovery-strategy\u003e\n         \u003c/discovery-strategies\u003e\n\n    \u003c/join\u003e\n\u003c/network\u003e\n```\n\n### If Swarm DNSRR network binding option is chosen, proceed with the below:\n\n* Create a Docker image for your application that uses Hazelcast\n\n* Create an overlay network for your service, `docker network create -d overlay [mynetname]`\n\n* Launch your services via `docker service create` against your Docker Swarm cluster:\n\nNote this example command assumes an entrypoint script exists that execs the `java` command.\n\n```\ndocker service create \\\n    --network [mynetname] \\\n    --name myHzService1 \\\n    --endpoint-mode dnsrr\n    [yourappimage] \\\n    java\n    -DserviceName=myHzService1\n    -DservicePort=5701\n    -DpeerServicesCsv=myHzService1:5701\n    -jar /test.jar\n```\n\nExample configuration, full text at [hazelcast-docker-swarm-dnsrr-discovery-spi-example.xml](src/main/resources/META-INF/hazelcast-docker-swarm-dnsrr-discovery-spi-example.xml)\n\n```\n    \u003cproperties\u003e\n        \u003c!-- Explicitly enable hazelcast discovery join methods --\u003e\n        \u003cproperty name=\"hazelcast.discovery.enabled\"\u003etrue\u003c/property\u003e\n    \u003c/properties\u003e\n\n    \u003cnetwork\u003e\n        \u003c!--\n            Auto-increment is turned off for the port; docker containers will\n            always be available at the available in-network ports.\n        --\u003e\n        \u003cport auto-increment=\"false\"\u003e${servicePort}\u003c/port\u003e\n        \n        \u003cmember-address-provider enabled=\"true\"\u003e\n            \u003cclass-name\u003eorg.bitsofinfo.hazelcast.spi.docker.swarm.dnsrr.DockerDNSRRMemberAddressProvider\u003c/class-name\u003e\n            \u003cproperties\u003e\n                \u003c!-- Name of the docker service that this instance is running in --\u003e\n                \u003cproperty name=\"serviceName\"\u003e${serviceName}\u003c/property\u003e\n\n                \u003c!-- Internal port that hazelcast is listening on --\u003e\n                \u003cproperty name=\"servicePort\"\u003e${servicePort}\u003c/property\u003e\n            \u003c/properties\u003e\n        \u003c/member-address-provider\u003e\n        \n        \u003cjoin\u003e\n            \u003c!-- Explicitly disable other cluster join methods --\u003e\n            \u003cmulticast enabled=\"false\"/\u003e\n            \u003caws enabled=\"false\"/\u003e\n            \u003ctcp-ip enabled=\"false\" /\u003e\n\n            \u003cdiscovery-strategies\u003e\n                \u003cdiscovery-strategy\n                    enabled=\"true\"\n                    class=\"org.bitsofinfo.hazelcast.spi.docker.swarm.dnsrr.discovery.DockerDNSRRDiscoveryStrategy\"\n                \u003e\n                    \u003cproperties\u003e\n                        \u003c!--\n                            Comma separated list of docker services and associated ports\n                            to be considered peers of this service.\n\n                            Note, this must include itself (the definition of\n                            serviceName and servicePort) if the service is to\n                            cluster with other instances of this service.\n                        --\u003e\n                        \u003cproperty name=\"peerServicesCsv\"\u003e${peerServicesCsv}\u003c/property\u003e\n                    \u003c/properties\u003e\n                \u003c/discovery-strategy\u003e\n            \u003c/discovery-strategies\u003e\n        \u003c/join\u003e\n    \u003c/network\u003e\n```\n\n## \u003ca id=\"building\"\u003e\u003c/a\u003eBuilding from source\n\n* From the root of this project, build a Jar : `./gradlew jar`\n\n* Include the built jar artifact located at `build/libs/hazelcast-docker-swarm-discovery-spi-[VERSION].jar` in your hazelcast project\n\n* 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):\n\n```\ncompile group: 'com.spotify', name: 'docker-client', version: '8.7.3'\n```\n\n\n## \u003ca id=\"tests\"\u003e\u003c/a\u003eUnit-tests\n\n[![Build Status](https://travis-ci.org/bitsofinfo/hazelcast-docker-swarm-discovery-spi.svg?branch=master)](https://travis-ci.org/bitsofinfo/hazelcast-docker-swarm-discovery-spi)\n\nThere are really no traditional Java \"unit tests\" for this SPI due to its reliance on Docker.\n\nThere is however a [Travis CI test](https://travis-ci.org/bitsofinfo/hazelcast-docker-swarm-discovery-spi) that properly\nvalidates the SPI functionality in a real Docker swarm environment that brings up a single instance, scales it to 10 hazelcast\nnodes and then back down to 2 nodes. Demonstrating the proper discovery of peer hazelcast members.\n\nSee the [.travis.yml](.travis.yml) file for the full details.\n\n\n## \u003ca id=\"related\"\u003e\u003c/a\u003eRelated info\n\n* https://docs.docker.com/engine/swarm/\n* http://docs.hazelcast.org/docs/3.8/manual/html-single/index.html#discovery-spi\n* https://github.com/hazelcast/hazelcast/issues/10801\n* https://github.com/hazelcast/hazelcast/issues/10802\n* https://github.com/hazelcast/hazelcast/issues/11997\n\n\n## \u003ca id=\"todo\"\u003e\u003c/a\u003eTodo\n\n* None at this time\n\n## \u003ca id=\"troubleshooting\"\u003e\u003c/a\u003e Troubleshooting\n\nIf you get an exception (e.g. `AbstractMethodError`), this may have been caused by having `jersey-common` library twice.\n(One from the plugin itself -as a transitive dependency- and the other from the shaded `docker-client` library. In such\na case you may add an exclusion to your project's build file.\n\nFor maven:\n\n```\n  \u003cdependency\u003e\n    \u003cgroupId\u003eorg.bitsofinfo\u003c/groupId\u003e\n    \u003cartifactId\u003ehazelcast-docker-swarm-discovery-spi\u003c/artifactId\u003e\n    \u003cversion\u003e1.0-RC13\u003c/version\u003e\n    \u003cexclusions\u003e\n      \u003cexclusion\u003e\n        \u003cgroupId\u003eorg.glassfish.jersey.core\u003c/groupId\u003e\n        \u003cartifactId\u003ejersey-common\u003c/artifactId\u003e\n      \u003c/exclusion\u003e\n    \u003c/exclusions\u003e\n  \u003c/dependency\u003e\n```\n\nFor gradle:\n\n```\n  compile('org.bitsofinfo:hazelcast-docker-swarm-discovery-spi:1.0-RC13') {\n    exclude module: 'jersey-common'\n  }\n```\n\nFor details please see [Pull Request #6](https://github.com/bitsofinfo/hazelcast-docker-swarm-discovery-spi/pull/6).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbitsofinfo%2Fhazelcast-docker-swarm-discovery-spi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbitsofinfo%2Fhazelcast-docker-swarm-discovery-spi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbitsofinfo%2Fhazelcast-docker-swarm-discovery-spi/lists"}