Class PiecePickerImpl
- java.lang.Object
-
- com.biglybt.core.peermanager.piecepicker.impl.PiecePickerImpl
-
- All Implemented Interfaces:
PiecePicker
public class PiecePickerImpl extends java.lang.Object implements PiecePicker
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private class
PiecePickerImpl.DiskManagerListenerImpl
An instance of this listener is registered with peerControlprivate class
PiecePickerImpl.PEPeerListenerImpl
An instance of this listener is registered with each peerprivate class
PiecePickerImpl.PEPeerManagerListenerImpl
An instance of this listener is registered with peerControl Through this, we learn of peers joining and leaving and attach/detach listeners to themprotected static class
PiecePickerImpl.RealTimeData
private static class
PiecePickerImpl.RealTimePeerRequest
-
Field Summary
Fields Modifier and Type Field Description private int
allocate_request_loop_count
protected int[]
availability
periodically updated consistent view of availability for calculatingprotected int[]
availabilityAsynch
asyncronously updated availabilityprotected long
availabilityChange
private long
availabilityComputeChange
protected long
availabilityDrift
indicates availability needs to be recomputed due to detected driftprotected AEMonitor
availabilityMon
private long
bytesUnavailable
protected static boolean
completionPriority
private DiskManager
diskManager
private PiecePickerImpl.DiskManagerListenerImpl
diskManagerListener
private SpeedTokenDispenser
dispenser
protected DiskManagerPiece[]
dmPieces
private static boolean
EGM_IS_BLOCK_BASED
private static boolean
enable_request_hints
private static long
END_GAME_MODE_RESERVED_TRIGGER
private static long
END_GAME_MODE_RESERVED_TRIGGER_BLOCKS
private static long
END_GAME_MODE_SIZE_TRIGGER
private static long
END_GAME_MODE_SIZE_TRIGGER_BLOCKS
private static long
END_GAME_MODE_TIMEOUT
private boolean
endGameMode
A flag to indicate when we're in endgame modeprivate boolean
endGameModeAbandoned
private java.lang.Object
endGameModeChunkLock
private java.util.Map<java.lang.Long,EndGameModeChunk>
endGameModeChunkMap
private java.util.LinkedList<EndGameModeChunk>
endGameModeChunks
The list of chunks needing to be downloaded (the mechanism change when entering end-game mode)private float[]
fileAvailabilities
private long
fileAvailabilitiesCalcTime
protected long
filePriorityChange
event # of user file priority settings changesprivate static long
FIRST_PIECE_MIN_NB
min # pieces in file for first/last prioritizationprotected static boolean
firstPiecePriority
protected static boolean
firstPiecePriorityForce
private CopyOnWriteSet<java.lang.Integer>
forced_pieces
private int[]
global_request_hint
private float
globalAvail
private float
globalAvgAvail
private int
globalMax
private int
globalMin
private int
globalMinOthers
The rarest availability level of pieces that we affirmatively want to try to request from others soonest ie; our prime targets for requesting rarest piecesprotected boolean
hasNeededUndonePiece
private static boolean
includeLanPeersInReqLimiting
private long
lastProviderRecalcTime
private CopyOnWriteList<PiecePickerListener>
listeners
private static boolean
LOG_RTA
private static LogIDs
LOGID
private int
max_file_priority
private int
min_file_priority
protected int
nbPieces
protected int
nbPiecesDone
private int
nbRarestActive
protected long
neededUndonePieceChange
private static int
NO_REQUEST_BACKOFF_MAX_LOOPS
private static int
NO_REQUEST_BACKOFF_MAX_MILLIS
protected static long
paramPriorityChange
event # of user settings controlling priority changesprivate PEPeerControl
peerControl
protected java.util.Map
peerListeners
private PEPeerManagerListener
peerManagerListener
protected PEPiece[]
pePieces
private static int
PRIORITY_DW_AGE
ms a block is expected to complete inprivate static int
PRIORITY_DW_STALE
ms since last writeprivate static int
PRIORITY_FORCED
private static int
PRIORITY_OVERRIDES_RAREST
currently webseeds + other explicit priorities are around 10000 or more - at this point we ignore rarityprivate CopyOnWriteList
priority_providers
private static int
PRIORITY_REALTIME
priority at and above which pieces require real-time schedulingprivate static int
PRIORITY_REQUEST_HINT
private static int
PRIORITY_SEQUENTIAL_START
private static int
PRIORITY_W_AGE
priority boost due to being too oldprivate static int
PRIORITY_W_COMPLETION
Additional boost for more completed High priorityprivate static int
PRIORITY_W_FILE_BASE
user sets file as "High"private static int
PRIORITY_W_FILE_RANGE
private static int
PRIORITY_W_FIRSTLAST
user select prioritize first/lastprivate static int
PRIORITY_W_PIECE_DONE
finish pieces already almost doneprivate static int
PRIORITY_W_SAME_PIECE
keep working on same pieceprivate long
priorityAvailChange
last availability event # when priority bases were calculatedprivate long
priorityFileChange
last user priority event # when priority bases were calculatedprivate long
priorityParamChange
last user parameter settings event # when priority bases were calculatedprivate boolean
priorityRTAexists
private long[]
provider_piece_priorities
private long[]
provider_piece_rtas
(package private) static java.util.Random
random
private java.util.List<PEPiece>
rarestStartedPieces
private static int
REQUESTS_MAX
Max number of request sent to a peerprivate static int
REQUESTS_MIN_MAX
private static int
REQUESTS_MIN_MIN
Min number of requests sent to a peerprivate boolean
reverse_block_order
private static long
RTA_END_GAME_MODE_SIZE_TRIGGER
private static long
RTA_END_GAME_MODE_SIZE_TRIGGER_BLOCKS
private CopyOnWriteList
rta_providers
protected int
sequentialDownload
private static int
SLOPE_REQUESTS
Default number of requests sent to a peer, (for each X B/s another request will be used)private int[]
startPriorities
the priority for starting each piece/base priority for resumingprivate static long
TIME_AVAIL_REBUILD
min ms for forced availability rebuildprivate long
time_last_avail
private long
time_last_rebuild
private static long
TIME_MIN_AVAILABILITY
min ms for recalculating availability - reducing this has serious ramificationsprivate static long
TIME_MIN_FILE_AVAILABILITY
private static long
TIME_MIN_PRIORITIES
min ms for recalculating base prioritiesprivate long
timeAvailLessThanOne
private long
timeAvailRebuild
private long
timeEndGameModeEntered
private long
timeLastPriorities
time that base priorities were last computed-
Fields inherited from interface com.biglybt.core.peermanager.piecepicker.PiecePicker
REQUEST_HINT_MAX_LIFE
-
-
Constructor Summary
Constructors Constructor Description PiecePickerImpl(PEPeerControl pc)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
abandonEndGameMode()
void
addEndGameChunks(PEPiece pePiece)
adds every block from the piece to the list of chuncks to be selected for egm requestingvoid
addHavePiece(PEPeer peer, int pieceNumber)
void
addListener(PiecePickerListener listener)
void
addPriorityProvider(PiecePriorityProvider provider)
void
addRTAProvider(PieceRTAProvider provider)
void
allocateRequests()
one reason requests don't stem from the individual peers is so the connections can be sorted by best uploaders, providing some ooprtunity to download the most important (ie; rarest and/or highest priority) pieces faster and more reliablyprivate int
calcRarestAllowed()
Count current global min avail pieces in progress (not counting non-rarest pieces but keep them to compensate high churn, remove completed ones, ignore idle ones)protected void
checkDownloadablePiece()
Early-outs when finds a downloadable piece Either way sets hasNeededUndonePiece and neededUndonePieceChange if necessaryprivate void
checkEndGameMode()
void
clearEndGameChunks()
void
clearSequential()
private void
computeBasePriorities()
This computes the base priority for all pieces that need requesting if there's been any availability change or user priority setting changes since the last call, which will be most of the time since availability changes so dynamicaly It will change startPriorities[] (unless there was nothing to do)private void
computeEndGameModeChunks()
private boolean
computeProviderPriorities()
void
destroy()
protected int
findPieceInEndGameMode(PEPeerTransport pt, int wants)
protected int
findPieceToDownload(PEPeerTransport pt, int nbWanted)
protected boolean
findRTAPieceToDownload(PEPeerTransport pt, boolean best_uploader, long best_uploader_next_block_eta)
void
generateEvidence(IndentWriter writer)
int[]
getAvailability()
int
getAvailability(int pieceNumber)
long
getAvailWentBadTime()
float
getAvgAvail()
long
getBytesUnavailable()
java.lang.String
getEGMInfo()
int
getEGMRequestCount(int piece_number, int block_number)
int[]
getGlobalRequestHint()
int
getMaxAvailability()
float
getMinAvailability()
float
getMinAvailability(int fileIndex)
int
getNbPiecesDone()
long
getNeededUndonePieceChange()
protected int
getNextBlockETAFromNow(PEPeerTransport pt)
int
getNumberOfPieces()
PEPeerManager
getPeerManager()
java.lang.String
getPieceString(int piece_number)
protected int
getPieceToStart(BitFlags startCandidates)
java.util.List
getPriorityProviders()
private int
getRequestCandidate(PEPeerTransport pt)
This method is the downloading core.boolean
getReverseBlockOrder()
java.util.List
getRTAProviders()
int
getSequentialInfo()
boolean
hasDownloadablePiece()
boolean
hasEndGameModeBeenAbandoned()
boolean
isForcePiece(int pieceNumber)
boolean
isInEndGameMode()
protected void
leaveEndGameMode()
private int[]
recomputeAvailability()
void
removeFromEndGameModeChunks(int pieceNumber, int offset)
void
removeListener(PiecePickerListener listener)
void
removePriorityProvider(PiecePriorityProvider provider)
void
removeRTAProvider(PieceRTAProvider provider)
void
setForcePiece(int pieceNumber, boolean forced)
void
setGlobalRequestHint(int piece_number, int start_bytes, int byte_count)
void
setReverseBlockOrder(boolean is_reverse)
void
setSequentialAscendingFrom(int start_piece)
void
setSequentialDescendingFrom(int start_piece)
private void
setSequentialDownload(int val)
private void
syncFilePriorities()
void
updateAvailability()
This methd will compute the pieces' overall availability (including ourself) and the _globalMinOthers & _globalAvail
-
-
-
Field Detail
-
LOG_RTA
private static final boolean LOG_RTA
- See Also:
- Constant Field Values
-
EGM_IS_BLOCK_BASED
private static final boolean EGM_IS_BLOCK_BASED
- See Also:
- Constant Field Values
-
LOGID
private static final LogIDs LOGID
-
TIME_MIN_AVAILABILITY
private static final long TIME_MIN_AVAILABILITY
min ms for recalculating availability - reducing this has serious ramifications- See Also:
- Constant Field Values
-
TIME_MIN_FILE_AVAILABILITY
private static final long TIME_MIN_FILE_AVAILABILITY
- See Also:
- Constant Field Values
-
TIME_MIN_PRIORITIES
private static final long TIME_MIN_PRIORITIES
min ms for recalculating base priorities- See Also:
- Constant Field Values
-
TIME_AVAIL_REBUILD
private static final long TIME_AVAIL_REBUILD
min ms for forced availability rebuild- See Also:
- Constant Field Values
-
PRIORITY_W_FIRSTLAST
private static final int PRIORITY_W_FIRSTLAST
user select prioritize first/last- See Also:
- Constant Field Values
-
FIRST_PIECE_MIN_NB
private static final long FIRST_PIECE_MIN_NB
min # pieces in file for first/last prioritization- See Also:
- Constant Field Values
-
PRIORITY_W_FILE_BASE
private static final int PRIORITY_W_FILE_BASE
user sets file as "High"- See Also:
- Constant Field Values
-
PRIORITY_W_FILE_RANGE
private static final int PRIORITY_W_FILE_RANGE
- See Also:
- Constant Field Values
-
PRIORITY_W_COMPLETION
private static final int PRIORITY_W_COMPLETION
Additional boost for more completed High priority- See Also:
- Constant Field Values
-
PRIORITY_W_AGE
private static final int PRIORITY_W_AGE
priority boost due to being too old- See Also:
- Constant Field Values
-
PRIORITY_DW_AGE
private static final int PRIORITY_DW_AGE
ms a block is expected to complete in- See Also:
- Constant Field Values
-
PRIORITY_DW_STALE
private static final int PRIORITY_DW_STALE
ms since last write- See Also:
- Constant Field Values
-
PRIORITY_W_PIECE_DONE
private static final int PRIORITY_W_PIECE_DONE
finish pieces already almost done- See Also:
- Constant Field Values
-
PRIORITY_W_SAME_PIECE
private static final int PRIORITY_W_SAME_PIECE
keep working on same piece- See Also:
- Constant Field Values
-
PRIORITY_OVERRIDES_RAREST
private static final int PRIORITY_OVERRIDES_RAREST
currently webseeds + other explicit priorities are around 10000 or more - at this point we ignore rarity- See Also:
- Constant Field Values
-
PRIORITY_REQUEST_HINT
private static final int PRIORITY_REQUEST_HINT
- See Also:
- Constant Field Values
-
PRIORITY_SEQUENTIAL_START
private static final int PRIORITY_SEQUENTIAL_START
- See Also:
- Constant Field Values
-
PRIORITY_REALTIME
private static final int PRIORITY_REALTIME
priority at and above which pieces require real-time scheduling- See Also:
- Constant Field Values
-
PRIORITY_FORCED
private static final int PRIORITY_FORCED
- See Also:
- Constant Field Values
-
REQUESTS_MIN_MIN
private static final int REQUESTS_MIN_MIN
Min number of requests sent to a peer- See Also:
- Constant Field Values
-
REQUESTS_MIN_MAX
private static final int REQUESTS_MIN_MAX
- See Also:
- Constant Field Values
-
REQUESTS_MAX
private static final int REQUESTS_MAX
Max number of request sent to a peer- See Also:
- Constant Field Values
-
SLOPE_REQUESTS
private static final int SLOPE_REQUESTS
Default number of requests sent to a peer, (for each X B/s another request will be used)- See Also:
- Constant Field Values
-
RTA_END_GAME_MODE_SIZE_TRIGGER
private static final long RTA_END_GAME_MODE_SIZE_TRIGGER
- See Also:
- Constant Field Values
-
END_GAME_MODE_RESERVED_TRIGGER
private static final long END_GAME_MODE_RESERVED_TRIGGER
- See Also:
- Constant Field Values
-
END_GAME_MODE_SIZE_TRIGGER
private static final long END_GAME_MODE_SIZE_TRIGGER
- See Also:
- Constant Field Values
-
RTA_END_GAME_MODE_SIZE_TRIGGER_BLOCKS
private static final long RTA_END_GAME_MODE_SIZE_TRIGGER_BLOCKS
- See Also:
- Constant Field Values
-
END_GAME_MODE_RESERVED_TRIGGER_BLOCKS
private static final long END_GAME_MODE_RESERVED_TRIGGER_BLOCKS
- See Also:
- Constant Field Values
-
END_GAME_MODE_SIZE_TRIGGER_BLOCKS
private static final long END_GAME_MODE_SIZE_TRIGGER_BLOCKS
- See Also:
- Constant Field Values
-
END_GAME_MODE_TIMEOUT
private static final long END_GAME_MODE_TIMEOUT
- See Also:
- Constant Field Values
-
NO_REQUEST_BACKOFF_MAX_MILLIS
private static final int NO_REQUEST_BACKOFF_MAX_MILLIS
- See Also:
- Constant Field Values
-
NO_REQUEST_BACKOFF_MAX_LOOPS
private static final int NO_REQUEST_BACKOFF_MAX_LOOPS
-
random
static final java.util.Random random
-
diskManager
private final DiskManager diskManager
-
peerControl
private final PEPeerControl peerControl
-
diskManagerListener
private final PiecePickerImpl.DiskManagerListenerImpl diskManagerListener
-
peerListeners
protected final java.util.Map peerListeners
-
peerManagerListener
private final PEPeerManagerListener peerManagerListener
-
nbPieces
protected final int nbPieces
-
dmPieces
protected final DiskManagerPiece[] dmPieces
-
pePieces
protected final PEPiece[] pePieces
-
rarestStartedPieces
private final java.util.List<PEPiece> rarestStartedPieces
-
availabilityMon
protected final AEMonitor availabilityMon
-
endGameModeChunkLock
private final java.lang.Object endGameModeChunkLock
-
nbPiecesDone
protected volatile int nbPiecesDone
-
availabilityAsynch
protected volatile int[] availabilityAsynch
asyncronously updated availability
-
availabilityDrift
protected volatile long availabilityDrift
indicates availability needs to be recomputed due to detected drift
-
timeAvailRebuild
private long timeAvailRebuild
-
availability
protected volatile int[] availability
periodically updated consistent view of availability for calculating
-
time_last_avail
private long time_last_avail
-
availabilityChange
protected volatile long availabilityChange
-
availabilityComputeChange
private volatile long availabilityComputeChange
-
time_last_rebuild
private long time_last_rebuild
-
timeAvailLessThanOne
private long timeAvailLessThanOne
-
globalAvail
private float globalAvail
-
globalAvgAvail
private float globalAvgAvail
-
nbRarestActive
private int nbRarestActive
-
globalMin
private int globalMin
-
globalMax
private int globalMax
-
bytesUnavailable
private long bytesUnavailable
-
globalMinOthers
private volatile int globalMinOthers
The rarest availability level of pieces that we affirmatively want to try to request from others soonest ie; our prime targets for requesting rarest pieces
-
filePriorityChange
protected volatile long filePriorityChange
event # of user file priority settings changes
-
sequentialDownload
protected volatile int sequentialDownload
-
priorityParamChange
private volatile long priorityParamChange
last user parameter settings event # when priority bases were calculated
-
priorityFileChange
private volatile long priorityFileChange
last user priority event # when priority bases were calculated
-
priorityAvailChange
private volatile long priorityAvailChange
last availability event # when priority bases were calculated
-
priorityRTAexists
private boolean priorityRTAexists
-
timeLastPriorities
private long timeLastPriorities
time that base priorities were last computed
-
startPriorities
private int[] startPriorities
the priority for starting each piece/base priority for resuming
-
hasNeededUndonePiece
protected volatile boolean hasNeededUndonePiece
-
neededUndonePieceChange
protected volatile long neededUndonePieceChange
-
endGameMode
private volatile boolean endGameMode
A flag to indicate when we're in endgame mode
-
endGameModeAbandoned
private volatile boolean endGameModeAbandoned
-
timeEndGameModeEntered
private volatile long timeEndGameModeEntered
-
endGameModeChunks
private java.util.LinkedList<EndGameModeChunk> endGameModeChunks
The list of chunks needing to be downloaded (the mechanism change when entering end-game mode)
-
endGameModeChunkMap
private java.util.Map<java.lang.Long,EndGameModeChunk> endGameModeChunkMap
-
lastProviderRecalcTime
private long lastProviderRecalcTime
-
rta_providers
private final CopyOnWriteList rta_providers
-
provider_piece_rtas
private long[] provider_piece_rtas
-
priority_providers
private final CopyOnWriteList priority_providers
-
provider_piece_priorities
private long[] provider_piece_priorities
-
allocate_request_loop_count
private int allocate_request_loop_count
-
max_file_priority
private int max_file_priority
-
min_file_priority
private int min_file_priority
-
reverse_block_order
private boolean reverse_block_order
-
global_request_hint
private int[] global_request_hint
-
enable_request_hints
private static boolean enable_request_hints
-
includeLanPeersInReqLimiting
private static boolean includeLanPeersInReqLimiting
-
listeners
private final CopyOnWriteList<PiecePickerListener> listeners
-
fileAvailabilities
private volatile float[] fileAvailabilities
-
fileAvailabilitiesCalcTime
private volatile long fileAvailabilitiesCalcTime
-
forced_pieces
private volatile CopyOnWriteSet<java.lang.Integer> forced_pieces
-
firstPiecePriority
protected static volatile boolean firstPiecePriority
-
firstPiecePriorityForce
protected static volatile boolean firstPiecePriorityForce
-
completionPriority
protected static volatile boolean completionPriority
-
paramPriorityChange
protected static volatile long paramPriorityChange
event # of user settings controlling priority changes
-
dispenser
private final SpeedTokenDispenser dispenser
-
-
Constructor Detail
-
PiecePickerImpl
public PiecePickerImpl(PEPeerControl pc)
-
-
Method Detail
-
getPeerManager
public PEPeerManager getPeerManager()
- Specified by:
getPeerManager
in interfacePiecePicker
-
addHavePiece
public final void addHavePiece(PEPeer peer, int pieceNumber)
- Specified by:
addHavePiece
in interfacePiecePicker
-
updateAvailability
public final void updateAvailability()
This methd will compute the pieces' overall availability (including ourself) and the _globalMinOthers & _globalAvail- Specified by:
updateAvailability
in interfacePiecePicker
-
recomputeAvailability
private int[] recomputeAvailability()
-
getNumberOfPieces
public int getNumberOfPieces()
- Specified by:
getNumberOfPieces
in interfacePiecePicker
-
getAvailability
public final int[] getAvailability()
- Specified by:
getAvailability
in interfacePiecePicker
-
getAvailability
public final int getAvailability(int pieceNumber)
- Specified by:
getAvailability
in interfacePiecePicker
-
getMinAvailability
public final float getMinAvailability()
- Specified by:
getMinAvailability
in interfacePiecePicker
-
getMinAvailability
public float getMinAvailability(int fileIndex)
- Specified by:
getMinAvailability
in interfacePiecePicker
-
getBytesUnavailable
public final long getBytesUnavailable()
- Specified by:
getBytesUnavailable
in interfacePiecePicker
-
getAvailWentBadTime
public final long getAvailWentBadTime()
- Specified by:
getAvailWentBadTime
in interfacePiecePicker
-
getMaxAvailability
public final int getMaxAvailability()
- Specified by:
getMaxAvailability
in interfacePiecePicker
-
getAvgAvail
public final float getAvgAvail()
- Specified by:
getAvgAvail
in interfacePiecePicker
-
getNbPiecesDone
public int getNbPiecesDone()
- Specified by:
getNbPiecesDone
in interfacePiecePicker
-
checkDownloadablePiece
protected final void checkDownloadablePiece()
Early-outs when finds a downloadable piece Either way sets hasNeededUndonePiece and neededUndonePieceChange if necessary
-
allocateRequests
public final void allocateRequests()
one reason requests don't stem from the individual peers is so the connections can be sorted by best uploaders, providing some ooprtunity to download the most important (ie; rarest and/or highest priority) pieces faster and more reliably- Specified by:
allocateRequests
in interfacePiecePicker
-
getNextBlockETAFromNow
protected int getNextBlockETAFromNow(PEPeerTransport pt)
-
calcRarestAllowed
private int calcRarestAllowed()
Count current global min avail pieces in progress (not counting non-rarest pieces but keep them to compensate high churn, remove completed ones, ignore idle ones)- Returns:
- number of pieces that may be started due to the "rarest first" picking rule
-
syncFilePriorities
private void syncFilePriorities()
-
computeBasePriorities
private void computeBasePriorities()
This computes the base priority for all pieces that need requesting if there's been any availability change or user priority setting changes since the last call, which will be most of the time since availability changes so dynamicaly It will change startPriorities[] (unless there was nothing to do)
-
findPieceToDownload
protected final int findPieceToDownload(PEPeerTransport pt, int nbWanted)
- Parameters:
pt
- the PEPeerTransport we're working on- Returns:
- int # of blocks that were requested (0 if no requests were made)
-
findRTAPieceToDownload
protected final boolean findRTAPieceToDownload(PEPeerTransport pt, boolean best_uploader, long best_uploader_next_block_eta)
-
getRequestCandidate
private int getRequestCandidate(PEPeerTransport pt)
This method is the downloading core. It decides, for a given peer, which block should be requested. Here is the overall algorithm : 0. If there a FORCED_PIECE or reserved piece, that will be started/resumed if possible 1. Scan all the active pieces and find the rarest piece (and highest priority among equally rarest) that can possibly be continued by this peer, if any 2. While scanning the active pieces, develop a list of equally highest priority pieces (and equally rarest among those) as candidates for starting a new piece 3. If it can't find any piece, this means all pieces are already downloaded/full requested 4. Returns int[] pieceNumber, blockNumber if a request to be made is found, or null if none could be found- Parameters:
pc
- PEPeerTransport to work with- Returns:
- int with pieceNumberto be requested or -1 if no request could be found
-
getPieceToStart
protected final int getPieceToStart(BitFlags startCandidates)
- Parameters:
startCandidates
- BitFlags of potential candidates to choose from- Returns:
- int the piece number that was chosen to be started. Note it's possible for the chosen piece to have been started already (by another thread). This method considers that potential to not be relevant.
-
hasDownloadablePiece
public final boolean hasDownloadablePiece()
- Specified by:
hasDownloadablePiece
in interfacePiecePicker
-
getNeededUndonePieceChange
public final long getNeededUndonePieceChange()
- Specified by:
getNeededUndonePieceChange
in interfacePiecePicker
- Returns:
- long value indicated serial number of current count of changes to hasNeededUndonePiece. A method interesting in tracking changes can compare this with a locally stored value to determine if the hasNeededUndonePiece status has changed since the last check.
-
checkEndGameMode
private void checkEndGameMode()
-
computeEndGameModeChunks
private void computeEndGameModeChunks()
-
isInEndGameMode
public final boolean isInEndGameMode()
- Specified by:
isInEndGameMode
in interfacePiecePicker
-
hasEndGameModeBeenAbandoned
public boolean hasEndGameModeBeenAbandoned()
- Specified by:
hasEndGameModeBeenAbandoned
in interfacePiecePicker
-
addEndGameChunks
public final void addEndGameChunks(PEPiece pePiece)
adds every block from the piece to the list of chuncks to be selected for egm requesting- Specified by:
addEndGameChunks
in interfacePiecePicker
-
findPieceInEndGameMode
protected final int findPieceInEndGameMode(PEPeerTransport pt, int wants)
-
removeFromEndGameModeChunks
public final void removeFromEndGameModeChunks(int pieceNumber, int offset)
- Specified by:
removeFromEndGameModeChunks
in interfacePiecePicker
-
clearEndGameChunks
public final void clearEndGameChunks()
- Specified by:
clearEndGameChunks
in interfacePiecePicker
-
leaveEndGameMode
protected void leaveEndGameMode()
-
abandonEndGameMode
protected void abandonEndGameMode()
-
computeProviderPriorities
private boolean computeProviderPriorities()
-
addRTAProvider
public void addRTAProvider(PieceRTAProvider provider)
- Specified by:
addRTAProvider
in interfacePiecePicker
-
removeRTAProvider
public void removeRTAProvider(PieceRTAProvider provider)
- Specified by:
removeRTAProvider
in interfacePiecePicker
-
getRTAProviders
public java.util.List getRTAProviders()
- Specified by:
getRTAProviders
in interfacePiecePicker
-
addPriorityProvider
public void addPriorityProvider(PiecePriorityProvider provider)
- Specified by:
addPriorityProvider
in interfacePiecePicker
-
removePriorityProvider
public void removePriorityProvider(PiecePriorityProvider provider)
- Specified by:
removePriorityProvider
in interfacePiecePicker
-
getPriorityProviders
public java.util.List getPriorityProviders()
- Specified by:
getPriorityProviders
in interfacePiecePicker
-
addListener
public void addListener(PiecePickerListener listener)
- Specified by:
addListener
in interfacePiecePicker
-
removeListener
public void removeListener(PiecePickerListener listener)
- Specified by:
removeListener
in interfacePiecePicker
-
setForcePiece
public void setForcePiece(int pieceNumber, boolean forced)
- Specified by:
setForcePiece
in interfacePiecePicker
-
isForcePiece
public boolean isForcePiece(int pieceNumber)
- Specified by:
isForcePiece
in interfacePiecePicker
-
setSequentialDownload
private void setSequentialDownload(int val)
-
setSequentialAscendingFrom
public void setSequentialAscendingFrom(int start_piece)
- Specified by:
setSequentialAscendingFrom
in interfacePiecePicker
-
setSequentialDescendingFrom
public void setSequentialDescendingFrom(int start_piece)
- Specified by:
setSequentialDescendingFrom
in interfacePiecePicker
-
clearSequential
public void clearSequential()
- Specified by:
clearSequential
in interfacePiecePicker
-
getSequentialInfo
public int getSequentialInfo()
- Specified by:
getSequentialInfo
in interfacePiecePicker
- Returns:
- 0 - inactive; +ve -> ascending from (n-1) -ve -> descending from (-n+1)
-
getEGMInfo
public java.lang.String getEGMInfo()
- Specified by:
getEGMInfo
in interfacePiecePicker
-
getEGMRequestCount
public int getEGMRequestCount(int piece_number, int block_number)
- Specified by:
getEGMRequestCount
in interfacePiecePicker
-
setGlobalRequestHint
public void setGlobalRequestHint(int piece_number, int start_bytes, int byte_count)
- Specified by:
setGlobalRequestHint
in interfacePiecePicker
-
getGlobalRequestHint
public int[] getGlobalRequestHint()
- Specified by:
getGlobalRequestHint
in interfacePiecePicker
-
setReverseBlockOrder
public void setReverseBlockOrder(boolean is_reverse)
- Specified by:
setReverseBlockOrder
in interfacePiecePicker
-
getReverseBlockOrder
public boolean getReverseBlockOrder()
- Specified by:
getReverseBlockOrder
in interfacePiecePicker
-
destroy
public void destroy()
- Specified by:
destroy
in interfacePiecePicker
-
getPieceString
public java.lang.String getPieceString(int piece_number)
- Specified by:
getPieceString
in interfacePiecePicker
-
generateEvidence
public void generateEvidence(IndentWriter writer)
- Specified by:
generateEvidence
in interfacePiecePicker
-
-