Skip to content

Commit 8e0d16b

Browse files
committed
Add readme and JavaDocs
1 parent eee806e commit 8e0d16b

File tree

82 files changed

+1088
-191
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+1088
-191
lines changed

.codestyle/checkstyle.xml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ limitations under the License.
7171

7272
<!-- Checks for Javadoc comments. -->
7373
<!-- See http://checkstyle.sf.net/config_javadoc.html -->
74-
<!-- <module name="JavadocMethod">
74+
<module name="JavadocMethod">
7575
<property name="scope" value="protected"/>
7676
<property name="allowedAnnotations" value="Override, Test"/>
7777
<property name="allowThrowsTagsForSubclasses" value="true"/>
@@ -90,15 +90,14 @@ limitations under the License.
9090
<module name="SummaryJavadoc">
9191
<property name="forbiddenSummaryFragments" value="^@return the *|^This method returns |^A [{]@code [a-zA-Z0-9]+[}]( is a )"/>
9292
</module>
93-
<module name="JavadocParagraph"/>
9493
<module name="SingleLineJavadoc">
9594
<property name="ignoreInlineTags" value="false"/>
9695
</module>
9796
<module name="AtclauseOrder">
9897
<property name="tagOrder" value="@param, @return, @throws, @see, @since, @author, @version, @deprecated"/>
9998
<property name="target" value="CLASS_DEF, INTERFACE_DEF, ENUM_DEF, METHOD_DEF, CTOR_DEF, VARIABLE_DEF"/>
10099
</module>
101-
<module name="NonEmptyAtclauseDescription"/> -->
100+
<module name="NonEmptyAtclauseDescription"/>
102101

103102

104103
<!-- Checks for Naming Conventions. -->

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,15 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
1111

1212
- Add more unit and integration tests.
1313

14+
## [1.0.2](https://github.com/appulse-projects/epmd-java/releases/tag/1.0.2) - 2018-06-06
15+
16+
Code refactoring.
17+
18+
### Added
19+
20+
- JavaDoc comments.
21+
- `README.md` content.
22+
1423
## [1.0.1](https://github.com/appulse-projects/epmd-java/releases/tag/1.0.1) - 2018-03-23
1524

