public class ServerManagementTCP extends ServerManagement
Modifier and Type | Class and Description |
---|---|
private class |
ServerManagementTCP.ClientHandler
Private runnable class allowing to serve one client.
|
Modifier and Type | Field and Description |
---|---|
private java.net.ServerSocket |
socket |
baseDirectory, fileListWatcher, logger, punisher, ratioWatcher, server, stop, tracker
Constructor and Description |
---|
ServerManagementTCP(java.lang.String baseDirectory,
HostItem server,
HostItem tracker,
Logger logger)
Constructor for TCP implementation, with baseDirectory and TCPPort parameters.
|
Modifier and Type | Method and Description |
---|---|
protected void |
closeSocket()
Closes socket
|
protected <T extends Payload> |
createProtocolP2PPacket(T payload)
Create packets
|
protected java.lang.Object |
getTrackerSocket()
Getter for tracker socket
|
void |
run()
Implementation of runnable.
|
protected void |
writeLog(java.lang.Exception e,
LogLevel logLevel)
Implementation of writeLog
|
protected void |
writeLog(java.lang.String text,
LogLevel logLevel)
Implementation of writeLog
|
handleRequest, sendHashResponse, sendListResponse, sendLoadResponse, sendSizeResponse, sendUnregisterRequest, setStop, updateFileList
sendEmptyDirectory, sendEmptyFile, sendInternalError, sendNotATracker, sendNotFound, sendUnknownHost
public ServerManagementTCP(java.lang.String baseDirectory, HostItem server, HostItem tracker, Logger logger)
baseDirectory
- the root directory where files are storedhostName
- the server will bind on this addressTCPPort
- the server will listen on this portlogger
- Logger itemtracker
- Trackerpublic void run()
protected void writeLog(java.lang.String text, LogLevel logLevel)
writeLog
in class ServeErrors
text
- Text to loglogLevel
- level of loggingprotected void writeLog(java.lang.Exception e, LogLevel logLevel)
writeLog
in class ServeErrors
e
- exception to loglogLevel
- level of loggingprotected <T extends Payload> ProtocolP2PPacket<T> createProtocolP2PPacket(T payload)
createProtocolP2PPacket
in class ServeErrors
payload
- Payloadprotected java.lang.Object getTrackerSocket() throws java.net.SocketException, java.net.UnknownHostException, java.io.IOException
getTrackerSocket
in class ServerManagement
java.net.SocketException
java.net.UnknownHostException
java.io.IOException
protected void closeSocket()
closeSocket
in class ServerManagement