clear profiles out of memory on shutdown

This commit is contained in:
zzz
2011-06-15 15:20:00 +00:00
parent 3c88c854bf
commit 20ad7a44a7
3 changed files with 21 additions and 1 deletions

View File

@ -99,6 +99,11 @@ class PeerManager {
}
}
/** @since 0.8.8 */
void clearProfiles() {
_organizer.clearProfiles();
}
Set selectPeers() {
return _organizer.selectAllPeers();
}

View File

@ -47,8 +47,10 @@ public class PeerManagerFacadeImpl implements PeerManagerFacade {
public void shutdown() {
_log.info("Shutting down the peer manager");
_testJob.stopTesting();
if (_manager != null)
if (_manager != null) {
_manager.storeProfiles();
_manager.clearProfiles();
}
}
public void restart() {

View File

@ -227,6 +227,19 @@ public class ProfileOrganizer {
public boolean isWellIntegrated(Hash peer) { return isX(_wellIntegratedPeers, peer); }
public boolean isFailing(Hash peer) { return isX(_failingPeers, peer); }
/** @since 0.8.8 */
void clearProfiles() {
getReadLock();
try {
_failingPeers.clear();
_fastPeers.clear();
_highCapacityPeers.clear();
_notFailingPeers.clear();
_notFailingPeersList.clear();
_wellIntegratedPeers.clear();
} finally { releaseReadLock(); }
}
/**
* if a peer sends us more than 5 replies in a searchReply that we cannot
* fetch, stop listening to them.