Skip to content

Commit c549526

Browse files
authored
Merge pull request #135 from pierotofy/prequeue
Transient slots
2 parents c557a18 + a1f615b commit c549526

File tree

4 files changed

+17
-4
lines changed

4 files changed

+17
-4
lines changed

libs/classes/Node.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ module.exports = class Node{
2828
info: {}
2929
};
3030
this.turn = 0;
31+
this.transients = 0;
3132

3233
this.timeout = 10000;
3334
}
@@ -161,7 +162,15 @@ module.exports = class Node{
161162
}
162163

163164
availableSlots(){
164-
return Math.max(0, this.getInfoProperty('maxParallelTasks', 0) - this.getInfoProperty('taskQueueCount', 0));
165+
return Math.max(0, this.getInfoProperty('maxParallelTasks', 0) - this.getInfoProperty('taskQueueCount', 0) - this.transients);
166+
}
167+
168+
incTransients(){
169+
this.transients++;
170+
}
171+
172+
decTransients(){
173+
if (--this.transients < 0) this.transients = 0;
165174
}
166175

167176
proxyTargetUrl(){

libs/nodes.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ module.exports = {
151151
return {
152152
node: n,
153153
maxImages: n.getInfo().maxImages ? n.getInfo().maxImages : 999999999,
154-
slots: Math.max(0, n.getInfo().maxParallelTasks - n.getInfo().taskQueueCount),
154+
slots: n.availableSlots(),
155155
queueCount: n.getInfo().taskQueueCount
156156
};
157157
});

libs/taskNew.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ module.exports = {
307307
if (!approved) throw new Error(error);
308308

309309
let node = await nodes.findBestAvailableNode(imagesCount, true);
310-
310+
311311
// Do we need to / can we create a new node via autoscaling?
312312
const autoscale = (!node || node.availableSlots() === 0) &&
313313
asrProvider.isAllowedToCreateNewNodes() &&
@@ -524,10 +524,14 @@ module.exports = {
524524
eventEmitter.emit('close');
525525

526526
try{
527+
if (!autoscale) node.incTransients();
527528
await taskNewInit();
528529
await taskNewUpload();
529530
await taskNewCommit();
531+
if (!autoscale) node.decTransients();
530532
}catch(e){
533+
if (!autoscale) node.decTransients();
534+
531535
// Attempt to retry
532536
if (retries < MAX_UPLOAD_RETRIES){
533537
retries++;

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ClusterODM",
3-
"version": "1.5.5",
3+
"version": "1.5.6",
44
"description": "",
55
"main": "index.js",
66
"scripts": {

0 commit comments

Comments
 (0)