How to use the aerospike.client function in aerospike

To help you get started, we’ve selected a few aerospike examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github aerospike-edu / student-workbook / AS101 / NodeJS / solution / app.js View on Github external
var inquirer = require('inquirer');
var user_service = require('./scripts/user_service');
var tweet_service = require('./scripts/tweet_service');

// Connect to the Aerospike Cluster

//Exercise K1, Exercise R2, Exercise Q3 & Exercise A2
var hostaddr = '127.0.0.1';
//Override with your AWS IP Address
hostaddr = "54.xx.yy.zz" ;

// Note: Node.js client does not implement default modlua config for client node.
// This is needed when using stream udfs.

// Exercise A2
var client = aerospike.client({
    hosts: [ { addr: hostaddr, port: 3000 }],
    modlua:{systemPath:'/usr/local/aerospike/lua',
            userPath:'/usr/local/aerospike/usr-lua'
           }
}).connect( function(response) {
    // Check for errors
    // Exercise K1
    if ( response == null ) {
      // Connection succeeded
      console.log("Connection to the Aerospike cluster succeeded!");
    }
    else {
      // Connection failed
      console.log("Connection to the Aerospike cluster failed. Please check cluster IP and Port settings and try again.");
      process.exit(0);
    }
github aerospike-edu / student-workbook / deprecated / answers / Complete / Node / app.js View on Github external
//  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
//  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
//  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
//  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
//  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
//  * IN THE SOFTWARE. 

'use strict';

var aerospike = require('aerospike');
var inquirer = require('inquirer');
var user_service = require('./scripts/user_service');
var tweet_service = require('./scripts/tweet_service');

// Connect to the Aerospike Cluster
var client = aerospike.client({
    hosts: [ { addr: '172.16.159.172', port: 3000 } ]
}).connect(function(response) {
    // Check for errors
    if ( response.code == aerospike.status.AEROSPIKE_OK ) {
      // Connection succeeded
      console.log("Connection to the Aerospike cluster succeeded!");
    }
    else {
      // Connection failed
      console.log("Connection to the Aerospike cluster failed. Please check cluster IP and Port settings and try again.");
      process.exit(0);
    }
});

// Setup tear down
process.on('exit', function() {
github aerospike / aerospike-client-nodejs / examples / simple_get.js View on Github external
if(argv.password !== null)
{
	config.password = argv.password;
}
/*******************************************************************************
 *
 * Establish a connection and execute the opetation.
 * 
 ******************************************************************************/

function format(o) {
    return JSON.stringify(o, null, '    ');
}

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);
    }

    //
    // Perform the operation
    //

    var key = {
        ns:  argv.namespace,
        set: argv.set,
        key: keyv
    };
github aerospike-edu / student-workbook / deprecated / answers / Aggregations / Node / app.js View on Github external
//  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
//  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
//  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
//  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
//  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
//  * IN THE SOFTWARE. 

'use strict';

var aerospike = require('aerospike');
var inquirer = require('inquirer');
var user_service = require('./scripts/user_service');
var tweet_service = require('./scripts/tweet_service');

// Connect to the Aerospike Cluster
var client = aerospike.client({
    hosts: [ { addr: '172.16.159.170', port: 3000 } ]
}).connect(function(response) {
    // Check for errors
    if ( response.code == aerospike.status.AEROSPIKE_OK ) {
      // Connection succeeded
      console.log("Connection to the Aerospike cluster succeeded!");
    }
    else {
      // Connection failed
      console.log("Connection to the Aerospike cluster failed. Please check cluster IP and Port settings and try again.");
      process.exit(0);
    }
});

// Setup tear down
process.on('exit', function() {
github aerospike-edu / student-workbook / deprecated / exercises / RecordUDF / Node / app.js View on Github external
//  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
//  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
//  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
//  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
//  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
//  * IN THE SOFTWARE. 

'use strict';

var aerospike = require('aerospike');
var inquirer = require('inquirer');
var user_service = require('./scripts/user_service');
var tweet_service = require('./scripts/tweet_service');

// Connect to the Aerospike Cluster
var client = aerospike.client({
    hosts: [ { addr: 'YOUR_IP_ADDRESS', port: 3000 } ]
}).connect(function(response) {
    // Check for errors
    if ( response.code == aerospike.status.AEROSPIKE_OK ) {
      // Connection succeeded
      console.log("Connection to the Aerospike cluster succeeded!");
    }
    else {
      // Connection failed
      console.log("Connection to the Aerospike cluster failed. Please check cluster IP and Port settings and try again.");
      process.exit(0);
    }
});

// Setup tear down
process.on('exit', function() {
github aerospike / aerospike-client-nodejs / benchmarks / worker.js View on Github external
}
}

if (argv.host) {
  config.hosts = [{ addr: argv.host, port: argv.port || 3000 }]
}

if (argv.user !== null) {
  config.user = argv.user
}

if (argv.password !== null) {
  config.password = argv.password
}

var client = aerospike.client(config)

client.connect(function (err) {
  if (err) {
    logger.error('Aerospike server connection error: ', err)
    process.exit(1)
  } else {
    logger.info('worker connected: ' + client.config.hosts)
  }
})

// *****************************************************************************
// Operations
// *****************************************************************************
/**
* key are in range [min ... max]
*/
github aerospike / aerospike-client-nodejs / examples / put_get.js View on Github external
var env = require('./env')
var aerospike = require('aerospike')

var status = aerospike.Status
var policy = aerospike.Policy
var client = aerospike.client(env.config)
client = client.connect()
if (client === null)
{
    console.log("Client object is null \n ---Application Exiting --- ")
	process.exit(1)
}


var n = env.nops
var m = 0

console.time(n + " put+get")
for (var i = 0; i < n; i++ ) {

  var key0 = {
    ns: env.namespace,
github aerospike / aerospike-client-nodejs / examples / benchmark / put.js View on Github external
nops: {
            alias: "N",
            default: 100000,
            describe: "Total number of operations for benchmarking."
        }
    });

var argv = argp.argv;

if ( argv.help === true) {
    argp.showHelp()
    return;
}
var cluster = require('cluster');
var numCPUs = require('os').cpus().length;
var client = aerospike.client({
    hosts: [
        { addr: argv.host, port: argv.port }
    ],
    policies: {
        timeout: argv.timeout
    }
}).connect(function(err) {
    if (err.code != status.AEROSPIKE_OK) {
        console.log("Aerospike server connection Error: %j", err)
        return;
    }
});


if (client === null)
{
github aerospike-community / aerospike-session-store-expressjs / lib / aerospike_store.js View on Github external
options = options || {}
    Store.call(this, options)

    this.as_namespace = options.namespace || 'test'
    this.as_set = options.set || 'express-session'
    this.ttl = options.ttl
    this.mapper = options.mapper || new DataMapper()

    if (options.serializer) {
      throw new Error('The `serializer` option is no longer supported - supply a custom data mapper instead.')
    }

    if (options.client) {
      this.client = options.client
    } else {
      this.client = Aerospike.client(options)
      this.client.connect(error => {
        if (error) {
          debug('ERROR - %s', error.message)
          process.nextTick(() => this._onDisconnected())
        } else {
          process.nextTick(() => this._onConnected())
        }
      })
    }

    this.connected = false
    this.client.on('nodeAdded', () => this._onConnected())
    this.client.on('disconnected', () => this._onDisconnected())
  }
github aerospike / aerospike-client-nodejs / examples / shared / client.js View on Github external
module.exports = exports = function (argv) {
  const config = defaultConfig(argv)
  Aerospike.setDefaultLogging(config.log)
  const client = Aerospike.client(config)
  client.captureStackTraces = argv.debugStacktraces
  return client
}