3030import io .appulse .epmd .java .core .model .request .GetEpmdDump ;
3131import io .appulse .epmd .java .core .model .request .Kill ;
3232import io .appulse .epmd .java .core .model .request .Registration ;
33+ import io .appulse .epmd .java .core .model .request .Stop ;
3334import io .appulse .epmd .java .core .model .response .EpmdDump ;
3435import io .appulse .epmd .java .core .model .response .KillResult ;
3536import io .appulse .epmd .java .core .model .response .RegistrationResult ;
@@ -84,6 +85,7 @@ public EpmdClient (@NonNull InetAddress address, int port) {
8485 nodesLocatorService = new NodesLocatorService (address , port );
8586 this .address = address ;
8687 this .port = port ;
88+ log .debug ("Instantiated EPMD client to '{}:{}'" , address , port );
8789 }
8890
8991 public int register (String name , int nodePort , NodeType type , Protocol protocol , Version low , Version high ) {
@@ -100,23 +102,23 @@ public int register (String name, int nodePort, NodeType type, Protocol protocol
100102 }
101103
102104 public int register (@ NonNull Registration request ) {
103- log .debug ("Registering: {} " , request .getName ());
105+ log .debug ("Registering: '{}' " , request .getName ());
104106 val connection = getLocalConnection ();
105107
106108 RegistrationResult response ;
107109 try {
108110 response = connection .send (request , RegistrationResult .class );
109111 } catch (Exception ex ) {
110- log .error ("{} wasn't registered successfully" , request .getName ());
112+ log .error ("'{}' wasn't registered successfully" , request .getName ());
111113 throw new EpmdRegistrationException (ex );
112114 }
113115
114116 if (!response .isOk ()) {
115- log .error ("{} wasn't registered successfully" , request .getName ());
117+ log .error ("'{}' wasn't registered successfully" , request .getName ());
116118 throw new EpmdRegistrationException ();
117119 }
118120
119- log .info ("{} was registered successfully" , request .getName ());
121+ log .info ("'{}' was registered successfully" , request .getName ());
120122 return response .getCreation ();
121123 }
122124
@@ -127,6 +129,12 @@ public List<EpmdDump.NodeDump> dumpAll () {
127129 }
128130 }
129131
132+ public void stop (@ NonNull String node ) {
133+ try (val connection = new Connection (address , port )) {
134+ connection .send (new Stop (node ));
135+ }
136+ }
137+
130138 /**
131139 * This request kills the running EPMD server.
132140 *
@@ -194,7 +202,7 @@ private static int getDefaultPort () {
194202 } catch (NumberFormatException | SecurityException ex ) {
195203 throw new RuntimeException (ex );
196204 }
197- log .debug ("Default EPMD port is: {} " , port );
205+ log .debug ("Default EPMD port is: '{}' " , port );
198206 return port ;
199207 }
200208 }
0 commit comments