Package org.apache.tomcat.util.net
Class Acceptor<U>
- java.lang.Object
-
- org.apache.tomcat.util.net.Acceptor<U>
-
- Type Parameters:
U- the type of the socket
- All Implemented Interfaces:
java.lang.Runnable
- Direct Known Subclasses:
Nio2Endpoint.Nio2Acceptor
public class Acceptor<U> extends java.lang.Object implements java.lang.RunnableAcceptor thread that accepts incoming connections.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classAcceptor.AcceptorStateStates of the acceptor lifecycle.
-
Field Summary
Fields Modifier and Type Field Description protected Acceptor.AcceptorStatestateCurrent state of the acceptor.
-
Constructor Summary
Constructors Constructor Description Acceptor(AbstractEndpoint<?,U> endpoint)Constructs a new Acceptor.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description Acceptor.AcceptorStategetState()Returns the current state of the acceptor.protected inthandleExceptionWithDelay(int currentErrorDelay)Handles exceptions where a delay is required to prevent a Thread from entering a tight loop which will consume CPU and may also trigger large amounts of logging.voidrun()voidstop()Deprecated.This method will be removed in Tomcat 10.1.x onwards.voidstop(int waitSeconds)Deprecated.Unused.voidstopMillis(int waitMilliseconds)Stops the acceptor, optionally waiting for it to finish.
-
-
-
Field Detail
-
state
protected volatile Acceptor.AcceptorState state
Current state of the acceptor.
-
-
Constructor Detail
-
Acceptor
public Acceptor(AbstractEndpoint<?,U> endpoint)
Constructs a new Acceptor.- Parameters:
endpoint- The endpoint associated with this acceptor
-
-
Method Detail
-
getState
public final Acceptor.AcceptorState getState()
Returns the current state of the acceptor.- Returns:
- The current acceptor state
-
run
public void run()
- Specified by:
runin interfacejava.lang.Runnable
-
stop
@Deprecated public void stop()
Deprecated.This method will be removed in Tomcat 10.1.x onwards. Usestop(int)instead.Signals the Acceptor to stop, waiting at most 10 seconds for the stop to complete before returning. If the stop does not complete in that time a warning will be logged.
-
stop
@Deprecated public void stop(int waitSeconds)
Deprecated.Unused. Will be remove in Tomcat 11 onwards.Signals the Acceptor to stop, optionally waiting for that stop process to complete before returning. If a wait is requested and the stop does not complete in that time a warning will be logged.- Parameters:
waitSeconds- The time to wait in seconds. Use a value less than zero for no wait.
-
stopMillis
public void stopMillis(int waitMilliseconds)
Stops the acceptor, optionally waiting for it to finish.- Parameters:
waitMilliseconds- The number of milliseconds to wait for the acceptor to stop
-
handleExceptionWithDelay
protected int handleExceptionWithDelay(int currentErrorDelay)
Handles exceptions where a delay is required to prevent a Thread from entering a tight loop which will consume CPU and may also trigger large amounts of logging. For example, this can happen if the ulimit for open files is reached.- Parameters:
currentErrorDelay- The current delay being applied on failure- Returns:
- The delay to apply on the next failure
-
-