Merge branch 'jetty-9.3.x' of github.com:eclipse/jetty.project into jetty-9.3.x
This commit is contained in:
commit
602222182c
|
@ -559,6 +559,9 @@ public class AnnotationConfiguration extends AbstractConfiguration
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean timeout = !latch.await(getMaxScanWait(context), TimeUnit.SECONDS);
|
boolean timeout = !latch.await(getMaxScanWait(context), TimeUnit.SECONDS);
|
||||||
|
long elapsedMs = TimeUnit.MILLISECONDS.convert(System.nanoTime()-start, TimeUnit.NANOSECONDS);
|
||||||
|
|
||||||
|
LOG.info("Scanning elapsed time={}ms",elapsedMs);
|
||||||
|
|
||||||
if (LOG.isDebugEnabled())
|
if (LOG.isDebugEnabled())
|
||||||
{
|
{
|
||||||
|
@ -567,7 +570,7 @@ public class AnnotationConfiguration extends AbstractConfiguration
|
||||||
|
|
||||||
LOG.debug("Scanned {} container path jars, {} WEB-INF/lib jars, {} WEB-INF/classes dirs in {}ms for context {}",
|
LOG.debug("Scanned {} container path jars, {} WEB-INF/lib jars, {} WEB-INF/classes dirs in {}ms for context {}",
|
||||||
_containerPathStats.getTotal(), _webInfLibStats.getTotal(), _webInfClassesStats.getTotal(),
|
_containerPathStats.getTotal(), _webInfLibStats.getTotal(), _webInfClassesStats.getTotal(),
|
||||||
(TimeUnit.MILLISECONDS.convert(System.nanoTime()-start, TimeUnit.NANOSECONDS)),
|
elapsedMs,
|
||||||
context);
|
context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,12 @@
|
||||||
<Ref id="idMgr"/>
|
<Ref id="idMgr"/>
|
||||||
</Set>
|
</Set>
|
||||||
<Set name="scavengeIntervalSec">600</Set>
|
<Set name="scavengeIntervalSec">600</Set>
|
||||||
|
<!-- uncomment and configure the secs before a memcache entry is evicted
|
||||||
|
<Set name="expirySec">86400</Set>
|
||||||
|
-->
|
||||||
|
<!-- uncomment and configure whether memcached does heartbeats or not
|
||||||
|
<Set name="heartbeats">false</Set>
|
||||||
|
-->
|
||||||
<Set name="host"><Env name="MEMCACHE_PORT_11211_TCP_ADDR" default="localhost"/></Set>
|
<Set name="host"><Env name="MEMCACHE_PORT_11211_TCP_ADDR" default="localhost"/></Set>
|
||||||
<Set name="port"><Env name="MEMCACHE_PORT_11211_TCP_PORT" default="11211"/></Set>
|
<Set name="port"><Env name="MEMCACHE_PORT_11211_TCP_PORT" default="11211"/></Set>
|
||||||
</New>
|
</New>
|
||||||
|
|
|
@ -52,6 +52,7 @@ public class GCloudMemcachedSessionManager extends GCloudSessionManager
|
||||||
protected String _port;
|
protected String _port;
|
||||||
protected MemcachedClient _client;
|
protected MemcachedClient _client;
|
||||||
protected int _expirySec = 0;
|
protected int _expirySec = 0;
|
||||||
|
private boolean _heartbeats = true;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -212,6 +213,15 @@ public class GCloudMemcachedSessionManager extends GCloudSessionManager
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param heartbeats if true memcached heartbeats are enabled. Default is true.
|
||||||
|
*/
|
||||||
|
public void setHeartbeats (boolean heartbeats)
|
||||||
|
{
|
||||||
|
_heartbeats = heartbeats;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void doStart() throws Exception
|
public void doStart() throws Exception
|
||||||
{
|
{
|
||||||
|
@ -222,6 +232,8 @@ public class GCloudMemcachedSessionManager extends GCloudSessionManager
|
||||||
|
|
||||||
XMemcachedClientBuilder builder = new XMemcachedClientBuilder(_host+":"+_port);
|
XMemcachedClientBuilder builder = new XMemcachedClientBuilder(_host+":"+_port);
|
||||||
_client = builder.build();
|
_client = builder.build();
|
||||||
|
_client.setEnableHeartBeat(_heartbeats);
|
||||||
|
|
||||||
|
|
||||||
_client.setTranscoder(new ContextClassloaderSerializingTranscoder());
|
_client.setTranscoder(new ContextClassloaderSerializingTranscoder());
|
||||||
super.doStart();
|
super.doStart();
|
||||||
|
|
|
@ -282,7 +282,7 @@ public class ByteArrayEndPoint extends AbstractEndPoint
|
||||||
|
|
||||||
try(Locker.Lock lock = _locker.lock())
|
try(Locker.Lock lock = _locker.lock())
|
||||||
{
|
{
|
||||||
if (BufferUtil.isEmpty(_out))
|
if (BufferUtil.isEmpty(_out) && !_closed && !_oshut)
|
||||||
_hasOutput.await(time,unit);
|
_hasOutput.await(time,unit);
|
||||||
|
|
||||||
b=_out;
|
b=_out;
|
||||||
|
|
|
@ -38,11 +38,20 @@ import org.eclipse.jetty.util.ByteArrayOutputStream2;
|
||||||
import org.eclipse.jetty.util.ssl.SslContextFactory;
|
import org.eclipse.jetty.util.ssl.SslContextFactory;
|
||||||
import org.eclipse.jetty.util.thread.Scheduler;
|
import org.eclipse.jetty.util.thread.Scheduler;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A local connector, mostly for testing purposes.
|
||||||
|
* <pre>
|
||||||
|
* HttpTester.Request request = HttpTester.newRequest();
|
||||||
|
* request.setURI("/some/resource");
|
||||||
|
* HttpTester.Response response =
|
||||||
|
* HttpTester.parseResponse(HttpTester.from(localConnector.getResponse(request.generate())));
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class LocalConnector extends AbstractConnector
|
public class LocalConnector extends AbstractConnector
|
||||||
{
|
{
|
||||||
private final BlockingQueue<LocalEndPoint> _connects = new LinkedBlockingQueue<>();
|
private final BlockingQueue<LocalEndPoint> _connects = new LinkedBlockingQueue<>();
|
||||||
|
|
||||||
|
|
||||||
public LocalConnector(Server server, Executor executor, Scheduler scheduler, ByteBufferPool pool, int acceptors, ConnectionFactory... factories)
|
public LocalConnector(Server server, Executor executor, Scheduler scheduler, ByteBufferPool pool, int acceptors, ConnectionFactory... factories)
|
||||||
{
|
{
|
||||||
super(server,executor,scheduler,pool,acceptors,factories);
|
super(server,executor,scheduler,pool,acceptors,factories);
|
||||||
|
@ -200,18 +209,34 @@ public class LocalConnector extends AbstractConnector
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get a single response using a parser to search for the end of the message.
|
/** Get a single response using a parser to search for the end of the message.
|
||||||
* @param requestsBuffer The request to send
|
* @param requestBuffer The request to send
|
||||||
|
* @param time The time to wait
|
||||||
|
* @param unit The units of the wait
|
||||||
|
* @return ByteBuffer containing response or null.
|
||||||
|
* @throws Exception If there is a problem
|
||||||
|
*/
|
||||||
|
public ByteBuffer getResponse(ByteBuffer requestBuffer, long time,TimeUnit unit) throws Exception
|
||||||
|
{
|
||||||
|
boolean head = BufferUtil.toString(requestBuffer).toLowerCase().startsWith("head ");
|
||||||
|
if (LOG.isDebugEnabled())
|
||||||
|
LOG.debug("requests {}", BufferUtil.toUTF8String(requestBuffer));
|
||||||
|
LocalEndPoint endp = executeRequest(requestBuffer);
|
||||||
|
return endp.waitForResponse(head,time,unit);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Get a single response using a parser to search for the end of the message.
|
||||||
|
* @param requestBuffer The request to send
|
||||||
* @param head True if the response is for a head request
|
* @param head True if the response is for a head request
|
||||||
* @param time The time to wait
|
* @param time The time to wait
|
||||||
* @param unit The units of the wait
|
* @param unit The units of the wait
|
||||||
* @return ByteBuffer containing response or null.
|
* @return ByteBuffer containing response or null.
|
||||||
* @throws Exception If there is a problem
|
* @throws Exception If there is a problem
|
||||||
*/
|
*/
|
||||||
public ByteBuffer getResponse(ByteBuffer requestsBuffer,boolean head, long time,TimeUnit unit) throws Exception
|
public ByteBuffer getResponse(ByteBuffer requestBuffer,boolean head, long time,TimeUnit unit) throws Exception
|
||||||
{
|
{
|
||||||
if (LOG.isDebugEnabled())
|
if (LOG.isDebugEnabled())
|
||||||
LOG.debug("requests {}", BufferUtil.toUTF8String(requestsBuffer));
|
LOG.debug("requests {}", BufferUtil.toUTF8String(requestBuffer));
|
||||||
LocalEndPoint endp = executeRequest(requestsBuffer);
|
LocalEndPoint endp = executeRequest(requestBuffer);
|
||||||
return endp.waitForResponse(head,time,unit);
|
return endp.waitForResponse(head,time,unit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -226,6 +251,25 @@ public class LocalConnector extends AbstractConnector
|
||||||
return getResponse(rawRequest,false,30,TimeUnit.SECONDS);
|
return getResponse(rawRequest,false,30,TimeUnit.SECONDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Get a single response using a parser to search for the end of the message.
|
||||||
|
* @param rawRequest The request to send
|
||||||
|
* @param time The time to wait
|
||||||
|
* @param unit The units of the wait
|
||||||
|
* @return ByteBuffer containing response or null.
|
||||||
|
* @throws Exception If there is a problem
|
||||||
|
*/
|
||||||
|
public String getResponse(String rawRequest,long time,TimeUnit unit) throws Exception
|
||||||
|
{
|
||||||
|
boolean head = rawRequest.toLowerCase().startsWith("head ");
|
||||||
|
ByteBuffer requestsBuffer = BufferUtil.toBuffer(rawRequest, StandardCharsets.ISO_8859_1);
|
||||||
|
if (LOG.isDebugEnabled())
|
||||||
|
LOG.debug("request {}", BufferUtil.toUTF8String(requestsBuffer));
|
||||||
|
LocalEndPoint endp = executeRequest(requestsBuffer);
|
||||||
|
|
||||||
|
return BufferUtil.toString(endp.waitForResponse(head,time,unit), StandardCharsets.ISO_8859_1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/** Get a single response using a parser to search for the end of the message.
|
/** Get a single response using a parser to search for the end of the message.
|
||||||
* @param rawRequest The request to send
|
* @param rawRequest The request to send
|
||||||
* @param head True if the response is for a head request
|
* @param head True if the response is for a head request
|
||||||
|
@ -244,8 +288,6 @@ public class LocalConnector extends AbstractConnector
|
||||||
return BufferUtil.toString(endp.waitForResponse(head,time,unit), StandardCharsets.ISO_8859_1);
|
return BufferUtil.toString(endp.waitForResponse(head,time,unit), StandardCharsets.ISO_8859_1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** Local EndPoint
|
/** Local EndPoint
|
||||||
*/
|
*/
|
||||||
public class LocalEndPoint extends ByteArrayEndPoint
|
public class LocalEndPoint extends ByteArrayEndPoint
|
||||||
|
@ -333,6 +375,29 @@ public class LocalConnector extends AbstractConnector
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Wait for a response using a parser to detect the end of message
|
||||||
|
* @return Buffer containing full response or null for EOF;
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public String getResponse() throws Exception
|
||||||
|
{
|
||||||
|
return getResponse(false,30,TimeUnit.SECONDS);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Wait for a response using a parser to detect the end of message
|
||||||
|
* @param head
|
||||||
|
* @param time
|
||||||
|
* @param unit
|
||||||
|
* @return Buffer containing full response or null for EOF;
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public String getResponse(boolean head, long time,TimeUnit unit) throws Exception
|
||||||
|
{
|
||||||
|
ByteBuffer response = waitForResponse(head,time,unit);
|
||||||
|
if (response!=null)
|
||||||
|
return BufferUtil.toString(response);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/** Wait for a response using a parser to detect the end of message
|
/** Wait for a response using a parser to detect the end of message
|
||||||
* @param head
|
* @param head
|
||||||
|
@ -391,7 +456,6 @@ public class LocalConnector extends AbstractConnector
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
HttpParser parser = new HttpParser(handler);
|
HttpParser parser = new HttpParser(handler);
|
||||||
parser.setHeadResponse(head);
|
parser.setHeadResponse(head);
|
||||||
try(ByteArrayOutputStream2 bout = new ByteArrayOutputStream2();)
|
try(ByteArrayOutputStream2 bout = new ByteArrayOutputStream2();)
|
||||||
|
@ -399,9 +463,19 @@ public class LocalConnector extends AbstractConnector
|
||||||
loop: while(true)
|
loop: while(true)
|
||||||
{
|
{
|
||||||
// read a chunk of response
|
// read a chunk of response
|
||||||
ByteBuffer chunk = BufferUtil.hasContent(_responseData)
|
ByteBuffer chunk;
|
||||||
? _responseData : waitForOutput(time,unit);
|
if (BufferUtil.hasContent(_responseData))
|
||||||
_responseData=null;
|
chunk = _responseData;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
chunk = waitForOutput(time,unit);
|
||||||
|
if (BufferUtil.isEmpty(chunk) && (!isOpen() || isOutputShutdown()))
|
||||||
|
{
|
||||||
|
parser.atEOF();
|
||||||
|
parser.parseNext(BufferUtil.EMPTY_BUFFER);
|
||||||
|
break loop;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Parse the content of this chunk
|
// Parse the content of this chunk
|
||||||
while (BufferUtil.hasContent(chunk))
|
while (BufferUtil.hasContent(chunk))
|
||||||
|
|
Loading…
Reference in New Issue