jetty-9 more removal of AsyncConnection

This commit is contained in:
Greg Wilkins 2012-05-08 15:30:32 +02:00
parent dc02390449
commit 6d64bcd38a
6 changed files with 28 additions and 69 deletions

View File

@ -269,27 +269,29 @@ public class HttpGeneratorServerTest
if (chunks-->1)
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
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(chunk),
BufferUtil.toSummaryString(buffer),
BufferUtil.toSummaryString(content),
action,gen.getState());*/
action,gen.getState());
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,
BufferUtil.toSummaryString(header),
BufferUtil.toSummaryString(chunk),
BufferUtil.toSummaryString(buffer),
BufferUtil.toSummaryString(content),
action,gen.getState());*/
action,gen.getState());
switch(result)
{
@ -413,14 +415,15 @@ public class HttpGeneratorServerTest
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];
// System.err.println(t);
System.err.println("\n==========================================");
System.err.println(t);
gen.reset();
tr[r].getHttpFields().clear();
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)
{

View File

@ -447,7 +447,6 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa
while (changes-->0 && (change=_changes.poll())!=null)
{
Channel ch=null;
SelectionKey key=null;
try
{
@ -468,13 +467,13 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa
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);
key.attach(endpoint);
}
else if (channel.isOpen())
{
key = channel.register(selector,SelectionKey.OP_CONNECT,att);
channel.register(selector,SelectionKey.OP_CONNECT,att);
}
}
else if (change instanceof SocketChannel)
@ -482,7 +481,7 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa
// Newly registered channel
final SocketChannel channel=(SocketChannel)change;
ch=channel;
key = channel.register(selector,SelectionKey.OP_READ,null);
SelectionKey key = channel.register(selector,SelectionKey.OP_READ,null);
SelectChannelEndPoint endpoint = createEndPoint(channel,key);
key.attach(endpoint);
}
@ -555,7 +554,7 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa
if (wait>0)
{
long before=now;
selected=selector.select(wait);
selector.select(wait);
now = System.currentTimeMillis();
_timeout.setNow(now);

View File

@ -44,7 +44,7 @@ public class SslConnection extends AbstractAsyncConnection
static final Logger LOG = Log.getLogger("org.eclipse.jetty.io.ssl");
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 IOFuture.Callback _netWriteCallback = new NetWriteCallback();
@ -69,7 +69,6 @@ public class SslConnection extends AbstractAsyncConnection
private IOFuture _netWriteFuture;
private final class NetWriteCallback implements IOFuture.Callback
{
@Override
@ -235,9 +234,6 @@ public class SslConnection extends AbstractAsyncConnection
_appConnection.onIdleExpired(idleForMs);
}
long _last;
/* ------------------------------------------------------------ */
@Override
public void onReadable()
@ -245,7 +241,6 @@ public class SslConnection extends AbstractAsyncConnection
_lock.lock();
try
{
_last=System.currentTimeMillis();
LOG.debug("onReadable {}",this);
_netReadFuture=null;
@ -572,11 +567,6 @@ public class SslConnection extends AbstractAsyncConnection
return _engine;
}
public EndPoint getIoEndPoint()
{
return _endp;
}
@Override
public void shutdownOutput() throws IOException
{
@ -745,11 +735,6 @@ public class SslConnection extends AbstractAsyncConnection
return _endp.getCreatedTimeStamp();
}
public AbstractAsyncConnection getAsyncConnection()
{
return _appConnection;
}
@Override
public IOFuture readable() throws IllegalStateException
{

View File

@ -507,7 +507,7 @@ public class SelectChannelEndPointTest
server.configureBlocking(false);
_manager.register(server);
int writes = 100000;
int writes = 1000;
final byte[] bytes="HelloWorld-".getBytes(StringUtil.__UTF8_CHARSET);
byte[] count="0\n".getBytes(StringUtil.__UTF8_CHARSET);

View File

@ -19,6 +19,7 @@ import java.io.PrintWriter;
import java.net.InetSocketAddress;
import java.net.SocketTimeoutException;
import java.nio.ByteBuffer;
import java.sql.Connection;
import java.util.List;
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.HttpVersion;
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.RuntimeIOException;
import org.eclipse.jetty.io.UncheckedPrintWriter;
@ -75,7 +76,7 @@ public abstract class HttpChannel
private int _requests;
private final Server _server;
private final AsyncConnection _connection;
private final EndPoint _endp;
private final HttpURI _uri;
private final HttpFields _requestFields;
@ -111,10 +112,10 @@ public abstract class HttpChannel
/** Constructor
*
*/
public HttpChannel(Server server,AsyncConnection connection)
public HttpChannel(Server server,EndPoint endp)
{
_server = server;
_connection = connection;
_endp = endp;
_uri = new HttpURI(URIUtil.__CHARSET);
_requestFields = new HttpFields();
_responseFields = new HttpFields(server.getMaxCookieVersion());
@ -122,13 +123,7 @@ public abstract class HttpChannel
_response = new Response(this);
_async = _request.getAsyncContinuation();
}
/* ------------------------------------------------------------ */
public AsyncConnection getConnection()
{
return _connection;
}
/* ------------------------------------------------------------ */
public HttpParser.RequestHandler getRequestHandler()
{
@ -201,13 +196,13 @@ public abstract class HttpChannel
/* ------------------------------------------------------------ */
public InetSocketAddress getLocalAddress()
{
return getConnection().getEndPoint().getLocalAddress();
return _endp.getLocalAddress();
}
/* ------------------------------------------------------------ */
public InetSocketAddress getRemoteAddress()
{
return getConnection().getEndPoint().getRemoteAddress();
return _endp.getRemoteAddress();
}
/* ------------------------------------------------------------ */

View File

@ -27,7 +27,6 @@ import org.eclipse.jetty.http.HttpGenerator.Action;
import org.eclipse.jetty.http.HttpParser;
import org.eclipse.jetty.http.HttpStatus;
import org.eclipse.jetty.io.AbstractAsyncConnection;
import org.eclipse.jetty.io.AsyncConnection;
import org.eclipse.jetty.io.AsyncEndPoint;
import org.eclipse.jetty.io.CompletedIOFuture;
import org.eclipse.jetty.io.EofException;
@ -168,7 +167,7 @@ public class HttpConnection extends AbstractAsyncConnection
@Override
public void onReadable()
{
AsyncConnection connection = this;
AbstractAsyncConnection connection = this;
boolean progress=true;
try
@ -226,7 +225,7 @@ public class HttpConnection extends AbstractAsyncConnection
// look for a switched connection instance?
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)
connection=switched;
}
@ -470,28 +469,6 @@ public class HttpConnection extends AbstractAsyncConnection
_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)
{
super(server,HttpConnection.this);
super(server,getEndPoint());
}
@Override
@ -654,7 +631,7 @@ public class HttpConnection extends AbstractAsyncConnection
try
{
// Wait until we can read
getEndPoint().read().block();
getEndPoint().readable().block();
// We will need a buffer to read into
if (_requestBuffer==null)