Skip to content

Commit

Permalink
Normalize thread names (#17804)
Browse files Browse the repository at this point in the history
Signed-off-by: Leo Siepel <[email protected]>
  • Loading branch information
lsiepel authored Dec 8, 2024
1 parent 5829b90 commit fb54c2b
Show file tree
Hide file tree
Showing 30 changed files with 73 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -579,15 +579,17 @@ public void connect() {
logger.trace("{} - Starting Reader Thread for {}:{}", handler.getThingID(), config.ipAddress,
config.googletvPort);

Thread readerThread = new Thread(this::readerThreadJob, "GoogleTV reader " + handler.getThingID());
Thread readerThread = new Thread(this::readerThreadJob,
"OH-binding-" + handler.getThingUID() + "-GoogleTVReader");
readerThread.setDaemon(true);
readerThread.start();
this.readerThread = readerThread;

logger.trace("{} - Starting Sender Thread for {}:{}", handler.getThingID(), config.ipAddress,
config.googletvPort);

Thread senderThread = new Thread(this::senderThreadJob, "GoogleTV sender " + handler.getThingID());
Thread senderThread = new Thread(this::senderThreadJob,
"OH-binding-" + handler.getThingUID() + "-GoogleTVSender");
senderThread.setDaemon(true);
senderThread.start();
this.senderThread = senderThread;
Expand Down Expand Up @@ -698,12 +700,14 @@ public void shimInitialize() {
this.shimServerSocket = serverSocket;
this.shimQueue.clear();

Thread readerThread = new Thread(this::shimReaderThreadJob, "GoogleTV shim reader");
Thread readerThread = new Thread(this::shimReaderThreadJob,
"OH-binding-" + handler.getThingUID() + "-GoogleTVShimReader");
readerThread.setDaemon(true);
readerThread.start();
this.shimReaderThread = readerThread;

Thread senderThread = new Thread(this::shimSenderThreadJob, "GoogleTV shim sender");
Thread senderThread = new Thread(this::shimSenderThreadJob,
"OH-binding-" + handler.getThingUID() + "-GoogleTVShimSender");
senderThread.setDaemon(true);
senderThread.start();
this.shimSenderThread = senderThread;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -443,12 +443,14 @@ public void connect() {

setStatus(false, "offline.initializing");

Thread readerThread = new Thread(this::readerThreadJob, "ShieldTV reader " + handler.getThingID());
Thread readerThread = new Thread(this::readerThreadJob,
"OH-binding-" + handler.getThingUID() + "-ShieldTVReader");
readerThread.setDaemon(true);
readerThread.start();
this.readerThread = readerThread;

Thread senderThread = new Thread(this::senderThreadJob, "ShieldTV sender " + handler.getThingID());
Thread senderThread = new Thread(this::senderThreadJob,
"OH-binding-" + handler.getThingUID() + "-ShieldTVSender");
senderThread.setDaemon(true);
senderThread.start();
this.senderThread = senderThread;
Expand Down Expand Up @@ -513,13 +515,13 @@ public void shimInitialize() {
this.shimServerSocket = serverSocket;

Thread readerThread = new Thread(this::shimReaderThreadJob,
"ShieldTV shim reader " + handler.getThingID());
"OH-binding-" + handler.getThingUID() + "-ShieldTVShimReader");
readerThread.setDaemon(true);
readerThread.start();
this.shimReaderThread = readerThread;

Thread senderThread = new Thread(this::shimSenderThreadJob,
"ShieldTV shim sender" + handler.getThingID());
"OH-binding-" + handler.getThingUID() + "-ShieldTVShimSender");
senderThread.setDaemon(true);
senderThread.start();
this.shimSenderThread = senderThread;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,12 +242,12 @@ private synchronized void connect() {
scheduleConnectRetry(reconnectIntervalMinutes);
return;
}
Thread localReaderThread = new Thread(this::readerThreadJob, "Anthem reader");
Thread localReaderThread = new Thread(this::readerThreadJob, "OH-binding-" + getThing().getUID() + "-Reader");
localReaderThread.setDaemon(true);
localReaderThread.start();
this.readerThread = localReaderThread;

Thread localSenderThread = new Thread(this::senderThreadJob, "Anthem sender");
Thread localSenderThread = new Thread(this::senderThreadJob, "OH-binding-" + getThing().getUID() + "-Sender");
localSenderThread.setDaemon(true);
localSenderThread.start();
this.senderThread = localSenderThread;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ public synchronized void start() throws ArgoRemoteServerStubStartupException {
// to stop, actually)
s.setStopTimeout(1000L);
try {
new Thread() {
new Thread("OH-binding-" + this.id + "-APIStub") {
@Override
public void run() {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ public class EchonetLiteBridgeHandler extends BaseBridgeHandler {
private final ArrayBlockingQueue<Message> requests = new ArrayBlockingQueue<>(1024);
private final Map<InstanceKey, EchonetObject> devicesByKey = new HashMap<>();
private final EchonetMessageBuilder messageBuilder = new EchonetMessageBuilder();
private final Thread networkingThread = new Thread(this::poll);
private final Thread networkingThread = new Thread(this::poll,
"OH-binding-" + EchonetLiteBindingConstants.BINDING_ID);
private final EchonetMessage echonetMessage = new EchonetMessage();
private final MonotonicClock clock = new MonotonicClock();

Expand All @@ -76,8 +77,6 @@ private void start(final InstanceKey managementControllerKey, InstanceKey discov
logger.debug("Binding echonet channel");
echonetChannel = new EchonetChannel(discoveryKey.address);
logger.debug("Starting networking thread");

networkingThread.setName("OH-binding-" + EchonetLiteBindingConstants.BINDING_ID);
networkingThread.setDaemon(true);
networkingThread.start();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,10 @@ public void initialize() {

scheduler.submit(() -> {
populateChannels(config.protocol);
String readerThreadName = "OH-binding-" + getThing().getUID().getAsString();

EkeyUdpPacketReceiver localReceiver = receiver = new EkeyUdpPacketReceiver(
Objects.requireNonNullElse(config.natIp, config.ipAddress), config.port, readerThreadName);
Objects.requireNonNullElse(config.natIp, config.ipAddress), config.port,
"OH-binding-" + getThing().getUID());
localReceiver.addEkeyPacketListener(this);
try {
localReceiver.openConnection();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,8 @@ public void onFailure(@Nullable Session session, @Nullable Throwable failure) {
public void onGoAway(@Nullable Session session, @Nullable GoAwayFrame frame) {
Objects.requireNonNull(session);
if (session.equals(http2Session)) {
Thread recreateThread = new Thread(() -> recreateSession());
Thread recreateThread = new Thread(() -> recreateSession(),
"OH-binding-" + bridgeHandler.getThing().getUID() + "-RecreateSession");
Clip2Bridge.this.recreateThread = recreateThread;
recreateThread.start();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.insteon.internal.InsteonBindingConstants;
import org.openhab.binding.insteon.internal.InsteonLegacyBindingConstants;
import org.openhab.binding.insteon.internal.config.InsteonLegacyNetworkConfiguration;
import org.openhab.binding.insteon.internal.device.InsteonAddress;
Expand Down Expand Up @@ -178,9 +179,9 @@ public void start() {
}

readThread = new Thread(reader);
setParamsAndStart(readThread, "Reader");
setParamsAndStart(readThread, "OH-binding-" + InsteonBindingConstants.BINDING_ID + "-LegacyReader");
writeThread = new Thread(writer);
setParamsAndStart(writeThread, "Writer");
setParamsAndStart(writeThread, "OH-binding-" + InsteonBindingConstants.BINDING_ID + "-LegacyWriter");

if (!mdbb.isComplete()) {
modem.initialize();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,8 @@ public void initialize() {
if (!config.ipAddress.isEmpty()) {
updateStatus(ThingStatus.UNKNOWN);
scheduler.submit(() -> {

String readerThreadName = "OH-binding-" + getThing().getUID().getAsString();

IntesisBoxSocketApi intesisLocalApi = intesisBoxSocketApi = new IntesisBoxSocketApi(config.ipAddress,
config.port, readerThreadName);
config.port, "OH-binding-" + getThing().getUID());
intesisLocalApi.addIntesisBoxChangeListener(this);
try {
intesisLocalApi.openConnection();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import java.util.Set;
import java.util.concurrent.locks.ReentrantLock;

import org.openhab.binding.keba.internal.KebaBindingConstants;
import org.openhab.core.thing.ThingStatus;
import org.openhab.core.thing.ThingStatusDetail;
import org.slf4j.Logger;
Expand Down Expand Up @@ -71,7 +72,8 @@ public void start() {
selector = Selector.open();

if (transceiverThread == null) {
transceiverThread = new Thread(transceiverRunnable, "OH-binding-Keba-Transceiver");
transceiverThread = new Thread(transceiverRunnable,
"OH-binding-" + KebaBindingConstants.BINDING_ID + "-Transceiver");
transceiverThread.start();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public void authenticate(BiConsumer<LxErrorCode, String> doneCallback) {
authenticationLock.unlock();
}
};
new Thread(init).start();
new Thread(init, "OH-binding-" + thingHandler.getThingId() + "-Authenticate").start();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ private synchronized void connect() {
sendCommand(new LIPCommand(TargetType.BRIDGE, LutronOperation.QUERY, LutronCommandType.SYSTEM, null,
SYSTEM_DBEXPORTDATETIME));

messageSender = new Thread(this::sendCommandsThread, "Lutron sender");
messageSender = new Thread(this::sendCommandsThread, "OH-binding-" + getThing().getUID() + "-IPBridgeSender");
messageSender.start();

logger.debug("Starting keepAlive job with interval {}", heartbeatInterval);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -304,12 +304,12 @@ private synchronized void connect() {

updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.NONE, STATUS_INITIALIZING);

Thread readerThread = new Thread(this::readerThreadJob, "Lutron reader");
Thread readerThread = new Thread(this::readerThreadJob, "OH-binding-" + getThing().getUID() + "-BridgeReader");
readerThread.setDaemon(true);
readerThread.start();
this.readerThread = readerThread;

Thread senderThread = new Thread(this::senderThreadJob, "Lutron sender");
Thread senderThread = new Thread(this::senderThreadJob, "OH-binding-" + getThing().getUID() + "-BridgeSender");
senderThread.setDaemon(true);
senderThread.start();
this.senderThread = senderThread;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public void startProcessing() {

updateStatus(ThingStatus.ONLINE);

messageSender = new Thread(this::sendCommandsThread, "Luxom sender");
messageSender = new Thread(this::sendCommandsThread, "OH-binding-" + getThing().getUID() + "-Sender");
messageSender.start();

logger.debug("Starting heartbeat job with interval {} (seconds)", HEARTBEAT_INTERVAL_SECONDS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,8 @@ private synchronized void startAutomaticRefresh() {
pollingJob = scheduler.scheduleWithFixedDelay(this::refreshData, 0, refreshInterval, TimeUnit.SECONDS);
}
if (queueConsumerThread == null || !queueConsumerThread.isAlive()) {
queueConsumerThread = new Thread(new QueueConsumer(commandQueue), "max-queue-consumer");
queueConsumerThread = new Thread(new QueueConsumer(commandQueue),
"OH-binding-" + getThing().getUID() + "-max-queue-consumer");
queueConsumerThread.setDaemon(true);
queueConsumerThread.start();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
*/
package org.openhab.binding.mihome.internal.socket;

import static org.openhab.binding.mihome.internal.XiaomiGatewayBindingConstants.BINDING_ID;

import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
Expand Down Expand Up @@ -71,7 +73,7 @@ public XiaomiSocket(String owner) {
*/
public XiaomiSocket(int port, String owner) {
this.port = port;
socketReceiveThread.setName("XiaomiSocketReceiveThread(" + port + ", " + owner + ")");
socketReceiveThread.setName("OH-binding-" + BINDING_ID + "-XiaomiSocket(" + port + ", " + owner + ")");
}

public void initialize() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.milight.internal.MilightBindingConstants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -185,7 +186,7 @@ public MilightV6SessionManager(String bridgeId, ISessionState observer, @Nullabl
throw new IllegalArgumentException("keepAliveInterval not within given limits!");
}

sessionThread = new Thread(this, "SessionThread");
sessionThread = new Thread(this, "OH-binding-" + MilightBindingConstants.BINDING_ID + "-SessionThread");
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.milight.internal.MilightBindingConstants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -48,7 +49,7 @@ public class QueuedSend implements Runnable, Closeable {
*/
public void start() {
willbeclosed = false;
thread = new Thread(this);
thread = new Thread(this, "OH-binding-" + MilightBindingConstants.BINDING_ID + "-QueuedSend");
thread.start();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ public class EmulatedV6Bridge {
FAKE_MAC[2], FAKE_MAC[3], FAKE_MAC[4], FAKE_MAC[5], 1 };

EmulatedV6Bridge() {
new Thread(this::runDiscovery).start();
new Thread(this::runBrigde).start();
new Thread(this::runDiscovery, "OH-binding-" + MilightBindingConstants.BINDING_ID + "-runDiscovery").start();
new Thread(this::runBridge, "OH-binding-" + MilightBindingConstants.BINDING_ID + "-runBridge").start();
}

private void replaceWithMac(byte[] data, int offset) {
Expand Down Expand Up @@ -144,7 +144,7 @@ public void runDiscovery() {
}
}

public void runBrigde() {
public void runBridge() {
try {
byte[] a = new byte[0];
DatagramPacket sPacket = new DatagramPacket(a, a.length);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ private void baseConnect() {
return;
}

Thread parserThread = new Thread(parser, "OH-pentair-" + this.getThing().getUID() + "-parser");
Thread parserThread = new Thread(parser, "OH-binding-" + this.getThing().getUID() + "-parser");
this.parserThread = parserThread;

parserThread.setDaemon(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;

import org.openhab.binding.russound.internal.RussoundBindingConstants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -127,8 +128,10 @@ public void connect(int timeout) throws IOException {

responses.clear();

dispatchingThread = new Thread(new Dispatcher());
responseThread = new Thread(new ResponseReader());
dispatchingThread = new Thread(new Dispatcher(),
"OH-binding-" + RussoundBindingConstants.BINDING_ID + "-dispatcher");
responseThread = new Thread(new ResponseReader(),
"OH-binding-" + RussoundBindingConstants.BINDING_ID + "-responseReader");

dispatchingThread.start();
responseThread.start();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.satel.internal.SatelBindingConstants;
import org.openhab.binding.satel.internal.command.IntegraVersionCommand;
import org.openhab.binding.satel.internal.command.SatelCommand;
import org.openhab.binding.satel.internal.command.SatelCommand.State;
Expand Down Expand Up @@ -520,7 +521,7 @@ public void run() {
SatelModule.this.communicationLoop(CommunicationWatchdog.this);
logger.debug("Communication thread stopped");
}
});
}, "OH-binding-" + SatelBindingConstants.BINDING_ID + "-dispatcher");
thread.start();
this.thread = thread;
// if module is not initialized yet, send version command
Expand Down
Loading

0 comments on commit fb54c2b

Please sign in to comment.