org.eclipse.jetty.server.nio
类 SelectChannelConnector

java.lang.Object
  继承者 org.eclipse.jetty.util.component.AbstractLifeCycle
      继承者 org.eclipse.jetty.util.component.AggregateLifeCycle
          继承者 org.eclipse.jetty.server.AbstractConnector
              继承者 org.eclipse.jetty.server.nio.AbstractNIOConnector
                  继承者 org.eclipse.jetty.server.nio.SelectChannelConnector
所有已实现的接口:
HttpBuffers, Connector, NIOConnector, Destroyable, Dumpable, LifeCycle
直接已知子类:
InheritedChannelConnector, NetworkTrafficSelectChannelConnector, SslSelectChannelConnector

public class SelectChannelConnector
extends AbstractNIOConnector

Selecting NIO connector.

This connector uses efficient NIO buffers with a non blocking threading model. Direct NIO buffers are used and threads are only allocated to connections with requests. Synchronization is used to simulate blocking for the servlet API, and any unflushed content at the end of request handling is written asynchronously.

This connector is best used when there are a many connections that have idle periods.

When used with Continuation, threadless waits are supported. If a filter or servlet returns after calling Continuation.suspend() or when a runtime exception is thrown from a call to Continuation.undispatch(), Jetty will will not send a response to the client. Instead the thread is released and the Continuation is placed on the timer queue. If the Continuation timeout expires, or it's resume method is called, then the request is again allocated a thread and the request is retried. The limitation of this approach is that request content is not available on the retried request, thus if possible it should be read after the continuation or saved as a request attribute or as the associated object of the Continuation instance.


嵌套类摘要
 
从类 org.eclipse.jetty.util.component.AbstractLifeCycle 继承的嵌套类/接口
AbstractLifeCycle.AbstractLifeCycleListener
 
从接口 org.eclipse.jetty.util.component.LifeCycle 继承的嵌套类/接口
LifeCycle.Listener
 
字段摘要
protected  ServerSocketChannel _acceptChannel
           
 
从类 org.eclipse.jetty.server.AbstractConnector 继承的字段
_buffers, _lowResourceMaxIdleTime, _maxIdleTime, _soLingerTime
 
从类 org.eclipse.jetty.util.component.AbstractLifeCycle 继承的字段
_listeners, FAILED, RUNNING, STARTED, STARTING, STOPPED, STOPPING
 
构造方法摘要
SelectChannelConnector()
          Constructor.
 
方法摘要
 void accept(int acceptorID)
           
 void close()
           
 void customize(EndPoint endpoint, Request request)
          Customize a request for an endpoint.
protected  void doStart()
          Start the managed lifecycle beans in the order they were added.
protected  void endPointClosed(SelectChannelEndPoint endpoint)
           
 Object getConnection()
           
 int getLocalPort()
           
 int getLowResourcesConnections()
           
 int getLowResourcesMaxIdleTime()
           
 SelectorManager getSelectorManager()
           
protected  AsyncConnection newConnection(SocketChannel channel, AsyncEndPoint endpoint)
           
protected  SelectChannelEndPoint newEndPoint(SocketChannel channel, SelectorManager.SelectSet selectSet, SelectionKey key)
           
 void open()
          Opens the connector
 void persist(EndPoint endpoint)
          Persist an endpoint.
 void setLowResourcesConnections(int lowResourcesConnections)
          Set the number of connections, which if exceeded places this manager in low resources state.
 void setLowResourcesMaxIdleTime(int lowResourcesMaxIdleTime)
          Set the period in ms that a connection is allowed to be idle when this there are more than getLowResourcesConnections() connections.
 void setMaxIdleTime(int maxIdleTime)
          Set the maximum Idle time for a connection, which roughly translates to the Socket.setSoTimeout(int) call, although with NIO implementations other mechanisms may be used to implement the timeout.
 void setThreadPool(ThreadPool pool)
          Set the ThreadPool.
 
