aerospike 6.0.2 → 6.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/binding.gyp +2 -0
  2. package/lib/aerospike.js +2 -0
  3. package/lib/binding/glibc@2.31/node-v108-linux-arm64/aerospike.node +0 -0
  4. package/lib/binding/glibc@2.31/node-v108-linux-x64/aerospike.node +0 -0
  5. package/lib/binding/glibc@2.31/node-v115-linux-arm64/aerospike.node +0 -0
  6. package/lib/binding/glibc@2.31/node-v115-linux-x64/aerospike.node +0 -0
  7. package/lib/binding/glibc@2.31/node-v127-linux-arm64/aerospike.node +0 -0
  8. package/lib/binding/glibc@2.31/node-v127-linux-x64/aerospike.node +0 -0
  9. package/lib/binding/glibc@2.31/node-v131-linux-arm64/aerospike.node +0 -0
  10. package/lib/binding/glibc@2.31/node-v131-linux-x64/aerospike.node +0 -0
  11. package/lib/binding/glibc@2.35/node-v108-linux-arm64/aerospike.node +0 -0
  12. package/lib/binding/glibc@2.35/node-v108-linux-x64/aerospike.node +0 -0
  13. package/lib/binding/glibc@2.35/node-v115-linux-arm64/aerospike.node +0 -0
  14. package/lib/binding/glibc@2.35/node-v115-linux-x64/aerospike.node +0 -0
  15. package/lib/binding/glibc@2.35/node-v127-linux-arm64/aerospike.node +0 -0
  16. package/lib/binding/glibc@2.35/node-v127-linux-x64/aerospike.node +0 -0
  17. package/lib/binding/glibc@2.35/node-v131-linux-arm64/aerospike.node +0 -0
  18. package/lib/binding/glibc@2.35/node-v131-linux-x64/aerospike.node +0 -0
  19. package/lib/binding/node-v108-darwin-arm64/aerospike.node +0 -0
  20. package/lib/binding/node-v108-darwin-x64/aerospike.node +0 -0
  21. package/lib/binding/node-v108-win32-x64/aerospike.dll +0 -0
  22. package/lib/binding/node-v108-win32-x64/aerospike.node +0 -0
  23. package/lib/binding/node-v115-darwin-arm64/aerospike.node +0 -0
  24. package/lib/binding/node-v115-darwin-x64/aerospike.node +0 -0
  25. package/lib/binding/node-v115-win32-x64/aerospike.dll +0 -0
  26. package/lib/binding/node-v115-win32-x64/aerospike.node +0 -0
  27. package/lib/binding/node-v127-darwin-arm64/aerospike.node +0 -0
  28. package/lib/binding/node-v127-darwin-x64/aerospike.node +0 -0
  29. package/lib/binding/node-v127-win32-x64/aerospike.dll +0 -0
  30. package/lib/binding/node-v127-win32-x64/aerospike.node +0 -0
  31. package/lib/binding/node-v131-darwin-arm64/aerospike.node +0 -0
  32. package/lib/binding/node-v131-darwin-x64/aerospike.node +0 -0
  33. package/lib/binding/node-v131-win32-x64/aerospike.dll +0 -0
  34. package/lib/binding/node-v131-win32-x64/aerospike.node +0 -0
  35. package/lib/client.js +31 -1
  36. package/lib/commands/index.js +2 -0
  37. package/lib/metrics_listeners.js +28 -0
  38. package/lib/policies/metrics_policy.js +37 -0
  39. package/lib/policy.js +3 -0
  40. package/package.json +1 -1
  41. package/src/include/client.h +2 -0
  42. package/src/include/conversions.h +32 -0
  43. package/src/include/policy.h +4 -0
  44. package/src/main/client.cc +5 -0
  45. package/src/main/commands/disable_metrics.cc +48 -0
  46. package/src/main/commands/enable_metrics.cc +508 -0
  47. package/src/main/policy.cc +42 -0
  48. package/src/main/scan.cc +0 -1
  49. package/src/main/util/conversions.cc +282 -0
  50. package/test/batch_read.js +8 -8
  51. package/test/get.js +4 -4
  52. package/test/operate.js +4 -4
  53. package/ts-test/package-lock.json +1017 -666
  54. package/ts-test/package.json +8 -5
  55. package/ts-test/tests/batch_read.ts +8 -8
  56. package/ts-test/tests/batch_write.ts +9 -9
  57. package/ts-test/tests/exists.ts +6 -6
  58. package/ts-test/tests/get.ts +4 -4
  59. package/ts-test/tests/metrics.ts +336 -0
  60. package/ts-test/tests/metrics_cluster_name.ts +127 -0
  61. package/ts-test/tests/metrics_node_close.ts +176 -0
  62. package/ts-test/tests/operate.ts +4 -4
  63. package/ts-test/tests/scan.ts +1 -1
  64. package/ts-test/tests/test_helper.ts +9 -1
  65. package/ts-test/tests/udf.ts +2 -2
  66. package/ts-test/tests/util/options.ts +5 -1
  67. package/ts-test/tests/util/statefulAsyncTest.ts +1 -1
  68. package/typings/index.d.ts +486 -3
