Code cleanup.
Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
This commit is contained in:
parent
b37ce63588
commit
bff5b3eb8f
|
@ -1501,14 +1501,15 @@ public abstract class HTTP2Session extends ContainerLifeCycle implements ISessio
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>The HTTP/2 specification requires that stream ids are monotonically increasing,
|
* <p>The HTTP/2 specification requires that stream ids are monotonically increasing,
|
||||||
* see https://tools.ietf.org/html/rfc7540#section-5.1.1.</p>
|
* see <a href="https://tools.ietf.org/html/rfc7540#section-5.1.1">RFC 7540, 5.1.1</a>.</p>
|
||||||
* <p>This implementation uses a queue to atomically reserve a stream id and claim
|
* <p>This implementation uses a queue to atomically reserve a stream id and claim
|
||||||
* a slot in the queue; the slot is then assigned the entries to write.</p>
|
* a slot in the queue; the slot is then assigned the entries to write.</p>
|
||||||
* <p>Concurrent threads push slots in the queue but only one thread flushes
|
* <p>Concurrent threads push slots in the queue but only one thread flushes
|
||||||
* the slots, up to the slot that has a non-null entries to write, therefore
|
* the slots, up to the slot that has a non-null entries to write, therefore
|
||||||
* guaranteeing that frames are sent strictly in their stream id order.</p>
|
* guaranteeing that frames are sent strictly in their stream id order.</p>
|
||||||
* <p>This class also coordinates the creation of streams with the close of
|
* <p>This class also coordinates the creation of streams with the close of
|
||||||
* the session, see https://tools.ietf.org/html/rfc7540#section-6.8.</p>
|
* the session, see
|
||||||
|
* <a href="https://tools.ietf.org/html/rfc7540#section-6.8">RFC 7540, 6.8</a>.</p>
|
||||||
*/
|
*/
|
||||||
private class StreamsState
|
private class StreamsState
|
||||||
{
|
{
|
||||||
|
@ -1527,7 +1528,7 @@ public abstract class HTTP2Session extends ContainerLifeCycle implements ISessio
|
||||||
|
|
||||||
private CloseState getCloseState()
|
private CloseState getCloseState()
|
||||||
{
|
{
|
||||||
try (AutoLock l = lock.lock())
|
try (AutoLock ignored = lock.lock())
|
||||||
{
|
{
|
||||||
return closed;
|
return closed;
|
||||||
}
|
}
|
||||||
|
@ -1536,7 +1537,7 @@ public abstract class HTTP2Session extends ContainerLifeCycle implements ISessio
|
||||||
private CompletableFuture<Void> shutdown()
|
private CompletableFuture<Void> shutdown()
|
||||||
{
|
{
|
||||||
CompletableFuture<Void> future;
|
CompletableFuture<Void> future;
|
||||||
try (AutoLock l = lock.lock())
|
try (AutoLock ignored = lock.lock())
|
||||||
{
|
{
|
||||||
if (shutdownCallback != null)
|
if (shutdownCallback != null)
|
||||||
return shutdownCallback;
|
return shutdownCallback;
|
||||||
|
@ -1550,7 +1551,7 @@ public abstract class HTTP2Session extends ContainerLifeCycle implements ISessio
|
||||||
{
|
{
|
||||||
boolean sendGoAway = false;
|
boolean sendGoAway = false;
|
||||||
boolean tryRunZeroStreamsAction = false;
|
boolean tryRunZeroStreamsAction = false;
|
||||||
try (AutoLock l = lock.lock())
|
try (AutoLock ignored = lock.lock())
|
||||||
{
|
{
|
||||||
switch (closed)
|
switch (closed)
|
||||||
{
|
{
|
||||||
|
@ -1661,7 +1662,7 @@ public abstract class HTTP2Session extends ContainerLifeCycle implements ISessio
|
||||||
LOG.debug("Halting ({}) for {}", reason, HTTP2Session.this);
|
LOG.debug("Halting ({}) for {}", reason, HTTP2Session.this);
|
||||||
GoAwayFrame goAwayFrame = null;
|
GoAwayFrame goAwayFrame = null;
|
||||||
GoAwayFrame goAwayFrameEvent;
|
GoAwayFrame goAwayFrameEvent;
|
||||||
try (AutoLock l = lock.lock())
|
try (AutoLock ignored = lock.lock())
|
||||||
{
|
{
|
||||||
switch (closed)
|
switch (closed)
|
||||||
{
|
{
|
||||||
|
@ -1696,7 +1697,7 @@ public abstract class HTTP2Session extends ContainerLifeCycle implements ISessio
|
||||||
{
|
{
|
||||||
boolean failStreams = false;
|
boolean failStreams = false;
|
||||||
boolean tryRunZeroStreamsAction = false;
|
boolean tryRunZeroStreamsAction = false;
|
||||||
try (AutoLock l = lock.lock())
|
try (AutoLock ignored = lock.lock())
|
||||||
{
|
{
|
||||||
switch (closed)
|
switch (closed)
|
||||||
{
|
{
|
||||||
|
@ -1806,7 +1807,7 @@ public abstract class HTTP2Session extends ContainerLifeCycle implements ISessio
|
||||||
String reason = "input_shutdown";
|
String reason = "input_shutdown";
|
||||||
Throwable cause = null;
|
Throwable cause = null;
|
||||||
boolean failStreams = false;
|
boolean failStreams = false;
|
||||||
try (AutoLock l = lock.lock())
|
try (AutoLock ignored = lock.lock())
|
||||||
{
|
{
|
||||||
switch (closed)
|
switch (closed)
|
||||||
{
|
{
|
||||||
|
@ -1866,7 +1867,7 @@ public abstract class HTTP2Session extends ContainerLifeCycle implements ISessio
|
||||||
boolean sendGoAway = false;
|
boolean sendGoAway = false;
|
||||||
GoAwayFrame goAwayFrame = null;
|
GoAwayFrame goAwayFrame = null;
|
||||||
Throwable cause = null;
|
Throwable cause = null;
|
||||||
try (AutoLock l = lock.lock())
|
try (AutoLock ignored = lock.lock())
|
||||||
{
|
{
|
||||||
switch (closed)
|
switch (closed)
|
||||||
{
|
{
|
||||||
|
@ -1933,7 +1934,7 @@ public abstract class HTTP2Session extends ContainerLifeCycle implements ISessio
|
||||||
{
|
{
|
||||||
GoAwayFrame goAwayFrame;
|
GoAwayFrame goAwayFrame;
|
||||||
Throwable cause;
|
Throwable cause;
|
||||||
try (AutoLock l = lock.lock())
|
try (AutoLock ignored = lock.lock())
|
||||||
{
|
{
|
||||||
switch (closed)
|
switch (closed)
|
||||||
{
|
{
|
||||||
|
@ -1970,7 +1971,7 @@ public abstract class HTTP2Session extends ContainerLifeCycle implements ISessio
|
||||||
private void onWriteFailure(Throwable x)
|
private void onWriteFailure(Throwable x)
|
||||||
{
|
{
|
||||||
String reason = "write_failure";
|
String reason = "write_failure";
|
||||||
try (AutoLock l = lock.lock())
|
try (AutoLock ignored = lock.lock())
|
||||||
{
|
{
|
||||||
switch (closed)
|
switch (closed)
|
||||||
{
|
{
|
||||||
|
@ -2028,7 +2029,7 @@ public abstract class HTTP2Session extends ContainerLifeCycle implements ISessio
|
||||||
// but only one moves to CLOSED and runs the action.
|
// but only one moves to CLOSED and runs the action.
|
||||||
Runnable action = null;
|
Runnable action = null;
|
||||||
CompletableFuture<Void> future;
|
CompletableFuture<Void> future;
|
||||||
try (AutoLock l = lock.lock())
|
try (AutoLock ignored = lock.lock())
|
||||||
{
|
{
|
||||||
long count = streamCount.get();
|
long count = streamCount.get();
|
||||||
if (count > 0)
|
if (count > 0)
|
||||||
|
@ -2133,7 +2134,7 @@ public abstract class HTTP2Session extends ContainerLifeCycle implements ISessio
|
||||||
private Stream newUpgradeStream(HeadersFrame frame, Stream.Listener listener, Consumer<Throwable> failFn)
|
private Stream newUpgradeStream(HeadersFrame frame, Stream.Listener listener, Consumer<Throwable> failFn)
|
||||||
{
|
{
|
||||||
int streamId;
|
int streamId;
|
||||||
try (AutoLock l = lock.lock())
|
try (AutoLock ignored = lock.lock())
|
||||||
{
|
{
|
||||||
streamId = localStreamIds.getAndAdd(2);
|
streamId = localStreamIds.getAndAdd(2);
|
||||||
HTTP2Session.this.onStreamCreated(streamId);
|
HTTP2Session.this.onStreamCreated(streamId);
|
||||||
|
@ -2153,7 +2154,7 @@ public abstract class HTTP2Session extends ContainerLifeCycle implements ISessio
|
||||||
|
|
||||||
private boolean newRemoteStream(int streamId)
|
private boolean newRemoteStream(int streamId)
|
||||||
{
|
{
|
||||||
try (AutoLock l = lock.lock())
|
try (AutoLock ignored = lock.lock())
|
||||||
{
|
{
|
||||||
switch (closed)
|
switch (closed)
|
||||||
{
|
{
|
||||||
|
@ -2237,7 +2238,7 @@ public abstract class HTTP2Session extends ContainerLifeCycle implements ISessio
|
||||||
private int reserveSlot(Slot slot, int streamId, Consumer<Throwable> fail)
|
private int reserveSlot(Slot slot, int streamId, Consumer<Throwable> fail)
|
||||||
{
|
{
|
||||||
Throwable failure = null;
|
Throwable failure = null;
|
||||||
try (AutoLock l = lock.lock())
|
try (AutoLock ignored = lock.lock())
|
||||||
{
|
{
|
||||||
if (closed == CloseState.NOT_CLOSED)
|
if (closed == CloseState.NOT_CLOSED)
|
||||||
{
|
{
|
||||||
|
@ -2263,7 +2264,7 @@ public abstract class HTTP2Session extends ContainerLifeCycle implements ISessio
|
||||||
|
|
||||||
private void freeSlot(Slot slot, int streamId)
|
private void freeSlot(Slot slot, int streamId)
|
||||||
{
|
{
|
||||||
try (AutoLock l = lock.lock())
|
try (AutoLock ignored = lock.lock())
|
||||||
{
|
{
|
||||||
slots.remove(slot);
|
slots.remove(slot);
|
||||||
}
|
}
|
||||||
|
@ -2292,7 +2293,7 @@ public abstract class HTTP2Session extends ContainerLifeCycle implements ISessio
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
List<HTTP2Flusher.Entry> entries;
|
List<HTTP2Flusher.Entry> entries;
|
||||||
try (AutoLock l = lock.lock())
|
try (AutoLock ignored = lock.lock())
|
||||||
{
|
{
|
||||||
if (flushing == null)
|
if (flushing == null)
|
||||||
flushing = thread;
|
flushing = thread;
|
||||||
|
@ -2320,7 +2321,7 @@ public abstract class HTTP2Session extends ContainerLifeCycle implements ISessio
|
||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString()
|
||||||
{
|
{
|
||||||
try (AutoLock l = lock.lock())
|
try (AutoLock ignored = lock.lock())
|
||||||
{
|
{
|
||||||
return String.format("state=[streams=%d,%s,goAwayRecv=%s,goAwaySent=%s,failure=%s]",
|
return String.format("state=[streams=%d,%s,goAwayRecv=%s,goAwaySent=%s,failure=%s]",
|
||||||
streamCount.get(),
|
streamCount.get(),
|
||||||
|
|
Loading…
Reference in New Issue