Skip to content

Commit

Permalink
S3UTILS-158: setTimeout for job ending and metrics server setup in co…
Browse files Browse the repository at this point in the history
…untMaster
  • Loading branch information
benzekrimaha committed May 13, 2024
1 parent 37f5be4 commit e734262
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"jest/globals": true
},
"parserOptions": {
"ecmaVersion": 9
"ecmaVersion": "latest"
},
"rules": {
"no-plusplus": 0,
Expand Down
13 changes: 12 additions & 1 deletion CountItems/CountMaster.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
const async = require('async');
const { reshapeExceptionError } = require('arsenal').errorUtils;
const { threshold, frequency } = require('../utils/constants');

class CountMaster {
static waitingForPromScraping = false;
constructor(params) {
this.log = params.log;
this.manager = params.manager;
this.client = params.client;
this.metrics = params.metrics;
}

stop(signal, callback) {
Expand Down Expand Up @@ -34,6 +37,13 @@ class CountMaster {
}
return next();
}),
next => {
this.metrics.start();
this.log.info('metrics server started', {
port: 8003,
});
return next();
},
next => this.manager.setup(next),
next => this.client.getBucketInfos(this.log, (err, bucketList) => {
if (err) {
Expand All @@ -58,7 +68,8 @@ class CountMaster {
});
return this.stop(null, () => callback(err));
}
return this.stop(null, () => callback());
CountMaster.waitingForPromScraping = true;
return setTimeout(() => this.stop(null, () => callback()), threshold * frequency * 1000 * 4);
});
}
}
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
"jsprim": "1.4.2"
},
"devDependencies": {
"@babel/eslint-parser": "^7.24.5",
"@sinonjs/fake-timers": "^9.1.2",
"eslint": "^8.8.0",
"eslint-config-airbnb": "^19.0.0",
Expand Down
2 changes: 2 additions & 0 deletions utils/constants.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
module.exports = {
MaxParallelLimit: 10,
frequency: 30,
threshold: 5,
};
31 changes: 30 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -923,6 +923,15 @@
dependencies:
"@babel/highlight" "^7.0.0"

"@babel/eslint-parser@^7.24.5":
version "7.24.5"
resolved "https://registry.yarnpkg.com/@babel/eslint-parser/-/eslint-parser-7.24.5.tgz#3b0f7d383a540329a30a6a9937cfc89461d26217"
integrity sha512-gsUcqS/fPlgAw1kOtpss7uhY6E9SFFANQ6EFX5GTvzUwaV0+sGaZWk6xq22MOdeT9wfxyokW3ceCUvOiRtZciQ==
dependencies:
"@nicolo-ribaudo/eslint-scope-5-internals" "5.1.1-v1"
eslint-visitor-keys "^2.1.0"
semver "^6.3.1"

"@babel/highlight@^7.0.0":
version "7.0.0"
resolved "https://registry.yarnpkg.com/@babel/highlight/-/highlight-7.0.0.tgz#f710c38c8d458e6dd9a201afb637fcb781ce99e4"
Expand Down Expand Up @@ -985,6 +994,13 @@
dependencies:
sparse-bitfield "^3.0.3"

"@nicolo-ribaudo/[email protected]":
version "5.1.1-v1"
resolved "https://registry.yarnpkg.com/@nicolo-ribaudo/eslint-scope-5-internals/-/eslint-scope-5-internals-5.1.1-v1.tgz#dbf733a965ca47b1973177dc0bb6c889edcfb129"
integrity sha512-54/JRvkLIzzDWshCWfuhadfrfZVPiElY8Fcgmg1HroEly/EDSszzhBAsarCux+D/kOslTRquNzuyGSmUSTTHGg==
dependencies:
eslint-scope "5.1.1"

"@npmcli/fs@^1.0.0":
version "1.1.0"
resolved "https://registry.yarnpkg.com/@npmcli/fs/-/fs-1.1.0.tgz#bec1d1b89c170d40e1b73ad6c943b0b75e7d2951"
Expand Down Expand Up @@ -3102,6 +3118,14 @@ eslint-plugin-jest@^23.6.0:
"@typescript-eslint/experimental-utils" "^2.5.0"
micromatch "^4.0.2"

[email protected]:
version "5.1.1"
resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-5.1.1.tgz#e786e59a66cb92b3f6c1fb0d508aab174848f48c"
integrity sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw==
dependencies:
esrecurse "^4.3.0"
estraverse "^4.1.1"

eslint-scope@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-5.0.0.tgz#e87c8887c73e8d1ec84f1ca591645c358bfc8fb9"
Expand Down Expand Up @@ -3130,7 +3154,7 @@ eslint-visitor-keys@^1.1.0:
resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-1.1.0.tgz#e2a82cea84ff246ad6fb57f9bde5b46621459ec2"
integrity sha512-8y9YjtM1JBJU/A9Kc+SbaOV4y29sSWckBwMHa+FGtVj5gN/sbnKDf6xJUl+8g7FAij9LVaP8C24DUiH/f/2Z9A==

eslint-visitor-keys@^2.0.0:
eslint-visitor-keys@^2.0.0, eslint-visitor-keys@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-2.1.0.tgz#f65328259305927392c938ed44eb0a5c9b2bd303"
integrity sha512-0rSmRBzXgDzIsD6mGdJgevzgezI534Cer5L/vyMX0kHzT/jiB43jRhd9YUlMGYLQy2zprNmoT8qasCGtY+QaKw==
Expand Down Expand Up @@ -7383,6 +7407,11 @@ semver@^6.0.0, semver@^6.3.0:
resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.0.tgz#ee0a64c8af5e8ceea67687b133761e1becbd1d3d"
integrity sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==

semver@^6.3.1:
version "6.3.1"
resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.1.tgz#556d2ef8689146e46dcea4bfdd095f3434dffcb4"
integrity sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==

semver@^7.3.5:
version "7.3.5"
resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.5.tgz#0b621c879348d8998e4b0e4be94b3f12e6018ef7"
Expand Down

0 comments on commit e734262

Please sign in to comment.