public abstract class ServerManagement extends ServeErrors implements java.lang.Runnable
Modifier and Type | Field and Description |
---|---|
protected java.lang.String |
baseDirectory |
protected FileWatcher |
fileListWatcher |
protected Logger |
logger |
protected java.util.Random |
punisher |
protected RatioWatcher |
ratioWatcher |
protected HostItem |
server |
protected boolean |
stop |
protected HostItem |
tracker |
Constructor and Description |
---|
ServerManagement(java.lang.String baseDirectory,
HostItem server,
HostItem tracker,
Logger logger)
Constructor
|
Modifier and Type | Method and Description |
---|---|
protected abstract void |
closeSocket()
Closes socket
|
protected abstract java.lang.Object |
getTrackerSocket()
Getter for tracker socket
|
protected <T extends ProtocolP2PPacket<?>> |
handleRequest(T pd)
Handle request.
|
protected <T extends ProtocolP2PPacket<?>> |
sendHashResponse(T pd)
Send hash response to hash request
|
protected <T extends ProtocolP2PPacket<?>> |
sendListResponse(T pd)
Send response to list request
|
protected <T extends ProtocolP2PPacket<?>> |
sendLoadResponse(T pd)
Send response to load request
|
protected <T extends ProtocolP2PPacket<?>> |
sendSizeResponse(T pd)
Send response to size request
|
protected void |
sendUnregisterRequest()
Send unregister request to tracker
|
void |
setStop()
Stop the thread
|
void |
updateFileList()
Trigger a manual check of the file list
|
createProtocolP2PPacket, sendEmptyDirectory, sendEmptyFile, sendInternalError, sendNotATracker, sendNotFound, sendUnknownHost, writeLog, writeLog
protected volatile boolean stop
protected FileWatcher fileListWatcher
protected Logger logger
protected java.lang.String baseDirectory
protected HostItem server
protected HostItem tracker
protected java.util.Random punisher
protected RatioWatcher ratioWatcher
public void setStop()
protected abstract void closeSocket()
public void updateFileList()
protected <T extends ProtocolP2PPacket<?>> void sendListResponse(T pd)
pd
- Request receivedprotected <T extends ProtocolP2PPacket<?>> void sendHashResponse(T pd)
pd
- Request receivedprotected <T extends ProtocolP2PPacket<?>> void sendLoadResponse(T pd)
pd
- Request receivedprotected <T extends ProtocolP2PPacket<?>> void sendSizeResponse(T pd)
pd
- Request receivedprotected abstract java.lang.Object getTrackerSocket() throws java.net.SocketException, java.net.UnknownHostException, java.io.IOException
java.net.SocketException
java.net.UnknownHostException
java.io.IOException
protected void sendUnregisterRequest()
protected <T extends ProtocolP2PPacket<?>> void handleRequest(T pd) throws LocalException
LocalException