package/binding.gyp CHANGED
@@ -84,6 +84,8 @@
84
84
  'src/main/expressions.cc',
85
85
  'src/main/async.cc',
86
86
  'src/main/command.cc',
87
+ 'src/main/commands/disable_metrics.cc',
88
+ 'src/main/commands/enable_metrics.cc',
87
89
  'src/main/commands/apply_async.cc',
88
90
  'src/main/commands/batch_exists.cc',
89
91
  'src/main/commands/batch_get.cc',
package/lib/aerospike.js CHANGED
@@ -186,6 +186,7 @@ exports.CommandQueuePolicy = require('./policy').CommandQueuePolicy
186
186
  exports.InfoPolicy = require('./policy').InfoPolicy
187
187
  exports.ListPolicy = require('./policy').ListPolicy
188
188
  exports.MapPolicy = require('./policy').MapPolicy
189
+ exports.MetricsPolicy = require('./policy').MetricsPolicy
189
190
  exports.AdminPolicy = require('./policy').AdminPolicy
190
191
 
191
192
  /**
@@ -738,6 +739,7 @@ exports.setupGlobalCommandQueue = function (policy) {
738
739
  */
739
740
  exports.batchType = require('./batch_type')
740
741
 
742
+ exports.MetricsListeners = require('./metrics_listeners')
741
743
  /**
742
744
  * The {@link module:aerospike/commit_status|aerospike/commit_status}
743
745
  * module contains a list of commit statuses.
package/lib/client.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // *****************************************************************************
2
- // Copyright 2013-2024 Aerospike, Inc.
2
+ // Copyright 2013-2025 Aerospike, Inc.
3
3
  //
4
4
  // Licensed under the Apache License, Version 2.0 (the "License")
5
5
  // you may not use this file except in compliance with the License.
@@ -255,6 +255,36 @@ Client.prototype.commit = function (transaction, callback) {
255
255
  return cmd.execute()
256
256
  }
257
257
 
258
+ Client.prototype.enableMetrics = function (policy, callback) {
259
+ let args
260
+
261
+ if (typeof policy === 'function') {
262
+ callback = policy
263
+ policy = null
264
+ }
265
+
266
+ if (!(policy) || !(policy.metricsListeners)) {
267
+ args = [policy, null, null, null, null]
268
+ } else {
269
+ args = [
270
+ policy,
271
+ policy.metricsListeners.enableListener,
272
+ policy.metricsListeners.snapshotListener,
273
+ policy.metricsListeners.nodeCloseListener,
274
+ policy.metricsListeners.disableListener
275
+ ]
276
+ }
277
+
278
+ const cmd = new Commands.EnableMetrics(this, args, callback)
279
+
280
+ return cmd.execute()
281
+ }
282
+
283
+ Client.prototype.disableMetrics = function (callback) {
284
+ const cmd = new Commands.DisableMetrics(this, [], callback)
285
+ return cmd.execute()
286
+ }
287
+
258
288
  /**
259
289
  * @function Client#contextToBase64
260
290
  *
@@ -35,6 +35,8 @@ exports.BatchRemove = class BatchRemoveCommand extends BatchCommand('batchRemove
35
35
  exports.BatchSelect = class BatchSelectCommand extends BatchCommand('batchSelect') { }
36
36
  exports.ChangePassword = class ChangePasswordCommand extends Command('changePassword') { }
37
37
  exports.Connect = class ConnectCommand extends ConnectCommandBase('connect') { }
38
+ exports.DisableMetrics = class DisableMetricsCommand extends Command('disableMetrics') { }
39
+ exports.EnableMetrics = class EnableMetricsCommand extends Command('enableMetrics') { }
38
40
  exports.Exists = class ExistsCommand extends ExistsCommandBase('existsAsync') { }
39
41
  exports.Get = class GetCommand extends ReadRecordCommand('getAsync') { }
40
42
  exports.IndexCreate = class IndexCreateCommand extends Command('indexCreate') { }
@@ -0,0 +1,28 @@
1
+ // *****************************************************************************
2
+ // Copyright 2025 Aerospike, Inc.
3
+ //
4
+ // Licensed under the Apache License, Version 2.0 (the "License")
5
+ // you may not use this file except in compliance with the License.
6
+ // You may obtain a copy of the License at
7
+ //
8
+ // http://www.apache.org/licenses/LICENSE-2.0
9
+ //
10
+ // Unless required by applicable law or agreed to in writing, software
11
+ // distributed under the License is distributed on an "AS IS" BASIS,
12
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ // See the License for the specific language governing permissions and
14
+ // limitations under the License.
15
+ // *****************************************************************************
16
+
17
+ 'use strict'
18
+
19
+ class MetricsListeners {
20
+ constructor (options) {
21
+ this.enableListener = options.enableListener
22
+ this.snapshotListener = options.snapshotListener
23
+ this.nodeCloseListener = options.nodeCloseListener
24
+ this.disableListener = options.disableListener
25
+ }
26
+ }
27
+
28
+ module.exports = MetricsListeners
@@ -0,0 +1,37 @@
1
+ // *****************************************************************************
2
+ // Copyright 2025 Aerospike, Inc.
3
+ //
4
+ // Licensed under the Apache License, Version 2.0 (the "License")
5
+ // you may not use this file except in compliance with the License.
6
+ // You may obtain a copy of the License at
7
+ //
8
+ // http://www.apache.org/licenses/LICENSE-2.0
9
+ //
10
+ // Unless required by applicable law or agreed to in writing, software
11
+ // distributed under the License is distributed on an "AS IS" BASIS,
12
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ // See the License for the specific language governing permissions and
14
+ // limitations under the License.
15
+ // *****************************************************************************
16
+
17
+ 'use strict'
18
+
19
+ class MetricsPolicy {
20
+ constructor (props) {
21
+ props = props || {}
22
+
23
+ this.metricsListeners = props.metricsListeners
24
+
25
+ this.reportDir = props.reportDir
26
+
27
+ this.reportSizeLimit = props.reportSizeLimit
28
+
29
+ this.interval = props.interval
30
+
31
+ this.latencyColumns = props.latencyColumns
32
+
33
+ this.latencyShift = props.latecnyShift
34
+ }
35
+ }
36
+
37
+ module.exports = MetricsPolicy
package/lib/policy.js CHANGED
@@ -31,6 +31,7 @@ const HLLPolicy = require('./policies/hll_policy')
31
31
  const InfoPolicy = require('./policies/info_policy')
32
32
  const ListPolicy = require('./policies/list_policy')
33
33
  const MapPolicy = require('./policies/map_policy')
34
+ const MetricsPolicy = require('./policies/metrics_policy')
34
35
  const OperatePolicy = require('./policies/operate_policy')
35
36
  const QueryPolicy = require('./policies/query_policy')
36
37
  const ReadPolicy = require('./policies/read_policy')
@@ -429,6 +430,8 @@ exports.InfoPolicy = InfoPolicy
429
430
  */
