Add StatsControl support#68
Conversation
2582b0c to
8ea3457
Compare
…ol is exposed to the client
|
I updated the PR based on the Java parity review. Main changes:
Validation: |
|
@mayankkumar12345 @Akshay-Sundarraj I recommend you add @cezarfx as a reviewer. |
| * or the statistics were last cleared. | ||
| * @returns {object} Statistics object | ||
| */ | ||
| getStats(): object; |
There was a problem hiding this comment.
In Java user register StatsHandler and get a call-back periodically. How it works in nodejs? Why client has methods to expose stats?
There was a problem hiding this comment.
Now client is exposed to the statscontrol only.
| console.error(err); | ||
| } finally { | ||
| if (client != null) { | ||
| const stats = client.getStats(); |
There was a problem hiding this comment.
In java and python client does not expose stats directly. Also, do we have a way to start and stop collection like in statsControl.start(); and statsControl.stop();
There was a problem hiding this comment.
Now client is exposed to the statscontrol only so the client.getstats() is removed.Yes there is the way to start and stop the collections using start() and stop() functions.
| * log output should be pretty-printed. | ||
| * @property {boolean} [statsEnableLog=true] Whether interval statistics | ||
| * should be logged. | ||
| * @property {function|object} [statsHandler] Handler called with a statistics |
There was a problem hiding this comment.
Can statsHandler be concrete class instead of object?
There was a problem hiding this comment.
Yes we can but this implementation supports a function callback or an object with accept(stats), matching Java’s handler.accept(stats) style that's why I kept it like this.
I updated the JSDoc to document this as StatsHandler instead of generic function|object, so its clear that plain objects are not valid unless they implement accept(stats).
… recording logical query stats. - Updated examples/docs to prefer StatsControl.Profile constants instead of raw profile strings. - Added JSDoc for StatsHandler to show it accepts either a callback function or an object with accept(stats). - Added short comments in stats.js and stats_control.js to explain the main stats classes and flow. - Added top-level comments in stats-related test files.
mayankkumar12345
left a comment
There was a problem hiding this comment.
Addressed review comments and added replies for the remaining points.
| throw new NoSQLArgumentError( | ||
| `Invalid statsEnableLog value: ${cfg.statsEnableLog}`, cfg); | ||
| } | ||
| if (cfg.statsHandler != null && |
There was a problem hiding this comment.
but user can pass anything in stats handler so this check would be necessary.
| * log output should be pretty-printed. | ||
| * @property {boolean} [statsEnableLog=true] Whether interval statistics | ||
| * should be logged. | ||
| * @property {function|object} [statsHandler] Handler called with a statistics |
There was a problem hiding this comment.
Yes we can but this implementation supports a function callback or an object with accept(stats), matching Java’s handler.accept(stats) style that's why I kept it like this.
I updated the JSDoc to document this as StatsHandler instead of generic function|object, so its clear that plain objects are not valid unless they implement accept(stats).
| * or the statistics were last cleared. | ||
| * @returns {object} Statistics object | ||
| */ | ||
| getStats(): object; |
There was a problem hiding this comment.
Now client is exposed to the statscontrol only.
| console.error(err); | ||
| } finally { | ||
| if (client != null) { | ||
| const stats = client.getStats(); |
There was a problem hiding this comment.
Now client is exposed to the statscontrol only so the client.getstats() is removed.Yes there is the way to start and stop the collections using start() and stop() functions.
Akshay-Sundarraj
left a comment
There was a problem hiding this comment.
I've checked basic flow and formatting. Looks fine to me. Get approval from @cezarfx and merge
|
Please check with cezar on git commit. Ideally we should have only 1 commit log for this entire PR |
Adds Java SDK parity StatsControl support to the Node.js SDK.
Includes:
Validation:
Notes:
CloudSim stats load check should use:
node examples/javascript/stats_load_check.js --config examples/config/cloudsim.json --operation fullFlow --table Users --profile ALL --total 1 --concurrency 1
KV proxy/KVLite stats load check should use:
node examples/javascript/stats_load_check.js --config examples/config/kvlite.json --operation fullFlow --table Users --profile ALL --total 1 --concurrency 1
ALL profile can include query text and query plans, matching Java SDK behaviour.