Merge branch 'jetty-9' of ssh://git.eclipse.org/gitroot/jetty/org.eclipse.jetty.project into jetty-9
This commit is contained in:
commit
964fa9325a
|
@ -7,7 +7,7 @@ public abstract class AbstractEndPoint implements EndPoint
|
|||
private final long _created=System.currentTimeMillis();
|
||||
private final InetSocketAddress _local;
|
||||
private final InetSocketAddress _remote;
|
||||
private volatile int _maxIdleTime;
|
||||
private volatile long _maxIdleTime;
|
||||
private volatile long _idleTimestamp=System.currentTimeMillis();
|
||||
|
||||
|
||||
|
@ -25,13 +25,13 @@ public abstract class AbstractEndPoint implements EndPoint
|
|||
|
||||
|
||||
@Override
|
||||
public int getMaxIdleTime()
|
||||
public long getMaxIdleTime()
|
||||
{
|
||||
return _maxIdleTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMaxIdleTime(int timeMs)
|
||||
public void setMaxIdleTime(long timeMs)
|
||||
{
|
||||
_maxIdleTime=timeMs;
|
||||
}
|
||||
|
@ -62,11 +62,6 @@ public abstract class AbstractEndPoint implements EndPoint
|
|||
_idleTimestamp=System.currentTimeMillis();
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public void onClose()
|
||||
{
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
@Override
|
||||
public String toString()
|
||||
|
|
|
@ -146,11 +146,15 @@ public class AsyncByteArrayEndPoint extends ByteArrayEndPoint implements AsyncEn
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onOpen()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClose()
|
||||
{
|
||||
_checkTimeout.cancel();
|
||||
super.onClose();
|
||||
}
|
||||
|
||||
private static class TimeoutTask extends TimerTask
|
||||
|
|
|
@ -103,6 +103,7 @@ public interface AsyncEndPoint extends EndPoint
|
|||
|
||||
void setAsyncConnection(AsyncConnection connection);
|
||||
|
||||
void onClose();
|
||||
void onOpen();
|
||||
|
||||
void onClose();
|
||||
}
|
||||
|
|
|
@ -116,13 +116,13 @@ public interface EndPoint
|
|||
* extraordinary handling takes place.
|
||||
* @return the max idle time in ms or if ms <= 0 implies an infinite timeout
|
||||
*/
|
||||
int getMaxIdleTime();
|
||||
long getMaxIdleTime();
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/** Set the max idle time.
|
||||
* @param timeMs the max idle time in MS. Timeout <= 0 implies an infinite timeout
|
||||
*/
|
||||
void setMaxIdleTime(int timeMs);
|
||||
void setMaxIdleTime(long timeMs);
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -73,7 +73,7 @@ public class SelectChannelEndPoint extends ChannelEndPoint implements Runnable,
|
|||
};
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public SelectChannelEndPoint(SocketChannel channel, ManagedSelector selectSet, SelectionKey key, int maxIdleTime) throws IOException
|
||||
public SelectChannelEndPoint(SocketChannel channel, ManagedSelector selectSet, SelectionKey key, long maxIdleTime) throws IOException
|
||||
{
|
||||
super(channel);
|
||||
_manager = selectSet.getManager();
|
||||
|
@ -327,6 +327,11 @@ public class SelectChannelEndPoint extends ChannelEndPoint implements Runnable,
|
|||
updateKey();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onOpen()
|
||||
{
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
@Override
|
||||
public void onClose()
|
||||
|
|
|
@ -51,6 +51,7 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa
|
|||
|
||||
private final ManagedSelector[] _selectSets;
|
||||
private long _selectSetIndex;
|
||||
private volatile long _maxIdleTime;
|
||||
|
||||
protected SelectorManager()
|
||||
{
|
||||
|
@ -62,11 +63,18 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa
|
|||
this._selectSets = new ManagedSelector[selectors];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return the max idle time
|
||||
*/
|
||||
protected abstract int getMaxIdleTime();
|
||||
protected long getMaxIdleTime()
|
||||
{
|
||||
return _maxIdleTime;
|
||||
}
|
||||
|
||||
public void setMaxIdleTime(long maxIdleTime)
|
||||
{
|
||||
_maxIdleTime = maxIdleTime;
|
||||
}
|
||||
|
||||
protected abstract void execute(Runnable task);
|
||||
|
||||
|
@ -139,18 +147,27 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa
|
|||
/**
|
||||
* @param endpoint the endPoint being opened
|
||||
*/
|
||||
protected abstract void endPointOpened(AsyncEndPoint endpoint);
|
||||
protected void endPointOpened(AsyncEndPoint endpoint)
|
||||
{
|
||||
endpoint.getAsyncConnection().onOpen();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param endpoint the endPoint being closed
|
||||
*/
|
||||
protected abstract void endPointClosed(AsyncEndPoint endpoint);
|
||||
protected void endPointClosed(AsyncEndPoint endpoint)
|
||||
{
|
||||
endpoint.getAsyncConnection().onClose();
|
||||
endpoint.onClose();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param endpoint the endPoint being upgraded
|
||||
* @param oldConnection the previous connection
|
||||
*/
|
||||
protected abstract void endPointUpgraded(AsyncEndPoint endpoint,AsyncConnection oldConnection);
|
||||
protected void endPointUpgraded(AsyncEndPoint endpoint, AsyncConnection oldConnection)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param channel the socket channel
|
||||
|
|
|
@ -1,11 +1,5 @@
|
|||
package org.eclipse.jetty.io;
|
||||
|
||||
import static org.hamcrest.Matchers.greaterThan;
|
||||
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.IOException;
|
||||
|
@ -30,42 +24,25 @@ import org.junit.Assert;
|
|||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.hamcrest.Matchers.greaterThan;
|
||||
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class SelectChannelEndPointTest
|
||||
{
|
||||
protected volatile AsyncEndPoint _lastEndp;
|
||||
protected ServerSocketChannel _connector;
|
||||
protected QueuedThreadPool _threadPool = new QueuedThreadPool();
|
||||
private int maxIdleTimeout = 600000; // TODO: use smaller value
|
||||
protected SelectorManager _manager = new SelectorManager()
|
||||
{
|
||||
@Override
|
||||
protected int getMaxIdleTime()
|
||||
{
|
||||
return maxIdleTimeout;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void execute(Runnable task)
|
||||
{
|
||||
_threadPool.execute(task);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void endPointClosed(AsyncEndPoint endpoint)
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void endPointOpened(AsyncEndPoint endpoint)
|
||||
{
|
||||
endpoint.getAsyncConnection().onOpen();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void endPointUpgraded(AsyncEndPoint endpoint, AsyncConnection oldConnection)
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public AsyncConnection newConnection(SocketChannel channel, AsyncEndPoint endpoint, Object attachment)
|
||||
{
|
||||
|
@ -81,6 +58,9 @@ public class SelectChannelEndPointTest
|
|||
return endp;
|
||||
}
|
||||
};
|
||||
{
|
||||
_manager.setMaxIdleTime(600000); // TODO: use smaller value
|
||||
}
|
||||
|
||||
// Must be volatile or the test may fail spuriously
|
||||
protected volatile int _blockAt=0;
|
||||
|
|
|
@ -7,7 +7,6 @@ import java.nio.ByteBuffer;
|
|||
import java.nio.channels.SelectionKey;
|
||||
import java.nio.channels.ServerSocketChannel;
|
||||
import java.nio.channels.SocketChannel;
|
||||
|
||||
import javax.net.ssl.SSLEngine;
|
||||
import javax.net.ssl.SSLSocket;
|
||||
|
||||
|
@ -32,38 +31,14 @@ public class SslConnectionTest
|
|||
protected volatile AsyncEndPoint _lastEndp;
|
||||
protected ServerSocketChannel _connector;
|
||||
protected QueuedThreadPool _threadPool = new QueuedThreadPool();
|
||||
private int maxIdleTimeout = 600000; // TODO: use smaller value
|
||||
protected SelectorManager _manager = new SelectorManager()
|
||||
{
|
||||
@Override
|
||||
protected int getMaxIdleTime()
|
||||
{
|
||||
return maxIdleTimeout;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void execute(Runnable task)
|
||||
{
|
||||
_threadPool.execute(task);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void endPointClosed(AsyncEndPoint endpoint)
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void endPointOpened(AsyncEndPoint endpoint)
|
||||
{
|
||||
// System.err.println("endPointOpened");
|
||||
endpoint.getAsyncConnection().onOpen();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void endPointUpgraded(AsyncEndPoint endpoint, AsyncConnection oldConnection)
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public AsyncConnection newConnection(SocketChannel channel, AsyncEndPoint endpoint, Object attachment)
|
||||
{
|
||||
|
@ -89,6 +64,9 @@ public class SslConnectionTest
|
|||
return endp;
|
||||
}
|
||||
};
|
||||
{
|
||||
_manager.setMaxIdleTime(600000); // TODO: use smaller value
|
||||
}
|
||||
|
||||
// Must be volatile or the test may fail spuriously
|
||||
protected volatile int _blockAt=0;
|
||||
|
|
|
@ -191,7 +191,7 @@ public abstract class AbstractConnector extends AggregateLifeCycle implements Co
|
|||
* @return Returns the maxIdleTime.
|
||||
*/
|
||||
@Override
|
||||
public int getMaxIdleTime()
|
||||
public long getMaxIdleTime()
|
||||
{
|
||||
return _maxIdleTime;
|
||||
}
|
||||
|
@ -437,8 +437,6 @@ public abstract class AbstractConnector extends AggregateLifeCycle implements Co
|
|||
/* ------------------------------------------------------------ */
|
||||
protected void connectionOpened(AsyncConnection connection)
|
||||
{
|
||||
// TODO: should we dispatch the call to onOpen() to another thread ?
|
||||
connection.onOpen();
|
||||
_stats.connectionOpened();
|
||||
}
|
||||
|
||||
|
@ -453,9 +451,6 @@ public abstract class AbstractConnector extends AggregateLifeCycle implements Co
|
|||
/* ------------------------------------------------------------ */
|
||||
protected void connectionClosed(AsyncConnection connection)
|
||||
{
|
||||
// TODO: should we dispatch the call to onClose() to another thread ?
|
||||
connection.onClose();
|
||||
|
||||
long duration = System.currentTimeMillis() - connection.getEndPoint().getCreatedTimeStamp();
|
||||
// TODO: remove casts to HttpConnection
|
||||
int requests = (connection instanceof HttpConnection)?((HttpConnection)connection).getHttpChannel().getRequests():0;
|
||||
|
|
|
@ -54,7 +54,7 @@ public interface Connector extends LifeCycle
|
|||
/**
|
||||
* @return Max Idle time for connections in milliseconds
|
||||
*/
|
||||
int getMaxIdleTime();
|
||||
long getMaxIdleTime();
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
|
|
|
@ -204,7 +204,6 @@ public class LocalHttpConnector extends HttpConnector
|
|||
public void onClose()
|
||||
{
|
||||
super.onClose();
|
||||
connectionClosed(getAsyncConnection());
|
||||
_closed.countDown();
|
||||
}
|
||||
|
||||
|
|
|
@ -210,7 +210,6 @@ public class SelectChannelConnector extends HttpConnector implements NetConnecto
|
|||
/* ------------------------------------------------------------------------------- */
|
||||
protected void endPointClosed(AsyncEndPoint endpoint)
|
||||
{
|
||||
endpoint.onClose();
|
||||
connectionClosed(endpoint.getAsyncConnection());
|
||||
}
|
||||
|
||||
|
@ -238,7 +237,7 @@ public class SelectChannelConnector extends HttpConnector implements NetConnecto
|
|||
}
|
||||
|
||||
@Override
|
||||
protected int getMaxIdleTime()
|
||||
protected long getMaxIdleTime()
|
||||
{
|
||||
return SelectChannelConnector.this.getMaxIdleTime();
|
||||
}
|
||||
|
@ -246,6 +245,7 @@ public class SelectChannelConnector extends HttpConnector implements NetConnecto
|
|||
@Override
|
||||
protected void endPointClosed(AsyncEndPoint endpoint)
|
||||
{
|
||||
super.endPointClosed(endpoint);
|
||||
SelectChannelConnector.this.endPointClosed(endpoint);
|
||||
}
|
||||
|
||||
|
@ -253,6 +253,7 @@ public class SelectChannelConnector extends HttpConnector implements NetConnecto
|
|||
protected void endPointOpened(AsyncEndPoint endpoint)
|
||||
{
|
||||
// TODO handle max connections and low resources
|
||||
super.endPointOpened(endpoint);
|
||||
connectionOpened(endpoint.getAsyncConnection());
|
||||
}
|
||||
|
||||
|
|
|
@ -287,22 +287,6 @@ public class SPDYClient
|
|||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void endPointOpened(AsyncEndPoint endpoint)
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void endPointUpgraded(AsyncEndPoint endpoint, AsyncConnection oldConnection)
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void endPointClosed(AsyncEndPoint endpoint)
|
||||
{
|
||||
endpoint.getAsyncConnection().onClose();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AsyncConnection newConnection(final SocketChannel channel, AsyncEndPoint endPoint, Object attachment)
|
||||
{
|
||||
|
|
|
@ -21,7 +21,6 @@ import java.nio.channels.SocketChannel;
|
|||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import javax.net.ssl.SSLEngine;
|
||||
import javax.net.ssl.SSLException;
|
||||
|
||||
|
@ -51,36 +50,12 @@ public class WebSocketClientSelectorManager extends SelectorManager
|
|||
this.executor = executor;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void endPointClosed(AsyncEndPoint endpoint)
|
||||
{
|
||||
endpoint.getAsyncConnection().onClose();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void endPointOpened(AsyncEndPoint endpoint)
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void endPointUpgraded(AsyncEndPoint endpoint, AsyncConnection oldConnection)
|
||||
{
|
||||
// TODO Investigate role of this with websocket
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void execute(Runnable task)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getMaxIdleTime()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public SslContextFactory getSslContextFactory()
|
||||
{
|
||||
return sslContextFactory;
|
||||
|
|
Loading…
Reference in New Issue