summaryrefslogtreecommitdiffstats
path: root/logserver
diff options
context:
space:
mode:
authorArne H Juul <arnej@yahoo-inc.com>2017-05-24 16:48:35 +0200
committerArne H Juul <arnej@yahoo-inc.com>2017-05-24 16:48:35 +0200
commitf0b5c8367a922813e11b82bd07af45c5b0d50f49 (patch)
tree1ab83608510227e1b9e6d6c9cf5b50162571c56a /logserver
parent1ea2105e3c0a9279e134eca0fef347a52f3f1820 (diff)
add thread safety
* access to currentBatchList was not protected by lock, leading to currentBatchList in flushBatch(). * also: fix javadoc warnings
Diffstat (limited to 'logserver')
-rw-r--r--logserver/src/main/java/com/yahoo/logserver/LogDispatcher.java13
-rw-r--r--logserver/src/main/java/com/yahoo/logserver/PluginLoader.java1
-rw-r--r--logserver/src/main/java/com/yahoo/logserver/handlers/AbstractLogHandler.java2
-rw-r--r--logserver/src/main/java/com/yahoo/logserver/handlers/archive/ArchiverHandler.java10
-rw-r--r--logserver/src/main/java/com/yahoo/logserver/handlers/archive/LogWriter.java2
-rw-r--r--logserver/src/main/java/com/yahoo/logserver/handlers/replicator/FormattedBufferCache.java2
-rw-r--r--logserver/src/main/java/com/yahoo/logserver/handlers/replicator/Replicator.java1
7 files changed, 9 insertions, 22 deletions
diff --git a/logserver/src/main/java/com/yahoo/logserver/LogDispatcher.java b/logserver/src/main/java/com/yahoo/logserver/LogDispatcher.java
index f7828b4dc9f..e13a2f09323 100644
--- a/logserver/src/main/java/com/yahoo/logserver/LogDispatcher.java
+++ b/logserver/src/main/java/com/yahoo/logserver/LogDispatcher.java
@@ -71,17 +71,17 @@ public class LogDispatcher implements LogHandler, SelectLoopHook {
}
private void flushBatch() {
- if (currentBatchList == null) {
- return;
+ List<LogMessage> todo;
+ synchronized(this) {
+ todo = currentBatchList;
+ currentBatchList = null;
}
-
+ if (todo == null) return;
for (LogHandler ht : handlers) {
- ht.handle(currentBatchList);
+ ht.handle(todo);
}
- currentBatchList = null;
}
-
public void handle(List<LogMessage> messages) {
throw new IllegalStateException("method not supported");
}
@@ -132,7 +132,6 @@ public class LogDispatcher implements LogHandler, SelectLoopHook {
* thread has already been registered, we log a warning and
* just do nothing.
* <p>
- * <p>
* If the thread is not alive it will be start()'ed.
*/
public synchronized void registerLogHandler(LogHandler ht) {
diff --git a/logserver/src/main/java/com/yahoo/logserver/PluginLoader.java b/logserver/src/main/java/com/yahoo/logserver/PluginLoader.java
index 6347226f5de..42355022f16 100644
--- a/logserver/src/main/java/com/yahoo/logserver/PluginLoader.java
+++ b/logserver/src/main/java/com/yahoo/logserver/PluginLoader.java
@@ -7,7 +7,6 @@ package com.yahoo.logserver;
* all of its knows plugins. In addition, if a plugin loader's
* canReload() method returns <code>true</code>, plugins may be loaded
* again after they are unloaded.
- * <p>
* <p> Plugins loaded through such reload-capable plugin loaders may
* be upgraded without restarting the server.
*
diff --git a/logserver/src/main/java/com/yahoo/logserver/handlers/AbstractLogHandler.java b/logserver/src/main/java/com/yahoo/logserver/handlers/AbstractLogHandler.java
index a2da987f802..362312434d3 100644
--- a/logserver/src/main/java/com/yahoo/logserver/handlers/AbstractLogHandler.java
+++ b/logserver/src/main/java/com/yahoo/logserver/handlers/AbstractLogHandler.java
@@ -101,7 +101,6 @@ public abstract class AbstractLogHandler implements LogHandler {
* does something to it. This is the one you wish to
* override when you write a new handler.
* <p>
- * <p>
* <em>
* If your handle method is slow you should document this fact
* so that decisions can be made with regard to configuration.
@@ -123,7 +122,6 @@ public abstract class AbstractLogHandler implements LogHandler {
* the #handle() has undefined behavior, but it should be assumed
* that log messages will be silently dropped.
* <p>
- * <p>
* #close() usually implies #flush() but don't bet on it.
*/
public abstract void close();
diff --git a/logserver/src/main/java/com/yahoo/logserver/handlers/archive/ArchiverHandler.java b/logserver/src/main/java/com/yahoo/logserver/handlers/archive/ArchiverHandler.java
index d2a3d566c38..b1169aff02e 100644
--- a/logserver/src/main/java/com/yahoo/logserver/handlers/archive/ArchiverHandler.java
+++ b/logserver/src/main/java/com/yahoo/logserver/handlers/archive/ArchiverHandler.java
@@ -25,28 +25,26 @@ import com.yahoo.logserver.handlers.AbstractLogHandler;
* is to make it easy to locate messages in a time interval, while
* ensuring that no log file exceeds the maximum allowed size.
* <p>
- * <p>
* This class is not thread safe.
* </p>
* <p>
- * <p>
* TODO:
* </p>
* <ul>
* <li> Add file locking support in order to make it
* possible to do concurrent compression of log
* files.
- * <p>
+ * </li>
* <li> Add support for disk monitoring. Should have
* high/low watermark mechanism and three modes
* of operation: normal, tight and full. In
* "tight" mode disk is running low and compression
* and cleanup should possibly be more frequent.
- * <p>
+ * </li>
* <li> Add compression task which periodically scans
* the log directory looking for uncompressed
* candidate log files.
- * <p>
+ * </li>
* </ul>
*
* @author Bjorn Borud
@@ -151,7 +149,6 @@ public class ArchiverHandler extends AbstractLogHandler {
* down number representing year, month, day and hour in order
* to partition logging in time.
* <p>
- * <p>
* This method is not thread-safe.
*/
public int dateHash(long time) {
@@ -170,7 +167,6 @@ public class ArchiverHandler extends AbstractLogHandler {
/**
* Generate prefix for log filenames based on log message.
* <p>
- * <p>
* <EM>This message is <code>public</code> only because we need
* access to it in unit tests. For all practical purposes this
* method does not exist to you, the application programmer, OK? :-)</EM>
diff --git a/logserver/src/main/java/com/yahoo/logserver/handlers/archive/LogWriter.java b/logserver/src/main/java/com/yahoo/logserver/handlers/archive/LogWriter.java
index 5fa7dd7f4b6..17af537026a 100644
--- a/logserver/src/main/java/com/yahoo/logserver/handlers/archive/LogWriter.java
+++ b/logserver/src/main/java/com/yahoo/logserver/handlers/archive/LogWriter.java
@@ -36,7 +36,6 @@ public class LogWriter extends Writer {
* This is called when we want to rotate the output file to
* start writing the next file. There are two scenarios when
* we do this:
- * <p>
* <UL>
* <LI> initial case, when we have no file
* <LI> when we have filled the file and want to rotate it
@@ -102,7 +101,6 @@ public class LogWriter extends Writer {
* that would circumvent rotation when it grows past its
* maximum size. use the one that takes String instead.
* <p>
- * <p>
* <em>
* (This is a class which is only used internally anyway)
* </em>
diff --git a/logserver/src/main/java/com/yahoo/logserver/handlers/replicator/FormattedBufferCache.java b/logserver/src/main/java/com/yahoo/logserver/handlers/replicator/FormattedBufferCache.java
index 284781b12bb..daf408c17a4 100644
--- a/logserver/src/main/java/com/yahoo/logserver/handlers/replicator/FormattedBufferCache.java
+++ b/logserver/src/main/java/com/yahoo/logserver/handlers/replicator/FormattedBufferCache.java
@@ -17,12 +17,10 @@ import com.yahoo.logserver.formatter.LogFormatterManager;
* still ensuring we don't format more messages than we strictly need
* to and that we don't keep around more buffers that we ought to.
* <p>
- * <p>
* This is not a general purpose class, I think, so please
* refer to the source code of the Replicator class for
* information on how to use this.
* <p>
- * <p>
* This class is not threadsafe.
*
* @author Bjorn Borud
diff --git a/logserver/src/main/java/com/yahoo/logserver/handlers/replicator/Replicator.java b/logserver/src/main/java/com/yahoo/logserver/handlers/replicator/Replicator.java
index 5ede34a1f79..1d8da93c483 100644
--- a/logserver/src/main/java/com/yahoo/logserver/handlers/replicator/Replicator.java
+++ b/logserver/src/main/java/com/yahoo/logserver/handlers/replicator/Replicator.java
@@ -18,7 +18,6 @@ import com.yahoo.logserver.handlers.AbstractLogHandler;
* The Replicator plugin is used for replicating log messages sent
* to the logserver.
* <p>
- * <p>
* Per default the replicator will start dropping messages enqueued
* to a client if the outbound message queue reaches 5000 messages.
* This limit can be configured by setting the system property