Skip to content

Commit

Permalink
latest 1.0-RC1
Browse files Browse the repository at this point in the history
  • Loading branch information
bitsofinfo committed Jan 21, 2016
1 parent 8910304 commit 423d9fe
Show file tree
Hide file tree
Showing 3 changed files with 125 additions and 28 deletions.
89 changes: 71 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,76 @@
# hazelcast-etcd-discovery-spi

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

* [Status](#status)
* [Releases](#releases)
* [Requirements](#requirements)
* [Maven/Gradle install](#mavengradle)
* [Features](#features)
* [Build/Usage](#usage)
* [Usage](#usage)
* [Build from source](#building)
* [Unit tests](#tests)
* [Related Info](#related)
* [Todo](#todo)
* [Notes](#notes)
* [Docker info](#docker)

![Alt text](/docs/diag.png "Diagram1")

## <a id="status"></a>Status

This is beta code.
This is beta code, tested against Hazelcast 3.6-EA and 3.6-RC1

## <a id="releases"></a>Releases

* [1.0-RC1](https://github.com/bitsofinfo/hazelcast-etcd-discovery-spi/releases/tag/1.0-RC1): Tested against Hazelcast 3.6-EA and 3.6-RC1

## <a id="requirements"></a>Requirements

* Java 6+
* [Hazelcast 3.6-EA+](https://hazelcast.org/)
* [Hazelcast 3.6-RC1+](https://hazelcast.org/)
* [Etcd](https://github.com/coreos/etcd)

## <a id="mavengradle"></a>Maven/Gradle

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

### Gradle:

```
repositories {
jcenter()
}
dependencies {
compile 'org.bitsofinfo:hazelcast-etcd-discovery-spi:1.0-RC1'
}
```

### Maven:

```
<dependencies>
<dependency>
<groupId>org.bitsofinfo</groupId>
<artifactId>hazelcast-etcd-discovery-spi</artifactId>
<version>1.0-RC1</version>
</dependency>
</dependencies>
<repositories>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>bintray</name>
<url>http://jcenter.bintray.com</url>
</repository>
</repositories>
```

## <a id="features"></a>Features


Expand All @@ -40,23 +87,15 @@ This is beta code.
* Control which IP/PORT is published for the hazelcast node in Etcd
* Configurable discovery delay
* Automatic Etcd de-registration of instance via ShutdownHook

## <a id="usage"></a>Usage

## <a id="usage"></a>Build & Usage
* Ensure your project has the `hazelcast-etcd-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 Etcd running and available somewhere on your network, start it such as:
```
./etcd
```
* From the root of this project, build a Jar : `./gradlew assemble`

* Include the built jar artifact located at `build/libs/hazelcast-etcd-discovery-spi-1.0.0.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: 'org.mousio', name: 'etcd4j', version:'2.7.0'
compile group: 'com.google.code.gson', name: 'gson', version:'2.4'
```

* Configure your hazelcast.xml configuration file to use the `EtcdDiscoveryStrategy` (similar to the below): [See hazelcast-etcd-discovery-spi-example.xml](src/main/resources/hazelcast-etcd-discovery-spi-example.xml) for a full example with documentation of options.

Expand Down Expand Up @@ -103,17 +142,31 @@ $ ./etcdctl get /hz-discovery-test-cluster/hz-discovery-test-cluster-192.168.0.2
```


## <a id="building"></a>Build from source

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

* Include the built jar artifact located at `build/libs/hazelcast-etcd-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: 'org.mousio', name: 'etcd4j', version:'2.9.0'
compile group: 'com.google.code.gson', name: 'gson', version:'2.4'
```


## <a id="tests"></a>Unit-tests

It may also help you to understand the functionality by checking out and running the unit-tests
located at [src/test/java](src/test/java). Be sure to read the comments as some of the tests require
located at [src/test/java](src/test/java). **BE SURE TO READ** the comments as some of the tests require
you to setup your local Etcd and edit certain files.

## <a id="related"></a>Related info

* https://github.com/coreos/etcd
* https://github.com/jurmous/etcd4j
* http://docs.hazelcast.org/docs/3.6-EA/manual/html-single/index.html#discovery-spi
* http://docs.hazelcast.org/docs/3.6-RC1/manual/html-single/index.html#discovery-spi
* **Consul** version of this: https://github.com/bitsofinfo/hazelcast-consul-discovery-spi

## <a id="notes"></a> Notes
Expand All @@ -125,7 +178,7 @@ that would need to automatically register themselves with Etcd for higher level

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-EA/manual/html-single/index.html#using-variables](http://docs.hazelcast.org/docs/3.6-EA/manual/html-single/index.html#using-variables)
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-RC1/manual/html-single/index.html#using-variables](http://docs.hazelcast.org/docs/3.6-RC1/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](src/main/java/org/bitsofinfo/hazelcast/discovery/etcd/ExplicitIpPortRegistrator.java) `EtcdRegistrator` **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 Etcd.

Expand Down
62 changes: 52 additions & 10 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,24 +1,66 @@
buildscript {
repositories {
jcenter()
}
}

apply plugin: 'java'
plugins {
id "com.jfrog.bintray" version "1.5"
}

group = 'org.bitsofinfo'
version = '1.0.0'

description = """hazelcast-etcd-discovery-spi"""
allprojects {
repositories {
jcenter()
}
apply plugin: 'maven'
apply plugin: 'maven-publish'
apply plugin: 'java'
}

sourceCompatibility = 1.6
targetCompatibility = 1.6

repositories {
jcenter()
}

dependencies {

compile group: 'com.hazelcast', name: 'hazelcast', version:'3.6-EA'
compile group: 'org.mousio', name: 'etcd4j', version:'2.7.0'
compile group: 'com.hazelcast', name: 'hazelcast', version:'3.6-RC1'
compile group: 'org.mousio', name: 'etcd4j', version:'2.9.0'
compile group: 'com.google.code.gson', name: 'gson', version:'2.4'

testCompile 'junit:junit:4.12'

}

bintray {
user = project.hasProperty('bintrayUser') ? project.property('bintrayUser') : System.getenv('bintrayUser')
key = project.hasProperty('bintrayApiKey') ? project.property('bintrayApiKey') : System.getenv('bintrayApiKey')
publications = ['hazelcastEtcdDiscoverySpi']
pkg {
repo = 'maven'
name = 'hazelcast-etcd-discovery-spi'
licenses = ['Apache-2.0']
vcsUrl = 'https://github.com/bitsofinfo/hazelcast-etcd-discovery-spi'
publicDownloadNumbers = true
version {
name = project.property('version')
desc = project.property('version') + " : " + project.property('description')
released = new Date()
vcsTag = project.property('version')
}
}
}

publishing {
publications {
hazelcastEtcdDiscoverySpi(MavenPublication) {
from components.java
groupId project.property('group')
artifactId 'hazelcast-etcd-discovery-spi'
version project.property('version')
}
}
}




2 changes: 2 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
version=1.0-RC1
description=hazelcast-etcd-discovery-spi - Etcd based discovery strategy SPI for Hazelcast enabled applications

0 comments on commit 423d9fe

Please sign in to comment.