Methods Summary |
---|
protected java.net.Socket | acceptSocket()
if( !isRunning() || getServerSocket()==null ) return null;
Socket socket = null;
try {
if(getServerSocketFactory()==null) {
socket = getServerSocketChannel().accept().socket();
} else {
socket = getServerSocketFactory().acceptSocket(getServerSocket());
}
if (null == socket) {
getLogger().log(Level.WARNING,"selectorThread.acceptSocket");
} else {
if (!isRunning()) {
socket.close(); // rude, but unlikely!
socket = null;
} else if (getServerSocketFactory() != null) {
getServerSocketFactory().initSocket( socket );
}
}
} catch(InterruptedIOException iioe) {
// normal part -- should happen regularly so
// that the endpoint can release if the server
// is shutdown.
} catch (AccessControlException ace) {
// When using the Java SecurityManager this exception
// can be thrown if you are restricting access to the
// socket with SocketPermission's.
// Log the unauthorized access and continue
getLogger().log(Level.WARNING,"selectorThread.wrongPermission",
new Object[]{getServerSocket(), ace});
} catch (IOException e) {
String msg = null;
if (isRunning()) {
getLogger().log(Level.SEVERE,"selectorThread.shutdownException",
new Object[]{getServerSocket(), e});
}
if (socket != null) {
try {
socket.close();
} catch(Throwable ex) {
getLogger().log(Level.SEVERE,"selectorThread.shutdownException",
new Object[]{getServerSocket(), ex});
}
socket = null;
}
if( !isRunning() ) return null;
} catch (Throwable t) {
try{
if (socket != null)
socket.close();
} catch (IOException ex){
;
}
getLogger().log(Level.FINE,
"selectorThread.errorOnRequest",
t);
}
return socket;
|
public java.lang.String[] | getEnabledCipherSuites()
return null;
|
public java.lang.String[] | getEnabledProtocols()
return null;
|
protected ReadBlockingTask | getReadBlockingTask(java.net.Socket socket)Return a ReadBlockingTask from the pool.
If the pool is empty,
create a new instance.
ReadBlockingTask task = null;
if (isRecycleTasks()) {
task = (ReadBlockingTask)getReadTasks().poll();
}
if (task == null){
task = newReadBlockingTask(false);
}
ProcessorTask processorTask = task.getProcessorTask();
processorTask.setSocket(socket);
return task;
|
public org.apache.tomcat.util.net.SSLImplementation | getSSLImplementation()Return the current SSLImplementation this Thread
return sslImplementation;
|
public org.apache.tomcat.util.net.ServerSocketFactory | getServerSocketFactory()Return the ServerSocketFactory used when a blocking IO
is enabled.
return factory;
|
private void | handleConnection(java.net.Socket socket)Handle a blocking operation on the socket.
if (isMonitoringEnabled()) {
getGlobalRequestProcessor().increaseCountOpenConnections();
getPipelineStat().incrementTotalAcceptCount();
}
getReadBlockingTask(socket).execute();
|
public void | initEndpoint()initialized the endpoint by creating the ServerSocketChannel
and by initializing the server socket.
SelectorThreadConfig.configure(this);
initFileCacheFactory();
initAlgorithm();
initPipeline();
initMonitoringLevel();
setName("SelectorThread-" + getPort());
try{
if (getInet() == null) {
setServerSocket(getServerSocketFactory().createSocket(getPort(),
getSsBackLog()));
} else {
setServerSocket(getServerSocketFactory().createSocket(getPort(),
getSsBackLog(), getInet()));
}
getServerSocket().setReuseAddress(true);
} catch (SocketException ex){
throw new BindException(ex.getMessage() + ": " + getPort());
}
getServerSocket().setSoTimeout(getServerTimeout());
initReadBlockingTask(getMinReadQueueLength());
setInitialized(true);
getLogger().log(Level.FINE,"Initializing Grizzly Blocking Mode");
|
private void | initReadBlockingTask(int size)Create a pool of ReadBlockingTask
for (int i=0; i < size; i++){
getReadTasks().offer(newReadBlockingTask(false));
}
|
public boolean | isClientMode()
return false;
|
public boolean | isNeedClientAuth()
return false;
|
public boolean | isWantClientAuth()
return false;
|
protected com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask | newProcessorTask(boolean initialize)Create ProcessorTask objects and configure it to be ready
to proceed request.
ProcessorBlockingTask task = new ProcessorBlockingTask(initialize);
configureProcessorTask(task);
task.setMaxKeepAliveRequests(getMaxKeepAliveRequests());
if (secure){
task.setSSLImplementation(sslImplementation);
}
return task;
|
private ReadBlockingTask | newReadBlockingTask(boolean initialize)Create a ReadBlockingTask instance used with blocking
socket.
ReadBlockingTask task = new ReadBlockingTask();
task.setSelectorThread(this);
task.setPipeline(getProcessorPipeline());
task.setRecycle(isRecycleTasks());
task.attachProcessor(newProcessorTask(initialize));
task.setPipelineStatistic(getPipelineStat());
task.setSecure(secure);
return task;
|
public void | setClientMode(boolean clientMode)
|
public void | setEnabledCipherSuites(java.lang.String[] enabledCipherSuites)
|
public void | setEnabledProtocols(java.lang.String[] enabledProtocols)
|
public void | setNeedClientAuth(boolean needClientAuth)
|
public void | setSSLImplementation(org.apache.tomcat.util.net.SSLImplementation sslImplementation)Set the SSLImplementation used by this thread.It usually
means HTTPS will be used.
this.sslImplementation = sslImplementation;
|
public void | setSecure(boolean secure)
this.secure = secure;
|
public void | setServerSocketFactory(org.apache.tomcat.util.net.ServerSocketFactory factory)Set the ServerSocketFactory used when a blocking IO
is enabled.
this.factory = factory;
|
protected void | setSocketOptions(java.net.Socket socket)
super.setSocketOptions(socket);
if( getKeepAliveTimeoutInSeconds() > 0){
try{
socket.setSoTimeout( getKeepAliveTimeoutInSeconds() * 1000 );
} catch (SocketException ex){
logger.log(Level.WARNING,
"setSoTimeout exception ",ex);
}
}
|
public void | setWantClientAuth(boolean wantClientAuth)
|
public void | startEndpoint()Start the Acceptor Thread and wait for incoming connection, in a non
blocking mode.
setRunning(true);
rampUpProcessorTask();
registerComponents();
startPipelines();
startListener();
|
protected void | startListener()Start a blocking server Socket
Socket socket = null;
while (isRunning()){
socket = acceptSocket();
if (socket == null) {
continue;
}
try {
handleConnection(socket);
} catch (Throwable ex) {
getLogger().log(Level.FINE,
"selectorThread.handleConnectionException",
ex);
try {
socket.close();
} catch (IOException ioe){
// Do nothing
}
continue;
}
}
|