Socket
Socket
Sign inDemoInstall

aerospike

Package Overview
Dependencies
Maintainers
2
Versions
135
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

aerospike - npm Package Compare versions

Comparing version 1.0.15 to 1.0.16

.travis.yml

95

docs/client.md

@@ -193,3 +193,39 @@ # Client Class

```
<!--
################################################################################
execute()
################################################################################
-->
<a name="execute"></a>
### put(key, udfArgs, policy=null, callback)
Executes an UDF on a record in the database.
Parameters:
- `key` – A [Key object](datamodel.md#key), used to locate the record in the cluster.
- `udfArgs` – A [Record object](datamodel.md#UDFArgs) used for specifying the fields to store.
- `policy` – (optional) A [ApplyPolicy object](policies.md#ApplyPolicy) to use for this operation.
- `callback` – The function to call when the operation completes with the results of the operation.
The parameters for the `callback` argument:
- `error` – The [Error object](datamodel.md#error) representing the status of
the operation.
- `response` - A dictionary with the udf function name as the key and the value returned from the udf
function as the value.
- `key` – A [Key object](datamodel.md#key) for the record that was written.
Example:
```js
var key = aerospike.key
var udfArgs = { module : "udf_module", funcname: "udf_function", args:[args, to, udf, function] }
client.put(key('test','demo','key1'), udfArgs, function(error, res, key) {
// do something
});
```
<!--

@@ -465,2 +501,61 @@ ################################################################################

################################################################################
udfRegister()
################################################################################
-->
<a name="udfRegister"></a>
### select(udfModule, policy=null, callback)
Registers an UDF to the database cluster.
Parameters:
- `udfModule` – UDF filename specifying absolute file path.
- `policy` – (optional) The [Info Policy object](policies.md#InfoPolicy) to use for this operation.
- `callback` – The function to call when the operation completes with the results of the operation.
The parameters for the `callback` argument:
- `error` – The [Error object](datamodel.md#error) representing the status of
the operation.
Example:
```js
client.select("path/to/file/filename", function(error) {
// do something
});
```
<!--
################################################################################
udfRemove()
################################################################################
-->
<a name="udfRemove"></a>
### select(udfModule, policy=null, callback)
Registers an UDF to the database cluster.
Parameters:
- `udfModule` – UDF module name to be removed.
- `policy` – (optional) The [Info Policy object](policies.md#InfoPolicy) to use for this operation.
- `callback` – The function to call when the operation completes with the results of the operation.
The parameters for the `callback` argument:
- `error` – The [Error object](datamodel.md#error) representing the status of
the operation.
Example:
```js
client.select("udfModuleName", function(error) {
// do something
});
```
<!--
################################################################################
updateLogging()

@@ -467,0 +562,0 @@ ################################################################################

@@ -86,4 +86,27 @@ # Data Model

```
<!--
################################################################################
UDFArgs
################################################################################
-->
<a name="UDFArgs"></a>
## UDFArgs
Arguments to execute a UDF in the database.
- `module` – The UDF module name to be invoked in the database.
- `funcname` – The UDF function to be invoked in the database.
- `args` - (optional) The arguments to be passed to the UDF function.
Example:
```js
var udfArgs = {
module: udf_module,
funcname: udf_funcname,
args: [123, "str"]
}
```
<!--

@@ -90,0 +113,0 @@ ################################################################################

@@ -22,3 +22,21 @@ # Policies

