public abstract class TrackerManagement extends ServeErrors implements java.lang.Runnable
Modifier and Type | Field and Description |
---|---|
protected java.util.Map<java.lang.String,java.util.List<HostItem>> |
fileList |
protected java.util.Map<java.lang.String,java.lang.Long> |
fileSize |
protected java.util.List<HostItem> |
hostList |
protected Logger |
logger |
protected java.util.Map<HostItem,java.lang.Long> |
ratioDown |
protected java.util.Map<HostItem,java.lang.Long> |
ratioUp |
protected java.util.concurrent.atomic.AtomicInteger |
readLock |
protected boolean |
stop |
protected HostItem |
tracker |
protected java.util.concurrent.atomic.AtomicBoolean |
writeLock |
Constructor and Description |
---|
TrackerManagement(HostItem tracker,
Logger logger)
Constructor
|
Modifier and Type | Method and Description |
---|---|
protected abstract void |
closeHostItemSocket(HostItem hostItem)
Close HostItem socket
|
protected abstract java.lang.Object |
getHostItemSocket(HostItem hostItem)
Getter for HostItem socket
|
protected <T extends ProtocolP2PPacket<?>> |
handleDiscover(T pd)
Handle Discover request
|
protected <T extends ProtocolP2PPacket<?>> |
handleListRequest(T pd)
Handle List request
|
protected <T extends ProtocolP2PPacket<?>> |
handleListResponse(T pd,
HostItem host)
Handle List Responses
|
protected <T extends ProtocolP2PPacket<?>> |
handleRatio(T pd)
Handle Ratio request
|
protected <T extends ProtocolP2PPacket<?>> |
handleRegister(T pd)
Handle Registering
|
protected <T extends ProtocolP2PPacket<?>> |
handleRequest(T pd)
Handle requests
|
protected <T extends ProtocolP2PPacket<?>> |
handleSizeRequest(T pd)
Handle Size request
|
protected <T extends ProtocolP2PPacket<?>> |
handleUnregister(T pd)
Handle Unregistering
|
protected <T extends ProtocolP2PPacket<?>> |
handleUpdateRatio(T pd)
Handle Update Ratio
|
void |
setStop()
Stop the thread
|
createProtocolP2PPacket, sendEmptyDirectory, sendEmptyFile, sendInternalError, sendNotATracker, sendNotFound, sendUnknownHost, writeLog, writeLog
protected HostItem tracker
protected Logger logger
protected java.util.List<HostItem> hostList
protected java.util.Map<HostItem,java.lang.Long> ratioUp
protected java.util.Map<HostItem,java.lang.Long> ratioDown
protected java.util.Map<java.lang.String,java.util.List<HostItem>> fileList
protected java.util.Map<java.lang.String,java.lang.Long> fileSize
protected volatile boolean stop
protected java.util.concurrent.atomic.AtomicBoolean writeLock
protected java.util.concurrent.atomic.AtomicInteger readLock
protected <T extends ProtocolP2PPacket<?>> void handleDiscover(T pd) throws InternalError
pd
- Received requestInternalError
protected <T extends ProtocolP2PPacket<?>> void handleRatio(T pd) throws InternalError
pd
- Received requestInternalError
protected <T extends ProtocolP2PPacket<?>> void handleListResponse(T pd, HostItem host) throws InternalError
pd
- Received responseInternalError
protected <T extends ProtocolP2PPacket<?>> void handleUnregister(T pd) throws InternalError
pd
- Request receivedInternalError
protected abstract java.lang.Object getHostItemSocket(HostItem hostItem)
hostItem
- HostItemprotected abstract void closeHostItemSocket(HostItem hostItem)
hostItem
- HostItemprotected <T extends ProtocolP2PPacket<?>> void handleUpdateRatio(T pd) throws InternalError
pd
- Received requestInternalError
protected <T extends ProtocolP2PPacket<?>> void handleRegister(T pd) throws InternalError
pd
- Received requestInternalError
protected <T extends ProtocolP2PPacket<?>> void handleListRequest(T pd) throws InternalError
pd
- Received requestInternalError
protected <T extends ProtocolP2PPacket<?>> void handleSizeRequest(T pd) throws InternalError
pd
- Received requestInternalError
protected <T extends ProtocolP2PPacket<?>> void handleRequest(T pd) throws LocalException
LocalException
public void setStop()