Skip to content

Commit

Permalink
Minor bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Artem Labazin authored and Artem Labazin committed Feb 19, 2018
1 parent 64276d1 commit b48e94a
Show file tree
Hide file tree
Showing 11 changed files with 53 additions and 16 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

- Add more unit and integration tests.

## [0.4.1](https://github.com/appulse-projects/epmd-java/releases/tag/0.4.1) - 2018-02-16

Minor bug fixes

### Changed

- EPMD address and port are public now.
- Lookup cache doesn't cache not found items any more.

## [0.4.0](https://github.com/appulse-projects/epmd-java/releases/tag/0.4.0) - 2018-02-16

Introducing NIO server.
Expand Down
4 changes: 2 additions & 2 deletions client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Include the dependency to your project's pom.xml file:
<dependency>
<groupId>io.appulse.epmd.java</groupId>
<artifactId>client</artifactId>
<version>0.4.0</version>
<version>0.4.1</version>
</dependency>
...
</dependencies>
Expand All @@ -23,7 +23,7 @@ Include the dependency to your project's pom.xml file:
or Gradle:

```groovy
compile 'io.appulse.epmd.java:client:0.4.0'
compile 'io.appulse.epmd.java:client:0.4.1'
```

### Create client
Expand Down
2 changes: 1 addition & 1 deletion client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ limitations under the License.
<parent>
<groupId>io.appulse</groupId>
<artifactId>epmd-java</artifactId>
<version>0.4.0</version>
<version>0.4.1</version>
</parent>

<groupId>io.appulse.epmd.java</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,11 +175,11 @@ protected void finalize () throws Throwable {
super.finalize();
}

private static class Default {
public static class Default {

private static final InetAddress ADDRESS = getDefaultInetAddress();
public static final InetAddress ADDRESS = getDefaultInetAddress();

private static final int PORT = getDefaultPort();
public static final int PORT = getDefaultPort();

@SneakyThrows
private static InetAddress getDefaultInetAddress () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,17 @@ class LookupService {

COMPUTE = (key, value) -> {
if (value != null) {
log.debug("Used cached value {}", value);
return value;
}

val request = new GetNodeInfo(key.getNode());
try (val connection = new Connection(key.getAddress(), key.getPort())) {
return connection.send(request, NodeInfo.class);
val response = connection.send(request, NodeInfo.class);
log.debug("Lookup result is {}", response);
return response.isOk()
? response
: null;
}
};
}
Expand Down Expand Up @@ -93,7 +98,7 @@ public Optional<NodeInfo> lookup (@NonNull String node, @NonNull InetAddress add
val tokens = node.split("@", 2);
val shortName = tokens[0];

log.debug("Looking up node '{}' at '{}'", shortName, address);
log.debug("Looking up node '{}' at '{}:{}'", shortName, address, port);

val descriptor = new NodeDescriptor(shortName, address, port);
val nodeInfo = CACHE.compute(descriptor, COMPUTE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,30 @@ public void invalidRegistration () {
}
}

@Test
public void lookupAndRegistration () {
assertThat(client.register("node-1", 61_111, R3_ERLANG, TCP, R6, R6))
.isNotEqualTo(0);

val optional1 = client.lookup("node-1");
assertThat(optional1)
.isPresent();
assertThat(optional1.get().isOk())
.isTrue();

assertThat(client.lookup("node-2"))
.isNotPresent();

assertThat(client.register("node-2", 61_011, R3_ERLANG, TCP, R6, R6))
.isNotEqualTo(0);

val optional2 = client.lookup("node-2");
assertThat(optional2)
.isPresent();
assertThat(optional2.get().isOk())
.isTrue();
}

@Test
public void connectionBroken () {
try (EpmdClient client2 = new EpmdClient(8091)) {
Expand Down
2 changes: 1 addition & 1 deletion core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ limitations under the License.
<parent>
<groupId>io.appulse</groupId>
<artifactId>epmd-java</artifactId>
<version>0.4.0</version>
<version>0.4.1</version>
</parent>

<groupId>io.appulse.epmd.java</groupId>
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ limitations under the License.

<groupId>io.appulse</groupId>
<artifactId>epmd-java</artifactId>
<version>0.4.0</version>
<version>0.4.1</version>
<packaging>pom</packaging>

<modules>
Expand Down Expand Up @@ -68,7 +68,7 @@ limitations under the License.
<url>https://github.com/appulse-projects/epmd-java</url>
<connection>scm:git:https://github.com/appulse-projects/epmd-java.git</connection>
<developerConnection>scm:git:https://github.com/appulse-projects/epmd-java.git</developerConnection>
<tag>0.4.0</tag>
<tag>0.4.1</tag>
</scm>

<distributionManagement>
Expand Down
4 changes: 2 additions & 2 deletions server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Include the dependency to your project's pom.xml file:
<dependency>
<groupId>io.appulse.epmd.java</groupId>
<artifactId>server</artifactId>
<version>0.4.0</version>
<version>0.4.1</version>
</dependency>
...
</dependencies>
Expand All @@ -27,5 +27,5 @@ Include the dependency to your project's pom.xml file:
or Gradle:

```groovy
compile 'io.appulse.epmd.java:server:0.4.0'
compile 'io.appulse.epmd.java:server:0.4.1'
```
2 changes: 1 addition & 1 deletion server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ limitations under the License.
<parent>
<groupId>io.appulse</groupId>
<artifactId>epmd-java</artifactId>
<version>0.4.0</version>
<version>0.4.1</version>
</parent>

<groupId>io.appulse.epmd.java</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,7 @@ public void initChannel (SocketChannel channel) throws Exception {
} catch (InterruptedException ex) {
log.error("Server work exception", ex);
} finally {
workerGroup.shutdownGracefully();
bossGroup.shutdownGracefully();
close();
}
}

Expand Down

0 comments on commit b48e94a

Please sign in to comment.