java.lang.Object
org.klomp.snark.UDPTrackerClient.HostPort
org.klomp.snark.UDPTrackerClient.Tracker
- Enclosing class:
UDPTrackerClient
One UDP tracker and its connection state.
Field Summary
FieldsModifier and TypeFieldDescriptionprivate LongConnection id from the tracker, null when none is held.private intConsecutive failed requests to this tracker.private DestinationDestination used for the connection to this tracker.private final ObjectLock guarding the tracker destination.private longWhen the connection id expires.private UDPTrackerClient.ConnStateCurrent state of the connection id.Constructor Summary
Method Summary
All MethodsModifier and TypeMethodDescriptionvoidCalled when tracker connection attempt fails.The connection ID, or null if invalid.getDest(boolean fast) The destination, or null.longThe query timeout for this connection: the default, doubled for each consecutive failure up to eight times the default.voidgotError()Mark an error and notify waiters.booleanWhether a connection is in progress.booleanWhether the connection is valid.voidDoes not change state.voidsetConnection(long cid, long lifetime) Store the connection ID and expiration.voidsetConnInProgress(boolean yes) Store whether a connection to the tracker is in progress.toString()String form of the waiter.Methods inherited from class UDPTrackerClient.HostPort
equals, getPort, hashCode
Field Details
destLock
Lock guarding the tracker destination.dest
Destination used for the connection to this tracker.cid
Connection id from the tracker, null when none is held.expires
private long expiresWhen the connection id expires.consecFails
private int consecFailsConsecutive failed requests to this tracker.state
Current state of the connection id.
Constructor Details
Tracker
Prepares to talk to one UDP tracker.- Parameters:
host- the tracker hostport- the tracker port
Method Details
getDest
The destination, or null.- Parameters:
fast- if true, do not lookup- Returns:
- dest or null
setConnInProgress
public void setConnInProgress(boolean yes) Store whether a connection to the tracker is in progress.- Parameters:
yes- true while a connection is in progress
isConnInProgress
public boolean isConnInProgress()Whether a connection is in progress.- Returns:
- whether conn in progress
isConnValid
public boolean isConnValid()Whether the connection is valid.- Returns:
- whether conn valid
connFailed
public void connFailed()Called when tracker connection attempt fails.replyTimeout
public void replyTimeout()Does not change state.setConnection
public void setConnection(long cid, long lifetime) Store the connection ID and expiration.- Parameters:
cid- the connection ID to storelifetime- milliseconds from now until the ID expires
getConnection
gotError
public void gotError()Mark an error and notify waiters.getTimeout
public long getTimeout()The query timeout for this connection: the default, doubled for each consecutive failure up to eight times the default.- Returns:
- the timeout in milliseconds
toString
String form of the waiter.- Overrides:
toStringin classUDPTrackerClient.HostPort