Skip to content

Commit

Permalink
Issue #2828 - AbstractHTTP2ServerConnectionFactory concurrent connect…
Browse files Browse the repository at this point in the history
… low performance.

Fixed test failure.

Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
  • Loading branch information
sbordet committed Aug 22, 2018
1 parent 9a06acc commit 0f6ae93
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import java.util.ArrayList;
import java.util.Deque;
import java.util.List;
import java.util.Set;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLong;
Expand Down Expand Up @@ -698,7 +699,10 @@ public void onData(Stream stream, DataFrame frame, Callback callback)
// Give time to the server to process the reset and drain the flusher queue.
Thread.sleep(500);

HTTP2Session session = connector.getConnectionFactory(AbstractHTTP2ServerConnectionFactory.class).getBean(HTTP2Session.class);
AbstractHTTP2ServerConnectionFactory http2 = connector.getConnectionFactory(AbstractHTTP2ServerConnectionFactory.class);
Set<Session> sessions = http2.getBean(AbstractHTTP2ServerConnectionFactory.HTTP2SessionContainer.class).getSessions();
Assert.assertEquals(1, sessions.size());
HTTP2Session session = (HTTP2Session)sessions.iterator().next();
HTTP2Flusher flusher = session.getBean(HTTP2Flusher.class);
Assert.assertEquals(0, flusher.getFrameQueueSize());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import java.io.IOException;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
Expand Down Expand Up @@ -273,6 +274,11 @@ public void onClosed(Connection connection)
LifeCycle.stop(session);
}

public Set<Session> getSessions()
{
return new HashSet<>(sessions);
}

@ManagedAttribute(value = "The number of HTTP/2 sessions", readonly = true)
public int getSize()
{
Expand All @@ -295,7 +301,7 @@ public void dump(Appendable out, String indent) throws IOException
@Override
public String toString()
{
return String.format("%s@%x[size=%d]", getClass().getSimpleName(), hashCode(), sessions.size());
return String.format("%s@%x[size=%d]", getClass().getSimpleName(), hashCode(), getSize());
}
}
}

0 comments on commit 0f6ae93

Please sign in to comment.