```
<!--
################################################################################
ApplyPolicy
################################################################################
-->
<a name="ApplyPolicy"></a>
### Apply Policy Object
A policy effecting the behavior of UDF execution.
Attributes:
- `key` – Specifies the behavior for the key.
For values, see [Key Policy Values](policies.md#key).
- `timeout` – Maximum time in milliseconds to wait for the operation to
complete. If 0 (zero), then the value will default to
global default timeout value
<!--

@@ -25,0 +43,0 @@ ################################################################################

89

examples/batch_exists.js

@@ -19,3 +19,3 @@ /*******************************************************************************

*
* Check existence of a batch of records.
* Read a batch of records.
*

@@ -28,4 +28,4 @@ ******************************************************************************/

var policy = aerospike.policy;
var status = aerospike.status;
var Policy = aerospike.policy;
var Status = aerospike.status;

@@ -88,3 +88,3 @@ /*******************************************************************************

argp.showHelp();
return;
process.exit(0);
}

@@ -96,3 +96,3 @@

argp.showHelp();
return;
process.exit(1);
}

@@ -102,10 +102,14 @@

*
* Establish a connection to the cluster.
* Configure the client.
*
******************************************************************************/
var client = aerospike.client({
config = {
// the hosts to attempt to connect with.
hosts: [
{ addr: argv.host, port: argv.port }
],
// log configuration
log: {

@@ -115,15 +119,8 @@ level: argv['log-level'],

},
// default policies
policies: {
timeout: argv.timeout
}
}).connect(function (err, client) {
if ( err.code != status.AEROSPIKE_OK ) {
console.log("Aerospike server connection Error: %j", err)
return;
}
if ( client === null ) {
console.error("Error: Client not initialized.");
return;
}
});
};

@@ -136,28 +133,44 @@ /*******************************************************************************

console.time("batchExists");
function format(o) {
return JSON.stringify(o, null, ' ');
}
client.batchExists(keys, function (err, results) {
var i = 0;
if ( err.code == status.AEROSPIKE_OK ) {
for ( i = 0; i < results.length; i++ ) {
switch ( results[i].status ) {
case status.AEROSPIKE_OK:
console.log("OK - ", results[i].key, results[i].metadata);
break;
case status.AEROSPIKE_ERR_RECORD_NOT_FOUND:
console.log("NOT_FOUND - ", results[i].key);
break;
default:
console.log("ERR - %d - ", results[i].status, results[i].key);
}
}
aerospike.client(config).connect(function (err, client) {
if ( err.code != Status.AEROSPIKE_OK ) {
console.error("Error: Aerospike server connection error. ", err.message);
process.exit(1);
}
else {
console.log("ERR - ", err);
//
// Perform the operation
//
if ( argv.profile ) {
console.time("batch_get");
}
console.timeEnd("batchExists");
console.log();
client.batchExists(keys, function (err, results) {
var exitCode = 0;
client.close();
switch ( err.code ) {
case Status.AEROSPIKE_OK:
console.log(format(results));
break;
default:
console.error("Error: " + err.message);
exitCode = 1;
break;
}
if ( argv.profile ) {
console.log("---");
console.timeEnd("batch_get");
}
process.exit(exitCode);
});
});

@@ -27,4 +27,4 @@ /*******************************************************************************

var policy = aerospike.policy;
var status = aerospike.status;
var Policy = aerospike.policy;
var Status = aerospike.status;

@@ -87,3 +87,3 @@ /*******************************************************************************

argp.showHelp();
return;
process.exit(0);
}

@@ -95,3 +95,3 @@

argp.showHelp();
return;
process.exit(1);
}

@@ -101,10 +101,14 @@

*
* Establish a connection to the cluster.
* Configure the client.
*
******************************************************************************/
var client = aerospike.client({
config = {
// the hosts to attempt to connect with.
hosts: [
{ addr: argv.host, port: argv.port }
],
// log configuration
log: {

@@ -114,15 +118,8 @@ level: argv['log-level'],

},
// default policies
policies: {
timeout: argv.timeout
}
}).connect(function (err, client) {
if ( err.code != status.AEROSPIKE_OK ) {
console.log("Aerospike server connection Error: %j", err)
return;
}
if ( client === null ) {
console.error("Error: Client not initialized.");
return;
}
});
};

@@ -135,28 +132,44 @@ /*******************************************************************************

console.time("batchGet");
function format(o) {
return JSON.stringify(o, null, ' ');
}
client.batchGet(keys, function (err, results) {
var i = 0;
if ( err.code == status.AEROSPIKE_OK ) {
for ( i = 0; i < results.length; i++ ) {
switch ( results[i].status ) {
case status.AEROSPIKE_OK:
console.log("OK - ", results[i].key, results[i].metadata, results[i].record);
break;
case status.AEROSPIKE_ERR_RECORD_NOT_FOUND:
console.log("NOT_FOUND - ", results[i].key);
break;
default:
console.log("ERR - %d - ", results[i].status, results[i].key);
}
}
aerospike.client(config).connect(function (err, client) {
if ( err.code != Status.AEROSPIKE_OK ) {
console.error("Error: Aerospike server connection error. ", err.message);
process.exit(1);
}
else {
console.log("ERR - ", err);
//
// Perform the operation
//
if ( argv.profile ) {
console.time("batch_get");
}
console.timeEnd("batchGet");
console.log();
client.close();
client.batchGet(keys, function (err, results) {
var exitCode = 0;
switch ( err.code ) {
case Status.AEROSPIKE_OK:
console.log(format(results));
break;
default:
console.error("Error: " + err.message);
exitCode = 1;
break;
}
if ( argv.profile ) {
console.log("---");
console.timeEnd("batch_get");
}
process.exit(exitCode);
});
});

@@ -27,4 +27,4 @@ /*******************************************************************************

var policy = aerospike.policy;
var status = aerospike.status;
var Policy = aerospike.policy;
var Status = aerospike.status;

@@ -44,2 +44,6 @@ /*******************************************************************************

},
profile: {
boolean: true,
describe: "Profile the operation."
},
host: {

@@ -78,2 +82,14 @@ alias: "h",

describe: "Set for the keys."
},
'no-key': {
boolean: true,
describe: "Do not display the record's key."
},
'no-metadata': {
boolean: true,
describe: "Do not display the record's metadata."
},
'no-bins': {
boolean: true,
describe: "Do not display the record's bins."
}

@@ -83,14 +99,14 @@ });

var argv = argp.argv;
var keyv = argv._.length === 1 ? argv._[0] : null;
var keyv = argv._.shift();
if ( argv.help === true ) {
argp.showHelp();
return;
process.exit(0);
}
if ( keyv === null ) {
if ( ! keyv ) {
console.error("Error: Please provide a key for the operation");
console.error();
argp.showHelp();
return;
process.exit(1);
}

@@ -100,10 +116,14 @@

*
* Establish a connection to the cluster.
* Configure the client.
*
******************************************************************************/
var client = aerospike.client({
config = {
// the hosts to attempt to connect with.
hosts: [
{ addr: argv.host, port: argv.port }
],
// log configuration
log: {

@@ -113,47 +133,77 @@ level: argv['log-level'],

},
// default policies
policies: {
timeout: argv.timeout
}
}).connect(function (err, client ) {
if ( err.code != status.AEROSPIKE_OK ) {
console.log("Aerospike server connection Error: %j", err)
return;
}
if ( client === null ) {
console.error("Error: Client not initialized.");
return;
}
});
};
/*******************************************************************************
*
* Perform the operation
* Establish a connection and execute the opetation.
*
******************************************************************************/
var key = {
ns: argv.namespace,
set: argv.set,
key: keyv
};
function format(o) {
return JSON.stringify(o, null, ' ');
}
console.time("exists");
aerospike.client(config).connect(function (err, client) {
client.exists(key, function(err, metadata, key) {
switch ( err.code ) {
case status.AEROSPIKE_OK:
console.log("OK - ", key, metadata);
break;
case status.AEROSPIKE_ERR_RECORD_NOT_FOUND:
console.log("NOT_FOUND - ", key);
break;
default:
console.log("ERR - ", err, key);
if ( err.code != Status.AEROSPIKE_OK ) {
console.error("Error: Aerospike server connection error. ", err.message);
process.exit(1);
}
console.timeEnd("exists");
console.log();
client.close();
//
// Perform the operation
//
var key = {
ns: argv.namespace,
set: argv.set,
key: keyv
};
if ( argv.profile ) {
console.time("exists");
}
client.exists(key, function(err, metadata, key) {
var exitCode = 0;
switch ( err.code ) {
case Status.AEROSPIKE_OK:
var record = {};
if ( ! argv['no-key'] ) {
record.key = key;
}
if ( ! argv['no-metadata'] ) {
record.metadata = metadata;
}
console.log(format(record));
break;
case Status.AEROSPIKE_ERR_RECORD_NOT_FOUND:
console.error("Error: Not Found.");
exitCode = 1;
break;
default:
console.error("Error: " + err.message);
exitCode = 1;
break;
}
if ( argv.profile === true ) {
console.log("---");
console.timeEnd("exists");
}
process.exit(exitCode);
});
});

@@ -27,4 +27,4 @@ /*******************************************************************************

var policy = aerospike.policy;
var status = aerospike.status;
var Policy = aerospike.policy;
var Status = aerospike.status;

@@ -37,3 +37,3 @@ /*******************************************************************************

var argp = yargs
var argp = yargs
.usage("$0 [options] key")

@@ -45,2 +45,6 @@ .options({

},
profile: {
boolean: true,
describe: "Profile the operation."
},
host: {

@@ -79,2 +83,17 @@ alias: "h",

describe: "Set for the keys."
},
'key': {
boolean: true,
default: true,
describe: "Display the record's key."
},
'metadata': {
boolean: true,
default: true,
describe: "Display the record's metadata."
},
'bins': {
boolean: true,
default: true,
describe: "Display the record's bins."
}

@@ -84,25 +103,30 @@ });

var argv = argp.argv;
var keyv = argv._.length === 1 ? argv._[0] : null;
var keyv = argv._.shift();
if ( argv.help === true ) {
argp.showHelp();
return;
process.exit(0);
}
if ( keyv === null ) {
if ( ! keyv ) {
console.error("Error: Please provide a key for the operation");
console.error();
argp.showHelp();
return;
process.exit(1);
}
/*******************************************************************************
*
* Create a client object
*
* Configure the client.
*
******************************************************************************/
var client = aerospike.client({
config = {
// the hosts to attempt to connect with.
hosts: [
{ addr: argv.host, port: argv.port }
],
// log configuration
log: {

@@ -112,42 +136,82 @@ level: argv['log-level'],

},
// default policies
policies: {
timeout: argv.timeout
}
});
function as_connect_callback( err, as_client ) {
if (err.code != status.AEROSPIKE_OK) {
console.log("Aerospike server connection Error: %j", err);
setTimeout( function() { client.connect(as_connect_callback)} , 1000);
}
}
client.connect(as_connect_callback)
};
/*******************************************************************************
*
* Perform the operation
* Establish a connection and execute the opetation.
*
******************************************************************************/
var key = {
ns: argv.namespace,
set: argv.set,
key: keyv
};
function format(o) {
return JSON.stringify(o, null, ' ');
}
var get_fn = client.get;
console.time("get");
function get_cb( err, record, metadata, key) {
switch ( err.code ) {
case status.AEROSPIKE_OK:
console.log("OK - ", key, metadata, record);
break;
case status.AEROSPIKE_ERR_RECORD_NOT_FOUND:
console.log("NOT_FOUND -", key);
break;
default:
console.log("ERR - ", err, key);
aerospike.client(config).connect(function (err, client) {
if ( err.code != Status.AEROSPIKE_OK ) {
console.error("Error: Aerospike server connection error. ", err.message);
process.exit(1);
}
console.timeEnd("get");
console.log();
}
client.get(key, get_cb)
//
// Perform the operation
//
var key = {
ns: argv.namespace,
set: argv.set,
key: keyv
};
if ( argv.profile ) {
console.time("get");
}
client.get(key, function ( err, bins, metadata, key) {
var exitCode = 0;
switch ( err.code ) {
case Status.AEROSPIKE_OK:
var record = {};
if ( argv['key'] ) {
record.key = key;
}
if ( argv['metadata'] ) {
record.metadata = metadata;
}
if ( argv['bins'] ) {
record.bins = bins;
}
console.log(format(record));
break;
case Status.AEROSPIKE_ERR_RECORD_NOT_FOUND:
console.error("Error: Not Found.");
exitCode = 1;
break;
default:
console.error("Error: " + err.message);
exitCode = 1;
break;
}
if ( argv.profile ) {
console.log("---");
console.timeEnd("get");
}
process.exit(exitCode);
});
});

@@ -27,4 +27,4 @@ /*******************************************************************************

var policy = aerospike.policy;
var status = aerospike.status;
var Policy = aerospike.policy;
var Status = aerospike.status;

@@ -90,10 +90,14 @@ /*******************************************************************************

*
* Establish a connection to the cluster.
* Configure the client.
*
******************************************************************************/
var client = aerospike.client({
config = {
// the hosts to attempt to connect with.
hosts: [
{ addr: argv.host, port: argv.port }
],
// log configuration
log: {

@@ -103,15 +107,8 @@ level: argv['log-level'],

},
// default policies
policies: {
timeout: argv.timeout
}
}).connect(function (err, client ) {
if ( err.code != status.AEROSPIKE_OK ) {
console.log("Aerospike server connection Error: %j", err)
return;
}
if ( client === null ) {
console.error("Error: Client not initialized.");
return;
}
});
};

@@ -124,30 +121,45 @@ /*******************************************************************************

console.log("host...");
function format(o) {
return JSON.stringify(o, null, ' ');
}
client.info(request, {addr: argv.host, port: argv.port}, function(err, response, host) {
aerospike.client(config).connect(function (err, client) {
switch ( err.code ) {
case status.AEROSPIKE_OK:
console.log("OK - ", host, response);
console.log();
break;
default:
console.log("ERR - ", err, key);
console.log();
if ( err.code != Status.AEROSPIKE_OK ) {
console.error("Error: Aerospike server connection error. ", err.message);
process.exit(1);
}
console.log("cluster...");
//
// Perform the operation
//
if ( argv.profile ) {
console.time("info");
}
client.info(request, function(err, response, host) {
var exitCode = 0;
switch ( err.code ) {
case status.AEROSPIKE_OK:
console.log("OK - ", host, response);
case Status.AEROSPIKE_OK:
res = {
host: host,
response: response
};
console.log(format(res));
break;
default:
console.log("ERR - ", err, key);
console.error("Error: ", err.message);
exitCode = 1;
}
if ( argv.profile ) {
console.log("---");
console.timeEnd("info");
}
console.log();
process.exit(exitCode);
});
});

@@ -27,5 +27,5 @@ /*******************************************************************************

var op = aerospike.operator;
var policy = aerospike.policy;
var status = aerospike.status;
var Operator = aerospike.operator;
var Policy = aerospike.policy;
var Status = aerospike.status;

@@ -45,2 +45,6 @@ /*******************************************************************************

},
profile: {
boolean: true,
describe: "Profile the operation."
},
host: {

@@ -83,14 +87,14 @@ alias: "h",

var argv = argp.argv;
var keyv = argv._.length === 1 ? argv._[0] : null;
var keyv = argv._.shift();
if ( argv.help === true ) {
argp.showHelp();
return;
process.exit(0);
}
if ( keyv === null ) {
if ( ! keyv ) {
console.error("Error: Please provide a key for the operation");
console.error();
argp.showHelp();
return;
process.exit(1);
}

@@ -104,6 +108,10 @@

var client = aerospike.client({
config = {
// the hosts to attempt to connect with.
hosts: [
{ addr: argv.host, port: argv.port }
],
// log configuration
log: {

@@ -113,15 +121,8 @@ level: argv['log-level'],

},
// default policies
policies: {
timeout: argv.timeout
}
}).connect(function (err, client ) {
if ( err.code != status.AEROSPIKE_OK ) {
console.log("Aerospike server connection Error: %j", err)
return;
}
if ( client === null ) {
console.error("Error: Client not initialized.");
return;
}
});
};

@@ -134,33 +135,78 @@ /*******************************************************************************

var key = {
ns: argv.namespace,
set: argv.set,
key: keyv
};
function format(o) {
return JSON.stringify(o, null, ' ');
}
var ops = [
op.touch(1000),
op.incr('i', 1),
op.write('s', 'some_val'),
op.read('s')
];
aerospike.client(config).connect(function (err, client) {
console.time("operate");
if ( err.code != Status.AEROSPIKE_OK ) {
console.error("Error: Aerospike server connection error. ", err.message);
process.exit(1);
}
client.operate(key, ops, function(err, bins, metadata, key) {
switch ( err.code ) {
case status.AEROSPIKE_OK:
console.log("OK - ", key, metadata, bins);
break;
case status.AEROSPIKE_ERR_RECORD_NOT_FOUND:
console.log("NOT_FOUND - ", key);
break;
default:
console.log("ERR - ", err, key);
//
// Perform the operation
//
var key = {
ns: argv.namespace,
set: argv.set,
key: keyv
};
var ops = [
Operator.touch(1000),
Operator.incr('i', 1),
Operator.write('s', 'some_val'),
Operator.read('i'),
Operator.read('s')
];
if ( argv.profile ) {
console.time("operate");
}
console.timeEnd("operate");
console.log();
client.close();
client.operate(key, ops, function(err, bins, metadata, key) {
var exitCode = 0;
switch ( err.code ) {
case Status.AEROSPIKE_OK:
var record = {};
if ( ! argv['no-key'] ) {
record.key = key;
}
if ( ! argv['no-metadata'] ) {
record.metadata = metadata;
}
if ( ! argv['no-bins'] ) {
record.bins = bins;
}
console.log(format(record));
break;
case Status.AEROSPIKE_ERR_RECORD_NOT_FOUND:
console.error("Error: Not Found.");
exitCode = 1;
break;
default:
console.error("Error: " + err.message);
exitCode = 1;
break;
}
if ( argv.profile ) {
console.log("---");
console.timeEnd("operate");
}
process.exit(exitCode);
});
});

@@ -27,4 +27,4 @@ /*******************************************************************************

var policy = aerospike.policy;
var status = aerospike.status;
var Policy = aerospike.policy;
var Status = aerospike.status;

@@ -44,2 +44,6 @@ /*******************************************************************************

},
profile: {
boolean: true,
describe: "Profile the operation."
},
host: {

@@ -86,10 +90,10 @@ alias: "h",

argp.showHelp();
return;
process.exit(0);
}
if ( keyv === null ) {
if ( ! keyv ) {
console.error("Error: Please provide a key for the operation");
console.error();
argp.showHelp();
return;
process.exit(1);
}

@@ -99,10 +103,14 @@

*
* Establish a connection to the cluster.
* Configure the client.
*
******************************************************************************/
var client = aerospike.client({
config = {
// the hosts to attempt to connect with.
hosts: [
{ addr: argv.host, port: argv.port }
],
// log configuration
log: {

@@ -112,15 +120,8 @@ level: argv['log-level'],

},
// default policies
policies: {
timeout: argv.timeout
}
}).connect(function (err, client ) {
if ( err.code != status.AEROSPIKE_OK ) {
console.log("Aerospike server connection Error: %j", err)
return;
}
if ( client === null ) {
console.error("Error: Client not initialized.");
return;
}
});
};

@@ -133,37 +134,58 @@ /*******************************************************************************

var key = {
ns: argv.namespace,
set: argv.set,
key: keyv
};
aerospike.client(config).connect(function (err, client) {
var record = {
i: 123,
s: "abc",
arr: [1, 2, 3],
map: { str: "g3", num: 3, buff: new Buffer( [0xa, 0xb, 0xc])},
b: new Buffer([0xa, 0xb, 0xc]),
b2: new Uint8Array([0xa, 0xb, 0xc])
};
if ( err.code != Status.AEROSPIKE_OK ) {
console.error("Error: Aerospike server connection error. ", err.message);
process.exit(1);
}
var metadata = {
ttl: 10000,
gen: 0
};
//
// Perform the operation
//
console.time("put");
var key = {
ns: argv.namespace,
set: argv.set,
key: keyv
};
client.put(key, record, metadata, function(err, key) {
switch ( err.code ) {
case status.AEROSPIKE_OK:
console.log("OK - ", key);
break;
default:
console.log("ERR - ", err, key);
var bins = {
i: 123,
s: "abc",
l: [1, 2, 3],
m: { s: "g3", i: 3, b: new Buffer( [0xa, 0xb, 0xc])},
b: new Buffer([0xa, 0xb, 0xc]),
b2: new Uint8Array([0xa, 0xb, 0xc])
};
var metadata = {
ttl: 10000,
gen: 0
};
if ( argv.profile ) {
console.time("put");
}
console.timeEnd("put");
console.log();
client.close();
client.put(key, bins, metadata, function(err, key) {
var exitCode = 0;
switch ( err.code ) {
case Status.AEROSPIKE_OK:
break;
default:
console.error("Error: " + err.message);
exitCode = 1;
break;
}
if ( argv.profile === true ) {
console.log("---");
console.timeEnd("exists");
}
process.exit(exitCode);
});
});

@@ -43,4 +43,4 @@ /*******************************************************************************

var policy = aerospike.policy;
var status = aerospike.status;
var Policy = aerospike.policy;
var Status = aerospike.status;

@@ -112,3 +112,3 @@ /*******************************************************************************

argp.showHelp();
return;
process.exit(0);
}

@@ -118,10 +118,14 @@

*
* Establish a connection to the cluster.
* Configure the client.
*
******************************************************************************/
var client = aerospike.client({
config = {
// the hosts to attempt to connect with.
hosts: [
{ addr: argv.host, port: argv.port }
],
// log configuration
log: {

@@ -131,15 +135,8 @@ level: argv['log-level'],

},
// default policies
policies: {
timeout: argv.timeout
}
}).connect(function (err, client ) {
if ( err.code != status.AEROSPIKE_OK ) {
console.log("Aerospike server connection Error: %j", err)
return;
}
if ( client === null ) {
console.error("Error: Client not initialized.");
return;
}
});
};

@@ -152,69 +149,82 @@ /*******************************************************************************

function exists_done(client, start, end, skip) {
var total = end - start + 1;
var done = 0;
var success = 0;
var notfound = 0;
var failure = 0;
var skipped = 0;
var timeLabel = "range_exists @ " + total;
aerospike.client(config).connect(function (err, client) {
console.time(timeLabel);
if ( err.code != Status.AEROSPIKE_OK ) {
console.error("Error: Aerospike server connection error. ", err.message);
process.exit(1);
}
return function(err, metadata, key, skippy) {
//
// Perform the operation
//
if ( skippy === true ) {
console.log("SKIP - ", key);
skipped++;
}
else {
switch ( err.code ) {
case status.AEROSPIKE_OK:
console.log("OK - ", key, metadata);
success++;
break;
case status.AEROSPIKE_ERR_RECORD_NOT_FOUND:
console.log("NOT_FOUND - ", key);
notfound++;
break;
default:
console.log("ERR - ", err, key);
failure++;
function exists_done(client, start, end, skip) {
var total = end - start + 1;
var done = 0;
var success = 0;
var notfound = 0;
var failure = 0;
var skipped = 0;
var timeLabel = "range_exists @ " + total;
console.time(timeLabel);
return function(err, metadata, key, skippy) {
if ( skippy === true ) {
console.log("SKIP - ", key);
skipped++;
}
}
else {
switch ( err.code ) {
case Status.AEROSPIKE_OK:
console.log("OK - ", key, metadata);
success++;
break;
case Status.AEROSPIKE_ERR_RECORD_NOT_FOUND:
console.log("NOT_FOUND - ", key);
notfound++;
break;
default:
console.log("ERR - ", err, key);
failure++;
}
}
done++;
if ( done >= total ) {
console.timeEnd(timeLabel);
console.log();
console.log("RANGE: start=%d end=%d skip=%d", start, end, skip);
console.log("RESULTS: (%d completed, %d success, %d failed, %d notfound, %d skipped)", done, success, failure, notfound, skipped);
console.log();
client.close();
done++;
if ( done >= total ) {
console.timeEnd(timeLabel);
console.log();
console.log("RANGE: start=%d end=%d skip=%d", start, end, skip);
console.log("RESULTS: (%d completed, %d success, %d failed, %d notfound, %d skipped)", done, success, failure, notfound, skipped);
console.log();
client.close();
}
}
}
}
function exists_start(client, start, end, skip) {
var done = exists_done(client, start, end, skip);
var i = start, s = 0;
function exists_start(client, start, end, skip) {
var done = exists_done(client, start, end, skip);
var i = start, s = 0;
for (; i <= end; i++ ) {
var key = {
ns: argv.namespace,
set: argv.set,
key: i
};
for (; i <= end; i++ ) {
var key = {
ns: argv.namespace,
set: argv.set,
key: i
};
if ( skip !== 0 && ++s >= skip ) {
s = 0;
done(null,null,null,key,true);
continue;
if ( skip !== 0 && ++s >= skip ) {
s = 0;
done(null,null,null,key,true);
continue;
}
client.exists(key, done);
}
client.exists(key, done);
}
}
exists_start(client, argv.start, argv.end, argv.skip);
exists_start(client, argv.start, argv.end, argv.skip);
});

@@ -43,4 +43,4 @@ /*******************************************************************************

var policy = aerospike.policy;
var status = aerospike.status;
var Policy = aerospike.policy;
var Status = aerospike.status;

@@ -112,3 +112,3 @@ /*******************************************************************************

argp.showHelp();
return;
process.exit(0);
}

@@ -118,10 +118,14 @@

*
* Establish a connection to the cluster.
* Configure the client.
*
******************************************************************************/
var client = aerospike.client({
config = {
// the hosts to attempt to connect with.
hosts: [
{ addr: argv.host, port: argv.port }
],
// log configuration
log: {

@@ -131,15 +135,8 @@ level: argv['log-level'],

},
// default policies
policies: {
timeout: argv.timeout
}
}).connect(function (err, client ) {
if ( err.code != status.AEROSPIKE_OK ) {
console.log("Aerospike server connection Error: %j", err)
return;
}
if ( client === null ) {
console.error("Error: Client not initialized.");
return;
}
});
};

@@ -152,69 +149,83 @@ /*******************************************************************************

function get_done(client, start, end, skip) {
var total = end - start + 1;
var done = 0;
var success = 0;
var notfound = 0;
var failure = 0;
var skipped = 0;
var timeLabel = "range_get @ " + total;
aerospike.client(config).connect(function (err, client) {
console.time(timeLabel);
if ( err.code != Status.AEROSPIKE_OK ) {
console.error("Error: Aerospike server connection error. ", err.message);
process.exit(1);
}
return function(err, record, metadata, key, skippy) {
//
// Perform the operation
//
if ( skippy === true ) {
console.log("SKIP - ", key);
skipped++;
}
else {
switch ( err.code ) {
case status.AEROSPIKE_OK:
console.log("OK - ", key, metadata, record);
success++;
break;
case status.AEROSPIKE_ERR_RECORD_NOT_FOUND:
console.log("NOT_FOUND - ", key);
notfound++;
break;
default:
console.log("ERR - ", err, key);
failure++;
function get_done(client, start, end, skip) {
var total = end - start + 1;
var done = 0;
var success = 0;
var notfound = 0;
var failure = 0;
var skipped = 0;
var timeLabel = "range_get @ " + total;
console.time(timeLabel);
return function(err, record, metadata, key, skippy) {
if ( skippy === true ) {
console.log("SKIP - ", key);
skipped++;
}
}
else {
switch ( err.code ) {
case Status.AEROSPIKE_OK:
console.log("OK - ", key, metadata, record);
success++;
break;
case Status.AEROSPIKE_ERR_RECORD_NOT_FOUND:
console.log("NOT_FOUND - ", key);
notfound++;
break;
default:
console.log("ERR - ", err, key);
failure++;
}
}
done++;
if ( done >= total ) {
console.timeEnd(timeLabel);
console.log();
console.log("RANGE: start=%d end=%d skip=%d", start, end, skip);
console.log("RESULTS: (%d completed, %d success, %d failed, %d notfound, %d skipped)", done, success, failure, notfound, skipped);
console.log();
client.close();
done++;
if ( done >= total ) {
console.timeEnd(timeLabel);
console.log();
console.log("RANGE: start=%d end=%d skip=%d", start, end, skip);
console.log("RESULTS: (%d completed, %d success, %d failed, %d notfound, %d skipped)", done, success, failure, notfound, skipped);
console.log();
client.close();
}
}
}
}
function get_start(client, start, end, skip) {
var done = get_done(client, start, end, skip);
var i = start, s = 0;
function get_start(client, start, end, skip) {
var done = get_done(client, start, end, skip);
var i = start, s = 0;
for (; i <= end; i++ ) {
var key = {
ns: argv.namespace,
set: argv.set,
key: i
};
for (; i <= end; i++ ) {
var key = {
ns: argv.namespace,
set: argv.set,
key: i
};
if ( skip !== 0 && ++s >= skip ) {
s = 0;
done(null,null,null,key,true);
continue;
if ( skip !== 0 && ++s >= skip ) {
s = 0;
done(null,null,null,key,true);
continue;
}
client.get(key, done);
}
client.get(key, done);
}
}
get_start(client, argv.start, argv.end, argv.skip);
get_start(client, argv.start, argv.end, argv.skip);
});

@@ -43,4 +43,4 @@ /*******************************************************************************

var policy = aerospike.policy;
var status = aerospike.status;
var Policy = aerospike.policy;
var Status = aerospike.status;

@@ -112,3 +112,3 @@ /*******************************************************************************

argp.showHelp();
return;
process.exit(0);
}

@@ -118,10 +118,14 @@

*
* Establish a connection to the cluster.
* Configure the client.
*
******************************************************************************/
var client = aerospike.client({
config = {
// the hosts to attempt to connect with.
hosts: [
{ addr: argv.host, port: argv.port }
],
// log configuration
log: {

@@ -131,15 +135,8 @@ level: argv['log-level'],

},
// default policies
policies: {
timeout: argv.timeout
}
}).connect(function (err, client ) {
if ( err.code != status.AEROSPIKE_OK ) {
console.log("Aerospike server connection Error: %j", err)
return;
}
if ( client === null ) {
console.error("Error: Client not initialized.");
return;
}
});
};

@@ -152,76 +149,89 @@ /*******************************************************************************

function put_done(client, start, end, skip) {
var total = end - start + 1;
var done = 0;
var success = 0;
var failure = 0;
var skipped = 0;
var timeLabel = "range_put @ " + total;
aerospike.client(config).connect(function (err, client) {
console.time(timeLabel);
if ( err.code != Status.AEROSPIKE_OK ) {
console.error("Error: Aerospike server connection error. ", err.message);
process.exit(1);
}
return function(err, key, skippy) {
//
// Perform the operation
//
if ( skippy === true ) {
console.log("SKIP - ", key);
skipped++;
}
else {
switch ( err.code ) {
case status.AEROSPIKE_OK:
console.log("OK - ", key);
success++;
break;
default:
console.log("ERR - ", err, key);
failure++;
function put_done(client, start, end, skip) {
var total = end - start + 1;
var done = 0;
var success = 0;
var failure = 0;
var skipped = 0;
var timeLabel = "range_put @ " + total;
console.time(timeLabel);
return function(err, key, skippy) {
if ( skippy === true ) {
console.log("SKIP - ", key);
skipped++;
}
}
else {
switch ( err.code ) {
case Status.AEROSPIKE_OK:
console.log("OK - ", key);
success++;
break;
default:
console.log("ERR - ", err, key);
failure++;
}
}
done++;
if ( done >= total ) {
console.timeEnd(timeLabel);
console.log();
console.log("RANGE: start=%d end=%d skip=%d)", start, end, skip);
console.log("RESULTS: (%d completed, %d success, %d failed, %d skipped)", done, success, failure, skipped);
console.log();
client.close();
done++;
if ( done >= total ) {
console.timeEnd(timeLabel);
console.log();
console.log("RANGE: start=%d end=%d skip=%d)", start, end, skip);
console.log("RESULTS: (%d completed, %d success, %d failed, %d skipped)", done, success, failure, skipped);
console.log();
client.close();
}
}
}
}
function put_start(client, start, end, skip) {
var done = put_done(client, start, end, skip);
var i = start, s = 0;
function put_start(client, start, end, skip) {
var done = put_done(client, start, end, skip);
var i = start, s = 0;
for (; i <= end; i++ ) {
for (; i <= end; i++ ) {
var key = {
ns: argv.namespace,
set: argv.set,
key: i
};
var key = {
ns: argv.namespace,
set: argv.set,
key: i
};
if ( skip !== 0 && ++s >= skip ) {
s = 0;
done(null, key, true);
continue;
}
if ( skip !== 0 && ++s >= skip ) {
s = 0;
done(null, key, true);
continue;
}
var record = {
k: i,
s: "abc",
i: i * 1000 + 123,
b: new Buffer([0xa, 0xb, 0xc])
};
var record = {
k: i,
s: "abc",
i: i * 1000 + 123,
b: new Buffer([0xa, 0xb, 0xc])
};
var metadata = {
ttl: 10000,
gen: 0
};
var metadata = {
ttl: 10000,
gen: 0
};
client.put(key, record, metadata, done);
client.put(key, record, metadata, done);
}
}
}
put_start(client, argv.start, argv.end, argv.skip);
put_start(client, argv.start, argv.end, argv.skip);
});

@@ -43,4 +43,4 @@ /*******************************************************************************

var policy = aerospike.policy;
var status = aerospike.status;
var Policy = aerospike.policy;
var Status = aerospike.status;

@@ -112,3 +112,3 @@ /*******************************************************************************

argp.showHelp();
return;
process.exit(0);
}

@@ -118,10 +118,14 @@

*
* Establish a connection to the cluster.
* Configure the client.
*
******************************************************************************/
var client = aerospike.client({
config = {
// the hosts to attempt to connect with.
hosts: [
{ addr: argv.host, port: argv.port }
],
// log configuration
log: {

@@ -131,15 +135,8 @@ level: argv['log-level'],

},
// default policies
policies: {
timeout: argv.timeout
}
}).connect(function (err, client ) {
if ( err.code != status.AEROSPIKE_OK ) {
console.log("Aerospike server connection Error: %j", err)
return;
}
if ( client === null ) {
console.error("Error: Client not initialized.");
return;
}
});
};

@@ -152,68 +149,81 @@ /*******************************************************************************

function remove_done(client, start, end, skip) {
var total = end - start + 1;
var done = 0;
var success = 0;
var notfound = 0;
var failure = 0;
var skipped = 0;
var timeLabel = "range_remove @ " + total;
aerospike.client(config).connect(function (err, client) {
console.time(timeLabel);
if ( err.code != Status.AEROSPIKE_OK ) {
console.error("Error: Aerospike server connection error. ", err.message);
process.exit(1);
}
return function(err, key, skippy) {
//
// Perform the operation
//
function remove_done(client, start, end, skip) {
var total = end - start + 1;
var done = 0;
var success = 0;
var notfound = 0;
var failure = 0;
var skipped = 0;
var timeLabel = "range_remove @ " + total;
if ( skippy === true ) {
console.log("SKIP - ", key);
skipped++;
}
else {
switch ( err.code ) {
case status.AEROSPIKE_OK:
console.log("OK - ", key);
success++;
break;
case status.AEROSPIKE_ERR_RECORD_NOT_FOUND:
console.log("NOT_FOUND - ", key);
notfound++;
break;
default:
console.log("ERR - ", err, key);
failure++;
console.time(timeLabel);
return function(err, key, skippy) {
if ( skippy === true ) {
console.log("SKIP - ", key);
skipped++;
}
}
else {
switch ( err.code ) {
case Status.AEROSPIKE_OK:
console.log("OK - ", key);
success++;
break;
case Status.AEROSPIKE_ERR_RECORD_NOT_FOUND:
console.log("NOT_FOUND - ", key);
notfound++;
break;
default:
console.log("ERR - ", err, key);
failure++;
}
}
done++;
if ( done >= total ) {
console.timeEnd(timeLabel);
console.log();
console.log("RANGE: start=%d end=%d skip=%d", start, end, skip);
console.log("RESULTS: (%d completed, %d success, %d failed, %d notfound, %d skipped)", done, success, failure, notfound, skipped);
console.log();
client.close();
done++;
if ( done >= total ) {
console.timeEnd(timeLabel);
console.log();
console.log("RANGE: start=%d end=%d skip=%d", start, end, skip);
console.log("RESULTS: (%d completed, %d success, %d failed, %d notfound, %d skipped)", done, success, failure, notfound, skipped);
console.log();
client.close();
}
}
}
}
function remove_start(client, start, end, skip) {
var done = remove_done(client, start, end, skip);
var i = start, s = 0;
function remove_start(client, start, end, skip) {
var done = remove_done(client, start, end, skip);
var i = start, s = 0;
for (; i <= end; i++ ) {
var key = {
ns: argv.namespace,
set: argv.set,
key: i
};
for (; i <= end; i++ ) {
var key = {
ns: argv.namespace,
set: argv.set,
key: i
};
if ( skip !== 0 && ++s >= skip ) {
s = 0;
done(null, key, true);
continue;
if ( skip !== 0 && ++s >= skip ) {
s = 0;
done(null, key, true);
continue;
}
client.remove(key, done);
}
client.remove(key, done);
}
}
remove_start(client, argv.start, argv.end, argv.skip);
remove_start(client, argv.start, argv.end, argv.skip);
});

@@ -43,4 +43,4 @@ /*******************************************************************************

var policy = aerospike.policy;
var status = aerospike.status;
var Policy = aerospike.policy;
var Status = aerospike.status;

@@ -108,3 +108,3 @@ /*******************************************************************************

argp.showHelp();
return;
process.exit(0);
}

@@ -114,10 +114,14 @@

*
* Establish a connection to the cluster.
* Configure the client.
*
******************************************************************************/
var client = aerospike.client({
config = {
// the hosts to attempt to connect with.
hosts: [
{ addr: argv.host, port: argv.port }
],
// log configuration
log: {

@@ -127,15 +131,8 @@ level: argv['log-level'],

},
// default policies
policies: {
timeout: argv.timeout
}
}).connect(function (err, client ) {
if ( err.code != status.AEROSPIKE_OK ) {
console.log("Aerospike server connection Error: %j", err)
return;
}
if ( client === null ) {
console.error("Error: Client not initialized.");
return;
}
});
};

@@ -148,108 +145,121 @@ /*******************************************************************************

function put_done(client, start, end) {
var total = end - start + 1;
var done = 0;
var timeLabel = "range_put @ " + total;
aerospike.client(config).connect(function (err, client) {
console.time(timeLabel);
if ( err.code != Status.AEROSPIKE_OK ) {
console.error("Error: Aerospike server connection error. ", err.message);
process.exit(1);
}
return function(err, key) {
switch ( err.code ) {
case status.AEROSPIKE_OK:
console.log("OK - ", key);
break;
default:
console.log("ERR - ", err, key);
//
// Perform the operation
//
function put_done(client, start, end) {
var total = end - start + 1;
var done = 0;
var timeLabel = "range_put @ " + total;
console.time(timeLabel);
return function(err, key) {
switch ( err.code ) {
case Status.AEROSPIKE_OK:
console.log("OK - ", key);
break;
default:
console.log("ERR - ", err, key);
}
done++;
if ( done >= total ) {
console.timeEnd(timeLabel);
console.log();
get_start(client, start, end);
}
}
done++;
if ( done >= total ) {
console.timeEnd(timeLabel);
console.log();
get_start(client, start, end);
}
}
}
function put_start(client, start, end) {
var done = put_done(client, start, end);
var i = 0;
function put_start(client, start, end) {
var done = put_done(client, start, end);
var i = 0;
for ( i = start; i <= end; i++ ) {
var key = {
ns: argv.namespace,
set: argv.set,
key: i
};
for ( i = start; i <= end; i++ ) {
var key = {
ns: argv.namespace,
set: argv.set,
key: i
};
var record = {
k: i,
s: "abc",
i: i * 1000 + 123,
b: new Buffer([0xa, 0xb, 0xc])
};
var record = {
k: i,
s: "abc",
i: i * 1000 + 123,
b: new Buffer([0xa, 0xb, 0xc])
};
var metadata = {
ttl: 10000,
gen: 0
};
var metadata = {
ttl: 10000,
gen: 0
};
client.put(key, record, metadata, done);
client.put(key, record, metadata, done);
}
}
}
function get_done(client, start, end) {
var total = end - start + 1;
var done = 0;
var timeLabel = "range_get @ " + total;
function get_done(client, start, end) {
var total = end - start + 1;
var done = 0;
var timeLabel = "range_get @ " + total;
console.time(timeLabel);
console.time(timeLabel);
return function(err, record, metadata, key) {
switch ( err.code ) {
case status.AEROSPIKE_OK:
if ( record.k != key.key ) {
console.log("INVALID - ", key, metadata, record);
console.log(" - record.k != key.key");
}
else if ( record.i != record.k * 1000 + 123 ) {
console.log("INVALID - ", key, metadata, record);
console.log(" - record.i != record.k * 1000 + 123");
}
else if ( record.b[0] == 0xa && record.b[0] == 0xb && record.b[0] == 0xc ) {
console.log("INVALID - ", key, metadata, record);
console.log(" - record.b != [0xa,0xb,0xc]");
}
else {
console.log("VALID - ", key, metadata, record);
}
break;
default:
console.log("ERR - ", err, key);
}
done++;
if ( done >= total ) {
console.timeEnd(timeLabel);
console.log();
client.close();
}
};
}
return function(err, record, metadata, key) {
switch ( err.code ) {
case Status.AEROSPIKE_OK:
if ( record.k != key.key ) {
console.log("INVALID - ", key, metadata, record);
console.log(" - record.k != key.key");
}
else if ( record.i != record.k * 1000 + 123 ) {
console.log("INVALID - ", key, metadata, record);
console.log(" - record.i != record.k * 1000 + 123");
}
else if ( record.b[0] == 0xa && record.b[0] == 0xb && record.b[0] == 0xc ) {
console.log("INVALID - ", key, metadata, record);
console.log(" - record.b != [0xa,0xb,0xc]");
}
else {
console.log("VALID - ", key, metadata, record);
}
break;
default:
console.log("ERR - ", err, key);
}
done++;
if ( done >= total ) {
console.timeEnd(timeLabel);
console.log();
client.close();
}
};
}
function get_start(client, start, end) {
var done = get_done(client, start, end);
var i = 0;
function get_start(client, start, end) {
var done = get_done(client, start, end);
var i = 0;
for ( i = start; i <= end; i++ ) {
var key = {
ns: argv.namespace,
set: argv.set,
key: i
};
for ( i = start; i <= end; i++ ) {
var key = {
ns: argv.namespace,
set: argv.set,
key: i
};
client.get(key, done);
client.get(key, done);
}
}
}
put_start(client, argv.start, argv.end);
put_start(client, argv.start, argv.end);
});

@@ -27,4 +27,4 @@ /*******************************************************************************

var policy = aerospike.policy;
var status = aerospike.status;
var Policy = aerospike.policy;
var Status = aerospike.status;

@@ -44,2 +44,6 @@ /*******************************************************************************

},
profile: {
boolean: true,
describe: "Profile the operation."
},
host: {

@@ -82,14 +86,14 @@ alias: "h",

var argv = argp.argv;
var keyv = argv._.length === 1 ? argv._[0] : null;
var keyv = argv._.shift();
if ( argv.help === true ) {
argp.showHelp();
return;
process.exit(0);
}
if ( keyv === null ) {
if ( ! keyv ) {
console.error("Error: Please provide a key for the operation");
console.error();
argp.showHelp();
return;
process.exit(1);
}

@@ -103,6 +107,10 @@

var client = aerospike.client({
config = {
// the hosts to attempt to connect with.
hosts: [
{ addr: argv.host, port: argv.port }
],
// log configuration
log: {

@@ -112,15 +120,8 @@ level: argv['log-level'],

},
// default policies
policies: {
timeout: argv.timeout
}
}).connect(function (err, client ) {
if ( err.code != status.AEROSPIKE_OK ) {
console.log("Aerospike server connection Error: %j", err)
return;
}
if ( client === null ) {
console.error("Error: Client not initialized.");
return;
}
});
};

@@ -133,25 +134,47 @@ /*******************************************************************************

var key = {
ns: argv.namespace,
set: argv.set,
key: keyv
};
aerospike.client(config).connect(function (err, client) {
console.time("remove");
if ( err.code != Status.AEROSPIKE_OK ) {
console.error("Error: Aerospike server connection error. ", err.message);
process.exit(1);
}
client.remove(key, function(err, key) {
if ( err.code == status.AEROSPIKE_OK ) {
console.log("OK - ", key);
//
// Perform the operation
//
var key = {
ns: argv.namespace,
set: argv.set,
key: keyv
};
if ( argv.profile ) {
console.time("remove");
}
else if ( err.code == status.AEROSPIKE_ERR_RECORD_NOT_FOUND ) {
console.log("NOT_FOUND - ", key);
}
else {
console.log("ERR - ", err, key);
}
console.timeEnd("remove");
console.log("");
client.close();
client.remove(key, function(err, key) {
var exitCode = 0;
switch ( err.code ) {
case Status.AEROSPIKE_OK:
break;
case Status.AEROSPIKE_ERR_RECORD_NOT_FOUND:
console.error("Error: Not Found.");
exitCode = 1;
break;
default:
console.error("Error: " + err.message);
exitCode = 1;
break;
}
if ( argv.profile ) {
console.log("---");
console.timeEnd("remove");
}
process.exit(exitCode);
});
});

@@ -27,4 +27,4 @@ /*******************************************************************************

var policy = aerospike.policy;
var status = aerospike.status;
var Policy = aerospike.policy;
var Status = aerospike.status;

@@ -44,2 +44,6 @@ /*******************************************************************************

},
profile: {
boolean: true,
describe: "Profile the operation."
},
host: {

@@ -78,2 +82,17 @@ alias: "h",

describe: "Set for the keys."
},
'key': {
boolean: true,
default: true,
describe: "Display the record's key."
},
'metadata': {
boolean: true,
default: true,
describe: "Display the record's metadata."
},
'bins': {
boolean: true,
default: true,
describe: "Display the record's bins."
}

@@ -83,3 +102,3 @@ });

var argv = argp.argv;
var keyv = argv._.length > 1 ? argv._.shift() : null;
var keyv = argv._.shift();
var bins = argv._;

@@ -89,17 +108,17 @@

argp.showHelp();
return;
process.exit(0);
}
if ( keyv === null ) {
console.error("Error: Please provide a key for the operation.");
if ( ! keyv ) {
console.error("Error: Please provide a key for the operation");
console.error();
argp.showHelp();
return;
process.exit(1);
}
if ( argv._.length === 0 ) {
if ( bins.length === 0 ) {
console.error("Error: Please provide one or more bins to select.");
console.error();
argp.showHelp();
return;
process.exit(1);
}

@@ -109,10 +128,14 @@

*
* Establish a connection to the cluster.
* Configure the client.
*
******************************************************************************/
var client = aerospike.client({
config = {
// the hosts to attempt to connect with.
hosts: [
{ addr: argv.host, port: argv.port }
],
// log configuration
log: {

@@ -122,15 +145,8 @@ level: argv['log-level'],

},
// default policies
policies: {
timeout: argv.timeout
}
}).connect(function (err, client ) {
if ( err.code != status.AEROSPIKE_OK ) {
console.log("Aerospike server connection Error: %j", err)
return;
}
if ( client === null ) {
console.error("Error: Client not initialized.");
return;
}
});
};

@@ -143,25 +159,69 @@ /*******************************************************************************

var key = {
ns: argv.namespace,
set: argv.set,
key: keyv
};
function format(o) {
return JSON.stringify(o, null, ' ');
}
console.time("get");
aerospike.client(config).connect(function (err, client) {
client.select(key, bins, function(err, record, metadata, key) {
if ( err.code == status.AEROSPIKE_OK ) {
console.log("OK - ", key, metadata, record);
if ( err.code != Status.AEROSPIKE_OK ) {
console.error("Error: Aerospike server connection error. ", err.message);
process.exit(1);
}
else if ( err.code == status.AEROSPIKE_ERR_RECORD_NOT_FOUND ) {
console.log("NOT_FOUND - ", key);
//
// Perform the operation
//
var key = {
ns: argv.namespace,
set: argv.set,
key: keyv
};
if ( argv.profile ) {
console.time("select");
}
else {
console.log("ERR - ", err, key);
}
console.timeEnd("get");
console.log("");
client.close();
client.select(key, bins, function ( err, bins, metadata, key) {
var exitCode = 0;
switch ( err.code ) {
case Status.AEROSPIKE_OK:
var record = {};
if ( argv['key'] ) {
record.key = key;
}
if ( argv['metadata'] ) {
record.metadata = metadata;
}
if ( argv['bins'] ) {
record.bins = bins;
}
console.log(format(record));
break;
case Status.AEROSPIKE_ERR_RECORD_NOT_FOUND:
console.error("Error: Not Found.");
exitCode = 1;
break;
default:
console.error("Error: " + err.message);
exitCode = 1;
break;
}
if ( argv.profile ) {
console.log("---");
console.timeEnd("select");
}
process.exit(exitCode);
});
});
{
"name" : "aerospike",
"version" : "1.0.15",
"version" : "1.0.16",
"description" : "Aerospike Client Library",

@@ -5,0 +5,0 @@ "tags" : [ "aerospike", "database", "nosql" ],

@@ -139,2 +139,5 @@ /*******************************************************************************

// this high for low-end hosts
this.timeout(3000);
// number of records

@@ -141,0 +144,0 @@ var nrecords = 1000;

@@ -33,3 +33,3 @@ /*******************************************************************************

var config = {
var client = aerospike.client({
hosts: [

@@ -44,37 +44,24 @@ { addr: options.host, port: options.port }

}
};
});
before(function(done) {
done();
client.connect(function(err){
done();
});
});
after(function(done) {
client.close();
client = null;
done();
});
it('should get "objects" from a single node', function(done) {
it('should get "objects" from entire cluster', function(done) {
var host = {addr: options.host, port: options.port};
var count = 0;
aerospike.client(config)
.info("objects", host, function(err, response, host) {
expect(err).to.be.ok();
expect(err.code).to.equal(status.AEROSPIKE_OK);
count++;
}, function() {
expect(count).to.equal(1);
done();
});
});
it('should get "objects" from entire cluster', function(done) {
aerospike.client(config).connect(function(err, client){
client.info("objects", function(err, response, host) {
expect(err).to.be.ok();
expect(err.code).to.equal(status.AEROSPIKE_OK);
}, function() {
client.close();
done();
});
client.info("objects", host, function(err, response, host) {
expect(err).to.be.ok();
expect(err.code).to.equal(status.AEROSPIKE_OK);
done();
});
});
});

@@ -42,2 +42,3 @@ /*******************************************************************************

});
var config = {

@@ -62,4 +63,4 @@ hosts: [

config.log.file = fd;
aerospike.client(config)
.info("objects", host, function(err, response, host) {
aerospike.client(config).connect(function(err, client) {
client.info("objects", host, function(err, response, host) {
expect(err).to.be.ok();

@@ -73,4 +74,3 @@ expect(err.code).to.equal(status.AEROSPIKE_OK);

});
}, function() {
expect(count).to.equal(1);
});
});

@@ -77,0 +77,0 @@ });

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc