Class WebServerClientSocketThread
java.lang.Object
java.lang.Thread
net.sf.colossus.webserver.WebServerClientSocketThread
- All Implemented Interfaces:
Runnable
Thread to handle one user client connection at the WebServer side.
Reads always one line from the socket, hands it over to the actual
WebServerClient to parse and handle it.
- Author:
- Clemens Katzer
-
Nested Class Summary
Nested classes/interfaces inherited from class Thread
Thread.Builder, Thread.State, Thread.UncaughtExceptionHandler -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate booleanprivate booleanprivate booleanprivate static final intprivate static final intprivate intprivate longprivate boolean(package private) static final Loggerprivate final longprivate static final intprivate static final longprivate intprivate intprivate final RoundtripTimeBookkeeperprivate Socketprivate Threadprivate final WebServerClientprivate booleanprivate QueuedSocketWriterFields inherited from class Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcheckMaxIdleTime(long now) Currently this will log out only older clients, because they do not respond to the ping packets.voidprivate voidvoidvoidWaits until writer has written all messagesprotected void(package private) Stringprivate voidvoidrequestPingIfNeeded(long now) voidvoidrun()prepare socket to read/write, and then loop as long as lines from client come, and parse themvoidSend the given string/message over the socket to the client Calculate the time how long it took to write it to the socket, and log a warning if it was blocked in the write for more than MAX_WRITE_BLOCKTIME_MS milliseconds.voidvoidstoreEntry(long requestResponseArriveTime, long roundtripTime) Simply forward the RTT entry creation to the RTT bookkeepervoid(package private) booleanMethods inherited from class Thread
activeCount, checkAccess, clone, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, isVirtual, join, join, join, join, ofPlatform, ofVirtual, onSpinWait, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, sleep, start, startVirtualThread, stop, threadId, toString, yield
-
Field Details
-
LOGGER
-
PING_REQUEST_INTERVAL_SECONDS
private static final long PING_REQUEST_INTERVAL_SECONDS- See Also:
-
PING_MAX_TRIES
private static final int PING_MAX_TRIES- See Also:
-
IDLE_WARNING_INTERVAL_MINUTES
private static final int IDLE_WARNING_INTERVAL_MINUTES- See Also:
-
IDLE_WARNING_MAXCOUNT
private static final int IDLE_WARNING_MAXCOUNT- See Also:
-
MAX_WRITE_BLOCKTIME_MS
private final long MAX_WRITE_BLOCKTIME_MS- See Also:
-
theClient
-
rttBookKeeper
-
socket
-
writer
-
lastPacketReceived
private long lastPacketReceived -
pingsTried
private int pingsTried -
pingCounter
private int pingCounter -
idleWarningsSent
private int idleWarningsSent -
connLostWarningLogged
private boolean connLostWarningLogged -
stopper
-
forcedLogout
private boolean forcedLogout -
done
private boolean done -
toldToTerminate
private boolean toldToTerminate -
lastWasLogin
private boolean lastWasLogin
-
-
Constructor Details
-
WebServerClientSocketThread
-
-
Method Details
-
getClientInfo
String getClientInfo() -
createStopper
-
tellToTerminate
public void tellToTerminate() -
setLastWasLogin
public void setLastWasLogin() -
closeAndCleanupSocket
private void closeAndCleanupSocket() -
run
-
sendToClient
Send the given string/message over the socket to the client Calculate the time how long it took to write it to the socket, and log a warning if it was blocked in the write for more than MAX_WRITE_BLOCKTIME_MS milliseconds.- Parameters:
s-
-
flushMessages
public void flushMessages()Waits until writer has written all messages -
storeEntry
public void storeEntry(long requestResponseArriveTime, long roundtripTime) Simply forward the RTT entry creation to the RTT bookkeeper- Parameters:
requestResponseArriveTime- When response arrivedroundtripTime- Actual roundtrip time
-
requestPingIfNeeded
public void requestPingIfNeeded(long now) -
requestPingNow
public void requestPingNow() -
markForcedLogout
private void markForcedLogout() -
wasForcedLogout
boolean wasForcedLogout() -
forceLogout
-
clearIdleWarningsSent
public void clearIdleWarningsSent() -
checkMaxIdleTime
public void checkMaxIdleTime(long now) Currently this will log out only older clients, because they do not respond to the ping packets. TODO in future, distinct between ping packets and all other activities, and log out user which hasn't done anything and left WebClient standing around idle for very long.- Parameters:
now-
-