jetty-9 more removal of AsyncConnection
This commit is contained in:
parent
dc02390449
commit
6d64bcd38a
|
@ -269,27 +269,29 @@ public class HttpGeneratorServerTest
|
||||||
if (chunks-->1)
|
if (chunks-->1)
|
||||||
content.limit(content.position()+content.remaining()/2);
|
content.limit(content.position()+content.remaining()/2);
|
||||||
|
|
||||||
// System.err.printf("content %d %s%n",chunks,BufferUtil.toDetailString(content));
|
if (chunks<0)
|
||||||
|
throw new IllegalStateException();
|
||||||
|
System.err.printf("content %d %s%n",chunks,BufferUtil.toDetailString(content));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generate
|
// Generate
|
||||||
Action action=BufferUtil.hasContent(content)?null:Action.COMPLETE;
|
Action action=BufferUtil.hasContent(content)?null:Action.COMPLETE;
|
||||||
|
|
||||||
/* System.err.printf("generate(%s,%s,%s,%s,%s)@%s%n",
|
System.err.printf("generate(%s,%s,%s,%s,%s)@%s%n",
|
||||||
BufferUtil.toSummaryString(header),
|
BufferUtil.toSummaryString(header),
|
||||||
BufferUtil.toSummaryString(chunk),
|
BufferUtil.toSummaryString(chunk),
|
||||||
BufferUtil.toSummaryString(buffer),
|
BufferUtil.toSummaryString(buffer),
|
||||||
BufferUtil.toSummaryString(content),
|
BufferUtil.toSummaryString(content),
|
||||||
action,gen.getState());*/
|
action,gen.getState());
|
||||||
HttpGenerator.Result result=gen.generate(info,header,chunk,buffer,content,action);
|
HttpGenerator.Result result=gen.generate(info,header,chunk,buffer,content,action);
|
||||||
/*System.err.printf("%s (%s,%s,%s,%s,%s)@%s%n",
|
System.err.printf("%s (%s,%s,%s,%s,%s)@%s%n",
|
||||||
result,
|
result,
|
||||||
BufferUtil.toSummaryString(header),
|
BufferUtil.toSummaryString(header),
|
||||||
BufferUtil.toSummaryString(chunk),
|
BufferUtil.toSummaryString(chunk),
|
||||||
BufferUtil.toSummaryString(buffer),
|
BufferUtil.toSummaryString(buffer),
|
||||||
BufferUtil.toSummaryString(content),
|
BufferUtil.toSummaryString(content),
|
||||||
action,gen.getState());*/
|
action,gen.getState());
|
||||||
|
|
||||||
switch(result)
|
switch(result)
|
||||||
{
|
{
|
||||||
|
@ -413,14 +415,15 @@ public class HttpGeneratorServerTest
|
||||||
for (int c=0;c<(v==11?connect.length:(connect.length-1));c++)
|
for (int c=0;c<(v==11?connect.length:(connect.length-1));c++)
|
||||||
{
|
{
|
||||||
String t="v="+v+",chunks="+chunks+",connect="+connect[c]+",tr="+r+"="+tr[r];
|
String t="v="+v+",chunks="+chunks+",connect="+connect[c]+",tr="+r+"="+tr[r];
|
||||||
// System.err.println(t);
|
System.err.println("\n==========================================");
|
||||||
|
System.err.println(t);
|
||||||
|
|
||||||
gen.reset();
|
gen.reset();
|
||||||
tr[r].getHttpFields().clear();
|
tr[r].getHttpFields().clear();
|
||||||
|
|
||||||
String response=tr[r].build(tr[r],v,gen,"OK\r\nTest",connect[c],null,chunks);
|
String response=tr[r].build(tr[r],v,gen,"OK\r\nTest",connect[c],null,chunks);
|
||||||
|
|
||||||
// System.err.println("===\n"+t+"\n"+response+(gen.isPersistent()?"...\n":"---\n"));
|
System.err.println("---\n"+t+"\n"+response+(gen.isPersistent()?"...":"==="));
|
||||||
|
|
||||||
if (v==9)
|
if (v==9)
|
||||||
{
|
{
|
||||||
|
|
|
@ -447,7 +447,6 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa
|
||||||
while (changes-->0 && (change=_changes.poll())!=null)
|
while (changes-->0 && (change=_changes.poll())!=null)
|
||||||
{
|
{
|
||||||
Channel ch=null;
|
Channel ch=null;
|
||||||
SelectionKey key=null;
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -468,13 +467,13 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa
|
||||||
|
|
||||||
if ((channel instanceof SocketChannel) && ((SocketChannel)channel).isConnected())
|
if ((channel instanceof SocketChannel) && ((SocketChannel)channel).isConnected())
|
||||||
{
|
{
|
||||||
key = channel.register(selector,SelectionKey.OP_READ,att);
|
SelectionKey key = channel.register(selector,SelectionKey.OP_READ,att);
|
||||||
SelectChannelEndPoint endpoint = createEndPoint((SocketChannel)channel,key);
|
SelectChannelEndPoint endpoint = createEndPoint((SocketChannel)channel,key);
|
||||||
key.attach(endpoint);
|
key.attach(endpoint);
|
||||||
}
|
}
|
||||||
else if (channel.isOpen())
|
else if (channel.isOpen())
|
||||||
{
|
{
|
||||||
key = channel.register(selector,SelectionKey.OP_CONNECT,att);
|
channel.register(selector,SelectionKey.OP_CONNECT,att);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (change instanceof SocketChannel)
|
else if (change instanceof SocketChannel)
|
||||||
|
@ -482,7 +481,7 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa
|
||||||
// Newly registered channel
|
// Newly registered channel
|
||||||
final SocketChannel channel=(SocketChannel)change;
|
final SocketChannel channel=(SocketChannel)change;
|
||||||
ch=channel;
|
ch=channel;
|
||||||
key = channel.register(selector,SelectionKey.OP_READ,null);
|
SelectionKey key = channel.register(selector,SelectionKey.OP_READ,null);
|
||||||
SelectChannelEndPoint endpoint = createEndPoint(channel,key);
|
SelectChannelEndPoint endpoint = createEndPoint(channel,key);
|
||||||
key.attach(endpoint);
|
key.attach(endpoint);
|
||||||
}
|
}
|
||||||
|
@ -555,7 +554,7 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa
|
||||||
if (wait>0)
|
if (wait>0)
|
||||||
{
|
{
|
||||||
long before=now;
|
long before=now;
|
||||||
selected=selector.select(wait);
|
selector.select(wait);
|
||||||
now = System.currentTimeMillis();
|
now = System.currentTimeMillis();
|
||||||
_timeout.setNow(now);
|
_timeout.setNow(now);
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,7 @@ public class SslConnection extends AbstractAsyncConnection
|
||||||
static final Logger LOG = Log.getLogger("org.eclipse.jetty.io.ssl");
|
static final Logger LOG = Log.getLogger("org.eclipse.jetty.io.ssl");
|
||||||
|
|
||||||
private static final ByteBuffer __ZERO_BUFFER=BufferUtil.allocate(0);
|
private static final ByteBuffer __ZERO_BUFFER=BufferUtil.allocate(0);
|
||||||
private static final ThreadLocal<SslBuffers> __buffers = new ThreadLocal<SslBuffers>();
|
private static final ThreadLocal<SslBuffers> __buffers = new ThreadLocal<>();
|
||||||
|
|
||||||
private final Lock _lock = new ReentrantLock();
|
private final Lock _lock = new ReentrantLock();
|
||||||
private final IOFuture.Callback _netWriteCallback = new NetWriteCallback();
|
private final IOFuture.Callback _netWriteCallback = new NetWriteCallback();
|
||||||
|
@ -69,7 +69,6 @@ public class SslConnection extends AbstractAsyncConnection
|
||||||
private IOFuture _netWriteFuture;
|
private IOFuture _netWriteFuture;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private final class NetWriteCallback implements IOFuture.Callback
|
private final class NetWriteCallback implements IOFuture.Callback
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
|
@ -235,9 +234,6 @@ public class SslConnection extends AbstractAsyncConnection
|
||||||
_appConnection.onIdleExpired(idleForMs);
|
_appConnection.onIdleExpired(idleForMs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
long _last;
|
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
@Override
|
@Override
|
||||||
public void onReadable()
|
public void onReadable()
|
||||||
|
@ -245,7 +241,6 @@ public class SslConnection extends AbstractAsyncConnection
|
||||||
_lock.lock();
|
_lock.lock();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_last=System.currentTimeMillis();
|
|
||||||
LOG.debug("onReadable {}",this);
|
LOG.debug("onReadable {}",this);
|
||||||
|
|
||||||
_netReadFuture=null;
|
_netReadFuture=null;
|
||||||
|
@ -572,11 +567,6 @@ public class SslConnection extends AbstractAsyncConnection
|
||||||
return _engine;
|
return _engine;
|
||||||
}
|
}
|
||||||
|
|
||||||
public EndPoint getIoEndPoint()
|
|
||||||
{
|
|
||||||
return _endp;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void shutdownOutput() throws IOException
|
public void shutdownOutput() throws IOException
|
||||||
{
|
{
|
||||||
|
@ -745,11 +735,6 @@ public class SslConnection extends AbstractAsyncConnection
|
||||||
return _endp.getCreatedTimeStamp();
|
return _endp.getCreatedTimeStamp();
|
||||||
}
|
}
|
||||||
|
|
||||||
public AbstractAsyncConnection getAsyncConnection()
|
|
||||||
{
|
|
||||||
return _appConnection;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IOFuture readable() throws IllegalStateException
|
public IOFuture readable() throws IllegalStateException
|
||||||
{
|
{
|
||||||
|
|
|
@ -507,7 +507,7 @@ public class SelectChannelEndPointTest
|
||||||
server.configureBlocking(false);
|
server.configureBlocking(false);
|
||||||
|
|
||||||
_manager.register(server);
|
_manager.register(server);
|
||||||
int writes = 100000;
|
int writes = 1000;
|
||||||
|
|
||||||
final byte[] bytes="HelloWorld-".getBytes(StringUtil.__UTF8_CHARSET);
|
final byte[] bytes="HelloWorld-".getBytes(StringUtil.__UTF8_CHARSET);
|
||||||
byte[] count="0\n".getBytes(StringUtil.__UTF8_CHARSET);
|
byte[] count="0\n".getBytes(StringUtil.__UTF8_CHARSET);
|
||||||
|
|
|
@ -19,6 +19,7 @@ import java.io.PrintWriter;
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
import java.net.SocketTimeoutException;
|
import java.net.SocketTimeoutException;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
|
import java.sql.Connection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.servlet.DispatcherType;
|
import javax.servlet.DispatcherType;
|
||||||
|
@ -39,7 +40,7 @@ import org.eclipse.jetty.http.HttpStatus;
|
||||||
import org.eclipse.jetty.http.HttpURI;
|
import org.eclipse.jetty.http.HttpURI;
|
||||||
import org.eclipse.jetty.http.HttpVersion;
|
import org.eclipse.jetty.http.HttpVersion;
|
||||||
import org.eclipse.jetty.http.MimeTypes;
|
import org.eclipse.jetty.http.MimeTypes;
|
||||||
import org.eclipse.jetty.io.AsyncConnection;
|
import org.eclipse.jetty.io.EndPoint;
|
||||||
import org.eclipse.jetty.io.EofException;
|
import org.eclipse.jetty.io.EofException;
|
||||||
import org.eclipse.jetty.io.RuntimeIOException;
|
import org.eclipse.jetty.io.RuntimeIOException;
|
||||||
import org.eclipse.jetty.io.UncheckedPrintWriter;
|
import org.eclipse.jetty.io.UncheckedPrintWriter;
|
||||||
|
@ -75,7 +76,7 @@ public abstract class HttpChannel
|
||||||
private int _requests;
|
private int _requests;
|
||||||
|
|
||||||
private final Server _server;
|
private final Server _server;
|
||||||
private final AsyncConnection _connection;
|
private final EndPoint _endp;
|
||||||
private final HttpURI _uri;
|
private final HttpURI _uri;
|
||||||
|
|
||||||
private final HttpFields _requestFields;
|
private final HttpFields _requestFields;
|
||||||
|
@ -111,10 +112,10 @@ public abstract class HttpChannel
|
||||||
/** Constructor
|
/** Constructor
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public HttpChannel(Server server,AsyncConnection connection)
|
public HttpChannel(Server server,EndPoint endp)
|
||||||
{
|
{
|
||||||
_server = server;
|
_server = server;
|
||||||
_connection = connection;
|
_endp = endp;
|
||||||
_uri = new HttpURI(URIUtil.__CHARSET);
|
_uri = new HttpURI(URIUtil.__CHARSET);
|
||||||
_requestFields = new HttpFields();
|
_requestFields = new HttpFields();
|
||||||
_responseFields = new HttpFields(server.getMaxCookieVersion());
|
_responseFields = new HttpFields(server.getMaxCookieVersion());
|
||||||
|
@ -122,13 +123,7 @@ public abstract class HttpChannel
|
||||||
_response = new Response(this);
|
_response = new Response(this);
|
||||||
_async = _request.getAsyncContinuation();
|
_async = _request.getAsyncContinuation();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
|
||||||
public AsyncConnection getConnection()
|
|
||||||
{
|
|
||||||
return _connection;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
public HttpParser.RequestHandler getRequestHandler()
|
public HttpParser.RequestHandler getRequestHandler()
|
||||||
{
|
{
|
||||||
|
@ -201,13 +196,13 @@ public abstract class HttpChannel
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
public InetSocketAddress getLocalAddress()
|
public InetSocketAddress getLocalAddress()
|
||||||
{
|
{
|
||||||
return getConnection().getEndPoint().getLocalAddress();
|
return _endp.getLocalAddress();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
public InetSocketAddress getRemoteAddress()
|
public InetSocketAddress getRemoteAddress()
|
||||||
{
|
{
|
||||||
return getConnection().getEndPoint().getRemoteAddress();
|
return _endp.getRemoteAddress();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
|
|
|
@ -27,7 +27,6 @@ import org.eclipse.jetty.http.HttpGenerator.Action;
|
||||||
import org.eclipse.jetty.http.HttpParser;
|
import org.eclipse.jetty.http.HttpParser;
|
||||||
import org.eclipse.jetty.http.HttpStatus;
|
import org.eclipse.jetty.http.HttpStatus;
|
||||||
import org.eclipse.jetty.io.AbstractAsyncConnection;
|
import org.eclipse.jetty.io.AbstractAsyncConnection;
|
||||||
import org.eclipse.jetty.io.AsyncConnection;
|
|
||||||
import org.eclipse.jetty.io.AsyncEndPoint;
|
import org.eclipse.jetty.io.AsyncEndPoint;
|
||||||
import org.eclipse.jetty.io.CompletedIOFuture;
|
import org.eclipse.jetty.io.CompletedIOFuture;
|
||||||
import org.eclipse.jetty.io.EofException;
|
import org.eclipse.jetty.io.EofException;
|
||||||
|
@ -168,7 +167,7 @@ public class HttpConnection extends AbstractAsyncConnection
|
||||||
@Override
|
@Override
|
||||||
public void onReadable()
|
public void onReadable()
|
||||||
{
|
{
|
||||||
AsyncConnection connection = this;
|
AbstractAsyncConnection connection = this;
|
||||||
boolean progress=true;
|
boolean progress=true;
|
||||||
|
|
||||||
try
|
try
|
||||||
|
@ -226,7 +225,7 @@ public class HttpConnection extends AbstractAsyncConnection
|
||||||
// look for a switched connection instance?
|
// look for a switched connection instance?
|
||||||
if (_channel.getResponse().getStatus()==HttpStatus.SWITCHING_PROTOCOLS_101)
|
if (_channel.getResponse().getStatus()==HttpStatus.SWITCHING_PROTOCOLS_101)
|
||||||
{
|
{
|
||||||
AsyncConnection switched=(AsyncConnection)_channel.getRequest().getAttribute("org.eclipse.jetty.io.Connection");
|
AbstractAsyncConnection switched=(AbstractAsyncConnection)_channel.getRequest().getAttribute("org.eclipse.jetty.io.Connection");
|
||||||
if (switched!=null)
|
if (switched!=null)
|
||||||
connection=switched;
|
connection=switched;
|
||||||
}
|
}
|
||||||
|
@ -470,28 +469,6 @@ public class HttpConnection extends AbstractAsyncConnection
|
||||||
_channel.onClose();
|
_channel.onClose();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
|
||||||
@Override
|
|
||||||
public void onInputShutdown()
|
|
||||||
{
|
|
||||||
// If we don't have a committed response and we are not suspended
|
|
||||||
if (_generator.isIdle() && !_channel.getRequest().getAsyncContinuation().isSuspended())
|
|
||||||
{
|
|
||||||
// then no more can happen, so close.
|
|
||||||
try
|
|
||||||
{
|
|
||||||
_endp.close();
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
LOG.debug(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Make idle parser seek EOF
|
|
||||||
if (_parser.isIdle())
|
|
||||||
_parser.setPersistent(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
|
@ -500,7 +477,7 @@ public class HttpConnection extends AbstractAsyncConnection
|
||||||
{
|
{
|
||||||
private HttpOverHttpChannel(Server server)
|
private HttpOverHttpChannel(Server server)
|
||||||
{
|
{
|
||||||
super(server,HttpConnection.this);
|
super(server,getEndPoint());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -654,7 +631,7 @@ public class HttpConnection extends AbstractAsyncConnection
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Wait until we can read
|
// Wait until we can read
|
||||||
getEndPoint().read().block();
|
getEndPoint().readable().block();
|
||||||
|
|
||||||
// We will need a buffer to read into
|
// We will need a buffer to read into
|
||||||
if (_requestBuffer==null)
|
if (_requestBuffer==null)
|
||||||
|
|
Loading…
Reference in New Issue