jetty-9 reworked the schedulers

This commit is contained in:
Greg Wilkins 2012-08-31 13:22:58 +10:00
parent 72827aa44d
commit 83dbca6553
169 changed files with 1427 additions and 542 deletions

View File

@ -41,7 +41,6 @@ public class ManyConnectors
SelectChannelConnector connector1 = new SelectChannelConnector(server);
connector1.setHost("127.0.0.1");
connector1.setPort(8888);
connector1.setName("admin");
String jetty_home = System.getProperty("jetty.home","../jetty-distribution/target/distribution");
System.setProperty("jetty.home", jetty_home);

View File

@ -72,7 +72,7 @@ public class HttpParser
private boolean _host;
/* ------------------------------------------------------------------------------- */
private State _state=State.START;
private volatile State _state=State.START;
private HttpMethod _method;
private String _methodString;
private HttpVersion _version;
@ -217,7 +217,7 @@ public class HttpParser
{
_methodString = _method.asString();
buffer.position(buffer.position()+_methodString.length()+1);
_state=State.SPACE1;
setState(State.SPACE1);
return;
}
}
@ -227,7 +227,7 @@ public class HttpParser
if (_version!=null)
{
buffer.position(buffer.position()+_version.asString().length()+1);
_state=State.SPACE1;
setState(State.SPACE1);
return;
}
}
@ -245,7 +245,7 @@ public class HttpParser
{
_string.setLength(0);
_string.append((char)ch);
_state=_requestHandler!=null?State.METHOD:State.RESPONSE_VERSION;
setState(_requestHandler!=null?State.METHOD:State.RESPONSE_VERSION);
return;
}
}
@ -314,7 +314,7 @@ public class HttpParser
HttpMethod method=HttpMethod.CACHE.get(_methodString);
if (method!=null)
_methodString=method.asString();
_state=State.SPACE1;
setState(State.SPACE1);
}
else if (ch < HttpTokens.SPACE && ch>=0)
{
@ -335,7 +335,7 @@ public class HttpParser
badMessage(buffer,HttpStatus.BAD_REQUEST_400,"Unknown Version");
return true;
}
_state=State.SPACE1;
setState(State.SPACE1);
}
else if (ch < HttpTokens.SPACE && ch>=0)
{
@ -351,12 +351,12 @@ public class HttpParser
{
if (_responseHandler!=null)
{
_state=State.STATUS;
setState(State.STATUS);
_responseStatus=ch-'0';
}
else
{
_state=State.URI;
setState(State.URI);
_utf8.reset();
_utf8.append(ch);
}
@ -371,7 +371,7 @@ public class HttpParser
case STATUS:
if (ch == HttpTokens.SPACE)
{
_state=State.SPACE2;
setState(State.SPACE2);
}
else if (ch>='0' && ch<='9')
{
@ -381,7 +381,7 @@ public class HttpParser
{
return_from_parse|=_responseHandler.startResponse(_version, _responseStatus, null);
_eol=ch;
_state=State.HEADER;
setState(State.HEADER);
}
else
{
@ -394,7 +394,7 @@ public class HttpParser
{
_uri=_utf8.toString();
_utf8.reset();
_state=State.SPACE2;
setState(State.SPACE2);
}
else if (ch < HttpTokens.SPACE && ch>=0)
{
@ -402,7 +402,7 @@ public class HttpParser
_uri=_utf8.toString();
_utf8.reset();
return_from_parse|=_requestHandler.startRequest(_method,_methodString,_uri,null);
_state=State.END;
setState(State.END);
BufferUtil.clear(buffer);
return_from_parse|=_handler.headerComplete();
return_from_parse|=_handler.messageComplete(_contentPosition);
@ -419,11 +419,11 @@ public class HttpParser
if (_responseHandler!=null)
{
_length=1;
_state=State.REASON;
setState(State.REASON);
}
else
{
_state=State.REQUEST_VERSION;
setState(State.REQUEST_VERSION);
// try quick look ahead
if (buffer.position()>0 && buffer.hasArray())
@ -434,7 +434,7 @@ public class HttpParser
_string.setLength(0);
buffer.position(buffer.position()+_version.asString().length()-1);
_eol=buffer.get();
_state=State.HEADER;
setState(State.HEADER);
return_from_parse|=_requestHandler.startRequest(_method,_methodString, _uri, _version);
}
}
@ -446,13 +446,13 @@ public class HttpParser
{
return_from_parse|=_responseHandler.startResponse(_version, _responseStatus, null);
_eol=ch;
_state=State.HEADER;
setState(State.HEADER);
}
else
{
// HTTP/0.9
return_from_parse|=_requestHandler.startRequest(_method,_methodString, _uri, null);
_state=State.END;
setState(State.END);
BufferUtil.clear(buffer);
return_from_parse|=_handler.headerComplete();
return_from_parse|=_handler.messageComplete(_contentPosition);
@ -472,7 +472,7 @@ public class HttpParser
}
_eol=ch;
_state=State.HEADER;
setState(State.HEADER);
return_from_parse|=_requestHandler.startRequest(_method,_methodString, _uri, _version);
continue;
}
@ -487,7 +487,7 @@ public class HttpParser
String reason=takeLengthString();
_eol=ch;
_state=State.HEADER;
setState(State.HEADER);
return_from_parse|=_responseHandler.startResponse(_version, _responseStatus, reason);
continue;
}
@ -547,7 +547,7 @@ public class HttpParser
// header value without name - continuation?
_length=-1;
_string.setLength(0);
_state=State.HEADER_VALUE;
setState(State.HEADER_VALUE);
break;
}
@ -673,23 +673,23 @@ public class HttpParser
switch (_endOfContent)
{
case EOF_CONTENT:
_state=State.EOF_CONTENT;
setState(State.EOF_CONTENT);
return_from_parse|=_handler.headerComplete();
break;
case CHUNKED_CONTENT:
_state=State.CHUNKED_CONTENT;
setState(State.CHUNKED_CONTENT);
return_from_parse|=_handler.headerComplete();
break;
case NO_CONTENT:
return_from_parse|=_handler.headerComplete();
_state=State.END;
setState(State.END);
return_from_parse|=_handler.messageComplete(_contentPosition);
break;
default:
_state=State.CONTENT;
setState(State.CONTENT);
return_from_parse|=_handler.headerComplete();
break;
}
@ -705,13 +705,13 @@ public class HttpParser
{
_headerString=_header.asString();
buffer.position(buffer.position()+_headerString.length());
_state=buffer.get(buffer.position()-1)==':'?State.HEADER_VALUE:State.HEADER_NAME;
setState(buffer.get(buffer.position()-1)==':'?State.HEADER_VALUE:State.HEADER_NAME);
break;
}
}
// New header
_state=State.HEADER_NAME;
setState(State.HEADER_NAME);
_string.setLength(0);
_string.append((char)ch);
_length=1;
@ -729,7 +729,7 @@ public class HttpParser
consumeCRLF(ch,buffer);
_headerString=takeLengthString();
_header=HttpHeader.CACHE.get(_headerString);
_state=State.HEADER;
setState(State.HEADER);
break;
@ -739,7 +739,7 @@ public class HttpParser
_headerString=takeLengthString();
_header=HttpHeader.CACHE.get(_headerString);
}
_state=State.HEADER_VALUE;
setState(State.HEADER_VALUE);
break;
case HttpTokens.SPACE:
case HttpTokens.TAB:
@ -758,7 +758,7 @@ public class HttpParser
}
_string.append((char)ch);
_length=_string.length();
_state=State.HEADER_IN_NAME;
setState(State.HEADER_IN_NAME);
}
}
@ -773,7 +773,7 @@ public class HttpParser
_headerString=takeString();
_length=-1;
_header=HttpHeader.CACHE.get(_headerString);
_state=State.HEADER;
setState(State.HEADER);
break;
case HttpTokens.COLON:
@ -783,11 +783,11 @@ public class HttpParser
_header=HttpHeader.CACHE.get(_headerString);
}
_length=-1;
_state=State.HEADER_VALUE;
setState(State.HEADER_VALUE);
break;
case HttpTokens.SPACE:
case HttpTokens.TAB:
_state=State.HEADER_NAME;
setState(State.HEADER_NAME);
_string.append((char)ch);
break;
default:
@ -821,7 +821,7 @@ public class HttpParser
_valueString=takeLengthString();
}
}
_state=State.HEADER;
setState(State.HEADER);
break;
case HttpTokens.SPACE:
case HttpTokens.TAB:
@ -830,7 +830,7 @@ public class HttpParser
{
_string.append((char)ch);
_length=_string.length();
_state=State.HEADER_IN_VALUE;
setState(State.HEADER_IN_VALUE);
}
}
break;
@ -861,12 +861,12 @@ public class HttpParser
}
_length=-1;
}
_state=State.HEADER;
setState(State.HEADER);
break;
case HttpTokens.SPACE:
case HttpTokens.TAB:
_string.append((char)ch);
_state=State.HEADER_VALUE;
setState(State.HEADER_VALUE);
break;
default:
_string.append((char)ch);
@ -919,7 +919,7 @@ public class HttpParser
case CONTENT:
if (_contentPosition==_contentLength)
{
_state=State.END;
setState(State.END);
if(_handler.messageComplete(_contentPosition))
return true;
}
@ -936,7 +936,7 @@ public class HttpParser
{
String chars = BufferUtil.toDetailString(buffer);
BufferUtil.clear(buffer);
throw new IllegalStateException(this+" Extra data after oshut: "+chars);
throw new IllegalStateException(this+" data when CLOSED: "+chars);
}
BufferUtil.clear(buffer);
}
@ -955,7 +955,7 @@ public class HttpParser
// Handle HEAD response
if (_responseStatus>0 && _headResponse)
{
_state=State.END;
setState(State.END);
if (_handler.messageComplete(_contentLength))
return true;
}
@ -987,7 +987,7 @@ public class HttpParser
long remaining=_contentLength - _contentPosition;
if (remaining == 0)
{
_state=State.END;
setState(State.END);
if (_handler.messageComplete(_contentPosition))
return true;
}
@ -1011,7 +1011,7 @@ public class HttpParser
if(_contentPosition == _contentLength)
{
_state=State.END;
setState(State.END);
if (_handler.messageComplete(_contentPosition))
return true;
}
@ -1030,7 +1030,7 @@ public class HttpParser
{
_chunkLength=0;
_chunkPosition=0;
_state=State.CHUNK_SIZE;
setState(State.CHUNK_SIZE);
}
break;
}
@ -1046,15 +1046,15 @@ public class HttpParser
{
if (_eol==HttpTokens.CARRIAGE_RETURN && buffer.hasRemaining() && buffer.get(buffer.position())==HttpTokens.LINE_FEED)
_eol=buffer.get();
_state=State.END;
setState(State.END);
if (_handler.messageComplete(_contentPosition))
return true;
}
else
_state=State.CHUNK;
setState(State.CHUNK);
}
else if (ch <= HttpTokens.SPACE || ch == HttpTokens.SEMI_COLON)
_state=State.CHUNK_PARAMS;
setState(State.CHUNK_PARAMS);
else if (ch >= '0' && ch <= '9')
_chunkLength=_chunkLength * 16 + (ch - '0');
else if (ch >= 'a' && ch <= 'f')
@ -1076,12 +1076,12 @@ public class HttpParser
{
if (_eol==HttpTokens.CARRIAGE_RETURN && buffer.hasRemaining() && buffer.get(buffer.position())==HttpTokens.LINE_FEED)
_eol=buffer.get();
_state=State.END;
setState(State.END);
if (_handler.messageComplete(_contentPosition))
return true;
}
else
_state=State.CHUNK;
setState(State.CHUNK);
}
break;
}
@ -1091,7 +1091,7 @@ public class HttpParser
int remaining=_chunkLength - _chunkPosition;
if (remaining == 0)
{
_state=State.CHUNKED_CONTENT;
setState(State.CHUNKED_CONTENT);
}
else
{
@ -1136,7 +1136,7 @@ public class HttpParser
private void badMessage(ByteBuffer buffer, int status, String reason)
{
BufferUtil.clear(buffer);
_state=State.CLOSED;
setState(State.CLOSED);
_handler.badMessage(status, reason);
}
@ -1150,12 +1150,15 @@ public class HttpParser
break;
case EOF_CONTENT:
_state=State.END;
setState(State.END);
_handler.messageComplete(_contentPosition);
break;
case CLOSED:
break;
default:
_state=State.END;
setState(State.END);
if (!_headResponse)
_handler.earlyEOF();
_handler.messageComplete(_contentPosition);
@ -1176,7 +1179,7 @@ public class HttpParser
default:
LOG.warn("Closing {}",this);
}
_state=State.CLOSED;
setState(State.CLOSED);
_endOfContent=EndOfContent.UNKNOWN_CONTENT;
_contentPosition=0;
_responseStatus=0;
@ -1188,7 +1191,7 @@ public class HttpParser
public void reset()
{
// reset state
_state=State.START;
setState(State.START);
_endOfContent=EndOfContent.UNKNOWN_CONTENT;
_contentPosition=0;
_responseStatus=0;
@ -1198,10 +1201,11 @@ public class HttpParser
}
/* ------------------------------------------------------------------------------- */
public void setState(State state)
private void setState(State state)
{
this._state=state;
_endOfContent=EndOfContent.UNKNOWN_CONTENT;
if (_state==State.CLOSED && state==State.END)
new Throwable().printStackTrace();
_state=state;
}
/* ------------------------------------------------------------------------------- */

