public class LegacyLogWriteExecutor
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
private static class |
LegacyLogWriteExecutor.ExecutorsThreadFactory
Private static class ExecutorsThreadFactory to provide meaningful names for threads used by the
executors.
|
private static class |
LegacyLogWriteExecutor.LegacyLogManagerQueueHolder
Initialization on demand holder for LegacyLogManagerQueue singleton initialization.
|
private static class |
LegacyLogWriteExecutor.WriteCallable
Private static class WriteCallable that extends Callable
|
| Modifier and Type | Field and Description |
|---|---|
private static CentralLogger |
LOG
A temporary logger to just write messages to server's log.
|
private java.lang.Object |
noRotationMutex
Mutex for no rotation related actions.
|
private java.util.Map<java.lang.String,java.util.concurrent.ExecutorService> |
noRotationPathToExecutorServicedMap
Map with absolute log file path : executor service pairs for clients that don't need file rotation.
|
private java.util.Map<java.lang.String,java.util.Set<java.lang.Long>> |
noRotationPathToPidMap
Map with absolute log file path : client pids pairs for clients that don't need file rotation.
|
private java.lang.Object |
rotationMutex
Mutex for rotation related actions.
|
private java.util.Map<java.lang.String,java.util.concurrent.ExecutorService> |
rotationPathToExecutorServicedMap
Map with absolute log file path : executor service pairs for clients that need file rotation.
|
private java.util.Map<java.lang.String,java.lang.Long> |
rotationPathToPidMap
Map with absolute log file path : client pid pairs for clients that need file rotation.
|
private static java.util.concurrent.ThreadFactory |
THREAD_FACTORY_NO_ROTATION
Thread factory for the thread executor providing threads for writing to log files without rotation.
|
private static java.util.concurrent.ThreadFactory |
THREAD_FACTORY_ROTATION
Thread factory for the thread executor providing threads for writing to log files with rotation.
|
| Modifier | Constructor and Description |
|---|---|
private |
LegacyLogWriteExecutor()
Private constructor for LegacyLogManagerQueue.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
close(long pid,
java.lang.String path,
boolean isRotation)
Closes the ExecutorService executing write tasks for the file path if no other pids are using it.
|
static LegacyLogWriteExecutor |
get()
Getter for LegacyLogManagerQueue singleton instance.
|
private java.util.concurrent.Future<java.lang.Boolean> |
write(java.util.concurrent.ExecutorService es,
java.io.FileWriter writer,
java.lang.String msg)
Creates a new WriteCallable and submits it to the ExecutorService.
|
java.util.Optional<java.util.concurrent.Future<java.lang.Boolean>> |
write(long pid,
java.lang.String path,
boolean isRotation,
java.io.FileWriter writer,
java.lang.String msg)
Each unique path has a dedicated thread and a queue (newSingleThreadExecutor).
|
private static final CentralLogger LOG
private static final java.util.concurrent.ThreadFactory THREAD_FACTORY_ROTATION
private static final java.util.concurrent.ThreadFactory THREAD_FACTORY_NO_ROTATION
private final java.lang.Object rotationMutex
private final java.util.Map<java.lang.String,java.lang.Long> rotationPathToPidMap
private final java.util.Map<java.lang.String,java.util.concurrent.ExecutorService> rotationPathToExecutorServicedMap
private final java.lang.Object noRotationMutex
private final java.util.Map<java.lang.String,java.util.Set<java.lang.Long>> noRotationPathToPidMap
private final java.util.Map<java.lang.String,java.util.concurrent.ExecutorService> noRotationPathToExecutorServicedMap
private LegacyLogWriteExecutor()
public static LegacyLogWriteExecutor get()
public boolean close(long pid,
java.lang.String path,
boolean isRotation)
pid - The process id of the client writing to the file.path - Absolute path to the file to write to.isRotation - Flag to indicate the file gets rotated.true.public java.util.Optional<java.util.concurrent.Future<java.lang.Boolean>> write(long pid,
java.lang.String path,
boolean isRotation,
java.io.FileWriter writer,
java.lang.String msg)
pid - The process id of the client writing to the file.path - Absolute path to the file to write to.isRotation - Flag to indicate the file gets rotated.writer - The prepared FileWriter for writing to the file.msg - The log message.private java.util.concurrent.Future<java.lang.Boolean> write(java.util.concurrent.ExecutorService es,
java.io.FileWriter writer,
java.lang.String msg)
es - The executor service to execute the WriteCallable.writer - The prepared FileWriter for writing to the file.msg - The log message.