better logging requires better thread names
This commit is contained in:
parent
5d91702272
commit
52caab3989
|
@ -11,6 +11,8 @@ import java.util.function.Consumer;
|
||||||
* Andrey Belomutskiy, (c) 2013-2020
|
* Andrey Belomutskiy, (c) 2013-2020
|
||||||
*/
|
*/
|
||||||
public class SimulatorExecHelper {
|
public class SimulatorExecHelper {
|
||||||
|
private final static NamedThreadFactory THREAD_FACTORY = new NamedThreadFactory("SimulatorExecHelper", true);
|
||||||
|
|
||||||
// see also SimulatorHelper
|
// see also SimulatorHelper
|
||||||
private static final String SIMULATOR_BINARY = "../simulator/build/rusefi_simulator.exe";
|
private static final String SIMULATOR_BINARY = "../simulator/build/rusefi_simulator.exe";
|
||||||
static Process simulatorProcess;
|
static Process simulatorProcess;
|
||||||
|
@ -42,8 +44,7 @@ public class SimulatorExecHelper {
|
||||||
public static void dumpProcessOutput(Process process) throws IOException {
|
public static void dumpProcessOutput(Process process) throws IOException {
|
||||||
BufferedReader input =
|
BufferedReader input =
|
||||||
new BufferedReader(new InputStreamReader(process.getInputStream()));
|
new BufferedReader(new InputStreamReader(process.getInputStream()));
|
||||||
Thread thread = new Thread(createErrorStreamEcho(process));
|
Thread thread = THREAD_FACTORY.newThread(createErrorStreamEcho(process));
|
||||||
thread.setDaemon(true);
|
|
||||||
thread.start();
|
thread.start();
|
||||||
|
|
||||||
String prefix = "from console: ";
|
String prefix = "from console: ";
|
||||||
|
|
|
@ -6,6 +6,7 @@ import com.opensr5.Logger;
|
||||||
import com.opensr5.io.ConfigurationImageFile;
|
import com.opensr5.io.ConfigurationImageFile;
|
||||||
import com.opensr5.io.DataListener;
|
import com.opensr5.io.DataListener;
|
||||||
import com.rusefi.ConfigurationImageDiff;
|
import com.rusefi.ConfigurationImageDiff;
|
||||||
|
import com.rusefi.NamedThreadFactory;
|
||||||
import com.rusefi.Timeouts;
|
import com.rusefi.Timeouts;
|
||||||
import com.rusefi.composite.CompositeEvent;
|
import com.rusefi.composite.CompositeEvent;
|
||||||
import com.rusefi.composite.CompositeParser;
|
import com.rusefi.composite.CompositeParser;
|
||||||
|
@ -32,25 +33,23 @@ import java.nio.ByteOrder;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.*;
|
||||||
import java.util.concurrent.Future;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
import java.util.concurrent.TimeoutException;
|
|
||||||
|
|
||||||
import static com.devexperts.logging.Logging.getLogging;
|
import static com.devexperts.logging.Logging.getLogging;
|
||||||
import static com.rusefi.binaryprotocol.IoHelper.*;
|
import static com.rusefi.binaryprotocol.IoHelper.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This object represents logical state of physical connection.
|
* This object represents logical state of physical connection.
|
||||||
*
|
* <p>
|
||||||
* Instance is connected until we experience issues. Once we decide to close the connection there is no restart -
|
* Instance is connected until we experience issues. Once we decide to close the connection there is no restart -
|
||||||
* new instance of this class would need to be created once we establish a new physical connection.
|
* new instance of this class would need to be created once we establish a new physical connection.
|
||||||
*
|
* <p>
|
||||||
* Andrey Belomutskiy, (c) 2013-2020
|
* Andrey Belomutskiy, (c) 2013-2020
|
||||||
* 3/6/2015
|
* 3/6/2015
|
||||||
*/
|
*/
|
||||||
public class BinaryProtocol implements BinaryProtocolCommands {
|
public class BinaryProtocol implements BinaryProtocolCommands {
|
||||||
private static final Logging log = getLogging(BinaryProtocol.class);
|
private static final Logging log = getLogging(BinaryProtocol.class);
|
||||||
|
private static final ThreadFactory THREAD_FACTORY = new NamedThreadFactory("text pull");
|
||||||
|
|
||||||
private static final String USE_PLAIN_PROTOCOL_PROPERTY = "protocol.plain";
|
private static final String USE_PLAIN_PROTOCOL_PROPERTY = "protocol.plain";
|
||||||
private static final String CONFIGURATION_RUSEFI_BINARY = "current_configuration.rusefi_binary";
|
private static final String CONFIGURATION_RUSEFI_BINARY = "current_configuration.rusefi_binary";
|
||||||
|
@ -101,7 +100,7 @@ public class BinaryProtocol implements BinaryProtocolCommands {
|
||||||
case Fields.TS_OUTPUT_COMMAND:
|
case Fields.TS_OUTPUT_COMMAND:
|
||||||
return "TS_OUTPUT_COMMAND";
|
return "TS_OUTPUT_COMMAND";
|
||||||
default:
|
default:
|
||||||
return "command " + (char) + command + "/" + command;
|
return "command " + (char) +command + "/" + command;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -228,7 +227,7 @@ public class BinaryProtocol implements BinaryProtocolCommands {
|
||||||
|
|
||||||
private void startTextPullThread(final DataListener listener) {
|
private void startTextPullThread(final DataListener listener) {
|
||||||
if (!linkManager.COMMUNICATION_QUEUE.isEmpty()) {
|
if (!linkManager.COMMUNICATION_QUEUE.isEmpty()) {
|
||||||
System.out.println("Current queue: " + linkManager.COMMUNICATION_QUEUE.size());
|
log.info("Current queue: " + linkManager.COMMUNICATION_QUEUE.size());
|
||||||
}
|
}
|
||||||
Runnable textPull = new Runnable() {
|
Runnable textPull = new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -254,8 +253,7 @@ public class BinaryProtocol implements BinaryProtocolCommands {
|
||||||
log.info("Stopping text pull");
|
log.info("Stopping text pull");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
Thread tr = new Thread(textPull);
|
Thread tr = THREAD_FACTORY.newThread(textPull);
|
||||||
tr.setName("text pull");
|
|
||||||
tr.start();
|
tr.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -396,7 +394,7 @@ public class BinaryProtocol implements BinaryProtocolCommands {
|
||||||
|
|
||||||
if (localCached != null) {
|
if (localCached != null) {
|
||||||
int crcOfLocallyCachedConfiguration = IoHelper.getCrc32(localCached.getContent());
|
int crcOfLocallyCachedConfiguration = IoHelper.getCrc32(localCached.getContent());
|
||||||
System.out.printf(CONFIGURATION_RUSEFI_BINARY + " Local cache CRC %x\n", crcOfLocallyCachedConfiguration);
|
log.info(String.format(CONFIGURATION_RUSEFI_BINARY + " Local cache CRC %x\n", crcOfLocallyCachedConfiguration));
|
||||||
|
|
||||||
byte packet[] = new byte[7];
|
byte packet[] = new byte[7];
|
||||||
packet[0] = COMMAND_CRC_CHECK_COMMAND;
|
packet[0] = COMMAND_CRC_CHECK_COMMAND;
|
||||||
|
@ -407,7 +405,7 @@ public class BinaryProtocol implements BinaryProtocolCommands {
|
||||||
// that's unusual - most of the protocol is LITTLE_ENDIAN
|
// that's unusual - most of the protocol is LITTLE_ENDIAN
|
||||||
bb.order(ByteOrder.BIG_ENDIAN);
|
bb.order(ByteOrder.BIG_ENDIAN);
|
||||||
int crcFromController = bb.getInt();
|
int crcFromController = bb.getInt();
|
||||||
System.out.printf("From rusEFI CRC %x\n", crcFromController);
|
log.info(String.format("From rusEFI CRC %x\n", crcFromController));
|
||||||
if (crcOfLocallyCachedConfiguration == crcFromController) {
|
if (crcOfLocallyCachedConfiguration == crcFromController) {
|
||||||
return localCached;
|
return localCached;
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,10 +8,12 @@ import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.concurrent.ThreadFactory;
|
||||||
|
|
||||||
import static com.rusefi.ui.util.UiUtils.setToolTip;
|
import static com.rusefi.ui.util.UiUtils.setToolTip;
|
||||||
|
|
||||||
public class SimulatorHelper {
|
public class SimulatorHelper {
|
||||||
|
private final static ThreadFactory THREAD_FACTORY = new NamedThreadFactory("SimulatorHelper");
|
||||||
public static final String BINARY = "rusefi_simulator.exe";
|
public static final String BINARY = "rusefi_simulator.exe";
|
||||||
private static Process process;
|
private static Process process;
|
||||||
|
|
||||||
|
@ -27,7 +29,7 @@ public class SimulatorHelper {
|
||||||
LinkManager.isSimulationMode = true;
|
LinkManager.isSimulationMode = true;
|
||||||
|
|
||||||
FileLog.MAIN.logLine("Executing " + BINARY);
|
FileLog.MAIN.logLine("Executing " + BINARY);
|
||||||
new Thread(new Runnable() {
|
THREAD_FACTORY.newThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package com.rusefi.sensor_logs;
|
package com.rusefi.sensor_logs;
|
||||||
|
|
||||||
import com.rusefi.FileLog;
|
import com.rusefi.FileLog;
|
||||||
|
import com.rusefi.NamedThreadFactory;
|
||||||
import com.rusefi.Timeouts;
|
import com.rusefi.Timeouts;
|
||||||
import com.rusefi.core.Sensor;
|
import com.rusefi.core.Sensor;
|
||||||
import com.rusefi.core.SensorCentral;
|
import com.rusefi.core.SensorCentral;
|
||||||
|
@ -13,7 +14,7 @@ import java.util.concurrent.Executor;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
|
|
||||||
public class BinarySensorLogRestarter implements SensorLog {
|
public class BinarySensorLogRestarter implements SensorLog {
|
||||||
private final static Executor UPLOAD_EXECUTOR = Executors.newSingleThreadExecutor();
|
private final static Executor UPLOAD_EXECUTOR = Executors.newSingleThreadExecutor(new NamedThreadFactory("BinarySensorLogRestarter"));
|
||||||
|
|
||||||
private BinarySensorLog logger;
|
private BinarySensorLog logger;
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package com.rusefi.ui;
|
package com.rusefi.ui;
|
||||||
|
|
||||||
|
import com.rusefi.NamedThreadFactory;
|
||||||
import com.rusefi.core.Sensor;
|
import com.rusefi.core.Sensor;
|
||||||
import com.rusefi.core.SensorCategory;
|
import com.rusefi.core.SensorCategory;
|
||||||
import com.rusefi.core.SensorCentral;
|
import com.rusefi.core.SensorCentral;
|
||||||
|
@ -11,6 +12,7 @@ import javax.swing.*;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.awt.event.*;
|
import java.awt.event.*;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
|
import java.util.concurrent.ThreadFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Andrey Belomutskiy, (c) 2013-2020
|
* Andrey Belomutskiy, (c) 2013-2020
|
||||||
|
@ -18,6 +20,7 @@ import java.util.LinkedList;
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("InfiniteLoopStatement")
|
@SuppressWarnings("InfiniteLoopStatement")
|
||||||
public class SensorLiveGraph extends JPanel {
|
public class SensorLiveGraph extends JPanel {
|
||||||
|
private final static ThreadFactory THREAD_FACTORY = new NamedThreadFactory("SensorLiveGraph", true);
|
||||||
private static final int COUNT = 30;
|
private static final int COUNT = 30;
|
||||||
private static final String SENSOR_TYPE = "sensor";
|
private static final String SENSOR_TYPE = "sensor";
|
||||||
private static final String PERIOD = "period";
|
private static final String PERIOD = "period";
|
||||||
|
@ -41,8 +44,7 @@ public class SensorLiveGraph extends JPanel {
|
||||||
String gaugeName = config.getProperty(SENSOR_TYPE, defaultSensor.name());
|
String gaugeName = config.getProperty(SENSOR_TYPE, defaultSensor.name());
|
||||||
this.sensor = Sensor.lookup(gaugeName, defaultSensor);
|
this.sensor = Sensor.lookup(gaugeName, defaultSensor);
|
||||||
|
|
||||||
Thread thread = new Thread(createRunnable());
|
Thread thread = THREAD_FACTORY.newThread(createRunnable());
|
||||||
thread.setDaemon(true);
|
|
||||||
thread.start();
|
thread.start();
|
||||||
period = ChangePeriod.lookup(config.getProperty(PERIOD));
|
period = ChangePeriod.lookup(config.getProperty(PERIOD));
|
||||||
autoScale = config.getBoolProperty(USE_AUTO_SCALE);
|
autoScale = config.getBoolProperty(USE_AUTO_SCALE);
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package com.rusefi.ui.light;
|
package com.rusefi.ui.light;
|
||||||
|
|
||||||
|
import com.rusefi.NamedThreadFactory;
|
||||||
import com.rusefi.Timeouts;
|
import com.rusefi.Timeouts;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
|
@ -8,8 +9,10 @@ import java.io.IOException;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.net.HttpURLConnection;
|
import java.net.HttpURLConnection;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
import java.util.concurrent.ThreadFactory;
|
||||||
|
|
||||||
public class InternetStatus {
|
public class InternetStatus {
|
||||||
|
private final static ThreadFactory THREAD_FACTORY = new NamedThreadFactory("InternetStatus");
|
||||||
private static final String GOOGLE = "http://google.com";
|
private static final String GOOGLE = "http://google.com";
|
||||||
private final JPanel panel = new JPanel();
|
private final JPanel panel = new JPanel();
|
||||||
private final JLabel status = new JLabel();
|
private final JLabel status = new JLabel();
|
||||||
|
@ -19,7 +22,7 @@ public class InternetStatus {
|
||||||
Font defaultFont = status.getFont();
|
Font defaultFont = status.getFont();
|
||||||
status.setFont(new Font(defaultFont.getName(), defaultFont.getStyle(), 2 * defaultFont.getSize()));
|
status.setFont(new Font(defaultFont.getName(), defaultFont.getStyle(), 2 * defaultFont.getSize()));
|
||||||
|
|
||||||
new Thread(() -> {
|
THREAD_FACTORY.newThread(() -> {
|
||||||
while (true) {
|
while (true) {
|
||||||
boolean isConnected = isServerReachable();
|
boolean isConnected = isServerReachable();
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -4,6 +4,7 @@ import com.fathzer.soft.javaluator.DoubleEvaluator;
|
||||||
import com.rusefi.AutoTest;
|
import com.rusefi.AutoTest;
|
||||||
import com.rusefi.FileLog;
|
import com.rusefi.FileLog;
|
||||||
import com.rusefi.InfixConverter;
|
import com.rusefi.InfixConverter;
|
||||||
|
import com.rusefi.NamedThreadFactory;
|
||||||
import com.rusefi.core.MessagesCentral;
|
import com.rusefi.core.MessagesCentral;
|
||||||
import com.rusefi.io.CommandQueue;
|
import com.rusefi.io.CommandQueue;
|
||||||
import com.rusefi.io.LinkManager;
|
import com.rusefi.io.LinkManager;
|
||||||
|
@ -21,6 +22,7 @@ import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
import java.awt.event.KeyAdapter;
|
import java.awt.event.KeyAdapter;
|
||||||
import java.awt.event.KeyEvent;
|
import java.awt.event.KeyEvent;
|
||||||
|
import java.util.concurrent.ThreadFactory;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
|
||||||
|
@ -29,6 +31,7 @@ import java.util.function.Function;
|
||||||
* Andrey Belomutskiy, (c) 2013-2020
|
* Andrey Belomutskiy, (c) 2013-2020
|
||||||
*/
|
*/
|
||||||
public class AnyCommand {
|
public class AnyCommand {
|
||||||
|
private final static ThreadFactory THREAD_FACTORY = new NamedThreadFactory("AnyCommand");
|
||||||
public static final String KEY = "last_value";
|
public static final String KEY = "last_value";
|
||||||
private static final String DECODE_RPN = "decode_rpn";
|
private static final String DECODE_RPN = "decode_rpn";
|
||||||
|
|
||||||
|
@ -171,7 +174,7 @@ public class AnyCommand {
|
||||||
int rpm = Integer.parseInt(parts[1]);
|
int rpm = Integer.parseInt(parts[1]);
|
||||||
int settleTime = Integer.parseInt(parts[2]);
|
int settleTime = Integer.parseInt(parts[2]);
|
||||||
int durationTime = Integer.parseInt(parts[3]);
|
int durationTime = Integer.parseInt(parts[3]);
|
||||||
new Thread(new Runnable() {
|
THREAD_FACTORY.newThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
MessagesCentral.getInstance().postMessage(AnyCommand.class, "Will test with RPM " + rpm + ", settle time" + settleTime + "s and duration" + durationTime + "s");
|
MessagesCentral.getInstance().postMessage(AnyCommand.class, "Will test with RPM " + rpm + ", settle time" + settleTime + "s and duration" + durationTime + "s");
|
||||||
|
|
Loading…
Reference in New Issue