Assign even more thread names at thread creation.

This commit is contained in:
Christoph Sturm 2019-09-03 17:47:57 +02:00
parent bcaac51830
commit 6273a58c3b
2 changed files with 37 additions and 45 deletions

View File

@ -49,33 +49,29 @@ public class SetupUtils {
// If users compile themselves they might miss that step and then would get an exception in the trade.
// To avoid that we add here at startup a sample encryption and signing to see if it don't causes an exception.
// See: https://github.com/bisq-network/exchange/blob/master/doc/build.md#7-enable-unlimited-strength-for-cryptographic-keys
Thread checkCryptoThread = new Thread() {
@Override
public void run() {
try {
Thread.currentThread().setName("checkCryptoThread");
// just use any simple dummy msg
Ping payload = new Ping(1, 1);
SealedAndSigned sealedAndSigned = EncryptionService.encryptHybridWithSignature(payload,
keyRing.getSignatureKeyPair(), keyRing.getPubKeyRing().getEncryptionPubKey());
DecryptedDataTuple tuple = encryptionService.decryptHybridWithSignature(sealedAndSigned,
keyRing.getEncryptionKeyPair().getPrivate());
if (tuple.getNetworkEnvelope() instanceof Ping &&
((Ping) tuple.getNetworkEnvelope()).getNonce() == payload.getNonce() &&
((Ping) tuple.getNetworkEnvelope()).getLastRoundTripTime() == payload.getLastRoundTripTime()) {
log.debug("Crypto test succeeded");
Thread checkCryptoThread = new Thread(() -> {
try {
// just use any simple dummy msg
Ping payload = new Ping(1, 1);
SealedAndSigned sealedAndSigned = EncryptionService.encryptHybridWithSignature(payload,
keyRing.getSignatureKeyPair(), keyRing.getPubKeyRing().getEncryptionPubKey());
DecryptedDataTuple tuple = encryptionService.decryptHybridWithSignature(sealedAndSigned,
keyRing.getEncryptionKeyPair().getPrivate());
if (tuple.getNetworkEnvelope() instanceof Ping &&
((Ping) tuple.getNetworkEnvelope()).getNonce() == payload.getNonce() &&
((Ping) tuple.getNetworkEnvelope()).getLastRoundTripTime() == payload.getLastRoundTripTime()) {
log.debug("Crypto test succeeded");
UserThread.execute(resultHandler::handleResult);
} else {
errorHandler.accept(new CryptoException("Payload not correct after decryption"));
}
} catch (CryptoException | ProtobufferException e) {
log.error(e.toString());
e.printStackTrace();
errorHandler.accept(e);
UserThread.execute(resultHandler::handleResult);
} else {
errorHandler.accept(new CryptoException("Payload not correct after decryption"));
}
} catch (CryptoException | ProtobufferException e) {
log.error(e.toString());
e.printStackTrace();
errorHandler.accept(e);
}
};
}, "checkCryptoThread");
checkCryptoThread.start();
}

View File

@ -21,11 +21,11 @@ import bisq.monitor.metric.MarketStats;
import bisq.monitor.metric.P2PMarketStats;
import bisq.monitor.metric.P2PNetworkLoad;
import bisq.monitor.metric.P2PRoundTripTime;
import bisq.monitor.metric.P2PSeedNodeSnapshot;
import bisq.monitor.metric.PriceNodeStats;
import bisq.monitor.metric.TorHiddenServiceStartupTime;
import bisq.monitor.metric.TorRoundTripTime;
import bisq.monitor.metric.TorStartupTime;
import bisq.monitor.metric.P2PSeedNodeSnapshot;
import bisq.monitor.reporter.ConsoleReporter;
import bisq.monitor.reporter.GraphiteReporter;
@ -114,28 +114,24 @@ public class Monitor {
configure();
// exit Metrics gracefully on shutdown
Runtime.getRuntime().addShutdownHook(new Thread() {
@Override
public void run() {
// set the name of the Thread for debugging purposes
setName("shutdownHook");
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
// set the name of the Thread for debugging purposes
log.info("system shutdown initiated");
log.info("system shutdown initiated");
log.info("shutting down active metrics...");
Metric.haltAllMetrics();
log.info("shutting down active metrics...");
Metric.haltAllMetrics();
try {
log.info("shutting down tor...");
Tor tor = Tor.getDefault();
checkNotNull(tor, "tor must not be null");
tor.shutdown();
} catch (Throwable ignore) {
}
try {
log.info("shutting down tor...");
Tor tor = Tor.getDefault();
checkNotNull(tor, "tor must not be null");
tor.shutdown();
} catch (Throwable ignore) {
}
log.info("system halt");
}
});
log.info("system halt");
}, "Monitor Shutdown Hook ")
);
}
/**