1625
Small refactoring.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
[![build_status](https://travis-ci.org/appulse-projects/epmd-java.svg?branch=master)](https://travis-ci.org/appulse-projects/epmd-java)
44
[![maven_central](https://maven-badges.herokuapp.com/maven-central/io.appulse/epmd-java/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.appulse/epmd-java)
55

6-
This is the set of projects, which implementing EPMD server and client.
6+
This is the set of projects, which implementing EPMD server and its client.
77

88
- [Core description](./core/README.md)
99
- [Client description](./client/README.md)

client/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Include the dependency to your project's pom.xml file:
1414
<dependency>
1515
<groupId>io.appulse.epmd.java</groupId>
1616
<artifactId>client</artifactId>
17-
<version>1.0.1</version>
17+
<version>1.0.2</version>
1818
</dependency>
1919
...
2020
</dependencies>
@@ -23,7 +23,7 @@ Include the dependency to your project's pom.xml file:
2323
or Gradle:
2424

2525
```groovy
26-
compile 'io.appulse.epmd.java:client:1.0.1'
26+
compile 'io.appulse.epmd.java:client:1.0.2'
2727
```
2828

2929
### Create client

client/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ limitations under the License.
2525
<parent>
2626
<groupId>io.appulse</groupId>
2727
<artifactId>epmd-java</artifactId>
28-
<version>1.0.1</version>
28+
<version>1.0.2</version>
2929
</parent>
3030

3131
<groupId>io.appulse.epmd.java</groupId>
@@ -43,7 +43,7 @@ limitations under the License.
4343
<dependency>
4444
<groupId>org.testcontainers</groupId>
4545
<artifactId>testcontainers</artifactId>
46-
<version>1.6.0</version>
46+
<version>1.7.3</version>
4747
<scope>test</scope>
4848
</dependency>
4949
</dependencies>

client/src/main/java/io/appulse/epmd/java/client/Connection.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,10 @@
3939
import lombok.val;
4040

4141
/**
42+
* EPMD connection.
4243
*
43-
* @author Artem Labazin
4444
* @since 0.2.2
45+
* @author Artem Labazin
4546
*/
4647
@Slf4j
4748
@RequiredArgsConstructor
@@ -70,7 +71,7 @@ class Connection implements Closeable {
7071

7172
Socket socket = new Socket();
7273

73-
public void send (@NonNull Object request) throws EpmdConnectionException {
74+
void send (@NonNull Object request) throws EpmdConnectionException {
7475
log.debug("Sending: {}", request);
7576

7677
val bytes = SERIALIZER.serialize(request);
@@ -87,7 +88,7 @@ public void send (@NonNull Object request) throws EpmdConnectionException {
8788
log.debug("Message {} was sent", request);
8889
}
8990

90-
public <T> T send (@NonNull Object request, @NonNull Class<T> responseType) throws EpmdConnectionException {
91+
<T> T send (@NonNull Object request, @NonNull Class<T> responseType) throws EpmdConnectionException {
9192
send(request);
9293

9394
byte[] messageBytes;
@@ -120,11 +121,11 @@ public void close () {
120121
socket.getLocalPort(), socket.getRemoteSocketAddress());
121122
}
122123

123-
public boolean isClosed () {
124+
boolean isClosed () {
124125
return socket.isClosed();
125126
}
126127

127-
public boolean isConnected () {
128+
boolean isConnected () {
128129
return socket.isConnected();
129130
}
130131

client/src/main/java/io/appulse/epmd/java/client/EpmdClient.java

Lines changed: 70 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@
4848
/**
4949
* EPMD client.
5050
*
51-
* @author Artem Labazin
5251
* @since 0.2.2
52+
* @author Artem Labazin
5353
*/
5454
@Slf4j
5555
@FieldDefaults(level = PRIVATE, makeFinal = true)
@@ -67,18 +67,44 @@ public final class EpmdClient implements Closeable {
6767

6868
Integer port;
6969

70+
/**
71+
* Default no arguments constructor.
72+
* <p>
73+
* It uses default inet address (localhost) and port (4369).
74+
*/
7075
public EpmdClient () {
7176
this(Default.ADDRESS, Default.PORT);
7277
}
7378

79+
/**
80+
* Constructs EPMD client with the specified {@link InetAddress}.
81+
* <p>
82+
* It uses default port (4369).
83+
*
84+
* @param address EPMD server address
85+
*/
7486
public EpmdClient (InetAddress address) {
7587
this(address, Default.PORT);
7688
}
7789

90+
/**
91+
* Constructs EPMD client with the specified port.
92+
* <p>
93+
* It uses default inet address (localhost).
94+
*
95+
* @param port EPMD server port
96+
*/
7897
public EpmdClient (int port) {
7998
this(Default.ADDRESS, port);
8099
}
81100

101+
/**
102+
* Constructs EPMD client with the specified address and port.
103+
*
104+
* @param address EPMD server address
105+
*
106+
* @param port EPMD server port
107+
*/
82108
@Builder
83109
public EpmdClient (@NonNull InetAddress address, int port) {
84110
lookupService = new LookupService(address, port);
@@ -88,6 +114,23 @@ public EpmdClient (@NonNull InetAddress address, int port) {
88114
log.debug("Instantiated EPMD client to '{}:{}'", address, port);
89115
}
90116

117+
/**
118+
* Registers node at EPMD server.
119+
*
120+
* @param name node name
121+
*
122+
* @param nodePort node port
123+
*
124+
* @param type node type
125+
*
126+
* @param protocol node protocol
127+
*
128+
* @param low lowest supported distribution protocol version
129+
*
130+
* @param high highest supported distribution protocol version
131+
*
132+
* @return creation id from EPMD
133+
*/
91134
public int register (String name, int nodePort, NodeType type, Protocol protocol, Version low, Version high) {
92135
val request = Registration.builder()
93136
.name(name)
@@ -101,6 +144,13 @@ public int register (String name, int nodePort, NodeType type, Protocol protocol
101144
return register(request);
102145
}
103146

147+
/**
148+
* Registers node at EPMD server.
149+
*
150+
* @param request registration holder
151+
*
152+
* @return creation id from EPMD
153+
*/
104154
public int register (@NonNull Registration request) {
105155
if (cache.containsKey(request.getName()) && cache.get(request.getName()).isConnected()) {
106156
log.error("Node with name '{}' already exists");
@@ -129,13 +179,23 @@ public int register (@NonNull Registration request) {
129179
return response.getCreation();
130180
}
131181

182+
/**
183+
* Returns nodes infos from EPMD.
184+
*
185+
* @return list of nodes from EPMD
186+
*/
132187
public List<EpmdDump.NodeDump> dumpAll () {
133188
try (val connection = new Connection(address, port)) {
134189
val dump = connection.send(new GetEpmdDump(), EpmdDump.class);
135190
return dump.getNodes();
136191
}
137192
}
138193

194+
/**
195+
* Stops a node by name.
196+
*
197+
* @param node node's name
198+
*/
139199
public void stop (@NonNull String node) {
140200
try (val connection = new Connection(address, port)) {
141201
connection.send(new Stop(node));
@@ -171,10 +231,19 @@ protected void finalize () throws Throwable {
171231
super.finalize();
172232
}
173233

234+
/**
235+
* EPMD client defaults.
236+
*/
174237
public static class Default {
175238

239+
/**
240+
* Default EPMD client address (localhost).
241+
*/
176242
public static final InetAddress ADDRESS = getDefaultInetAddress();
177243

244+
/**
245+
* Default EPMD client port (4369).
246+
*/
178247
public static final int PORT = getDefaultPort();
179248

180249
@SneakyThrows

client/src/main/java/io/appulse/epmd/java/client/LookupService.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,10 @@
3333
import lombok.val;
3434

3535
/**
36+
* Service for searching {@link NodeInfo} by node name.
3637
*
37-
* @author Artem Labazin
3838
* @since 0.2.2
39+
* @author Artem Labazin
3940
*/
4041
@Slf4j
4142
@RequiredArgsConstructor

client/src/main/java/io/appulse/epmd/java/client/NodesLocatorService.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,10 @@
3232
import lombok.val;
3333

3434
/**
35+
* Service for retrieving node descriptions at EPMD server.
3536
*
36-
* @author Artem Labazin
3737
* @since 0.2.2
38+
* @author Artem Labazin
3839
*/
3940
@Slf4j
4041
@RequiredArgsConstructor

client/src/main/java/io/appulse/epmd/java/client/exception/EpmdConnectionException.java

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,61 @@
1717
package io.appulse.epmd.java.client.exception;
1818

1919
/**
20+
* Error during EPMD connection.
2021
*
21-
* @author Artem Labazin
2222
* @since 0.2.2
23+
* @author Artem Labazin
2324
*/
2425
public class EpmdConnectionException extends RuntimeException {
2526

2627
private static final long serialVersionUID = -1017832971745823012L;
2728

29+
/**
30+
* Constructs a new runtime exception with null as its detail message.
31+
* <p>
32+
* The cause is not initialized, and may subsequently be initialized
33+
* by a call to Throwable.initCause(java.lang.Throwable).
34+
*/
35+
public EpmdConnectionException () {
36+
super();
37+
}
38+
39+
/**
40+
* Constructs a new runtime exception with null as its detail message.
41+
* <p>
42+
* The cause is not initialized, and may subsequently be initialized
43+
* by a call to Throwable.initCause(java.lang.Throwable).
44+
*
45+
* @param message the detail message.
46+
*/
2847
public EpmdConnectionException (String message) {
2948
super(message);
3049
}
3150

51+
/**
52+
* Constructs a new runtime exception with the specified detail message.
53+
* <p>
54+
* The cause is not initialized, and may subsequently be initialized
55+
* by a call to Throwable.initCause(java.lang.Throwable).
56+
*
57+
* @param message the detail message.
58+
*
59+
* @param cause the cause (which is saved for later retrieval by the Throwable.getCause() method).
60+
* (A null value is permitted, and indicates that the cause is nonexistent or unknown.)
61+
*/
3262
public EpmdConnectionException (String message, Throwable cause) {
3363
super(message, cause);
3464
}
3565

66+
/**
67+
* Constructs a new runtime exception with the specified cause and a detail message
68+
* of (cause==null ? null : cause.toString()) (which typically contains the class and detail message of cause).
69+
* <p>
70+
* This constructor is useful for runtime exceptions that are little more than wrappers for other throwables.
71+
*
72+
* @param cause the cause (which is saved for later retrieval by the Throwable.getCause() method).
73+
* (A null value is permitted, and indicates that the cause is nonexistent or unknown.)
74+
*/
3675
public EpmdConnectionException (Throwable cause) {
3776
super(cause);
3877
}

0 commit comments

Comments
 (0)