* Shutdown:

- More job queue cleanups
    - RouterInfo readin job checks for quick shutdown
    - Note that we should improve profile read job
This commit is contained in:
zzz
2011-06-18 19:58:50 +00:00
parent 4caf48bd86
commit 0fa5fa40e1
3 changed files with 16 additions and 4 deletions

View File

@ -280,14 +280,22 @@ public class JobQueue {
void shutdown() {
_alive = false;
_timedJobs.clear();
_readyJobs.clear();
synchronized (_jobLock) {
_timedJobs.clear();
_readyJobs.clear();
_jobLock.notifyAll();
}
// The JobQueueRunners are NOT daemons,
// so they must be stopped.
Job poison = new PoisonJob();
for (int i = 0; i < _queueRunners.size(); i++)
for (JobQueueRunner runner : _queueRunners.values()) {
runner.stopRunning();
_readyJobs.offer(poison);
// TODO interrupt thread for each runner
}
_queueRunners.clear();
_jobStats.clear();
_runnerId = 0;
/********
if (_log.shouldLog(Log.WARN)) {

View File

@ -359,6 +359,9 @@ class PersistentDataStore extends TransientDataStore {
if (routerInfoFiles.length > 5)
_alreadyWarned = false;
for (int i = 0; i < routerInfoFiles.length; i++) {
// drop out if the router gets killed right after startup
if (!_context.router().isAlive())
break;
Hash key = getRouterInfoHash(routerInfoFiles[i].getName());
if ( (key != null) && (!isKnown(key)) ) {
// Run it inline so we don't clog up the job queue, esp. at startup

View File

@ -117,6 +117,7 @@ class PeerManager {
}
void loadProfiles() {
// TODO do this in a Thread or a Job to not slow down the constructor
Set<PeerProfile> profiles = _persistenceHelper.readProfiles();
for (Iterator<PeerProfile> iter = profiles.iterator(); iter.hasNext();) {
PeerProfile prof = iter.next();