View File

@ -21,8 +21,6 @@ package org.eclipse.jetty.io;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.nio.ByteBuffer;
import java.util.concurrent.Future;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicReference;
@ -30,6 +28,7 @@ import java.util.concurrent.atomic.AtomicReference;
import org.eclipse.jetty.util.Callback;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.util.thread.Scheduler;
public abstract class AbstractEndPoint implements EndPoint
{
@ -38,8 +37,8 @@ public abstract class AbstractEndPoint implements EndPoint
private final InetSocketAddress _local;
private final InetSocketAddress _remote;
private final ScheduledExecutorService _scheduler;
private final AtomicReference<Future<?>> _timeout = new AtomicReference<>();
private final Scheduler _scheduler;
private final AtomicReference<Scheduler.Task> _timeout = new AtomicReference<>();
private final Runnable _idleTask = new Runnable()
{
@Override
@ -73,7 +72,7 @@ public abstract class AbstractEndPoint implements EndPoint
}
};
protected AbstractEndPoint(ScheduledExecutorService scheduler,InetSocketAddress local,InetSocketAddress remote)
protected AbstractEndPoint(Scheduler scheduler,InetSocketAddress local,InetSocketAddress remote)
{
_local=local;
_remote=remote;
@ -176,12 +175,12 @@ public abstract class AbstractEndPoint implements EndPoint
protected void scheduleIdleTimeout(long delay)
{
Future<?> newTimeout = null;
Scheduler.Task newTimeout = null;
if (isOpen() && delay > 0 && _scheduler!=null)
newTimeout = _scheduler.schedule(_idleTask, delay, TimeUnit.MILLISECONDS);
Future<?> oldTimeout = _timeout.getAndSet(newTimeout);
Scheduler.Task oldTimeout = _timeout.getAndSet(newTimeout);
if (oldTimeout != null)
oldTimeout.cancel(false);
oldTimeout.cancel();
}
protected long checkIdleTimeout()

View File

@ -21,7 +21,6 @@ package org.eclipse.jetty.io;
import java.nio.ByteBuffer;
import java.util.Queue;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.ConcurrentMap;
import org.eclipse.jetty.util.BufferUtil;

View File

@ -23,12 +23,12 @@ import java.net.InetSocketAddress;
import java.nio.ByteBuffer;
import java.nio.channels.ClosedChannelException;
import java.nio.charset.Charset;
import java.util.concurrent.ScheduledExecutorService;
import org.eclipse.jetty.util.BufferUtil;
import org.eclipse.jetty.util.StringUtil;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.util.thread.Scheduler;
/* ------------------------------------------------------------ */
@ -76,25 +76,25 @@ public class ByteArrayEndPoint extends AbstractEndPoint
}
/* ------------------------------------------------------------ */
public ByteArrayEndPoint(ScheduledExecutorService timer, long idleTimeoutMs)
public ByteArrayEndPoint(Scheduler scheduler, long idleTimeoutMs)
{
this(timer,idleTimeoutMs,null,null);
this(scheduler,idleTimeoutMs,null,null);
}
/* ------------------------------------------------------------ */
public ByteArrayEndPoint(ScheduledExecutorService timer, long idleTimeoutMs, byte[] input, int outputSize)
public ByteArrayEndPoint(Scheduler timer, long idleTimeoutMs, byte[] input, int outputSize)
{
this(timer,idleTimeoutMs,input!=null?BufferUtil.toBuffer(input):null,BufferUtil.allocate(outputSize));
}
/* ------------------------------------------------------------ */
public ByteArrayEndPoint(ScheduledExecutorService timer, long idleTimeoutMs, String input, int outputSize)
public ByteArrayEndPoint(Scheduler timer, long idleTimeoutMs, String input, int outputSize)
{
this(timer,idleTimeoutMs,input!=null?BufferUtil.toBuffer(input):null,BufferUtil.allocate(outputSize));
}
/* ------------------------------------------------------------ */
public ByteArrayEndPoint(ScheduledExecutorService timer, long idleTimeoutMs, ByteBuffer input, ByteBuffer output)
public ByteArrayEndPoint(Scheduler timer, long idleTimeoutMs, ByteBuffer input, ByteBuffer output)
{
super(timer,NOIP,NOIP);
_in=input==null?BufferUtil.EMPTY_BUFFER:input;

View File

@ -28,11 +28,11 @@ import java.nio.channels.ByteChannel;
import java.nio.channels.ClosedChannelException;
import java.nio.channels.GatheringByteChannel;
import java.nio.channels.SocketChannel;
import java.util.concurrent.ScheduledExecutorService;
import org.eclipse.jetty.util.BufferUtil;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.util.thread.Scheduler;
/**
* Channel End Point.
@ -47,7 +47,7 @@ public class ChannelEndPoint extends AbstractEndPoint
private volatile boolean _ishut;
private volatile boolean _oshut;
public ChannelEndPoint(ScheduledExecutorService scheduler,SocketChannel channel) throws IOException
public ChannelEndPoint(Scheduler scheduler,SocketChannel channel) throws IOException
{
super(scheduler,
(InetSocketAddress)channel.socket().getLocalSocketAddress(),

View File

@ -23,10 +23,10 @@ import java.nio.ByteBuffer;
import java.nio.channels.SelectionKey;
import java.nio.channels.SocketChannel;
import java.util.List;
import java.util.concurrent.ScheduledExecutorService;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.util.thread.Scheduler;
public class NetworkTrafficSelectChannelEndPoint extends SelectChannelEndPoint
{
@ -34,7 +34,7 @@ public class NetworkTrafficSelectChannelEndPoint extends SelectChannelEndPoint
private final List<NetworkTrafficListener> listeners;
public NetworkTrafficSelectChannelEndPoint(SocketChannel channel, SelectorManager.ManagedSelector selectSet, SelectionKey key, ScheduledExecutorService scheduler, long idleTimeout, List<NetworkTrafficListener> listeners) throws IOException
public NetworkTrafficSelectChannelEndPoint(SocketChannel channel, SelectorManager.ManagedSelector selectSet, SelectionKey key, Scheduler scheduler, long idleTimeout, List<NetworkTrafficListener> listeners) throws IOException
{
super(channel, selectSet, key, scheduler, idleTimeout);
this.listeners = listeners;

View File

@ -22,12 +22,12 @@ import java.io.IOException;
import java.nio.channels.CancelledKeyException;
import java.nio.channels.SelectionKey;
import java.nio.channels.SocketChannel;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.atomic.AtomicBoolean;
import org.eclipse.jetty.io.SelectorManager.ManagedSelector;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.util.thread.Scheduler;
/**
* An ChannelEndpoint that can be scheduled by {@link SelectorManager}.
@ -75,7 +75,7 @@ public class SelectChannelEndPoint extends ChannelEndPoint implements SelectorMa
*/
private volatile int _interestOps;
public SelectChannelEndPoint(SocketChannel channel, ManagedSelector selector, SelectionKey key, ScheduledExecutorService scheduler, long idleTimeout) throws IOException
public SelectChannelEndPoint(SocketChannel channel, ManagedSelector selector, SelectionKey key, Scheduler scheduler, long idleTimeout) throws IOException
{
super(scheduler,channel);
_selector = selector;

View File

@ -22,6 +22,7 @@ import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.Arrays;
import java.util.concurrent.Executor;
import javax.net.ssl.SSLEngine;
import javax.net.ssl.SSLEngineResult;
import javax.net.ssl.SSLEngineResult.HandshakeStatus;

View File

@ -18,16 +18,16 @@
package org.eclipse.jetty.io;
import java.nio.ByteBuffer;
import org.hamcrest.Matchers;
import org.junit.Test;
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import java.nio.ByteBuffer;
import org.hamcrest.Matchers;
import org.junit.Test;
public class ArrayByteBufferPoolTest
{
@Test

View File

@ -18,22 +18,6 @@
package org.eclipse.jetty.io;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeoutException;
import org.eclipse.jetty.toolchain.test.AdvancedRunner;
import org.eclipse.jetty.toolchain.test.annotation.Slow;
import org.eclipse.jetty.util.BufferUtil;
import org.eclipse.jetty.util.FutureCallback;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import static junit.framework.Assert.assertEquals;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.greaterThan;
@ -43,21 +27,38 @@ import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeoutException;
import org.eclipse.jetty.toolchain.test.AdvancedRunner;
import org.eclipse.jetty.toolchain.test.annotation.Slow;
import org.eclipse.jetty.util.BufferUtil;
import org.eclipse.jetty.util.FutureCallback;
import org.eclipse.jetty.util.thread.Scheduler;
import org.eclipse.jetty.util.thread.SimpleScheduler;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@RunWith(AdvancedRunner.class)
public class ByteArrayEndPointTest
{
private ScheduledExecutorService _scheduler;
private Scheduler _scheduler;
@Before
public void before()
public void before() throws Exception
{
_scheduler = Executors.newSingleThreadScheduledExecutor();
_scheduler = new SimpleScheduler();
_scheduler.start();
}
@After
public void after()
public void after() throws Exception
{
_scheduler.shutdownNow();
_scheduler.stop();
}
@Test

View File

@ -18,15 +18,15 @@
package org.eclipse.jetty.io;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import java.nio.ByteBuffer;
import org.eclipse.jetty.util.BufferUtil;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
public abstract class EndPointTest<T extends EndPoint>
{
public static class EndPointPair<T>

View File

@ -18,6 +18,11 @@
package org.eclipse.jetty.io;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
@ -39,11 +44,6 @@ import org.eclipse.jetty.util.IO;
import org.junit.Assert;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
public class IOTest
{
@Test

View File

@ -18,18 +18,18 @@
package org.eclipse.jetty.io;
import java.nio.ByteBuffer;
import java.util.Queue;
import java.util.concurrent.ConcurrentMap;
import org.junit.Test;
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import java.nio.ByteBuffer;
import java.util.Queue;
import java.util.concurrent.ConcurrentMap;
import org.junit.Test;
public class MappedByteBufferPoolTest
{
@Test

View File

@ -18,6 +18,10 @@
package org.eclipse.jetty.io;
import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertFalse;
import static junit.framework.Assert.assertTrue;
import java.net.ServerSocket;
import java.net.Socket;
import java.nio.ByteBuffer;
@ -27,10 +31,6 @@ import java.nio.channels.SocketChannel;
import org.junit.Test;
import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertFalse;
import static junit.framework.Assert.assertTrue;
/**
*
*/

View File

@ -28,8 +28,6 @@ import java.nio.channels.SelectionKey;
import java.nio.channels.ServerSocketChannel;
import java.nio.channels.SocketChannel;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
@ -38,6 +36,8 @@ import java.util.concurrent.atomic.AtomicReference;
import org.eclipse.jetty.util.BufferUtil;
import org.eclipse.jetty.util.Callback;
import org.eclipse.jetty.util.thread.QueuedThreadPool;
import org.eclipse.jetty.util.thread.Scheduler;
import org.eclipse.jetty.util.thread.SimpleScheduler;
import org.junit.After;
import org.junit.Assert;
import org.junit.Test;
@ -45,7 +45,7 @@ import org.junit.Test;
public class SelectChannelEndPointInterestsTest
{
private QueuedThreadPool threadPool;
private ScheduledExecutorService scheduler;
private Scheduler scheduler;
private ServerSocketChannel connector;
private SelectorManager selectorManager;
@ -54,7 +54,8 @@ public class SelectChannelEndPointInterestsTest
threadPool = new QueuedThreadPool();
threadPool.start();
scheduler = Executors.newSingleThreadScheduledExecutor();
scheduler = new SimpleScheduler();
scheduler.start();
connector = ServerSocketChannel.open();
connector.bind(new InetSocketAddress("localhost", 0));
@ -107,12 +108,12 @@ public class SelectChannelEndPointInterestsTest
@After
public void destroy() throws Exception
{
if (scheduler!=null)
scheduler.stop();
if (selectorManager != null)
selectorManager.stop();
if (connector != null)
connector.close();
if (scheduler != null)
scheduler.shutdownNow();
if (threadPool != null)
threadPool.stop();
}

View File

@ -18,6 +18,12 @@
package org.eclipse.jetty.io;
import static org.hamcrest.Matchers.greaterThan;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
@ -25,6 +31,7 @@ import java.net.Socket;
import java.nio.ByteBuffer;
import java.nio.channels.SocketChannel;
import java.util.concurrent.TimeUnit;
import javax.net.ssl.SSLEngine;
import javax.net.ssl.SSLEngineResult;
import javax.net.ssl.SSLEngineResult.HandshakeStatus;
@ -40,12 +47,6 @@ import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import static org.hamcrest.Matchers.greaterThan;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
public class SelectChannelEndPointSslTest extends SelectChannelEndPointTest
{

View File

@ -18,6 +18,12 @@
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;
@ -31,32 +37,26 @@ import java.nio.channels.ServerSocketChannel;
import java.nio.channels.SocketChannel;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import org.eclipse.jetty.util.BufferUtil;
import org.eclipse.jetty.util.FutureCallback;
import org.eclipse.jetty.util.StringUtil;
import org.eclipse.jetty.util.thread.QueuedThreadPool;
import org.eclipse.jetty.util.thread.Scheduler;
import org.eclipse.jetty.util.thread.SimpleScheduler;
import org.junit.After;
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 CountDownLatch _lastEndPointLatch;
protected volatile EndPoint _lastEndPoint;
protected ServerSocketChannel _connector;
protected QueuedThreadPool _threadPool = new QueuedThreadPool();
protected ScheduledExecutorService _scheduler = Executors.newSingleThreadScheduledExecutor();
protected Scheduler _scheduler = new SimpleScheduler();
protected SelectorManager _manager = new SelectorManager()
{
@Override
@ -93,6 +93,7 @@ public class SelectChannelEndPointTest
_lastEndPointLatch = new CountDownLatch(1);
_connector = ServerSocketChannel.open();
_connector.socket().bind(null);
_scheduler.start();
_threadPool.start();
_manager.start();
}
@ -100,6 +101,7 @@ public class SelectChannelEndPointTest
@After
public void stopManager() throws Exception
{
_scheduler.stop();
_manager.stop();
_threadPool.stop();
_connector.close();

View File

@ -28,13 +28,13 @@ import java.nio.channels.SelectionKey;
import java.nio.channels.ServerSocketChannel;
import java.nio.channels.SocketChannel;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import javax.net.ssl.SSLEngine;
import javax.net.ssl.SSLSocket;
import junit.framework.Assert;
import org.eclipse.jetty.io.ssl.SslConnection;
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
import org.eclipse.jetty.util.BufferUtil;
@ -42,6 +42,8 @@ import org.eclipse.jetty.util.FutureCallback;
import org.eclipse.jetty.util.StringUtil;
import org.eclipse.jetty.util.ssl.SslContextFactory;
import org.eclipse.jetty.util.thread.QueuedThreadPool;
import org.eclipse.jetty.util.thread.Scheduler;
import org.eclipse.jetty.util.thread.SimpleScheduler;
import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
@ -58,7 +60,7 @@ public class SslConnectionTest
private volatile FutureCallback<Void> _writeCallback;
protected ServerSocketChannel _connector;
protected QueuedThreadPool _threadPool = new QueuedThreadPool();
protected ScheduledExecutorService _scheduler = Executors.newSingleThreadScheduledExecutor();
protected Scheduler _scheduler = new SimpleScheduler();
protected SelectorManager _manager = new SelectorManager()
{
@Override
@ -112,6 +114,7 @@ public class SslConnectionTest
_connector = ServerSocketChannel.open();
_connector.socket().bind(null);
_threadPool.start();
_scheduler.start();
_manager.start();
}
@ -121,6 +124,7 @@ public class SslConnectionTest
if (_lastEndp.isOpen())
_lastEndp.close();
_manager.stop();
_scheduler.stop();
_threadPool.stop();
_connector.close();
}

View File

@ -18,6 +18,15 @@
package org.eclipse.jetty.io;
import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertFalse;
import static junit.framework.Assert.assertTrue;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.when;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.WritePendingException;
@ -45,15 +54,6 @@ import org.mockito.invocation.InvocationOnMock;
import org.mockito.runners.MockitoJUnitRunner;
import org.mockito.stubbing.Answer;
import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertFalse;
import static junit.framework.Assert.assertTrue;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.when;
@RunWith(MockitoJUnitRunner.class)
public class WriteFlusherTest
{

View File

@ -1,2 +1,2 @@
org.eclipse.jetty.util.log.class=org.eclipse.jetty.util.log.StdErrLog
org.eclipse.jetty.io.LEVEL=DEBUG
org.eclipse.jetty.io.LEVEL=INFO

View File

@ -24,10 +24,7 @@ import java.util.LinkedHashMap;
import java.util.Map;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.TimeUnit;
import org.eclipse.jetty.io.ByteBufferPool;
@ -41,6 +38,8 @@ import org.eclipse.jetty.util.component.Dumpable;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.util.ssl.SslContextFactory;
import org.eclipse.jetty.util.thread.Scheduler;
import org.eclipse.jetty.util.thread.SimpleScheduler;
/**
* <p>Partial implementation of {@link Connector}</p>
@ -55,11 +54,10 @@ public abstract class AbstractConnector extends AggregateLifeCycle implements Co
private final Server _server;
private final SslContextFactory _sslContextFactory;
private final Executor _executor;
private final ScheduledExecutorService _scheduler;
private final Scheduler _scheduler;
private final ByteBufferPool _byteBufferPool;
private final Thread[] _acceptors;
private volatile CountDownLatch _stopping;
private volatile String _name;
private volatile long _idleTimeout = 200000;
private volatile ConnectionFactory defaultConnectionFactory;
@ -74,30 +72,23 @@ public abstract class AbstractConnector extends AggregateLifeCycle implements Co
public AbstractConnector(
Server server,
Executor executor,
ScheduledExecutorService scheduler,
Scheduler scheduler,
ByteBufferPool pool,
SslContextFactory sslContextFactory,
int acceptors)
{
_server=server;
_executor=executor!=null?executor:_server.getThreadPool();
_scheduler=scheduler!=null?scheduler:Executors.newSingleThreadScheduledExecutor(new ThreadFactory()
{
@Override
public Thread newThread(Runnable r)
{
return new Thread(r, "Scheduler-" + getName());
}
});
_scheduler=scheduler!=null?scheduler:new SimpleScheduler();
_byteBufferPool = pool!=null?pool:new MappedByteBufferPool();
_sslContextFactory = sslContextFactory;
addBean(_server,false);
addBean(_executor);
if (executor==null)
unmanage(_executor);
addBean(_scheduler,scheduler==null);
addBean(_byteBufferPool,pool==null);
unmanage(_executor); // inherited from server
addBean(_scheduler);
addBean(_byteBufferPool);
addBean(_sslContextFactory);
addBean(_stats,true);
@ -341,18 +332,6 @@ public abstract class AbstractConnector extends AggregateLifeCycle implements Co
}
}
@Override
@ManagedAttribute("name of the connector")
public String getName()
{
return _name;
}
public void setName(String name)
{
_name = name;
}
protected void connectionOpened(Connection connection)
{
_stats.connectionOpened();
@ -373,7 +352,8 @@ public abstract class AbstractConnector extends AggregateLifeCycle implements Co
_stats.connectionClosed(duration, requests, requests);
}
public ScheduledExecutorService getScheduler()
@Override
public Scheduler getScheduler()
{
return _scheduler;
}

View File

@ -21,10 +21,10 @@ package org.eclipse.jetty.server;
import java.io.IOException;
import java.util.concurrent.Executor;
import java.util.concurrent.Future;
import java.util.concurrent.ScheduledExecutorService;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.util.ssl.SslContextFactory;
import org.eclipse.jetty.util.thread.Scheduler;
/**
* <p>Partial implementation of {@link NetworkConnector}.</p>
@ -34,7 +34,7 @@ public abstract class AbstractNetworkConnector extends AbstractConnector impleme
private volatile String _host;
private volatile int _port = 0;
public AbstractNetworkConnector(Server server, Executor executor, ScheduledExecutorService scheduler, ByteBufferPool pool, SslContextFactory sslContextFactory, int acceptors)
public AbstractNetworkConnector(Server server, Executor executor, Scheduler scheduler, ByteBufferPool pool, SslContextFactory sslContextFactory, int acceptors)
{
super(server, executor, scheduler, pool, sslContextFactory, acceptors);
}
@ -70,13 +70,7 @@ public abstract class AbstractNetworkConnector extends AbstractConnector impleme
@Override
protected void doStart() throws Exception
{
if (getName() == null)
setName(getHost() == null ? "0.0.0.0" : getHost() + ":" + getPort());
open();
setName(getName() + "/" + getLocalPort());
super.doStart();
}
@ -84,12 +78,7 @@ public abstract class AbstractNetworkConnector extends AbstractConnector impleme
protected void doStop() throws Exception
{
close();
super.doStop();
int i = getName().lastIndexOf("/");
if (i > 0)
setName(getName().substring(0, i));
}
@Override

View File

@ -19,7 +19,6 @@
package org.eclipse.jetty.server;
import java.util.concurrent.Executor;
import java.util.concurrent.ScheduledExecutorService;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.util.annotation.ManagedAttribute;
@ -27,6 +26,7 @@ import org.eclipse.jetty.util.annotation.ManagedObject;
import org.eclipse.jetty.util.component.Graceful;
import org.eclipse.jetty.util.component.LifeCycle;
import org.eclipse.jetty.util.ssl.SslContextFactory;
import org.eclipse.jetty.util.thread.Scheduler;
/**
* <p>A {@link Connector} accept connections and data from remote peers,
@ -36,11 +36,6 @@ import org.eclipse.jetty.util.ssl.SslContextFactory;
@ManagedObject("Connector Interface")
public interface Connector extends LifeCycle, Graceful
{
/**
* @return the name of the connector, defaulting to host:port
*/
public String getName();
/**
* @return the {@link Server} instance associated with this {@link Connector}
*/
@ -52,9 +47,9 @@ public interface Connector extends LifeCycle, Graceful
public Executor getExecutor();
/**
* @return the {@link ScheduledExecutorService} used to schedule tasks
* @return the {@link Scheduler} used to schedule tasks
*/
public ScheduledExecutorService getScheduler();
public Scheduler getScheduler();
/**
* @return the {@link ByteBufferPool} to acquire buffers from and release buffers to

View File

@ -22,6 +22,7 @@ import java.io.IOException;
import java.util.Collections;
import java.util.Enumeration;
import java.util.HashSet;
import javax.servlet.DispatcherType;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;

View File

@ -19,6 +19,7 @@
package org.eclipse.jetty.server;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

View File

@ -21,9 +21,9 @@ package org.eclipse.jetty.server;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.nio.ByteBuffer;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import javax.servlet.DispatcherType;
import javax.servlet.RequestDispatcher;
@ -47,6 +47,7 @@ import org.eclipse.jetty.util.StringUtil;
import org.eclipse.jetty.util.URIUtil;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.util.thread.Scheduler;
/* ------------------------------------------------------------ */
@ -617,7 +618,7 @@ public class HttpChannel<T> implements HttpParser.RequestHandler<T>, Runnable
_connector.getExecutor().execute(task);
}
public ScheduledExecutorService getScheduler()
public Scheduler getScheduler()
{
return _connector.getScheduler();
}

View File

@ -20,9 +20,8 @@ package org.eclipse.jetty.server;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Future;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import javax.servlet.AsyncContext;
import javax.servlet.AsyncEvent;
import javax.servlet.AsyncListener;
@ -41,6 +40,7 @@ import org.eclipse.jetty.server.handler.ContextHandler.Context;
import org.eclipse.jetty.util.URIUtil;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.util.thread.Scheduler;
/* ------------------------------------------------------------ */
/** Implementation of Continuation and AsyncContext interfaces
@ -723,7 +723,7 @@ public class HttpChannelState implements AsyncContext, Continuation
/* ------------------------------------------------------------ */
protected void scheduleTimeout()
{
ScheduledExecutorService scheduler = _channel.getScheduler();
Scheduler scheduler = _channel.getScheduler();
if (scheduler!=null)
_event._timeout=scheduler.schedule(new AsyncTimeout(),_timeoutMs,TimeUnit.MILLISECONDS);
}
@ -734,9 +734,9 @@ public class HttpChannelState implements AsyncContext, Continuation
AsyncEventState event=_event;
if (event!=null)
{
Future<?> task=event._timeout;
Scheduler.Task task=event._timeout;
if (task!=null)
task.cancel(false);
task.cancel();
}
}
@ -1038,7 +1038,7 @@ public class HttpChannelState implements AsyncContext, Continuation
/* ------------------------------------------------------------ */
public class AsyncEventState extends AsyncEvent
{
private Future<?> _timeout;
private Scheduler.Task _timeout;
private final ServletContext _suspendedContext;
private ServletContext _dispatchContext;
private String _pathInContext;

View File

@ -20,6 +20,7 @@ package org.eclipse.jetty.server;
import java.io.IOException;
import java.net.InetSocketAddress;
import javax.net.ssl.SSLEngine;
import javax.net.ssl.SSLSession;
import javax.servlet.ServletRequest;

View File

@ -20,6 +20,7 @@ package org.eclipse.jetty.server;
import java.io.IOException;
import java.io.InterruptedIOException;
import javax.servlet.ServletInputStream;
import org.eclipse.jetty.io.EofException;

View File

@ -22,6 +22,7 @@ import java.io.EOFException;
import java.io.IOException;
import java.io.InputStream;
import java.nio.ByteBuffer;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletOutputStream;
import javax.servlet.ServletRequest;

View File

@ -19,11 +19,11 @@
package org.eclipse.jetty.server;
import java.util.concurrent.Executor;
import java.util.concurrent.ScheduledExecutorService;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.util.annotation.Name;
import org.eclipse.jetty.util.ssl.SslContextFactory;
import org.eclipse.jetty.util.thread.Scheduler;
public class HttpServerConnector extends SelectChannelConnector
{
@ -37,7 +37,7 @@ public class HttpServerConnector extends SelectChannelConnector
this(server, null, null, null, sslContextFactory, 0, 0);
}
public HttpServerConnector(@Name("server") Server server, @Name("executor") Executor executor, @Name("scheduler") ScheduledExecutorService scheduler, @Name("bufferPool") ByteBufferPool pool, @Name("sslContextFactory") SslContextFactory sslContextFactory, @Name("acceptors") int acceptors, @Name("selectors") int selectors)
public HttpServerConnector(@Name("server") Server server, @Name("executor") Executor executor, @Name("scheduler") Scheduler scheduler, @Name("bufferPool") ByteBufferPool pool, @Name("sslContextFactory") SslContextFactory sslContextFactory, @Name("acceptors") int acceptors, @Name("selectors") int selectors)
{
super(server, executor, scheduler, pool, sslContextFactory, acceptors, selectors);
setDefaultConnectionFactory(new HttpServerConnectionFactory(this));

View File

@ -24,8 +24,8 @@ import java.util.concurrent.BlockingQueue;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.Executor;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import javax.net.ssl.SSLEngine;
import org.eclipse.jetty.io.ByteArrayEndPoint;
@ -36,6 +36,7 @@ import org.eclipse.jetty.io.ssl.SslConnection;
import org.eclipse.jetty.util.BufferUtil;
import org.eclipse.jetty.util.StringUtil;
import org.eclipse.jetty.util.ssl.SslContextFactory;
import org.eclipse.jetty.util.thread.Scheduler;
public class LocalConnector extends AbstractConnector
{
@ -51,7 +52,7 @@ public class LocalConnector extends AbstractConnector
this(server, null, null, null, sslContextFactory, 0);
}
public LocalConnector(Server server, Executor executor, ScheduledExecutorService scheduler, ByteBufferPool pool,
public LocalConnector(Server server, Executor executor, Scheduler scheduler, ByteBufferPool pool,
SslContextFactory sslContextFactory, int acceptors)
{
super(server,executor,scheduler,pool, sslContextFactory, acceptors);

View File

@ -24,6 +24,7 @@ import java.io.OutputStreamWriter;
import java.io.Writer;
import java.util.Locale;
import java.util.TimeZone;
import javax.servlet.http.Cookie;
import org.eclipse.jetty.http.HttpHeader;

View File

@ -37,6 +37,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import javax.servlet.AsyncContext;
import javax.servlet.AsyncListener;
import javax.servlet.DispatcherType;

View File

@ -25,6 +25,7 @@ import java.util.Collection;
import java.util.Collections;
import java.util.Locale;
import java.util.concurrent.atomic.AtomicInteger;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.Cookie;

View File

@ -29,7 +29,7 @@ import java.nio.channels.ServerSocketChannel;
import java.nio.channels.SocketChannel;
import java.util.concurrent.Executor;
import java.util.concurrent.Future;
import java.util.concurrent.ScheduledExecutorService;
import javax.net.ssl.SSLEngine;
import org.eclipse.jetty.io.ByteBufferPool;
@ -42,6 +42,7 @@ import org.eclipse.jetty.io.ssl.SslConnection;
import org.eclipse.jetty.util.annotation.ManagedObject;
import org.eclipse.jetty.util.annotation.Name;
import org.eclipse.jetty.util.ssl.SslContextFactory;
import org.eclipse.jetty.util.thread.Scheduler;
/**
* <p>Implementation of {@link NetworkConnector} based on NIO classes.</p>
@ -77,7 +78,7 @@ public class SelectChannelConnector extends AbstractNetworkConnector
public SelectChannelConnector(
@Name("server") Server server,
@Name("executor") Executor executor,
@Name("scheduler") ScheduledExecutorService scheduler,
@Name("scheduler") Scheduler scheduler,
@Name("bufferPool") ByteBufferPool pool,
@Name("sslContextFactory") SslContextFactory sslContextFactory,
@Name("acceptors") int acceptors,

View File

@ -20,7 +20,6 @@ package org.eclipse.jetty.server;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.SocketException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
@ -30,7 +29,6 @@ import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
@ -51,7 +49,6 @@ import org.eclipse.jetty.util.annotation.ManagedAttribute;
import org.eclipse.jetty.util.annotation.ManagedObject;
import org.eclipse.jetty.util.component.Container;
import org.eclipse.jetty.util.component.Destroyable;
import org.eclipse.jetty.util.component.Dumpable;
import org.eclipse.jetty.util.component.Graceful;
import org.eclipse.jetty.util.component.LifeCycle;
import org.eclipse.jetty.util.log.Log;

View File

@ -23,6 +23,7 @@ import java.io.IOException;
import java.security.Principal;
import java.util.Collection;
import java.util.Enumeration;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletRequestWrapper;

View File

@ -20,6 +20,7 @@ package org.eclipse.jetty.server;
import java.io.IOException;
import java.util.Collection;
import javax.servlet.ServletResponse;
import javax.servlet.ServletResponseWrapper;
import javax.servlet.http.Cookie;

View File

@ -20,6 +20,7 @@ package org.eclipse.jetty.server;
import java.util.EventListener;
import java.util.Set;
import javax.servlet.SessionCookieConfig;
import javax.servlet.SessionTrackingMode;
import javax.servlet.http.Cookie;

View File

@ -20,6 +20,7 @@ package org.eclipse.jetty.server;
import java.security.Principal;
import java.util.Map;
import javax.security.auth.Subject;
/* ------------------------------------------------------------ */

View File

@ -36,10 +36,7 @@ import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import javax.servlet.DispatcherType;
import javax.servlet.Filter;
@ -67,7 +64,6 @@ import org.eclipse.jetty.http.MimeTypes;
import org.eclipse.jetty.server.Dispatcher;
import org.eclipse.jetty.server.Handler;
import org.eclipse.jetty.server.HandlerContainer;
import org.eclipse.jetty.server.HttpChannel;
import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.util.ArrayUtil;
@ -151,7 +147,6 @@ public class ContextHandler extends ScopedHandler implements Attributes, Gracefu
private String[] _vhosts;
private Set<String> _connectors;
private EventListener[] _eventListeners;
private Logger _logger;
@ -396,36 +391,6 @@ public class ContextHandler extends ScopedHandler implements Attributes, Gracefu
return _vhosts;
}
/* ------------------------------------------------------------ */
/**
* @return an array of connector names that this context will accept a request from.
*/
@ManagedAttribute("Names and ports of accepted connectors")
public String[] getConnectorNames()
{
if (_connectors == null || _connectors.size() == 0)
return null;
return _connectors.toArray(new String[_connectors.size()]);
}
/* ------------------------------------------------------------ */
/**
* Set the names of accepted connectors.
*
* Names are either "host:port" or a specific configured name for a connector.
*
* @param connectors
* If non null, an array of connector names that this context will accept a request from.
*/
public void setConnectorNames(String[] connectors)
{
if (connectors == null || connectors.length == 0)
_connectors = null;
else
_connectors = new HashSet<String>(Arrays.asList(connectors));
}
/* ------------------------------------------------------------ */
/*
* @see javax.servlet.ServletContext#getAttribute(java.lang.String)
@ -903,14 +868,6 @@ public class ContextHandler extends ScopedHandler implements Attributes, Gracefu
return false;
}
// Check the connector
if (_connectors != null && _connectors.size() > 0)
{
String connector = HttpChannel.getCurrentHttpChannel().getConnector().getName();
if (connector == null || !_connectors.contains(connector))
return false;
}
// Are we not the root context?
if (_contextPath.length() > 1)
{

View File

@ -21,6 +21,7 @@ package org.eclipse.jetty.server.handler;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

View File

@ -22,6 +22,7 @@ import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintStream;
import java.util.Locale;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

View File

@ -21,6 +21,7 @@ package org.eclipse.jetty.server.handler;
import java.io.IOException;
import java.io.OutputStream;
import java.net.URL;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

View File

@ -22,6 +22,7 @@ import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.io.Writer;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

View File

@ -28,6 +28,7 @@ import java.util.Set;
import java.util.StringTokenizer;
import java.util.zip.DeflaterOutputStream;
import java.util.zip.GZIPOutputStream;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

View File

@ -21,6 +21,7 @@ package org.eclipse.jetty.server.handler;
import java.io.IOException;
import java.util.List;
import java.util.concurrent.CountDownLatch;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

View File

@ -19,6 +19,7 @@
package org.eclipse.jetty.server.handler;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

View File

@ -20,6 +20,7 @@ package org.eclipse.jetty.server.handler;
import java.io.IOException;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

View File

@ -20,6 +20,7 @@ package org.eclipse.jetty.server.handler;
import java.io.IOException;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

View File

@ -23,6 +23,7 @@ import java.net.InetSocketAddress;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

View File

@ -19,6 +19,7 @@
package org.eclipse.jetty.server.handler;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

View File

@ -19,6 +19,7 @@
package org.eclipse.jetty.server.handler;
import java.io.IOException;
import javax.servlet.DispatcherType;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;

View File

@ -21,6 +21,7 @@ package org.eclipse.jetty.server.handler;
import java.io.IOException;
import java.io.OutputStream;
import java.net.MalformedURLException;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;

View File

@ -19,6 +19,7 @@
package org.eclipse.jetty.server.handler;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

View File

@ -19,6 +19,7 @@
package org.eclipse.jetty.server.handler;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

View File

@ -21,6 +21,7 @@ package org.eclipse.jetty.server.handler;
import java.io.IOException;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

View File

@ -27,6 +27,7 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSessionActivationListener;

View File

@ -20,6 +20,7 @@ package org.eclipse.jetty.server.session;
import java.security.SecureRandom;
import java.util.Random;
import javax.servlet.http.HttpServletRequest;
import org.eclipse.jetty.server.SessionIdManager;

View File

@ -18,6 +18,8 @@
package org.eclipse.jetty.server.session;
import static java.lang.Math.round;
import java.util.Arrays;
import java.util.Collections;
import java.util.Enumeration;
@ -28,6 +30,7 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.CopyOnWriteArrayList;
import javax.servlet.SessionCookieConfig;
import javax.servlet.SessionTrackingMode;
import javax.servlet.http.HttpServletRequest;
@ -51,8 +54,6 @@ import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.util.statistic.CounterStatistic;
import org.eclipse.jetty.util.statistic.SampleStatistic;
import static java.lang.Math.round;
/* ------------------------------------------------------------ */
/**
* An Abstract implementation of SessionManager. The partial implementation of

View File

@ -28,6 +28,7 @@ import java.util.Iterator;
import java.util.Map;
import java.util.Random;
import java.util.Set;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

View File

@ -31,6 +31,7 @@ import java.util.Timer;
import java.util.TimerTask;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;

View File

@ -27,6 +27,7 @@ import java.io.IOException;
import java.io.ObjectOutputStream;
import java.io.OutputStream;
import java.util.Enumeration;
import javax.servlet.http.HttpServletRequest;
import org.eclipse.jetty.util.IO;

View File

@ -35,6 +35,7 @@ import java.util.List;
import java.util.Random;
import java.util.Timer;
import java.util.TimerTask;
import javax.naming.InitialContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

View File

@ -35,6 +35,7 @@ import java.util.ListIterator;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicReference;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;

View File

@ -21,6 +21,7 @@ package org.eclipse.jetty.server.session;
import java.io.IOException;
import java.util.EnumSet;
import java.util.EventListener;
import javax.servlet.DispatcherType;
import javax.servlet.ServletException;
import javax.servlet.SessionTrackingMode;

View File

@ -21,6 +21,7 @@ package org.eclipse.jetty.server.ssl;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.security.cert.X509Certificate;
import javax.net.ssl.SSLEngine;
import javax.net.ssl.SSLPeerUnverifiedException;
import javax.net.ssl.SSLSession;

View File

@ -21,6 +21,7 @@ package org.eclipse.jetty.server.ssl;
import java.io.File;
import java.security.SecureRandom;
import java.security.Security;
import javax.net.ssl.KeyManagerFactory;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLEngine;

View File

@ -18,6 +18,9 @@
package org.eclipse.jetty.server;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
@ -25,6 +28,7 @@ import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.net.Socket;
import java.net.URISyntaxException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@ -37,9 +41,6 @@ import org.eclipse.jetty.util.log.StdErrLog;
import org.junit.After;
import org.junit.Before;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
public abstract class AbstractHttpTest
{
protected static Server server;
@ -66,8 +67,8 @@ public abstract class AbstractHttpTest
@After
public void tearDown() throws Exception
{
((StdErrLog)Log.getLogger(HttpChannel.class)).setHideStacks(false);
server.stop();
((StdErrLog)Log.getLogger(HttpChannel.class)).setHideStacks(false);
}
protected SimpleHttpResponse executeRequest() throws URISyntaxException, IOException

View File

@ -18,6 +18,9 @@
package org.eclipse.jetty.server;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@ -25,6 +28,7 @@ import java.net.Socket;
import java.util.Arrays;
import java.util.concurrent.Exchanger;
import java.util.concurrent.TimeUnit;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@ -39,9 +43,6 @@ import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
public class AsyncRequestReadTest
{
private static Server server;

View File

@ -18,6 +18,8 @@
package org.eclipse.jetty.server;
import static org.junit.Assert.assertEquals;
import java.io.IOException;
import java.io.InputStream;
import java.net.InetAddress;
@ -25,6 +27,7 @@ import java.net.Socket;
import java.util.Random;
import java.util.Timer;
import java.util.TimerTask;
import javax.servlet.AsyncContext;
import javax.servlet.AsyncEvent;
import javax.servlet.AsyncListener;
@ -44,8 +47,6 @@ import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
public class AsyncStressTest
{
private static final Logger LOG = Log.getLogger(AsyncStressTest.class);

View File

@ -18,7 +18,12 @@
package org.eclipse.jetty.server;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@ -26,10 +31,6 @@ import javax.servlet.http.HttpServletResponse;
import org.eclipse.jetty.server.handler.AbstractHandler;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
/**
*
*/

View File

@ -18,6 +18,8 @@
package org.eclipse.jetty.server;
import static org.junit.Assert.assertTrue;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
@ -28,8 +30,6 @@ import java.util.concurrent.TimeUnit;
import org.junit.Test;
import static org.junit.Assert.assertTrue;
/**
* HttpServer Tester.
*/

View File

@ -18,6 +18,10 @@
package org.eclipse.jetty.server;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.matchers.JUnitMatchers.containsString;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@ -25,6 +29,7 @@ import java.net.Socket;
import java.net.SocketException;
import java.util.concurrent.Exchanger;
import java.util.concurrent.TimeUnit;
import javax.net.ssl.SSLException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
@ -37,10 +42,6 @@ import org.eclipse.jetty.util.IO;
import org.junit.Assert;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.matchers.JUnitMatchers.containsString;
public abstract class ConnectorTimeoutTest extends HttpServerTestFixture
{
protected static final int MAX_IDLE_TIME=500;

View File

@ -25,6 +25,7 @@ import java.io.OutputStreamWriter;
import java.io.Reader;
import java.io.Writer;
import java.util.Enumeration;
import javax.servlet.ServletException;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;

View File

@ -24,10 +24,16 @@
*/
package org.eclipse.jetty.server;
import static org.hamcrest.Matchers.greaterThan;
import static org.hamcrest.Matchers.startsWith;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@ -44,11 +50,6 @@ import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import static org.hamcrest.Matchers.greaterThan;
import static org.hamcrest.Matchers.startsWith;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
/**
*
*/

View File

@ -18,6 +18,9 @@
package org.eclipse.jetty.server;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
import java.io.IOException;
import java.util.Arrays;
import java.util.Collection;
@ -25,6 +28,7 @@ import java.util.concurrent.BrokenBarrierException;
import java.util.concurrent.CyclicBarrier;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import javax.servlet.AsyncContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
@ -36,11 +40,9 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
//TODO: reset buffer tests
//TODO: add protocol specific tests for connection: close and/or chunking
@RunWith(value = Parameterized.class)
public class HttpManyWaysToAsyncCommitBadBehaviourTest extends AbstractHttpTest
{

View File

@ -18,9 +18,14 @@
package org.eclipse.jetty.server;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.nullValue;
import static org.junit.Assert.assertThat;
import java.io.IOException;
import java.util.Arrays;
import java.util.Collection;
import javax.servlet.AsyncContext;
import javax.servlet.ServletException;
import javax.servlet.ServletResponse;
@ -33,10 +38,6 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.nullValue;
import static org.junit.Assert.assertThat;
//TODO: reset buffer tests
//TODO: add protocol specific tests for connection: close and/or chunking
@RunWith(value = Parameterized.class)

View File

@ -18,9 +18,14 @@
package org.eclipse.jetty.server;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.not;
import static org.junit.Assert.assertThat;
import java.io.IOException;
import java.util.Arrays;
import java.util.Collection;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@ -31,10 +36,6 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.not;
import static org.junit.Assert.assertThat;
//TODO: reset buffer tests
//TODO: add protocol specific tests for connection: close and/or chunking
@RunWith(value = Parameterized.class)

View File

@ -18,6 +18,12 @@
package org.eclipse.jetty.server;
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import java.io.BufferedReader;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
@ -30,6 +36,7 @@ import java.net.URL;
import java.util.Arrays;
import java.util.Random;
import java.util.concurrent.Exchanger;
import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
@ -46,12 +53,6 @@ import org.junit.Assert;
import org.junit.Test;
import org.junit.matchers.JUnitMatchers;
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
/**
*
*/

View File

@ -25,6 +25,7 @@ import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Writer;
import java.net.Socket;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLSession;
import javax.servlet.ServletException;

View File

@ -18,22 +18,23 @@
package org.eclipse.jetty.server;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.nio.charset.Charset;
import junit.framework.Assert;
import org.eclipse.jetty.http.HttpURI;
import org.eclipse.jetty.util.MultiMap;
import org.eclipse.jetty.util.StringUtil;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
public class HttpURITest
{
private final String[][] partial_tests=

View File

@ -18,6 +18,8 @@
package org.eclipse.jetty.server;
import static org.junit.Assert.assertEquals;
import java.io.IOException;
import java.nio.ByteBuffer;
@ -30,8 +32,6 @@ import org.eclipse.jetty.util.Utf8StringBuilder;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
public class HttpWriterTest
{
private HttpOutput _httpOut;

View File

@ -18,15 +18,15 @@
package org.eclipse.jetty.server;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import java.util.List;
import java.util.Vector;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
public class InclusiveByteRangeTest
{
@SuppressWarnings("unchecked")

View File

@ -18,9 +18,12 @@
package org.eclipse.jetty.server;
import static org.junit.Assert.assertEquals;
import java.io.IOException;
import java.io.InputStream;
import java.util.concurrent.atomic.AtomicInteger;
import javax.servlet.AsyncContext;
import javax.servlet.AsyncEvent;
import javax.servlet.AsyncListener;
@ -37,8 +40,6 @@ import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
public class LocalAsyncContextTest
{
protected Server _server = new Server();

View File

@ -18,13 +18,13 @@
package org.eclipse.jetty.server;
import static org.hamcrest.Matchers.containsString;
import static org.junit.Assert.assertThat;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import static org.hamcrest.Matchers.containsString;
import static org.junit.Assert.assertThat;
public class LocalConnectorTest
{
private Server _server;

View File

@ -18,6 +18,9 @@
package org.eclipse.jetty.server;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
@ -27,6 +30,7 @@ import java.nio.ByteBuffer;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
@ -41,9 +45,6 @@ import org.junit.After;
import org.junit.Ignore;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
@Ignore
public class NetworkTrafficListenerTest
{

View File

@ -24,6 +24,11 @@
*/
package org.eclipse.jetty.server;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.not;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.util.Date;
import java.util.Enumeration;
import java.util.List;
@ -37,11 +42,6 @@ import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.not;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
/**
*
*/

View File

@ -18,6 +18,14 @@
package org.eclipse.jetty.server;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
@ -29,6 +37,7 @@ import java.util.Arrays;
import java.util.Enumeration;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import javax.servlet.ServletException;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
@ -48,14 +57,6 @@ import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
public class RequestTest
{
private static final Logger LOG = Log.getLogger(RequestTest.class);

View File

@ -18,6 +18,9 @@
package org.eclipse.jetty.server;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileOutputStream;
@ -30,9 +33,6 @@ import org.eclipse.jetty.util.resource.Resource;
import org.eclipse.jetty.util.resource.ResourceCollection;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
public class ResourceCacheTest
{
@Test

View File

@ -18,6 +18,11 @@
package org.eclipse.jetty.server;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.LineNumberReader;
@ -26,8 +31,7 @@ import java.net.Socket;
import java.nio.ByteBuffer;
import java.util.Iterator;
import java.util.Locale;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import javax.servlet.ServletException;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
@ -43,34 +47,31 @@ import org.eclipse.jetty.server.handler.ContextHandler;
import org.eclipse.jetty.server.session.HashSessionIdManager;
import org.eclipse.jetty.server.session.HashSessionManager;
import org.eclipse.jetty.server.session.HashedSession;
import org.eclipse.jetty.util.thread.Scheduler;
import org.eclipse.jetty.util.thread.SimpleScheduler;
import org.hamcrest.Matchers;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
public class ResponseTest
{
private Server _server;
private HttpChannel _channel;
private ScheduledExecutorService _timer;
private Scheduler _scheduler;
@Before
public void init() throws Exception
{
_server = new Server();
_timer = new ScheduledThreadPoolExecutor(1);
LocalConnector connector = new LocalConnector(_server, null, _timer, null, null, 1);
_scheduler = new SimpleScheduler();
LocalConnector connector = new LocalConnector(_server, null, _scheduler, null, null, 1);
_server.addConnector(connector);
_server.setHandler(new DumpHandler());
_server.start();
AbstractEndPoint endp = new ByteArrayEndPoint(_timer, 5000);
AbstractEndPoint endp = new ByteArrayEndPoint(_scheduler, 5000);
ByteBufferHttpInput input = new ByteBufferHttpInput();
_channel = new HttpChannel(connector, new HttpConfiguration(null, false), endp, new HttpTransport()
{
@ -96,7 +97,6 @@ public class ResponseTest
{
_server.stop();
_server.join();
_timer.shutdownNow();
}
@Test

View File

@ -18,6 +18,9 @@
package org.eclipse.jetty.server;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
@ -25,6 +28,7 @@ import java.io.PrintWriter;
import java.net.Socket;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.CyclicBarrier;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@ -41,9 +45,6 @@ import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
public class SelectChannelStatisticsTest
{
private static final Logger LOG = Log.getLogger(SelectChannelStatisticsTest.class);

View File

@ -18,6 +18,8 @@
package org.eclipse.jetty.server;
import static org.junit.Assert.assertTrue;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
@ -28,8 +30,6 @@ import org.eclipse.jetty.util.IO;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.assertTrue;
public class SelectChannelTimeoutTest extends ConnectorTimeoutTest
{
@Before

View File

@ -18,6 +18,8 @@
package org.eclipse.jetty.server;
import static org.hamcrest.Matchers.lessThan;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@ -26,6 +28,7 @@ import java.nio.ByteBuffer;
import java.nio.channels.SocketChannel;
import java.util.Arrays;
import java.util.concurrent.atomic.AtomicInteger;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@ -38,8 +41,6 @@ import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;
import static org.hamcrest.Matchers.lessThan;
public class SlowClientWithPipelinedRequestTest
{
private final AtomicInteger handles = new AtomicInteger();

View File

@ -18,12 +18,17 @@
package org.eclipse.jetty.server;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assume.assumeTrue;
import java.io.IOException;
import java.net.Socket;
import java.util.Queue;
import java.util.Random;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.atomic.AtomicInteger;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@ -41,11 +46,7 @@ import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assume.assumeTrue;
@Ignore("Ignore until other tests are working")
@Ignore
public class StressTest
{
private static final Logger LOG = Log.getLogger(StressTest.class);
@ -119,6 +120,13 @@ public class StressTest
q.clear();
}
@Test
public void testMinNonPersistent() throws Throwable
{
doThreads(2,2,false);
}
@Test
public void testNonPersistent() throws Throwable
{

View File

@ -20,6 +20,7 @@ package org.eclipse.jetty.server;
import java.io.IOException;
import java.io.InputStream;
import javax.servlet.AsyncContext;
import javax.servlet.AsyncEvent;
import javax.servlet.AsyncListener;

View File

@ -18,7 +18,12 @@
package org.eclipse.jetty.server.handler;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@ -29,10 +34,6 @@ import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.Server;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
public class ContextHandlerCollectionTest
{
@Test

View File

@ -18,12 +18,18 @@
package org.eclipse.jetty.server.handler;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@ -37,11 +43,6 @@ import org.hamcrest.Matchers;
import org.junit.Assert;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
/**
* @version $Revision$
*/

Some files were not shown because too many files have changed in this diff Show More