Protocol: | <%= request.getProtocol() %> |
---|---|
Request URI: | <%= request.getRequestURI() %> |
ServletPath: | <%= request.getServletPath() %> |
PathInfo: | <%= request.getPathInfo() %> | HTTP/1.1")); + assertThat("Response Content", responseBody, containsString("Protocol: | HTTP/1.1"));
}
@Test
public void testGetJspExpr() throws Exception
{
- URI uri = serverLocalUri.resolve("/jsp/expr.jsp?A=1");
+ URI uri = serverLocalUri.resolve("/expr.jsp?A=1");
ContentResponse response = client.newRequest(uri)
.method(HttpMethod.GET)
.send();
@@ -88,7 +86,7 @@ public class OneWebAppWithJspTest extends AbstractEmbeddedTest
@Test
public void testGetJstlExpr() throws Exception
{
- URI uri = serverLocalUri.resolve("/jsp/jstl.jsp");
+ URI uri = serverLocalUri.resolve("/jstl.jsp");
ContentResponse response = client.newRequest(uri)
.method(HttpMethod.GET)
.send();
@@ -101,7 +99,7 @@ public class OneWebAppWithJspTest extends AbstractEmbeddedTest
assertThat("Response Content", responseBody, containsString("JSTL Example")); for (int i = 1; i <= 10; i++) { - assertThat("Reponse content (counting)", responseBody, containsString("" + i)); + assertThat("Response content (counting)", responseBody, containsString("" + i)); } } } diff --git a/demos/embedded/src/test/java/org/eclipse/jetty/demos/ProxyServerTest.java b/demos/embedded/src/test/java/org/eclipse/jetty/demos/ProxyServerTest.java index 8acad59fc2f..fe1d1c8f681 100644 --- a/demos/embedded/src/test/java/org/eclipse/jetty/demos/ProxyServerTest.java +++ b/demos/embedded/src/test/java/org/eclipse/jetty/demos/ProxyServerTest.java @@ -1,6 +1,6 @@ // // ======================================================================== -// Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others. +// Copyright (c) 1995-2021 Mort Bay Consulting Pty Ltd and others. // // This program and the accompanying materials are made available under the // terms of the Eclipse Public License v. 2.0 which is available at diff --git a/demos/embedded/src/test/java/org/eclipse/jetty/demos/RewriteServerTest.java b/demos/embedded/src/test/java/org/eclipse/jetty/demos/RewriteServerTest.java index af0f742b336..e02216d5574 100644 --- a/demos/embedded/src/test/java/org/eclipse/jetty/demos/RewriteServerTest.java +++ b/demos/embedded/src/test/java/org/eclipse/jetty/demos/RewriteServerTest.java @@ -1,6 +1,6 @@ // // ======================================================================== -// Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others. +// Copyright (c) 1995-2021 Mort Bay Consulting Pty Ltd and others. // // This program and the accompanying materials are made available under the // terms of the Eclipse Public License v. 2.0 which is available at diff --git a/demos/embedded/src/test/java/org/eclipse/jetty/demos/SecuredHelloHandlerTest.java b/demos/embedded/src/test/java/org/eclipse/jetty/demos/SecuredHelloHandlerTest.java index 6f8053f841c..bb674334345 100644 --- a/demos/embedded/src/test/java/org/eclipse/jetty/demos/SecuredHelloHandlerTest.java +++ b/demos/embedded/src/test/java/org/eclipse/jetty/demos/SecuredHelloHandlerTest.java @@ -1,6 +1,6 @@ // // ======================================================================== -// Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others. +// Copyright (c) 1995-2021 Mort Bay Consulting Pty Ltd and others. // // This program and the accompanying materials are made available under the // terms of the Eclipse Public License v. 2.0 which is available at diff --git a/demos/embedded/src/test/java/org/eclipse/jetty/demos/ServerUtil.java b/demos/embedded/src/test/java/org/eclipse/jetty/demos/ServerUtil.java index 88d76b78a3f..7808d581329 100644 --- a/demos/embedded/src/test/java/org/eclipse/jetty/demos/ServerUtil.java +++ b/demos/embedded/src/test/java/org/eclipse/jetty/demos/ServerUtil.java @@ -1,6 +1,6 @@ // // ======================================================================== -// Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others. +// Copyright (c) 1995-2021 Mort Bay Consulting Pty Ltd and others. // // This program and the accompanying materials are made available under the // terms of the Eclipse Public License v. 2.0 which is available at diff --git a/demos/embedded/src/test/java/org/eclipse/jetty/demos/ServerWithAnnotationsTest.java b/demos/embedded/src/test/java/org/eclipse/jetty/demos/ServerWithAnnotationsTest.java index 37df074281f..3a2ce059d20 100644 --- a/demos/embedded/src/test/java/org/eclipse/jetty/demos/ServerWithAnnotationsTest.java +++ b/demos/embedded/src/test/java/org/eclipse/jetty/demos/ServerWithAnnotationsTest.java @@ -1,6 +1,6 @@ // // ======================================================================== -// Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others. +// Copyright (c) 1995-2021 Mort Bay Consulting Pty Ltd and others. // // This program and the accompanying materials are made available under the // terms of the Eclipse Public License v. 2.0 which is available at @@ -36,8 +36,6 @@ public class ServerWithAnnotationsTest extends AbstractEmbeddedTest @BeforeEach public void startServer() throws Exception { - assumeTrue(JettyHome.JETTY_HOME != null, "jetty-home not found"); - server = ServerWithAnnotations.createServer(0); server.start(); } diff --git a/demos/embedded/src/test/java/org/eclipse/jetty/demos/ServerWithJMXTest.java b/demos/embedded/src/test/java/org/eclipse/jetty/demos/ServerWithJMXTest.java index 1cda7644807..07afd05fff3 100644 --- a/demos/embedded/src/test/java/org/eclipse/jetty/demos/ServerWithJMXTest.java +++ b/demos/embedded/src/test/java/org/eclipse/jetty/demos/ServerWithJMXTest.java @@ -1,6 +1,6 @@ // // ======================================================================== -// Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others. +// Copyright (c) 1995-2021 Mort Bay Consulting Pty Ltd and others. // // This program and the accompanying materials are made available under the // terms of the Eclipse Public License v. 2.0 which is available at diff --git a/demos/embedded/src/test/java/org/eclipse/jetty/demos/ServerWithJNDITest.java b/demos/embedded/src/test/java/org/eclipse/jetty/demos/ServerWithJNDITest.java index 53b2bc9136e..50a55ac0cfc 100644 --- a/demos/embedded/src/test/java/org/eclipse/jetty/demos/ServerWithJNDITest.java +++ b/demos/embedded/src/test/java/org/eclipse/jetty/demos/ServerWithJNDITest.java @@ -1,6 +1,6 @@ // // ======================================================================== -// Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others. +// Copyright (c) 1995-2021 Mort Bay Consulting Pty Ltd and others. // // This program and the accompanying materials are made available under the // terms of the Eclipse Public License v. 2.0 which is available at @@ -37,8 +37,6 @@ public class ServerWithJNDITest extends AbstractEmbeddedTest @BeforeEach public void startServer() throws Exception { - assumeTrue(JettyHome.JETTY_HOME != null, "jetty-home not found"); - server = ServerWithJNDI.createServer(0); server.start(); } diff --git a/demos/embedded/src/test/java/org/eclipse/jetty/demos/SimplestServerTest.java b/demos/embedded/src/test/java/org/eclipse/jetty/demos/SimplestServerTest.java index 1d7b5d06561..c08b5ff2bd0 100644 --- a/demos/embedded/src/test/java/org/eclipse/jetty/demos/SimplestServerTest.java +++ b/demos/embedded/src/test/java/org/eclipse/jetty/demos/SimplestServerTest.java @@ -1,6 +1,6 @@ // // ======================================================================== -// Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others. +// Copyright (c) 1995-2021 Mort Bay Consulting Pty Ltd and others. // // This program and the accompanying materials are made available under the // terms of the Eclipse Public License v. 2.0 which is available at diff --git a/demos/embedded/src/test/java/org/eclipse/jetty/demos/SplitFileServerTest.java b/demos/embedded/src/test/java/org/eclipse/jetty/demos/SplitFileServerTest.java index 97e48d3c50a..ef868998a99 100644 --- a/demos/embedded/src/test/java/org/eclipse/jetty/demos/SplitFileServerTest.java +++ b/demos/embedded/src/test/java/org/eclipse/jetty/demos/SplitFileServerTest.java @@ -1,6 +1,6 @@ // // ======================================================================== -// Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others. +// Copyright (c) 1995-2021 Mort Bay Consulting Pty Ltd and others. // // This program and the accompanying materials are made available under the // terms of the Eclipse Public License v. 2.0 which is available at diff --git a/demos/embedded/src/test/java/org/eclipse/jetty/demos/WebSocketJsrServerTest.java b/demos/embedded/src/test/java/org/eclipse/jetty/demos/WebSocketJsrServerTest.java index f4827debfef..83f88bf9195 100644 --- a/demos/embedded/src/test/java/org/eclipse/jetty/demos/WebSocketJsrServerTest.java +++ b/demos/embedded/src/test/java/org/eclipse/jetty/demos/WebSocketJsrServerTest.java @@ -1,6 +1,6 @@ // // ======================================================================== -// Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others. +// Copyright (c) 1995-2021 Mort Bay Consulting Pty Ltd and others. // // This program and the accompanying materials are made available under the // terms of the Eclipse Public License v. 2.0 which is available at diff --git a/demos/embedded/src/test/java/org/eclipse/jetty/demos/WebSocketServerTest.java b/demos/embedded/src/test/java/org/eclipse/jetty/demos/WebSocketServerTest.java index bddb8fb605b..b57692a9459 100644 --- a/demos/embedded/src/test/java/org/eclipse/jetty/demos/WebSocketServerTest.java +++ b/demos/embedded/src/test/java/org/eclipse/jetty/demos/WebSocketServerTest.java @@ -1,6 +1,6 @@ // // ======================================================================== -// Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others. +// Copyright (c) 1995-2021 Mort Bay Consulting Pty Ltd and others. // // This program and the accompanying materials are made available under the // terms of the Eclipse Public License v. 2.0 which is available at diff --git a/demos/pom.xml b/demos/pom.xml index ff304a19fd4..9133a25a797 100644 --- a/demos/pom.xml +++ b/demos/pom.xml @@ -35,6 +35,8 @@Asciidoctor include extension that includes into + * the document the output produced by starting a Jetty server. + *Example usage in an Asciidoc page: + *+ * include::jetty[setupArgs="--add-modules=http,deploy,demo-simple",highlight="WebAppContext"] + *+ * Available configuration parameters are: + *
Get the max usage duration in milliseconds of the pool's connections. + * Values {@code 0} and negative mean that there is no limit. + *This only guarantees that a connection cannot be acquired after the configured + * duration elapses, so that is only enforced when {@link #acquire(boolean)} is called. + * If a pool stays completely idle for a duration longer than the value + * returned by this method, the max duration will not be enforced. + * It's up to the idle timeout mechanism (see {@link HttpClient#getIdleTimeout()}) + * to handle closing idle connections. + */ + @ManagedAttribute(value = "The maximum duration in milliseconds a connection can be used for before it gets closed") + public long getMaxDuration() + { + return TimeUnit.NANOSECONDS.toMillis(maxDurationNanos); + } + + public void setMaxDuration(long maxDurationInMs) + { + this.maxDurationNanos = TimeUnit.MILLISECONDS.toNanos(maxDurationInMs); } protected int getMaxMultiplex() @@ -122,7 +162,7 @@ public abstract class AbstractConnectionPool extends ContainerLifeCycle implemen @ManagedAttribute(value = "The number of pending connections", readonly = true) public int getPendingConnectionCount() { - return pool.getReservedCount(); + return pending.get(); } @Override @@ -158,13 +198,17 @@ public abstract class AbstractConnectionPool extends ContainerLifeCycle implemen *Returns an idle connection, if available; * if an idle connection is not available, and the given {@code create} parameter is {@code true} * or {@link #isMaximizeConnections()} is {@code true}, - * then schedules the opening of a new connection, if possible within the configuration of this + * then attempts to open a new connection, if possible within the configuration of this * connection pool (for example, if it does not exceed the max connection count); - * otherwise returns {@code null}. + * otherwise it attempts to open a new connection, if the number of queued requests is + * greater than the number of pending connections; + * if no connection is available even after the attempts to open, return {@code null}. + *The {@code create} parameter is just a hint: the connection may be created even if + * {@code false}, or may not be created even if {@code true}. * - * @param create whether to schedule the opening of a connection if no idle connections are available + * @param create a hint to attempt to open a new connection if no idle connections are available * @return an idle connection or {@code null} if no idle connections are available - * @see #tryCreate(int) + * @see #tryCreate(boolean) */ @Override public Connection acquire(boolean create) @@ -172,75 +216,65 @@ public abstract class AbstractConnectionPool extends ContainerLifeCycle implemen if (LOG.isDebugEnabled()) LOG.debug("Acquiring create={} on {}", create, this); Connection connection = activate(); - if (connection == null && (create || isMaximizeConnections())) + if (connection == null) { - tryCreate(destination.getQueuedRequestCount()); + tryCreate(create); connection = activate(); } return connection; } /** - *Schedules the opening of a new connection. - *Whether a new connection is scheduled for opening is determined by the {@code maxPending} parameter: - * if {@code maxPending} is greater than the current number of connections scheduled for opening, - * then this method returns without scheduling the opening of a new connection; - * if {@code maxPending} is negative, a new connection is always scheduled for opening. + *Tries to create a new connection. + *Whether a new connection is created is determined by the {@code create} parameter + * and a count of demand and supply, where the demand is derived from the number of + * queued requests, and the supply is the number of pending connections time the + * {@link #getMaxMultiplex()} factor: if the demand is less than the supply, the + * connection will not be created. + *Since the number of queued requests used to derive the demand may be a stale + * value, it is possible that few more connections than strictly necessary may be + * created, but enough to satisfy the demand. * - * @param maxPending the max desired number of connections scheduled for opening, - * or a negative number to always trigger the opening of a new connection + * @param create a hint to request to create a connection */ - protected void tryCreate(int maxPending) - { - tryCreateAsync(maxPending); - } - - private CompletableFuture |