aboutsummaryrefslogtreecommitdiffstats
path: root/jdisc_http_service
diff options
context:
space:
mode:
Diffstat (limited to 'jdisc_http_service')
-rw-r--r--jdisc_http_service/src/main/java/com/yahoo/container/logging/AccessLogHandler.java5
-rw-r--r--jdisc_http_service/src/main/java/com/yahoo/container/logging/ConnectionLogHandler.java6
-rw-r--r--jdisc_http_service/src/main/java/com/yahoo/container/logging/FileConnectionLog.java2
-rw-r--r--jdisc_http_service/src/main/java/com/yahoo/container/logging/LogFileHandler.java11
-rw-r--r--jdisc_http_service/src/main/resources/configdefinitions/container.logging.connection-log.def5
-rw-r--r--jdisc_http_service/src/test/java/com/yahoo/container/logging/LogFileHandlerTestCase.java10
6 files changed, 20 insertions, 19 deletions
diff --git a/jdisc_http_service/src/main/java/com/yahoo/container/logging/AccessLogHandler.java b/jdisc_http_service/src/main/java/com/yahoo/container/logging/AccessLogHandler.java
index 4c156e2705f..376be879965 100644
--- a/jdisc_http_service/src/main/java/com/yahoo/container/logging/AccessLogHandler.java
+++ b/jdisc_http_service/src/main/java/com/yahoo/container/logging/AccessLogHandler.java
@@ -3,9 +3,6 @@ package com.yahoo.container.logging;
import com.yahoo.container.core.AccessLogConfig;
-import java.util.logging.Level;
-import java.util.logging.LogRecord;
-
/**
* @author Bjorn Borud
*/
@@ -14,7 +11,7 @@ class AccessLogHandler {
private final LogFileHandler<RequestLogEntry> logFileHandler;
AccessLogHandler(AccessLogConfig.FileHandler config, LogWriter<RequestLogEntry> logWriter) {
- logFileHandler = new LogFileHandler<>(toCompression(config), config.pattern(), config.rotation(), config.symlink(), logWriter);
+ logFileHandler = new LogFileHandler<>(toCompression(config), config.pattern(), config.rotation(), config.symlink(), config.queueSize(), logWriter);
}
public void log(RequestLogEntry entry) {
diff --git a/jdisc_http_service/src/main/java/com/yahoo/container/logging/ConnectionLogHandler.java b/jdisc_http_service/src/main/java/com/yahoo/container/logging/ConnectionLogHandler.java
index 2a36e251d24..418fe47d3e0 100644
--- a/jdisc_http_service/src/main/java/com/yahoo/container/logging/ConnectionLogHandler.java
+++ b/jdisc_http_service/src/main/java/com/yahoo/container/logging/ConnectionLogHandler.java
@@ -2,21 +2,19 @@
package com.yahoo.container.logging;
-import java.util.logging.Level;
-import java.util.logging.LogRecord;
-
/**
* @author mortent
*/
class ConnectionLogHandler {
private final LogFileHandler<ConnectionLogEntry> logFileHandler;
- public ConnectionLogHandler(String clusterName, LogWriter<ConnectionLogEntry> logWriter) {
+ public ConnectionLogHandler(String clusterName, int queueSize, LogWriter<ConnectionLogEntry> logWriter) {
logFileHandler = new LogFileHandler<>(
LogFileHandler.Compression.ZSTD,
String.format("logs/vespa/qrs/ConnectionLog.%s.%s", clusterName, "%Y%m%d%H%M%S"),
"0 60 ...",
String.format("ConnectionLog.%s", clusterName),
+ queueSize,
logWriter);
}
diff --git a/jdisc_http_service/src/main/java/com/yahoo/container/logging/FileConnectionLog.java b/jdisc_http_service/src/main/java/com/yahoo/container/logging/FileConnectionLog.java
index 968ba74b4f2..3d09f193864 100644
--- a/jdisc_http_service/src/main/java/com/yahoo/container/logging/FileConnectionLog.java
+++ b/jdisc_http_service/src/main/java/com/yahoo/container/logging/FileConnectionLog.java
@@ -17,7 +17,7 @@ public class FileConnectionLog extends AbstractComponent implements ConnectionLo
@Inject
public FileConnectionLog(ConnectionLogConfig config) {
- logHandler = new ConnectionLogHandler(config.cluster(), new JsonConnectionLogWriter());
+ logHandler = new ConnectionLogHandler(config.cluster(), config.queueSize(), new JsonConnectionLogWriter());
}
@Override
diff --git a/jdisc_http_service/src/main/java/com/yahoo/container/logging/LogFileHandler.java b/jdisc_http_service/src/main/java/com/yahoo/container/logging/LogFileHandler.java
index 7839a13b0ca..5aca804ba64 100644
--- a/jdisc_http_service/src/main/java/com/yahoo/container/logging/LogFileHandler.java
+++ b/jdisc_http_service/src/main/java/com/yahoo/container/logging/LogFileHandler.java
@@ -20,10 +20,11 @@ import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Optional;
-import java.util.concurrent.ArrayBlockingQueue;
+import java.util.concurrent.BlockingQueue;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
+import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -40,13 +41,13 @@ class LogFileHandler <LOGTYPE> {
enum Compression {NONE, GZIP, ZSTD}
private final static Logger logger = Logger.getLogger(LogFileHandler.class.getName());
- private final ArrayBlockingQueue<Operation<LOGTYPE>> logQueue = new ArrayBlockingQueue<>(10000);
+ private final BlockingQueue<Operation<LOGTYPE>> logQueue;
final LogThread<LOGTYPE> logThread;
@FunctionalInterface private interface Pollable<T> { Operation<T> poll() throws InterruptedException; }
- LogFileHandler(Compression compression, String filePattern, String rotationTimes, String symlinkName, LogWriter<LOGTYPE> logWriter) {
- this(compression, filePattern, calcTimesMinutes(rotationTimes), symlinkName, logWriter);
+ LogFileHandler(Compression compression, String filePattern, String rotationTimes, String symlinkName, int queueSize, LogWriter<LOGTYPE> logWriter) {
+ this(compression, filePattern, calcTimesMinutes(rotationTimes), symlinkName, queueSize, logWriter);
}
LogFileHandler(
@@ -54,7 +55,9 @@ class LogFileHandler <LOGTYPE> {
String filePattern,
long[] rotationTimes,
String symlinkName,
+ int queueSize,
LogWriter<LOGTYPE> logWriter) {
+ this.logQueue = new LinkedBlockingQueue<>(queueSize);
this.logThread = new LogThread<LOGTYPE>(logWriter, filePattern, compression, rotationTimes, symlinkName, this::poll);
this.logThread.start();
}
diff --git a/jdisc_http_service/src/main/resources/configdefinitions/container.logging.connection-log.def b/jdisc_http_service/src/main/resources/configdefinitions/container.logging.connection-log.def
index 3a2d49120c9..0606598aec7 100644
--- a/jdisc_http_service/src/main/resources/configdefinitions/container.logging.connection-log.def
+++ b/jdisc_http_service/src/main/resources/configdefinitions/container.logging.connection-log.def
@@ -1,4 +1,7 @@
namespace=container.logging
# Name of the cluster
-cluster string \ No newline at end of file
+cluster string
+
+# Max queue length of file handler
+queueSize int default=2048 \ No newline at end of file
diff --git a/jdisc_http_service/src/test/java/com/yahoo/container/logging/LogFileHandlerTestCase.java b/jdisc_http_service/src/test/java/com/yahoo/container/logging/LogFileHandlerTestCase.java
index 013f42cd5b0..7ae46f50492 100644
--- a/jdisc_http_service/src/test/java/com/yahoo/container/logging/LogFileHandlerTestCase.java
+++ b/jdisc_http_service/src/test/java/com/yahoo/container/logging/LogFileHandlerTestCase.java
@@ -43,7 +43,7 @@ public class LogFileHandlerTestCase {
String pattern = root.getAbsolutePath() + "/logfilehandlertest.%Y%m%d%H%M%S";
long[] rTimes = {1000, 2000, 10000};
- LogFileHandler<String> h = new LogFileHandler<>(Compression.NONE, pattern, rTimes, null, new StringLogWriter());
+ LogFileHandler<String> h = new LogFileHandler<>(Compression.NONE, pattern, rTimes, null, 2048, new StringLogWriter());
long now = System.currentTimeMillis();
long millisPerDay = 60*60*24*1000;
long tomorrowDays = (now / millisPerDay) +1;
@@ -65,7 +65,7 @@ public class LogFileHandlerTestCase {
File logFile = temporaryFolder.newFile("testLogFileG1.txt");
//create logfilehandler
- LogFileHandler<String> h = new LogFileHandler<>(Compression.NONE, logFile.getAbsolutePath(), "0 5 ...", null, new StringLogWriter());
+ LogFileHandler<String> h = new LogFileHandler<>(Compression.NONE, logFile.getAbsolutePath(), "0 5 ...", null, 2048, new StringLogWriter());
//write log
h.publish("testDeleteFileFirst1");
@@ -78,7 +78,7 @@ public class LogFileHandlerTestCase {
File logFile = temporaryFolder.newFile("testLogFileG2.txt");
//create logfilehandler
- LogFileHandler<String> h = new LogFileHandler<>(Compression.NONE, logFile.getAbsolutePath(), "0 5 ...", null, new StringLogWriter());
+ LogFileHandler<String> h = new LogFileHandler<>(Compression.NONE, logFile.getAbsolutePath(), "0 5 ...", null, 2048, new StringLogWriter());
//write log
h.publish("testDeleteFileDuringLogging1");
@@ -104,7 +104,7 @@ public class LogFileHandlerTestCase {
}
};
LogFileHandler<String> handler = new LogFileHandler<>(
- Compression.NONE, root.getAbsolutePath() + "/logfilehandlertest.%Y%m%d%H%M%S%s", new long[]{0}, "symlink", new StringLogWriter());
+ Compression.NONE, root.getAbsolutePath() + "/logfilehandlertest.%Y%m%d%H%M%S%s", new long[]{0}, "symlink", 2048, new StringLogWriter());
String message = formatter.format(new LogRecord(Level.INFO, "test"));
handler.publishAndWait(message);
@@ -150,7 +150,7 @@ public class LogFileHandlerTestCase {
File root = temporaryFolder.newFolder("testcompression" + compression.name());
LogFileHandler<String> h = new LogFileHandler<>(
- compression, root.getAbsolutePath() + "/logfilehandlertest.%Y%m%d%H%M%S%s", new long[]{0}, null, new StringLogWriter());
+ compression, root.getAbsolutePath() + "/logfilehandlertest.%Y%m%d%H%M%S%s", new long[]{0}, null, 2048, new StringLogWriter());
int logEntries = 10000;
for (int i = 0; i < logEntries; i++) {
h.publish("test");