Issue #207 - removing scheduler

This commit is contained in:
Joakim Erdfelt 2017-05-15 13:38:45 -07:00
parent 4e2f6265eb
commit 1ba61e8e0c
7 changed files with 17 additions and 39 deletions

View File

@ -40,7 +40,6 @@ 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.QueuedThreadPool;
import org.eclipse.jetty.util.thread.Scheduler;
import org.eclipse.jetty.util.thread.ShutdownThread;
import org.eclipse.jetty.websocket.api.Session;
import org.eclipse.jetty.websocket.api.WebSocketBehavior;
@ -520,11 +519,6 @@ public class WebSocketClient extends ContainerLifeCycle implements WebSocketCont
return this.containerScope.getPolicy();
}
public Scheduler getScheduler()
{
return httpClient.getScheduler();
}
public SessionFactory getSessionFactory()
{
return sessionFactory;

View File

@ -591,7 +591,7 @@ public class WebSocketUpgradeRequest extends HttpRequest implements CompleteList
endp = configure(endp);
WebSocketClientConnection connection = new WebSocketClientConnection(endp,wsClient.getExecutor(),wsClient.getScheduler(),wsClient.getPolicy(),
WebSocketClientConnection connection = new WebSocketClientConnection(endp,wsClient.getExecutor(),wsClient.getPolicy(),
wsClient.getBufferPool(), extensionStack);
URI requestURI = this.getURI();

View File

@ -23,7 +23,6 @@ import java.util.concurrent.Executor;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.EndPoint;
import org.eclipse.jetty.util.thread.Scheduler;
import org.eclipse.jetty.websocket.api.BatchMode;
import org.eclipse.jetty.websocket.api.FrameCallback;
import org.eclipse.jetty.websocket.api.WebSocketPolicy;
@ -41,9 +40,9 @@ public class WebSocketClientConnection extends AbstractWebSocketConnection
{
private final Masker masker;
public WebSocketClientConnection(EndPoint endp, Executor executor, Scheduler scheduler, WebSocketPolicy websocketPolicy, ByteBufferPool bufferPool, ExtensionStack extensionStack)
public WebSocketClientConnection(EndPoint endp, Executor executor, WebSocketPolicy websocketPolicy, ByteBufferPool bufferPool, ExtensionStack extensionStack)
{
super(endp,executor,scheduler,websocketPolicy,bufferPool, extensionStack);
super(endp,executor, websocketPolicy,bufferPool, extensionStack);
this.masker = new RandomMasker();
}

View File

@ -664,6 +664,7 @@ public class WebSocketSession extends ContainerLifeCycle implements Session, Rem
}
else if (cause instanceof SocketTimeoutException)
{
// A path often seen in Windows
close(StatusCode.SHUTDOWN, cause.getMessage(), onDisconnectCallback);
}
else if (cause instanceof IOException)
@ -672,6 +673,7 @@ public class WebSocketSession extends ContainerLifeCycle implements Session, Rem
}
else if (cause instanceof SocketException)
{
// A path unique to Unix
close(StatusCode.SHUTDOWN, cause.getMessage(), onDisconnectCallback);
}
else if (cause instanceof CloseException)
@ -711,7 +713,10 @@ public class WebSocketSession extends ContainerLifeCycle implements Session, Rem
}
/**
* Connection Disconnect Event
* Connection Disconnect Event.
* <p>
* Represents the low level Jetty Connection close/disconnect.
* </p>
*
* @param connection the connection
*/
@ -722,6 +727,7 @@ public class WebSocketSession extends ContainerLifeCycle implements Session, Rem
{
if (LOG.isDebugEnabled())
LOG.debug("{}.onSessionClosed()", containerScope.getClass().getSimpleName());
remote = null;
containerScope.onSessionClosed(this);
}
catch (Throwable t)
@ -732,6 +738,9 @@ public class WebSocketSession extends ContainerLifeCycle implements Session, Rem
/**
* Connection Open Event
* <p>
* Represents the low level Jetty Connection open/connect.
* </p>
*
* @param connection the connection
*/

View File

