Skip to content

Commit

Permalink
Revised README (#43)
Browse files Browse the repository at this point in the history
  • Loading branch information
pivovarit authored Jun 16, 2020
1 parent af481c4 commit 44c4dd7
Showing 1 changed file with 32 additions and 63 deletions.
95 changes: 32 additions & 63 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@
* [Compatibilities](#compatibilities)


# Hazelcast Discovery Plugin for Apache ZooKeeper
# Hazelcast Apache ZooKeeper Discovery Plugin

This plugin provides a service based discovery strategy by using Apache Curator to communicate with your Zookeeper server. You can use this plugin with Discovery SPI enabled Hazelcast 3.6.1 and higher applications.
This plugin provides a service-based discovery by using Apache Curator to communicate with your Zookeeper server.

You can use this plugin with Discovery SPI enabled Hazelcast 3.6.1 and higher applications.

## Configuration

Expand All @@ -24,7 +26,7 @@ This plugin provides a service based discovery strategy by using Apache Curator
```xml
<hazelcast xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.hazelcast.com/schema/config
http://www.hazelcast.com/schema/config/hazelcast-config-3.6.xsd"
http://www.hazelcast.com/schema/config/hazelcast-config-4.0.xsd"
xmlns="http://www.hazelcast.com/schema/config">

<properties>
Expand All @@ -34,19 +36,12 @@ This plugin provides a service based discovery strategy by using Apache Curator
<network>
<join>
<multicast enabled="false"/>
<tcp-ip enabled="false" />
<aws enabled="false"/>
<discovery-strategies>
<discovery-strategy enabled="true" class="com.hazelcast.zookeeper.ZookeeperDiscoveryStrategy">
<properties>
<!--
Connection string to your ZooKeeper server.
Default: There is no default, this is a required property.
Example: 127.0.0.1:2181
-->
<property name="zookeeper_url">{ip-address-of-zookeeper}:{port-of-zookeeper}</property>
<!--Path in ZooKeeper Hazelcast will useDefault: /discovery/hazelcast -->
<property name="zookeeper_path">{path-on-zookeeper}</property>
<property name="zookeeper_url">{ip-address-of-zookeeper}:{port-of-zookeeper}</property>
<!--defaults to /discovery/hazelcast -->
<property name="zookeeper_path">{path-on-zookeeper}</property>
<!--Name of this Hazelcast cluster. You can have multiple distinct clusters to use the same ZooKeeper installation.-->
<property name="group">{clusterId}</property>
</properties>
Expand All @@ -60,7 +55,7 @@ This plugin provides a service based discovery strategy by using Apache Curator
### Client XML Config

```xml
<hazelcast-client xsi:schemaLocation="http://www.hazelcast.com/schema/client-config hazelcast-client-config-3.6.xsd"
<hazelcast-client xsi:schemaLocation="http://www.hazelcast.com/schema/client-config hazelcast-client-config-4.0.xsd"
xmlns="http://www.hazelcast.com/schema/client-config"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

Expand All @@ -70,18 +65,11 @@ This plugin provides a service based discovery strategy by using Apache Curator

<network>
<aws enabled="false"/>
<smart-routing>true</smart-routing>
<redo-operation>true</redo-operation>
<discovery-strategies>
<discovery-strategy enabled="true" class="com.hazelcast.zookeeper.ZookeeperDiscoveryStrategy">
<properties>
<!--
Connection string to your ZooKeeper server.
Default: There is no default, this is a required property.
Example: 127.0.0.1:2181
-->
<property name="zookeeper_url">{ip-address-of-zookeeper}:{port-of-zookeeper}</property>
<!--Path in ZooKeeper Hazelcast will useDefault: /discovery/hazelcast -->
<!--Default: /discovery/hazelcast -->
<property name="zookeeper_path">{path-on-zookeeper}</property>
<!--Name of this Hazelcast cluster. You can have multiple distinct clusters to use the same ZooKeeper installation.-->
<property name="group">{clusterId}</property>
Expand All @@ -95,39 +83,33 @@ This plugin provides a service based discovery strategy by using Apache Curator
### Server Programmatic Config

```java
Config config = new Config();
config.getNetworkConfig().getJoin().getMulticastConfig().setEnabled(false);
config.setProperty("hazelcast.discovery.enabled", "true");

public static void main(String[] args) {

String zookeeperURL = "{ip-address-of-zookeeper}:{port-of-zookeeper}";

Config config = new Config();
config.getNetworkConfig().getJoin().getMulticastConfig().setEnabled(false);
config.setProperty(GroupProperty.DISCOVERY_SPI_ENABLED, "true");

DiscoveryStrategyConfig discoveryStrategyConfig = new DiscoveryStrategyConfig(new ZookeeperDiscoveryStrategyFactory());
discoveryStrategyConfig.addProperty(ZookeeperDiscoveryProperties.ZOOKEEPER_URL.key(), "{ip-address-of-zookeeper}:{port-of-zookeeper}");
discoveryStrategyConfig.addProperty(ZookeeperDiscoveryProperties.ZOOKEEPER_PATH.key(), "{path-on-zookeeper}");
discoveryStrategyConfig.addProperty(ZookeeperDiscoveryProperties.GROUP.key(), "{clusterId}");
config.getNetworkConfig().getJoin().getDiscoveryConfig().addDiscoveryStrategyConfig(discoveryStrategyConfig);
DiscoveryStrategyConfig discoveryStrategyConfig = new DiscoveryStrategyConfig(new ZookeeperDiscoveryStrategyFactory())
.addProperty(ZookeeperDiscoveryProperties.ZOOKEEPER_URL.key(), "{ip-address-of-zookeeper}:{port-of-zookeeper}")
.addProperty(ZookeeperDiscoveryProperties.ZOOKEEPER_PATH.key(), "{path-on-zookeeper}")
.addProperty(ZookeeperDiscoveryProperties.GROUP.key(), "{clusterId}");
config.getNetworkConfig().getJoin().getDiscoveryConfig().addDiscoveryStrategyConfig(discoveryStrategyConfig);

Hazelcast.newHazelcastInstance(config);
}
Hazelcast.newHazelcastInstance(config);
```

### Client Programmatic Config

```java
ClientConfig config = new ClientConfig();
config.getNetworkConfig().getAwsConfig().setEnabled(false);
config.setProperty(GroupProperty.DISCOVERY_SPI_ENABLED, "true");
ClientConfig config = new ClientConfig();

DiscoveryStrategyConfig discoveryStrategyConfig = new DiscoveryStrategyConfig(new ZookeeperDiscoveryStrategyFactory());
discoveryStrategyConfig.addProperty(ZookeeperDiscoveryProperties.ZOOKEEPER_URL.key(), "{ip-address-of-zookeeper}:{port-of-zookeeper}");
discoveryStrategyConfig.addProperty(ZookeeperDiscoveryProperties.ZOOKEEPER_PATH.key(), "{path-on-zookeeper}");
discoveryStrategyConfig.addProperty(ZookeeperDiscoveryProperties.GROUP.key(), "{clusterId}");
config.getNetworkConfig().getDiscoveryConfig().addDiscoveryStrategyConfig(discoveryStrategyConfig);
config.setProperty("hazelcast.discovery.enabled", "true");

HazelcastClient.newHazelcastClient(config);
DiscoveryStrategyConfig discoveryStrategyConfig = new DiscoveryStrategyConfig(new ZookeeperDiscoveryStrategyFactory())
.addProperty(ZookeeperDiscoveryProperties.ZOOKEEPER_URL.key(), "{ip-address-of-zookeeper}:{port-of-zookeeper}")
.addProperty(ZookeeperDiscoveryProperties.ZOOKEEPER_PATH.key(), "{path-on-zookeeper}")
.addProperty(ZookeeperDiscoveryProperties.GROUP.key(), "{clusterId}");
config.getNetworkConfig().getDiscoveryConfig().addDiscoveryStrategyConfig(discoveryStrategyConfig);

HazelcastClient.newHazelcastClient(config);

```
### Configuration via Maven
Expand All @@ -141,11 +123,6 @@ public static void main(String[] args) {

...
<dependencies>
<dependency>
<groupId>org.apache.curator</groupId>
<artifactId>curator-test</artifactId>
<version>${curator.version}</version>
</dependency>
<dependency>
<groupId>org.apache.curator</groupId>
<artifactId>curator-x-discovery</artifactId>
Expand All @@ -154,30 +131,22 @@ public static void main(String[] args) {
<dependency>
<groupId>com.hazelcast</groupId>
<artifactId>hazelcast-zookeeper</artifactId>
<version>${hazelcast.version}</version>
<version>${hazelcast-zookeeper.version}</version>
</dependency>
<dependency>
<groupId>com.hazelcast</groupId>
<artifactId>hazelcast</artifactId>
<version>${hazelcast.version}</version>
</dependency>
<dependency>
<groupId>com.hazelcast</groupId>
<artifactId>hazelcast-client</artifactId>
<version>${hazelcast.version}</version>
<dependency>
</dependencies>
...
</project>
```

## Compatibilities

In order for the hazelcast-zookeeper plugin to work for the Hazelcast Java client, you need to use Hazelcast Client 3.6.1 or higher.

hazelcast-zookeeper-3.6.3 has been tested with Curator 2.9.0 and Zookeeper 3.4.6

hazelcast-zookeeper-4.0 has been tested with Curator 4.0.1 and Zookeeper 3.5.7
- `3.6.3` has been tested with Curator 2.9.0 and Zookeeper 3.4.6
- `4.0.1` has been tested with Curator 4.0.1 and Zookeeper 3.5.7

### Known Issues
There is an issue between zookeeper and curator client in some versions. You may get `Received packet at server of unknown type 15` error.
There is an issue between Zookeeper and curator client in some versions. You may get `Received packet at server of unknown type 15` error.

0 comments on commit 44c4dd7

Please sign in to comment.