从类 org.eclipse.jetty.server.nio.AbstractNIOConnector 继承的方法
getUseDirectBuffers, setUseDirectBuffers
 
从类 org.eclipse.jetty.server.AbstractConnector 继承的方法
checkForwardedHeaders, configure, connectionClosed, connectionOpened, connectionUpgraded, doStop, getAcceptorPriorityOffset, getAcceptors, getAcceptQueueSize, getConfidentialPort, getConfidentialScheme, getConnections, getConnectionsDurationMax, getConnectionsDurationMean, getConnectionsDurationStdDev, getConnectionsDurationTotal, getConnectionsOpen, getConnectionsOpenMax, getConnectionsRequestsMax, getConnectionsRequestsMean, getConnectionsRequestsStdDev, getForwardedCipherSuiteHeader, getForwardedForHeader, getForwardedHostHeader, getForwardedProtoHeader, getForwardedServerHeader, getForwardedSslSessionIdHeader, getHost, getHostHeader, getIntegralPort, getIntegralScheme, getLeftMostFieldValue, getLowResourceMaxIdleTime, getMaxBuffers, getMaxIdleTime, getName, getPort, getRequestBuffers, getRequestBufferSize, getRequestBufferType, getRequestHeaderSize, getRequestHeaderType, getRequests, getResolveNames, getResponseBuffers, getResponseBufferSize, getResponseBufferType, getResponseHeaderSize, getResponseHeaderType, getReuseAddress, getServer, getSoLingerTime, getStatsOn, getStatsOnMs, getThreadPool, isConfidential, isForwarded, isIntegral, isLowResources, join, setAcceptorPriorityOffset, setAcceptors, setAcceptQueueSize, setConfidentialPort, setConfidentialScheme, setForwarded, setForwardedCipherSuiteHeader, setForwardedForHeader, setForwardedHostHeader, setForwardedProtoHeader, setForwardedServerHeader, setForwardedSslSessionIdHeader, setHost, setHostHeader, setIntegralPort, setIntegralScheme, setLowResourceMaxIdleTime, setMaxBuffers, setName, setPort, setRequestBuffers, setRequestBufferSize, setRequestHeaderSize, setResolveNames, setResponseBuffers, setResponseBufferSize, setResponseHeaderSize, setReuseAddress, setServer, setSoLingerTime, setStatsOn, statsReset, stopAccept, toString
 
从类 org.eclipse.jetty.util.component.AggregateLifeCycle 继承的方法
addBean, addBean, contains, destroy, dump, dump, dump, dump, dump, dumpObject, dumpStdErr, dumpThis, getBean, getBeans, getBeans, isManaged, manage, removeBean, removeBeans, unmanage
 
从类 org.eclipse.jetty.util.component.AbstractLifeCycle 继承的方法
addLifeCycleListener, getState, getState, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop
 
从类 java.lang.Object 继承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
从接口 org.eclipse.jetty.util.component.LifeCycle 继承的方法
addLifeCycleListener, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop
 
从接口 org.eclipse.jetty.util.component.Dumpable 继承的方法
dump, dump
 

字段详细信息

_acceptChannel

protected ServerSocketChannel _acceptChannel
构造方法详细信息

SelectChannelConnector

public SelectChannelConnector()
Constructor.

方法详细信息

setThreadPool

public void setThreadPool(ThreadPool pool)
从类 AbstractConnector 复制的描述
Set the ThreadPool. The threadpool passed is added via AggregateLifeCycle.addBean(Object) so that it's lifecycle may be managed as a AggregateLifeCycle.

覆盖:
AbstractConnector 中的 setThreadPool
参数:
pool - the threadPool to set

accept

public void accept(int acceptorID)
            throws IOException
指定者:
AbstractConnector 中的 accept
抛出:
IOException

close

public void close()
           throws IOException
抛出:
IOException

customize

public void customize(EndPoint endpoint,
                      Request request)
               throws IOException