@ -27,7 +27,6 @@ import java.util.List;
import java.util.Objects;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.Executor;
import java.util.concurrent.RejectedExecutionException;
import java.util.concurrent.atomic.AtomicBoolean;
import org.eclipse.jetty.io.AbstractConnection;
@ -39,7 +38,6 @@ import org.eclipse.jetty.util.component.ContainerLifeCycle;
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.thread.Scheduler;
import org.eclipse.jetty.websocket.api.BatchMode;
import org.eclipse.jetty.websocket.api.FrameCallback;
import org.eclipse.jetty.websocket.api.SuspendToken;
@ -77,7 +75,6 @@ public abstract class AbstractWebSocketConnection extends AbstractConnection imp
private final Logger LOG;
private final ByteBufferPool bufferPool;
private final Scheduler scheduler;
private final Generator generator;
private final Parser parser;
private final WebSocketPolicy policy;
@ -90,13 +87,12 @@ public abstract class AbstractWebSocketConnection extends AbstractConnection imp
private List<ExtensionConfig> extensions;
private ByteBuffer networkBuffer;
public AbstractWebSocketConnection(EndPoint endp, Executor executor, Scheduler scheduler, WebSocketPolicy policy, ByteBufferPool bufferPool, ExtensionStack extensionStack)
public AbstractWebSocketConnection(EndPoint endp, Executor executor, WebSocketPolicy policy, ByteBufferPool bufferPool, ExtensionStack extensionStack)
{
super(endp,executor);
Objects.requireNonNull(endp, "EndPoint");
Objects.requireNonNull(executor, "Executor");
Objects.requireNonNull(scheduler, "Scheduler");
Objects.requireNonNull(policy, "WebSocketPolicy");
Objects.requireNonNull(bufferPool, "ByteBufferPool");
@ -113,7 +109,6 @@ public abstract class AbstractWebSocketConnection extends AbstractConnection imp
this.generator = new Generator(policy,bufferPool);
this.parser = new Parser(policy,bufferPool,this);
this.scheduler = scheduler;
this.extensions = new ArrayList<>();
this.suspendToken = new AtomicBoolean(false);
this.flusher = new Flusher(policy.getOutputBufferSize(),generator,endp);
@ -146,19 +141,6 @@ public abstract class AbstractWebSocketConnection extends AbstractConnection imp
closed.set(true);
}
protected void execute(Runnable task)
{
try
{
getExecutor().execute(task);
}
catch (RejectedExecutionException e)
{
if (LOG.isDebugEnabled())
LOG.debug("Job not dispatched: {}",task);
}
}
@Override
public ByteBufferPool getBufferPool()
{
@ -216,11 +198,6 @@ public abstract class AbstractWebSocketConnection extends AbstractConnection imp
return getEndPoint().getRemoteAddress();
}
public Scheduler getScheduler()
{
return scheduler;
}
@Override
public boolean isOpen()
{

View File

@ -24,16 +24,15 @@ import java.util.concurrent.Executor;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.Connection;
import org.eclipse.jetty.io.EndPoint;
import org.eclipse.jetty.util.thread.Scheduler;
import org.eclipse.jetty.websocket.api.WebSocketPolicy;
import org.eclipse.jetty.websocket.common.extensions.ExtensionStack;
import org.eclipse.jetty.websocket.common.io.AbstractWebSocketConnection;
public class WebSocketServerConnection extends AbstractWebSocketConnection implements Connection.UpgradeTo
{
public WebSocketServerConnection(EndPoint endp, Executor executor, Scheduler scheduler, WebSocketPolicy policy, ByteBufferPool bufferPool, ExtensionStack extensionStack)
public WebSocketServerConnection(EndPoint endp, Executor executor, WebSocketPolicy policy, ByteBufferPool bufferPool, ExtensionStack extensionStack)
{
super(endp,executor,scheduler,policy,bufferPool,extensionStack);
super(endp,executor, policy,bufferPool,extensionStack);
}
@Override

View File

@ -562,7 +562,7 @@ public class WebSocketServerFactory extends ContainerLifeCycle implements WebSoc
ByteBufferPool bufferPool = connector.getByteBufferPool();
// Setup websocket connection
AbstractWebSocketConnection wsConnection = new WebSocketServerConnection(endp, executor, scheduler, getPolicy().clonePolicy(), bufferPool, extensionStack);
AbstractWebSocketConnection wsConnection = new WebSocketServerConnection(endp, executor, getPolicy().clonePolicy(), bufferPool, extensionStack);
extensionStack.setPolicy(wsConnection.getPolicy());
extensionStack.configure(wsConnection.getParser());