Skip to content

Commit 9191365

Browse files
committed
When jobs change, sync all data to master peers right away (don't wait for next tick).
1 parent 22316a2 commit 9191365

4 files changed

Lines changed: 20 additions & 3 deletions

File tree

lib/action.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,7 @@ class Actions {
472472
activeJobs: this.getActiveJobs(),
473473
jobsChanged: true
474474
} );
475+
this.masterSync();
475476

476477
if (!action.details) action.details = "";
477478

lib/api/jobs.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -835,6 +835,7 @@ class Jobs {
835835
activeJobs: self.getActiveJobs(),
836836
jobsChanged: true
837837
} );
838+
self.masterSync();
838839
}); // loadSession
839840
}
840841

@@ -950,6 +951,7 @@ class Jobs {
950951
activeJobs: self.getActiveJobs(),
951952
jobsChanged: true
952953
} );
954+
self.masterSync();
953955

954956
}); // loadSession
955957
}

lib/job.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ class Jobs {
216216
activeJobs: this.getActiveJobs(),
217217
jobsChanged: true
218218
} );
219+
this.masterSync();
219220
}
220221

221222
appendJobLog(job, msg, data) {
@@ -311,6 +312,7 @@ class Jobs {
311312
activeJobs: this.getActiveJobs(),
312313
jobsChanged: true
313314
} );
315+
this.masterSync();
314316
}
315317

316318
// FUTURE NOTE: This will only launch a max of 1 queued job per event per second (per tick)
@@ -1278,6 +1280,7 @@ class Jobs {
12781280
jobsChanged: true,
12791281
state: Tools.copyHashRemoveKeys( self.state, { dirty: 1 } )
12801282
} );
1283+
self.masterSync();
12811284

12821285
// and notify all job watchers that the job is fully complete
12831286
self.doPageBroadcast( 'Job?id=' + job.id, 'job_completed', {} );

lib/multi.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -976,8 +976,8 @@ class Multi {
976976
this.electionTimer = setTimeout( this.electMaster.bind(this), multi.master_timeout_sec * 1000 );
977977
}
978978

979-
masterTick() {
980-
// called every second, maintain master peers
979+
masterSync() {
980+
// sync all active data with peers
981981
var self = this;
982982
if (!this.master) return;
983983

@@ -990,7 +990,18 @@ class Multi {
990990
jobDetails: self.jobDetails,
991991
activeAlerts: self.activeAlerts
992992
});
993-
peer.socket.tick();
993+
});
994+
}
995+
996+
masterTick() {
997+
// called every second, maintain master peers
998+
var self = this;
999+
if (!this.master) return;
1000+
1001+
this.masterSync();
1002+
1003+
this.peers.forEach( function(peer) {
1004+
if (peer.socket) peer.socket.tick();
9941005
});
9951006
}
9961007

0 commit comments

Comments
 (0)