从接口 Connector 复制的描述
Customize a request for an endpoint. Called on every request to allow customization of the request for the particular endpoint (eg security properties from a SSL connection).

指定者:
接口 Connector 中的 customize
覆盖:
AbstractConnector 中的 customize
抛出:
IOException

persist

public void persist(EndPoint endpoint)
             throws IOException
从接口 Connector 复制的描述
Persist an endpoint. Called after every request if the connection is to remain open.

指定者:
接口 Connector 中的 persist
覆盖:
AbstractConnector 中的 persist
抛出:
IOException

getSelectorManager

public SelectorManager getSelectorManager()

getConnection

public Object getConnection()
返回:
the underlying socket, channel, buffer etc. for the connector.

getLocalPort

public int getLocalPort()
返回:
The actual port the connector is listening on or -1 if it has not been opened, or -2 if it has been closed.

open

public void open()
          throws IOException
从接口 Connector 复制的描述
Opens the connector

抛出:
IOException

setMaxIdleTime

public void setMaxIdleTime(int maxIdleTime)
从类 AbstractConnector 复制的描述
Set the maximum Idle time for a connection, which roughly translates to the Socket.setSoTimeout(int) call, although with NIO implementations other mechanisms may be used to implement the timeout. The max idle time is applied: Jetty interprets this value as the maximum time between some progress being made on the connection. So if a single byte is read or written, then the timeout (if implemented by jetty) is reset. However, in many instances, the reading/writing is delegated to the JVM, and the semantic is more strictly enforced as the maximum time a single read/write operation can take. Note, that as Jetty supports writes of memory mapped file buffers, then a write may take many 10s of seconds for large content written to a slow device.

Previously, Jetty supported separate idle timeouts and IO operation timeouts, however the expense of changing the value of soTimeout was significant, so these timeouts were merged. With the advent of NIO, it may be possible to again differentiate these values (if there is demand).

指定者:
接口 Connector 中的 setMaxIdleTime
覆盖:
AbstractConnector 中的 setMaxIdleTime
参数:
maxIdleTime - The maxIdleTime to set.

getLowResourcesConnections

public int getLowResourcesConnections()
返回:
the lowResourcesConnections

setLowResourcesConnections

public void setLowResourcesConnections(int lowResourcesConnections)
Set the number of connections, which if exceeded places this manager in low resources state. This is not an exact measure as the connection count is averaged over the select sets.

参数:
lowResourcesConnections - the number of connections
另请参见:
setLowResourcesMaxIdleTime(int)

getLowResourcesMaxIdleTime

public int getLowResourcesMaxIdleTime()
覆盖:
AbstractConnector 中的 getLowResourcesMaxIdleTime
返回:
the lowResourcesMaxIdleTime

setLowResourcesMaxIdleTime

public void setLowResourcesMaxIdleTime(int lowResourcesMaxIdleTime)
Set the period in ms that a connection is allowed to be idle when this there are more than getLowResourcesConnections() connections. This allows the server to rapidly close idle connections in order to gracefully handle high load situations.

覆盖:
AbstractConnector 中的 setLowResourcesMaxIdleTime
参数:
lowResourcesMaxIdleTime - the period in ms that a connection is allowed to be idle when resources are low.
另请参见:
setMaxIdleTime(int)

doStart

protected void doStart()
                throws Exception
从类 AggregateLifeCycle 复制的描述
Start the managed lifecycle beans in the order they were added.

覆盖:
AbstractConnector 中的 doStart
抛出:
Exception
另请参见:
AbstractLifeCycle.doStart()

newEndPoint

protected SelectChannelEndPoint newEndPoint(SocketChannel channel,
                                            SelectorManager.SelectSet selectSet,
                                            SelectionKey key)
                                     throws IOException
抛出:
IOException

endPointClosed

protected void endPointClosed(SelectChannelEndPoint endpoint)

newConnection

protected AsyncConnection newConnection(SocketChannel channel,
                                        AsyncEndPoint endpoint)


Copyright © 2013. All Rights Reserved.