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
0 commit comments