summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2023-07-17 12:20:51 +0200
committerSimon Rettberg2023-07-17 12:20:51 +0200
commit59de319979564c20dfe0c454834d0b9ac22ea3c4 (patch)
tree76f5f2546f8ad4e40fe87b850cef9c0171fb707b
parentFix whitespace (diff)
downloadtutor-module-59de319979564c20dfe0c454834d0b9ac22ea3c4.tar.gz
tutor-module-59de319979564c20dfe0c454834d0b9ac22ea3c4.tar.xz
tutor-module-59de319979564c20dfe0c454834d0b9ac22ea3c4.zip
[server] Tweak thread names
Names can actually be 15 chars, not 11...
-rw-r--r--dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/App.java10
-rw-r--r--dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/maintenance/Maintenance.java5
-rw-r--r--dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/thrift/BinaryListener.java14
3 files changed, 15 insertions, 14 deletions
diff --git a/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/App.java b/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/App.java
index 717ef221..472f2578 100644
--- a/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/App.java
+++ b/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/App.java
@@ -165,24 +165,24 @@ public class App {
// Shared executor for SSL thrift and HTTP thrift
ExecutorService es = new GrowingThreadPoolExecutor(3, 128, 2, TimeUnit.MINUTES,
- new ArrayBlockingQueue<Runnable>(4), new PrioThreadFactory("Web/SSL"));
+ new ArrayBlockingQueue<Runnable>(4), new PrioThreadFactory("Web/Thrift"));
// Start Thrift Server
Thread t;
// Plain
- t = new Thread(new BinaryListener(9090, false, null), "T-Pln:9090");
+ t = new Thread(new BinaryListener(9090, false, es), "Thr-Plain:9090");
t.setDaemon(true);
t.start();
// SSL
- t = new Thread(new BinaryListener(9091, true, es), "T-SSL:9091");
+ t = new Thread(new BinaryListener(9091, true, es), "Thr-SSL:9091");
t.start();
// Start RPC httpd
- t = new Thread(new WebServer(9080), "Rhttpd:9080");
+ t = new Thread(new WebServer(9080), "RPC-httpd:9080");
t.setDaemon(true);
t.start();
// Start JSON-Thrift httpd
- t = new Thread(new JsonHttpListener(9081, es), "Thttpd:9081");
+ t = new Thread(new JsonHttpListener(9081, es), "Thr-httpd:9081");
t.setDaemon(true);
t.start();
diff --git a/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/maintenance/Maintenance.java b/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/maintenance/Maintenance.java
index 767c7531..054e84c6 100644
--- a/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/maintenance/Maintenance.java
+++ b/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/maintenance/Maintenance.java
@@ -4,6 +4,7 @@ import java.util.HashSet;
import java.util.Set;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.atomic.AtomicInteger;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@@ -16,8 +17,10 @@ public class Maintenance extends Thread {
private static BlockingQueue<Runnable> queue = new LinkedBlockingQueue<>(50);
+ private static final AtomicInteger ID_CTR = new AtomicInteger();
+
private Maintenance() {
- super();
+ super("Maint-" + ID_CTR.incrementAndGet());
setPriority((Thread.MIN_PRIORITY + Thread.NORM_PRIORITY) / 2);
}
diff --git a/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/thrift/BinaryListener.java b/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/thrift/BinaryListener.java
index d730eace..abf5721c 100644
--- a/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/thrift/BinaryListener.java
+++ b/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/thrift/BinaryListener.java
@@ -30,8 +30,6 @@ public class BinaryListener implements Runnable {
private static final Logger log = LogManager.getLogger(BinaryListener.class);
private static final int MAX_MSG_LEN = 30 * 1000 * 1000;
- private static final int MINWORKERTHREADS = 2;
- private static final int MAXWORKERTHREADS = 96;
private final SatelliteServer.Processor<ServerHandler> processor = new SatelliteServer.Processor<ServerHandler>(
new ServerHandler());
@@ -41,10 +39,11 @@ public class BinaryListener implements Runnable {
public BinaryListener(int port, boolean secure, ExecutorService es)
throws TTransportException, NoSuchAlgorithmException, IOException {
- if (secure)
+ if (secure) {
server = initSecure(port, es);
- else
- server = initNormal(port);
+ } else {
+ server = initNormal(port, es);
+ }
}
@Override
@@ -75,13 +74,12 @@ public class BinaryListener implements Runnable {
args.protocolFactory(protFactory);
args.processor(processor);
args.executorService(es);
- args.minWorkerThreads(MINWORKERTHREADS).maxWorkerThreads(MAXWORKERTHREADS);
args.stopTimeoutVal(2).stopTimeoutUnit(TimeUnit.MINUTES);
args.transportFactory(new TFastFramedTransport.Factory(MAX_MSG_LEN));
return new TThreadPoolServer(args);
}
- private TServer initNormal(int port) throws TTransportException {
+ private TServer initNormal(int port, ExecutorService es) throws TTransportException {
final TNonblockingServerTransport serverTransport;
try {
serverTransport = new TNonblockingServerSocket(port);
@@ -93,7 +91,7 @@ public class BinaryListener implements Runnable {
THsHaServer.Args args = new THsHaServer.Args(serverTransport);
args.protocolFactory(protFactory);
args.processor(processor);
- args.maxWorkerThreads(8);
+ args.executorService(es);
args.maxReadBufferBytes = MAX_MSG_LEN;
return new THsHaServer(args);
}