430
431
  exports.AdminPolicy = AdminPolicy
431
432
 
433
+ exports.MetricsPolicy = MetricsPolicy
434
+
432
435
  /**
433
436
  * A policy affecting the behavior of list operations.
434
437
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aerospike",
3
- "version": "6.0.2",
3
+ "version": "6.1.0",
4
4
  "description": "Aerospike Client Library",
5
5
  "keywords": [
6
6
  "aerospike",
@@ -88,6 +88,8 @@ class AerospikeClient : public Nan::ObjectWrap {
88
88
  static NAN_METHOD(ChangePassword);
89
89
  static NAN_METHOD(Close);
90
90
  static NAN_METHOD(Connect);
91
+ static NAN_METHOD(DisableMetrics);
92
+ static NAN_METHOD(EnableMetrics);
91
93
  static NAN_METHOD(ExistsAsync);
92
94
  static NAN_METHOD(GetAsync);
93
95
  static NAN_METHOD(GetNodes);
@@ -22,7 +22,10 @@ extern "C" {
22
22
  #include <aerospike/aerospike.h>
23
23
  #include <aerospike/aerospike_key.h>
24
24
  #include <aerospike/aerospike_batch.h>
25
+ #include <aerospike/aerospike_stats.h>
26
+ #include <aerospike/as_metrics_writer.h>
25
27
  #include <aerospike/as_job.h>
28
+ #include <aerospike/as_node.h>
26
29
  #include <aerospike/as_key.h>
27
30
  #include <aerospike/as_record.h>
28
31
  #include <aerospike/as_scan.h>
@@ -107,6 +110,9 @@ int get_optional_int64_property(int64_t *intp, bool *defined,
107
110
  int get_optional_string_property(char **strp, bool *defined,
108
111
  v8::Local<v8::Object> obj, char const *prop,
109
112
  const LogInfo *log);
113
+ int get_optional_uint64_property(uint64_t *intp, bool *defined,
114
+ v8::Local<v8::Object> obj, char const *prop,
115
+ const LogInfo *log);
110
116
  int get_optional_uint32_property(uint32_t *intp, bool *defined,
111
117
  v8::Local<v8::Object> obj, char const *prop,
112
118
  const LogInfo *log);
@@ -119,6 +125,9 @@ bool get_optional_list_policy(as_list_policy *policy, bool *has_policy,
119
125
  v8::Local<v8::Object> obj, const LogInfo *log);
120
126
  bool get_map_policy(as_map_policy *policy, v8::Local<v8::Object> obj,
121
127
  const LogInfo *log);
128
+ int get_optional_report_dir_property(char **report_dir, bool *defined,
129
+ v8::Local<v8::Object> obj, const char *prop,
130
+ const LogInfo *log);
122
131
 
123
132
  // Functions to convert C client structure to v8 object(map)
124
133
  v8::Local<v8::Object> error_to_jsobject(as_error *error, const LogInfo *log);
@@ -180,6 +189,17 @@ int batch_remove_record_from_jsobject(as_batch_records *batch,
180
189
  void batch_records_free(as_batch_records *records, const LogInfo *log);
181
190
  int udfargs_from_jsobject(char **filename, char **funcname, as_list **args,
182
191
  v8::Local<v8::Object> obj, const LogInfo *log);
192
+
193
+ typedef struct {
194
+ uint32_t *connection;
195
+ uint32_t *write;
196
+ uint32_t *read;
197
+ uint32_t *batch;
198
+ uint32_t *query;
199
+ } latency;
200
+
201
+ void cluster_to_jsobject(as_cluster_s* cluster, v8::Local<v8::Object> v8_cluster, latency* latency, uint32_t bucket_max);
202
+ void node_to_jsobject(as_node_s* node, v8::Local<v8::Object> v8_node, latency* latency, uint32_t bucket_max);
183
203
  int extract_blob_from_jsobject(uint8_t **data, int *len,
184
204
  v8::Local<v8::Object> obj, const LogInfo *log);
185
205
  int list_from_jsarray(as_list **list, v8::Local<v8::Array> array,
@@ -206,3 +226,15 @@ int setGeneration(v8::Local<v8::Object> obj, uint16_t *generation,
206
226
  const LogInfo *log);
207
227
 
208
228
  size_t as_strlcpy(char *d, const char *s, size_t bufsize);
229
+
230
+ static inline void
231
+ as_conn_stats_init_internal(as_conn_stats* stats)
232
+ {
233
+ stats->in_pool = 0;
234
+ stats->in_use = 0;
235
+ stats->opened = 0;
236
+ stats->closed = 0;
237
+ };
238
+
239
+ void
240
+ as_conn_stats_sum_internal(as_conn_stats* stats, as_async_conn_pool* pool);
@@ -23,6 +23,8 @@ extern "C" {
23
23
  #include <aerospike/as_policy.h>
24
24
  #include <aerospike/as_partition_filter.h>
25
25
  #include <aerospike/as_event.h>
26
+ #include <aerospike/as_metrics_writer.h>
27
+ #include <aerospike/as_metrics.h>
26
28
  }
27
29
 
28
30
  // Functions to convert v8 policies to C structures
@@ -54,6 +56,8 @@ int infopolicy_from_jsobject(as_policy_info *policy, v8::Local<v8::Object> obj,
54
56
  const LogInfo *log);
55
57
  int adminpolicy_from_jsobject(as_policy_admin *policy, v8::Local<v8::Object> obj,
56
58
  const LogInfo *log);
59
+ int metricspolicy_from_jsobject_with_listeners(as_metrics_policy *policy, v8::Local<v8::Object> obj,
60
+ as_metrics_listeners* listeners, const LogInfo *log);
57
61
  int applypolicy_from_jsobject(as_policy_apply *policy,
58
62
  v8::Local<v8::Object> obj, const LogInfo *log);
59
63
  int scanpolicy_from_jsobject(as_policy_scan *policy, v8::Local<v8::Object> obj,
@@ -60,6 +60,7 @@ NAN_METHOD(AerospikeClient::New)
60
60
  client->log->fd = g_log_info.fd;
61
61
  client->log->level = g_log_info.level;
62
62
 
63
+
63
64
  // initialize the config to default values.
64
65
  as_config config;
65
66
  as_config_init(&config);
@@ -121,8 +122,10 @@ NAN_METHOD(AerospikeClient::Close)
121
122
  events_callback_close(&client->as->config);
122
123
  aerospike_close(client->as, &err);
123
124
  aerospike_destroy(client->as);
125
+
124
126
  free(client->as);
125
127
  free(client->log);
128
+
126
129
  client->closed = true;
127
130
  }
128
131
 
@@ -295,6 +298,8 @@ void AerospikeClient::Init()
295
298
  Nan::SetPrototypeMethod(tpl, "close", Close);
296
299
  Nan::SetPrototypeMethod(tpl, "connect", Connect);
297
300
  Nan::SetPrototypeMethod(tpl, "existsAsync", ExistsAsync);
301
+ Nan::SetPrototypeMethod(tpl, "disableMetrics", DisableMetrics);
302
+ Nan::SetPrototypeMethod(tpl, "enableMetrics", EnableMetrics);
298
303
  Nan::SetPrototypeMethod(tpl, "getAsync", GetAsync);
299
304
  Nan::SetPrototypeMethod(tpl, "getNodes", GetNodes);
300
305
  Nan::SetPrototypeMethod(tpl, "getStats", GetStats);
@@ -0,0 +1,48 @@
1
+ /*******************************************************************************
2
+ * Copyright 2013-2023 Aerospike, Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ ******************************************************************************/
16
+
17
+ #include "client.h"
18
+ #include "command.h"
19
+
20
+
21
+
22
+ extern "C" {
23
+ #include <aerospike/as_metrics.h>
24
+ }
25
+
26
+ using namespace v8;
27
+
28
+ NAN_METHOD(AerospikeClient::DisableMetrics)
29
+ {
30
+ TYPE_CHECK_REQ(info[0], IsFunction, "Callback must be a function");
31
+
32
+ AerospikeClient *client =
33
+ Nan::ObjectWrap::Unwrap<AerospikeClient>(info.This());
34
+ AsyncCommand *cmd =
35
+ new AsyncCommand("DisableMetrics", client, info[0].As<Function>());
36
+
37
+ if (aerospike_disable_metrics(client->as, &cmd->err) != AEROSPIKE_OK) {
38
+ cmd->ErrorCallback(&cmd->err);
39
+ goto Cleanup;
40
+ }
41
+ else{
42
+ Local<Value> argv[] = {Nan::Null(), Nan::Null()};
43
+ cmd->Callback(2, argv);
44
+ }
45
+
46
+ Cleanup:
47
+ delete cmd;
48
+ }