public class DefaultMaintenance extends Object implements Maintenance
| Constructor and Description |
|---|
DefaultMaintenance(int peerUrgency,
int[] intervalSeconds)
Constructor that initializes the maps as null references.
|
| Modifier and Type | Method and Description |
|---|---|
Maintenance |
init(List<Map<Number160,PeerStatistic>> peerMapVerified,
List<Map<Number160,PeerStatistic>> peerMapNonVerified,
ConcurrentCacheMap<Number160,PeerAddress> offlineMap,
ConcurrentCacheMap<Number160,PeerAddress> shutdownMap,
ConcurrentCacheMap<Number160,PeerAddress> exceptionMap)
Initializes the maintenance class.
|
protected boolean |
isUrgent(int bagIndex,
int bagSize,
int peersBefore)
Indicates if it is urgent to search for a peer.
|
static int |
log2(int n)
As seen in: http://stackoverflow.com/questions/3305059/how-do-you-calculate-log-base-2-in-java-for-integers.
|
static boolean |
needMaintenance(PeerStatistic peerStatatistic,
int[] intervalSeconds)
Indicates if a peer needs a maintenance check.
|
PeerStatistic |
nextForMaintenance(Collection<PeerAddress> notInterestedAddresses)
Finds the next peer that should have a maintenance check.
|
public DefaultMaintenance(int peerUrgency,
int[] intervalSeconds)
peerUrgency - The number of peers that should be in the verified map. If the number is lower, urgency is set to yes
and we are looking for peers in the non verified mapintervalSeconds - The number of intervals to test a peer. The longer a peer is available the less often we need to checkpublic Maintenance init(List<Map<Number160,PeerStatistic>> peerMapVerified, List<Map<Number160,PeerStatistic>> peerMapNonVerified, ConcurrentCacheMap<Number160,PeerAddress> offlineMap, ConcurrentCacheMap<Number160,PeerAddress> shutdownMap, ConcurrentCacheMap<Number160,PeerAddress> exceptionMap)
Maintenanceinit in interface MaintenancepeerMapVerified - The map with the bags of verified peerspeerMapNonVerified - The map with the bags of non verified peersofflineMap - The map with the offline peersshutdownMap - The map with the peers that friendly quitexceptionMap - The map with the peers that caused an exceptionpublic PeerStatistic nextForMaintenance(Collection<PeerAddress> notInterestedAddresses)
nextForMaintenance in interface Maintenanceprotected boolean isUrgent(int bagIndex,
int bagSize,
int peersBefore)
bagIndex - The number of the bagindex. The smaller the index, the more important the peerbagSize - The size of the current bagpeersBefore - The number of peers we have that are smaller than in this bag indexpublic static boolean needMaintenance(PeerStatistic peerStatatistic, int[] intervalSeconds)
peerStatatistic - The peer with its statisticspublic static int log2(int n)
n - The numberCopyright © 2014. All rights reserved.