Normalized thread names (#9581)

Related to #8216

Signed-off-by: Hilbrand Bouwkamp <hilbrand@h72.nl>
This commit is contained in:
Hilbrand Bouwkamp
2021-01-12 22:10:01 +01:00
committed by GitHub
parent 79dfb43e42
commit ac3f907b36
22 changed files with 75 additions and 43 deletions

View File

@@ -39,6 +39,10 @@ import org.slf4j.LoggerFactory;
public class SocketChannelSession implements SocketSession {
private final Logger logger = LoggerFactory.getLogger(SocketChannelSession.class);
/**
* The uid of the calling thing
*/
private final String uid;
/**
* The host/ip address to connect to
*/
@@ -77,10 +81,11 @@ public class SocketChannelSession implements SocketSession {
/**
* Creates the socket session from the given host and port
*
* @param uid the thing uid of the calling thing
* @param host a non-null, non-empty host/ip address
* @param port the port number between 1 and 65535
*/
public SocketChannelSession(String host, int port) {
public SocketChannelSession(String uid, String host, int port) {
if (host == null || host.trim().length() == 0) {
throw new IllegalArgumentException("Host cannot be null or empty");
}
@@ -88,6 +93,7 @@ public class SocketChannelSession implements SocketSession {
if (port < 1 || port > 65535) {
throw new IllegalArgumentException("Port must be between 1 and 65535");
}
this.uid = uid;
this.host = host;
this.port = port;
}
@@ -129,8 +135,12 @@ public class SocketChannelSession implements SocketSession {
}
socketChannel.set(channel);
new Thread(dispatcher).start();
new Thread(responseReader).start();
Thread dispatcherThread = new Thread(dispatcher, "OH-binding-" + uid + "-dispatcher");
dispatcherThread.setDaemon(true);
dispatcherThread.start();
Thread responseReaderThread = new Thread(responseReader, "OH-binding-" + uid + "-responseReader");
responseReaderThread.setDaemon(true);
responseReaderThread.start();
}
@Override

View File

@@ -449,7 +449,7 @@ public class AtlonaPro3Handler extends AtlonaHandler<AtlonaPro3Capabilities> {
return;
}
session = new SocketChannelSession(config.getIpAddress(), 23);
session = new SocketChannelSession(getThing().getUID().getAsString(), config.getIpAddress(), 23);
atlonaHandler = new AtlonaPro3PortocolHandler(session, config, getCapabilities(),
new StatefulHandlerCallback(new AtlonaHandlerCallback() {
@Override