Class EventOutputStreams
- java.lang.Object
-
- com.cloudbees.hudson.plugins.folder.computed.EventOutputStreams
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
public class EventOutputStreams extends Object implements Closeable
An factory forOutputStream
instances that can concurrently write to the same file and do lots of other wonderful magical things (excluding changing the baby's nappy).- Output is collected in batches, one batch per thread and flushed periodically.
- The file is only opened when actually writing.
- The file is rotated if it gets too big.
- You can close it over and over, it will auto re-open on next write!
FolderComputation.createEventsListener()
where there may be multiple concurrent events in flight and we need to:- Try to keep each events log messages close together, hence the batching
- Rotate after it gets too big
- Not hold the file open indefinitely - ideally only when writing so that it can be moved by other processes
- Since:
- 5.18
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
EventOutputStreams.OutputFile
Supplies the current output file destination.
-
Constructor Summary
Constructors Constructor Description EventOutputStreams(EventOutputStreams.OutputFile outputFile, boolean append)
EventOutputStreams(EventOutputStreams.OutputFile outputFile, boolean append, int fileCount)
EventOutputStreams(EventOutputStreams.OutputFile outputFile, long flushInterval, TimeUnit flushIntervalUnits, int flushSize, boolean append, long rotateSize, int fileCount)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
OutputStream
get()
Gets a newOutputStream
, the caller must close the stream in order to ensure all its output gets written.
-
-
-
Constructor Detail
-
EventOutputStreams
public EventOutputStreams(EventOutputStreams.OutputFile outputFile, boolean append)
-
EventOutputStreams
public EventOutputStreams(EventOutputStreams.OutputFile outputFile, boolean append, int fileCount)
-
EventOutputStreams
public EventOutputStreams(EventOutputStreams.OutputFile outputFile, long flushInterval, TimeUnit flushIntervalUnits, int flushSize, boolean append, long rotateSize, int fileCount)
-
-
Method Detail
-
get
public OutputStream get()
Gets a newOutputStream
, the caller must close the stream in order to ensure all its output gets written.- Returns:
- a new
OutputStream
.
-
close
public void close() throws IOException
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-
-