class LatencyCutoffStream
extends ServletOutputStream
Modifier and Type | Field and Description |
---|---|
private boolean |
isReported
Whether the message has been printed yet
|
private int |
limit
The limit on the number of bytes after which the message is printed
|
private OutputStream |
realOut
The output stream to receive the output
|
private long |
reqStartTime
The start of the request, for timing purposes
|
private int |
total
How many bytes have been output so far
|
private String |
url
The URL of the request being served
|
Constructor and Description |
---|
LatencyCutoffStream(OutputStream realOut,
int limit,
long reqStartTime,
String url)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Close the output stream
|
void |
flush()
Flush any pending data to the output stream
|
boolean |
isReported()
Tells whether the latency was reported yet
|
private void |
reportLatency()
Report the latency and set the flag saying it has been done.
|
void |
write(byte[] b)
Write an array of bytes to the output stream
|
void |
write(byte[] b,
int off,
int len)
Write a subset of bytes to the stream
|
void |
write(int b)
Write a single byte to the stream
|
private OutputStream realOut
private int total
private int limit
private String url
private long reqStartTime
private boolean isReported
public LatencyCutoffStream(OutputStream realOut, int limit, long reqStartTime, String url)
realOut
- The output stream to receive the limited outputlimit
- How many characters to output the message afterurl
- The URL of the request being servedpublic void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
close
in class OutputStream
IOException
public void flush() throws IOException
flush
in interface Flushable
flush
in class OutputStream
IOException
public void write(byte[] b) throws IOException
write
in class OutputStream
IOException
public void write(byte[] b, int off, int len) throws IOException
write
in class OutputStream
IOException
public void write(int b) throws IOException
write
in class OutputStream
IOException
public boolean isReported()
private void reportLatency()