Socket
Socket
Sign inDemoInstall

fash

Package Overview
Dependencies
Maintainers
3
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fash - npm Package Compare versions

Comparing version 2.4.0 to 2.4.1

128

bin/fash.js

@@ -213,3 +213,3 @@ #!/usr/bin/env node

if (opts.help || args.length !== 0 || !opts.v || !opts.d || !opts.b) {
if (opts.help || args.length !== 0 || !opts.v || !opts.b) {
this.do_help('help', {}, [subcmd], function (err) {

@@ -808,74 +808,74 @@ return callback(err ? err : true);

function (subcmd, opts, args, callback) {
var self = this;
var self = this;
if (opts.help || !opts.v) {
this.do_help('help', {}, [subcmd], function (err) {
return callback(err ? err : true);
});
}
if (opts.help || !opts.v) {
this.do_help('help', {}, [subcmd], function (err) {
return callback(err ? err : true);
});
}
var hashOptions = {
log: self.log
};
var hash;
var constructor;
var hashOptions = {
log: self.log
};
var hash;
var constructor;
vasync.pipeline({funcs: [
function prepInput(_, cb) {
if (!opts.l) {
console.error('leveldb backend requires a location');
self.do_help('help', {}, [subcmd], function (err) {
return callback(err ? err : true);
});
} else {
hashOptions.location = opts.l;
return cb();
}
return (undefined);
},
function loadRing(_, cb) {
// We choose not to support an IN_MEMORY backend.
hashOptions.backend = fash.BACKEND.LEVEL_DB;
constructor = fash.load;
hash = constructor(hashOptions, cb);
},
function getVnodeArray(_, cb) {
var vnodes = common.parseIntArray(opts.v);
_.vnodes = vnodes;
vasync.pipeline({funcs: [
function prepInput(_, cb) {
if (!opts.l) {
console.error('leveldb backend requires a location');
self.do_help('help', {}, [subcmd], function (err) {
return callback(err ? err : true);
});
} else {
hashOptions.location = opts.l;
return cb();
},
function getVnodePnodeAndData(_, cb) {
var dataHash = {};
function getResults(input, _cb) {
hash.getVnodePnodeAndData(input,
function (err, pnode, vnodeData) {
if (err) {
return _cb(verror.VError(err,
'unable to get pnode and data for for vnode ',
input));
}
dataHash[input] = {};
dataHash[input]['pnode'] = pnode;
dataHash[input]['vnodeData'] = vnodeData;
return _cb(err, null);
});
}
vasync.forEachPipeline({
'inputs': _.vnodes,
'func': getResults
}, function (err) {
}
return (undefined);
},
function loadRing(_, cb) {
// We choose not to support an IN_MEMORY backend.
hashOptions.backend = fash.BACKEND.LEVEL_DB;
constructor = fash.load;
hash = constructor(hashOptions, cb);
},
function getVnodeArray(_, cb) {
var vnodes = common.parseIntArray(opts.v);
_.vnodes = vnodes;
return cb();
},
function getVnodePnodeAndData(_, cb) {
var dataHash = {};
function getResults(input, _cb) {
hash.getVnodePnodeAndData(input,
function (err, pnode, vnodeData) {
if (err) {
return console.error(new verror.VError(err,
'unable to construct hash for vnode '));
return _cb(verror.VError(err,
'unable to get pnode and data for for vnode ',
input));
}
console.log('vnodes: ', dataHash);
dataHash[input] = {};
dataHash[input]['pnode'] = pnode;
dataHash[input]['vnodeData'] = vnodeData;
return _cb(err, null);
});
}
], arg: {}}, function (err) {
if (err)
console.error(new verror.VError(err));
});
return (undefined);
vasync.forEachPipeline({
'inputs': _.vnodes,
'func': getResults
}, function (err) {
if (err) {
return console.error(new verror.VError(err,
'unable to construct hash for vnode '));
}
console.log('vnodes: ', dataHash);
});
}
], arg: {}}, function (err) {
if (err)
console.error(new verror.VError(err));
});
return (undefined);
};

@@ -882,0 +882,0 @@ Fash.prototype.do_get_vnode_pnode_and_data.options = [ {

@@ -51,3 +51,3 @@ /*

function ConsistentHash(options, callback) {
dtrace._fash_probes['new-start'].fire(function() { return([]); });
dtrace._fash_probes['new-start'].fire(function () { return ([]); });
assert.object(options, 'options');

@@ -126,6 +126,6 @@

pnodeKeys.forEach(function(pnode) {
pnodeKeys.forEach(function (pnode) {
self.pnodes_.push(pnode);
var vnodes = self.pnodeToVnodeMap_[pnode];
Object.keys(vnodes).forEach(function(vnode) {
Object.keys(vnodes).forEach(function (vnode) {
var data = vnodes[vnode];

@@ -147,3 +147,3 @@ self.vnodeToPnodeMap_[vnode] = {

log.info('ConsistentHash.new: finished deserializing');
dtrace._fash_probes['new-done'].fire(function() {
dtrace._fash_probes['new-done'].fire(function () {
return ([null, 'deserialize']);

@@ -154,3 +154,3 @@ });

// instantiate pnodeToVnodeMap_
self.pnodes_.forEach(function(pnode, index) {
self.pnodes_.forEach(function (pnode, index) {
// make sure there are no duplicate keys in self.pnodes_

@@ -160,3 +160,3 @@ if (pnodeMap[pnode]) {

'duplicate pnodes in input');
dtrace._fash_probes['new-done'].fire(function() {
dtrace._fash_probes['new-done'].fire(function () {
return ([err ? err.message : null, 'createNewRing']);

@@ -214,3 +214,3 @@ });

allocateVnode();
dtrace._fash_probes['new-done'].fire(function() {
dtrace._fash_probes['new-done'].fire(function () {
return ([null, 'createNewRing']);

@@ -246,4 +246,4 @@ });

ConsistentHash.prototype.addData = function addData(vnode, data, cb) {
dtrace._fash_probes['adddata-start'].fire(function() {
return([vnode, data]);
dtrace._fash_probes['adddata-start'].fire(function () {
return ([vnode, data]);
});

@@ -296,4 +296,4 @@ var self = this;

dtrace._fash_probes['adddata-done'].fire(function() {
return([null, vnode, data]);
dtrace._fash_probes['adddata-done'].fire(function () {
return ([null, vnode, data]);
});

@@ -330,4 +330,5 @@

*/
ConsistentHash.prototype.remapVnode = function remapVnode(newPnode, vnodes, cb) {
dtrace._fash_probes['remapvnode-start'].fire(function() {
ConsistentHash.prototype.remapVnode =
function remapVnode(newPnode, vnodes, cb) {
dtrace._fash_probes['remapvnode-start'].fire(function () {
return ([newPnode, vnodes]);

@@ -342,3 +343,3 @@ });

assert.string(newPnode, 'newPnode');
if (typeof(vnodes) === 'number') {
if (typeof (vnodes) === 'number') {
vnodes = [vnodes];

@@ -357,3 +358,3 @@ }

if (vnodes) {
vnodes.forEach(function(v) {
vnodes.forEach(function (v) {
var err;

@@ -367,3 +368,6 @@ if ((v > self.vnodeCount_) || (v < 0)) {

} else if (self.vnodeToPnodeMap_[v].pnode === newPnode) {
// check that the vnode doesn't already belong to the newPnode.
/*
* check that the vnode doesn't already belong to the
* newPnode.
*/
err = new verror.VError('vnode ' + v +

@@ -373,3 +377,3 @@ ' already belongs to pnode');

if (err) {
dtrace._fash_probes['remapvnode-done'].fire(function() {
dtrace._fash_probes['remapvnode-done'].fire(function () {
return ([err ? err.message : null, newPnode, oldPnode,

@@ -412,8 +416,12 @@ vnode]);

* add vnode to new pnode
* 1) move the vnode object from the old pvmap to the new pvmap. Since
* we're just moving the vnode, there's no need to write any new values
* 1) move the vnode object from the old pvmap to the new pvmap
* since we're just moving the vnode, there's no need to write any
* new values.
*/
self.pnodeToVnodeMap_[newPnode][vnode] =
self.pnodeToVnodeMap_[oldPnode][vnode];
// 2) add a new pnode,data object to the vpmap for the current vnode.
/*
* 2) add a new pnode,data object to the vpmap for the current
* vnode
*/
self.vnodeToPnodeMap_[vnode] = {

@@ -425,5 +433,5 @@ pnode: newPnode,

/*
* remove vnode from current pnode mapping. but first set the value to
* 1 -- otherwise the vnode gets removed from the new pnode mappings
* as well.
* remove vnode from current pnode mapping. but first set the value
* to 1, otherwise the vnode gets removed from the new pnode
* mappings as well.
*/

@@ -450,3 +458,3 @@ self.pnodeToVnodeMap_[oldPnode][vnode] = 1;

dtrace._fash_probes['remapvnode-done'].fire(function() {
dtrace._fash_probes['remapvnode-done'].fire(function () {
return ([null, newPnode, oldPnode, vnode]);

@@ -474,3 +482,3 @@ });

ConsistentHash.prototype.removePnode = function removePnode(pnode, cb) {
dtrace._fash_probes['removepnode-start'].fire(function() {
dtrace._fash_probes['removepnode-start'].fire(function () {
return ([pnode]);

@@ -500,3 +508,3 @@ });

if (err) {
dtrace._fash_probes['removepnode-done'].fire(function() {
dtrace._fash_probes['removepnode-done'].fire(function () {
return ([err ? err.message : null, pnode]);

@@ -519,3 +527,3 @@ });

dtrace._fash_probes['removepnode-done'].fire(function() {
dtrace._fash_probes['removepnode-done'].fire(function () {
return ([err ? err.message : null, pnode]);

@@ -575,3 +583,3 @@ });

var vnodeArray = [];
Object.keys(vnodes).forEach(function(vnode) {
Object.keys(vnodes).forEach(function (vnode) {
vnodeArray.push(parseInt(vnode, 10));

@@ -598,7 +606,8 @@ });

ConsistentHash.prototype.getNode = function getNode(key, cb) {
dtrace._fash_probes['getnode-start'].fire(function() {
dtrace._fash_probes['getnode-start'].fire(function () {
return ([key]);
});
assert.optionalFunc(cb, 'callback');
var value = crypto.createHash(this.algorithm_.NAME).update(key).digest('hex');
var value = crypto.createHash(this.algorithm_.NAME).
update(key).digest('hex');
// find the node that corresponds to this hash.

@@ -608,4 +617,4 @@ var vnode = this.findVnode(value);

var data = this.pnodeToVnodeMap_[pnode][vnode];
dtrace._fash_probes['getnode-done'].fire(function() {
return([null, key, value, pnode, vnode, data]);
dtrace._fash_probes['getnode-done'].fire(function () {
return ([null, key, value, pnode, vnode, data]);
});

@@ -612,0 +621,0 @@ if (cb) {

@@ -28,3 +28,3 @@ /*

/*
* level db keys.
* LevelDB keys.
*/

@@ -42,3 +42,3 @@ var LKEY_VNODE_COUNT = 'VNODE_COUNT';

/*
* leveldb values.
* LevelDB values.
*/

@@ -48,3 +48,3 @@ var LVAL_NULL = 1;

/*
* leveldb default config
* LevelDB default configuration.
*/

@@ -85,3 +85,3 @@ var LEVEL_CONFIG = {

function ConsistentHash(options, cb) {
dtrace._fash_probes['new-start'].fire(function() { return([]); });
dtrace._fash_probes['new-start'].fire(function () { return ([]); });
assert.object(options, 'options');

@@ -173,3 +173,3 @@ assert.optionalObject(options.leveldbCfg, 'options.leveldbCfg');

_cb = once(_cb);
levelup(options.location, self.leveldbCfg_, function(err, db) {
levelup(options.location, self.leveldbCfg_, function (err, db) {
if (err) {

@@ -190,3 +190,3 @@ return _cb(new verror.VError(err));

_cb = once(_cb);
_.db.put(LKEY_VNODE_COUNT, self.vnodeCount_, function(err) {
_.db.put(LKEY_VNODE_COUNT, self.vnodeCount_, function (err) {
if (err) {

@@ -316,3 +316,3 @@ err = new verror.VError(err);

_.pnodeToVnodeMap[pnode],
function(err)
function (err)
{

@@ -325,3 +325,3 @@ if (err) {

}
_.db.put(LKEY_PNODE, Object.keys(pnodeMap), function(err) {
_.db.put(LKEY_PNODE, Object.keys(pnodeMap), function (err) {
if (err) {

@@ -335,3 +335,3 @@ err = new verror.VError(err);

_cb = once(_cb);
_.db.put(LKEY_VNODE_DATA, [], function(err) {
_.db.put(LKEY_VNODE_DATA, [], function (err) {
if (err) {

@@ -357,3 +357,3 @@ err = new verror.VError(err);

function commit(_, _cb) {
_.batch.write(function(err) {
_.batch.write(function (err) {
if (err) {

@@ -368,3 +368,3 @@ err = new verror.VError(err);

vasync.pipeline({funcs: tasks, arg: {}}, function(err) {
vasync.pipeline({funcs: tasks, arg: {}}, function (err) {
if (err) {

@@ -376,3 +376,3 @@ err = new verror.VError(err, 'unable to create ring');

}, 'finished instantiated new ring');
dtrace._fash_probes['new-done'].fire(function() {
dtrace._fash_probes['new-done'].fire(function () {
return ([err ? err.message : null, 'createNewRing']);

@@ -399,3 +399,3 @@ });

//location
levelup(options.location, self.leveldbCfg_, function(err, db) {
levelup(options.location, self.leveldbCfg_, function (err, db) {
if (err) {

@@ -417,3 +417,3 @@ return _cb(new verror.VError(err));

log.info('ConsistentHash.new.deserialize: put vnodeCount');
_.db.put(LKEY_VNODE_COUNT, topology.vnodes, function(err) {
_.db.put(LKEY_VNODE_COUNT, topology.vnodes, function (err) {
if (err) {

@@ -434,3 +434,3 @@ err = new verror.VError(err);

var pnodes = Object.keys(pvMap);
_.db.put(LKEY_PNODE, pnodes, function(err) {
_.db.put(LKEY_PNODE, pnodes, function (err) {
if (err) {

@@ -444,3 +444,3 @@ err = new verror.VError(err);

var pcount = pnodes.length;
pnodes.forEach(function(pnode) {
pnodes.forEach(function (pnode) {
var vnodes = Object.keys(pvMap[pnode]);

@@ -450,3 +450,3 @@ var vcount = vnodes.length;

// write /P/P and /V/V. and /P/P/V
vnodes.forEach(function(vnode, index) {
vnodes.forEach(function (vnode, index) {

@@ -461,3 +461,3 @@ /*

_.db.put(sprintf(LKEY_VNODE_V, vnode), pnode,
function(err)
function (err)
{

@@ -473,3 +473,3 @@ if (err) {

pvMap[pnode][vnode],
function(err) {
function (err) {
if (err) {

@@ -479,4 +479,3 @@ err = new verror.VError(err);

}
}
);
});

@@ -500,3 +499,3 @@ /*

vnodes,
function(err) {
function (err) {
if (err) {

@@ -506,4 +505,3 @@ err = new verror.VError(err);

}
}
);
});
}

@@ -513,8 +511,9 @@

if (vcount === 0 && --pcount === 0) {
_.db.put(LKEY_VNODE_DATA, vnodeData, function(err) {
if (err) {
err = new verror.VError(err);
}
return _cb(err);
});
_.db.put(LKEY_VNODE_DATA, vnodeData,
function (err) {
if (err) {
err = new verror.VError(err);
}
return _cb(err);
});
}

@@ -537,3 +536,3 @@ });

put(LKEY_COMPLETE, 1);
batch.write(function(err) {
batch.write(function (err) {
if (err) {

@@ -545,3 +544,3 @@ err = new verror.VError(err);

}
], arg: {}}, function(err) {
], arg: {}}, function (err) {
if (err) {

@@ -553,3 +552,3 @@ err = new verror.VError(err, 'unable to deserialize ring');

}, 'finished deserializing ring');
dtrace._fash_probes['new-done'].fire(function() {
dtrace._fash_probes['new-done'].fire(function () {
return ([err ? err.message : null, 'deserialize']);

@@ -567,3 +566,3 @@ });

function openDb(_, _cb) {
levelup(options.location, self.leveldbCfg_, function(err, db) {
levelup(options.location, self.leveldbCfg_, function (err, db) {
if (err) {

@@ -581,3 +580,3 @@ return _cb(new verror.VError(err));

function checkComplete(_, _cb) {
self.db_.get(LKEY_COMPLETE, function(err, value) {
self.db_.get(LKEY_COMPLETE, function (err, value) {
if (err) {

@@ -591,3 +590,3 @@ err = new verror.VError(err);

_cb = once(_cb);
self.db_.get(LKEY_VERSION, function(err, version) {
self.db_.get(LKEY_VERSION, function (err, version) {
if (err) {

@@ -599,3 +598,3 @@ return _cb(new verror.VError(err));

return _cb();
} catch(e) {
} catch (e) {
return _cb(new verror.VError(e));

@@ -606,3 +605,3 @@ }

function checkVnodes(_, _cb) {
self.db_.get(LKEY_VNODE_COUNT, function(err, vnodeCount) {
self.db_.get(LKEY_VNODE_COUNT, function (err, vnodeCount) {
if (err) {

@@ -619,3 +618,3 @@ err = new verror.VError(err);

self.db_.get(sprintf(LKEY_VNODE_V, _.vnodeCount - 1),
function(err, pnode) {
function (err, pnode) {
if (err) {

@@ -628,4 +627,4 @@ err = new verror.VError(err);

},
function getAlgorithm(_, _cb){
self.db_.get(LKEY_ALGORITHM, function(err, algorithm) {
function getAlgorithm(_, _cb) {
self.db_.get(LKEY_ALGORITHM, function (err, algorithm) {
if (err) {

@@ -640,7 +639,7 @@ err = new verror.VError(err);

}
], arg: {}}, function(err) {
], arg: {}}, function (err) {
if (err) {
err = new verror.VError(err, 'unable to load ring from db');
}
dtrace._fash_probes['new-done'].fire(function() {
dtrace._fash_probes['new-done'].fire(function () {
return ([err ? err.message : null, 'loadFromDb']);

@@ -676,7 +675,8 @@ });

ConsistentHash.prototype.getNode = function getNode(key, callback) {
dtrace._fash_probes['getnode-start'].fire(function() {
dtrace._fash_probes['getnode-start'].fire(function () {
return ([key]);
});
var self = this;
var value = crypto.createHash(this.algorithm_.NAME).update(key).digest('hex');
var value = crypto.createHash(this.algorithm_.NAME).update(key).
digest('hex');
// find the node that corresponds to this hash

@@ -686,7 +686,7 @@ var vnode = common.findVnode({

});
self.db_.get(sprintf(LKEY_VNODE_V, vnode), function(err, pnode) {
self.db_.get(sprintf(LKEY_VNODE_V, vnode), function (err, pnode) {
if (err) {
err = new verror.VError(err);
dtrace._fash_probes['getnode-done'].fire(function() {
return([err.message, key, value, null, vnode]);
dtrace._fash_probes['getnode-done'].fire(function () {
return ([err.message, key, value, null, vnode]);
});

@@ -696,3 +696,3 @@ return callback(err);

self.db_.get(sprintf(LKEY_PNODE_P_V, pnode, vnode),
function(_err, data)
function (_err, data)
{

@@ -703,4 +703,4 @@ if (_err) {

dtrace._fash_probes['getnode-done'].fire(function() {
return([_err ? _err.message : null,
dtrace._fash_probes['getnode-done'].fire(function () {
return ([_err ? _err.message : null,
key, value, pnode, vnode, data]);

@@ -726,4 +726,4 @@ });

ConsistentHash.prototype.addData = function addData(vnode, data, cb) {
dtrace._fash_probes['adddata-start'].fire(function() {
return([vnode, data]);
dtrace._fash_probes['adddata-start'].fire(function () {
return ([vnode, data]);
});

@@ -748,3 +748,3 @@ var self = this;

function getPnode(_, _cb) {
db.get(sprintf(LKEY_VNODE_V, vnode), function(err, pnode) {
db.get(sprintf(LKEY_VNODE_V, vnode), function (err, pnode) {
if (err) {

@@ -763,3 +763,3 @@ return _cb(new verror.VError(err, 'unable to add data'));

function getVnodeDataArray(_, _cb) {
db.get(LKEY_VNODE_DATA, function(err, vnodeData) {
db.get(LKEY_VNODE_DATA, function (err, vnodeData) {
if (err) {

@@ -800,3 +800,3 @@ return _cb(new verror.VError(err, 'unable to add data'));

function commit(_, _cb) {
_.batch.write(function(err) {
_.batch.write(function (err) {
if (err) {

@@ -810,5 +810,5 @@ err = new verror.VError(err, 'addData: unable to commit');

}
], arg:{}}, function(err) {
dtrace._fash_probes['adddata-done'].fire(function() {
return([err ? err.message : null, vnode, data]);
], arg: {}}, function (err) {
dtrace._fash_probes['adddata-done'].fire(function () {
return ([err ? err.message : null, vnode, data]);
});

@@ -825,3 +825,4 @@ return cb(err);

*/
ConsistentHash.prototype.getVnodePnodeAndData = function getVnodePnodeAndData(vnode, cb) {
ConsistentHash.prototype.getVnodePnodeAndData =
function getVnodePnodeAndData(vnode, cb) {
var self = this;

@@ -834,3 +835,3 @@

vnode: vnode
},'ConsistentHash.getDataVnode: entering');
}, 'ConsistentHash.getDataVnode: entering');

@@ -842,25 +843,28 @@ assert.number(vnode, 'vnode');

function getVnodePnode(_, _cb) {
db.get(sprintf(LKEY_VNODE_V, vnode), function(err, vnodePnode) {
if (err) {
return _cb(new verror.VError('cannot get pnode for vnode ' +
vnode + ', vnode ' + vnode + ' or pnode ' +
vnodePnode + ' may not exist.'));
}
_.pnode = vnodePnode;
return _cb();
});
db.get(sprintf(LKEY_VNODE_V, vnode),
function (err, vnodePnode) {
if (err) {
return _cb(new verror.VError(
'cannot get pnode for vnode ' + vnode +
', vnode ' + vnode + ' or pnode ' +
vnodePnode + ' may not exist.'));
}
_.pnode = vnodePnode;
return _cb();
});
},
function getVnodeData(_, _cb) {
db.get(sprintf(LKEY_PNODE_P_V, _.pnode, vnode), function(err, data)
{
if (err) {
return _cb(new verror.VError('cannot get data for vnode ' + vnode +
' and pnode ' + _.pnode));
} else {
_.vnodeData = data;
return _cb(null, _);
}
});
db.get(sprintf(LKEY_PNODE_P_V, _.pnode, vnode),
function (err, data) {
if (err) {
return _cb(new verror.VError(
'cannot get data for vnode ' + vnode +
' and pnode ' + _.pnode));
} else {
_.vnodeData = data;
return _cb(null, _);
}
});
}
], arg: {}}, function(err, results) {
], arg: {}}, function (err, results) {
log.info({err: err}, 'ConsistentHash.getDataVnode: exiting');

@@ -873,3 +877,4 @@ if (err) {

if (results.successes[1]) {
return cb(null, results.successes[1].pnode, results.successes[1].vnodeData);
return cb(null, results.successes[1].pnode,
results.successes[1].vnodeData);
}

@@ -895,3 +900,3 @@

db.get(LKEY_VNODE_DATA, function(err, vnodeArray) {
db.get(LKEY_VNODE_DATA, function (err, vnodeArray) {
if (err) {

@@ -906,4 +911,4 @@ err = new verror.VError(err);

/*
* Remaps a vnode on the hash ring. The node can be on an existing pnode, or a new
* one.
* Remaps a vnode on the hash ring. The node can be on an existing pnode,
* or a new one.
*

@@ -916,3 +921,3 @@ * @param {String} node The name of the node.

ConsistentHash.prototype.remapVnode = function remapVnode(newPnode, vnode, cb) {
dtrace._fash_probes['remapvnode-start'].fire(function() {
dtrace._fash_probes['remapvnode-start'].fire(function () {
return ([newPnode, vnode]);

@@ -957,3 +962,3 @@ });

function checkAndCreateNewPnode(_, _cb) {
db.get(sprintf(LKEY_PNODE_P, newPnode), function(err) {
db.get(sprintf(LKEY_PNODE_P, newPnode), function (err) {
if (err && err.name && err.name === 'NotFoundError') {

@@ -974,3 +979,3 @@ _.batch = _.batch.put(sprintf(LKEY_PNODE_P, newPnode), []);

// get the previous vnode to pnode mapping
db.get(sprintf(LKEY_VNODE_V, vnode), function(err, pnode) {
db.get(sprintf(LKEY_VNODE_V, vnode), function (err, pnode) {
if (err) {

@@ -991,3 +996,3 @@ return _cb(new verror.VError(err));

function getVnodeData(_, _cb) {
db.get(sprintf(LKEY_PNODE_P_V, _.oldPnode, vnode), function(err, d)
db.get(sprintf(LKEY_PNODE_P_V, _.oldPnode, vnode), function (err, d)
{

@@ -1004,7 +1009,8 @@ if (err) {

_.batch = _.batch.del(sprintf(LKEY_PNODE_P_V, _.oldPnode, vnode));
db.get(sprintf(LKEY_PNODE_P, _.oldPnode), function(err, oldVnodes) {
db.get(sprintf(LKEY_PNODE_P, _.oldPnode),
function (err, oldVnodes) {
if (err) {
return _cb(new verror.VError(err,
'couldn\'t get path /pnode/' +
_.oldPnode));
'couldn\'t get path' +
'/pnode/' + _.oldPnode));
}

@@ -1026,3 +1032,3 @@ var idx = oldVnodes.indexOf(vnode);

function addNewMapping(_, _cb) {
db.get(sprintf(LKEY_PNODE_P, newPnode), function(err, vnodes) {
db.get(sprintf(LKEY_PNODE_P, newPnode), function (err, vnodes) {
/*

@@ -1049,3 +1055,3 @@ * ignore NotFoundErrors if the pnode is new, since it hasn't

function addPnodeToPnodeArray(_, _cb) {
db.get(LKEY_PNODE, function(err, pnodes) {
db.get(LKEY_PNODE, function (err, pnodes) {
if (err) {

@@ -1064,3 +1070,3 @@ return _cb(new verror.VError(err));

function commit(_, _cb) {
_.batch.write(function(err) {
_.batch.write(function (err) {
if (err) {

@@ -1074,5 +1080,5 @@ return _cb(new verror.VError(err));

}
], arg: {}}, function(err) {
], arg: {}}, function (err) {
log.info({err: err}, 'ConsistentHash.remapVnode: exiting');
dtrace._fash_probes['remapvnode-done'].fire(function() {
dtrace._fash_probes['remapvnode-done'].fire(function () {
return ([err ? err.message : null, newPnode, oldPnode, vnode]);

@@ -1100,3 +1106,3 @@ });

// check that the pnode exists
db.get(sprintf(LKEY_PNODE_P, pnode), function(err, vnodes) {
db.get(sprintf(LKEY_PNODE_P, pnode), function (err, vnodes) {
if (err) {

@@ -1126,3 +1132,3 @@ return cb(new verror.VError(err, 'pnode is not in ring'));

assert.func(cb, 'callback');
db.get(LKEY_PNODE, function(err, pnodes) {
db.get(LKEY_PNODE, function (err, pnodes) {
if (err) {

@@ -1145,3 +1151,3 @@ err = new verror.VError(err, 'unable to get Pnodes');

ConsistentHash.prototype.removePnode = function removePnode(pnode, cb) {
dtrace._fash_probes['removepnode-start'].fire(function() {
dtrace._fash_probes['removepnode-start'].fire(function () {
return ([pnode]);

@@ -1161,4 +1167,4 @@ });

vasync.pipeline({funcs: [
function checkPnodeExists(_, _cb){
db.get(sprintf(LKEY_PNODE_P, pnode), function(err, v) {
function checkPnodeExists(_, _cb) {
db.get(sprintf(LKEY_PNODE_P, pnode), function (err, v) {
if (err) {

@@ -1183,3 +1189,3 @@ return _cb(new verror.VError(err, 'pnode does not exist'));

// get the pnode array
db.get(LKEY_PNODE, function(err, pnodes) {
db.get(LKEY_PNODE, function (err, pnodes) {
if (err) {

@@ -1195,3 +1201,3 @@ return _cb(new verror.VError(err));

pnodes.splice(pnodeIndex, 1);
batch.put(LKEY_PNODE, pnodes).write(function(_err) {
batch.put(LKEY_PNODE, pnodes).write(function (_err) {
if (_err) {

@@ -1209,4 +1215,4 @@ _err = new verror.VError(_err);

}
], arg: {}}, function(err) {
dtrace._fash_probes['removepnode-done'].fire(function() {
], arg: {}}, function (err) {
dtrace._fash_probes['removepnode-done'].fire(function () {
return ([err ? err.message : null, pnode]);

@@ -1229,3 +1235,3 @@ });

ConsistentHash.prototype.serialize = function serialize(callback) {
dtrace._fash_probes['serialize-start'].fire(function() {
dtrace._fash_probes['serialize-start'].fire(function () {
return ([]);

@@ -1248,3 +1254,3 @@ });

function getNumberOfVnodes(_, cb) {
db.get(LKEY_VNODE_COUNT, function(err, vnodes) {
db.get(LKEY_VNODE_COUNT, function (err, vnodes) {
serializedHash.vnodes = vnodes;

@@ -1259,3 +1265,3 @@ return cb(err);

db.get(sprintf(LKEY_VNODE_V, vnode),
(function(v, err, pnode)
(function (v, err, pnode)
{

@@ -1267,3 +1273,3 @@ if (err) {

db.get(sprintf(LKEY_PNODE_P_V, pnode, v),
function(_err, data)
function (_err, data)
{

@@ -1283,4 +1289,4 @@ if (_err) {

},
function getAlgorithm(_, cb){
db.get(LKEY_ALGORITHM, function(err, algorithm) {
function getAlgorithm(_, cb) {
db.get(LKEY_ALGORITHM, function (err, algorithm) {
if (err) {

@@ -1293,4 +1299,4 @@ err = new verror.VError(err);

},
function getVersion(_, cb){
db.get(LKEY_VERSION, function(err, version) {
function getVersion(_, cb) {
db.get(LKEY_VERSION, function (err, version) {
if (err) {

@@ -1305,3 +1311,3 @@ err = new verror.VError(err);

vasync.pipeline({funcs: tasks, arg: {}}, function(err) {
vasync.pipeline({funcs: tasks, arg: {}}, function (err) {
if (err) {

@@ -1318,3 +1324,3 @@ err = new verror.VError(err, 'unable to serialize ring');

dtrace._fash_probes['serialize-done'].fire(function() {
dtrace._fash_probes['serialize-done'].fire(function () {
return ([err ? err.message : null]);

@@ -1335,3 +1341,2 @@ });

module.exports.LKEY_VNODE_COUNT = LKEY_VNODE_COUNT;
module.exports.LKEY_VNODE_V = LKEY_VNODE_V;
module.exports.LKEY_VNODE_V = LKEY_VNODE_V;

@@ -67,3 +67,4 @@ /*

assert.string(options.hash, 'options.hash');
return parseInt(bignum(options.hash, 16).div(options.vnodeHashInterval), 10);
return parseInt(bignum(options.hash, 16).
div(options.vnodeHashInterval), 10);
}

@@ -89,8 +90,3 @@

}
vnodeArray[i] = parsedElement;
if (!vnodeArray[i] || vnodeArray[i] === '' || vnodeArray[i] === ',') {
continue;
}
newVnodeArray.push(vnodeArray[i]);
newVnodeArray.push(parsedElement);
}

@@ -97,0 +93,0 @@ return newVnodeArray;

@@ -42,35 +42,35 @@ /*

module.exports = function exportStaticProvider() {
if (!PROVIDER) {
try {
var dtrace = require('dtrace-provider');
PROVIDER = dtrace.createDTraceProvider('node-fash');
} catch (e) {
PROVIDER = {
fire: function () {},
enable: function () {},
addProbe: function () {
var p = {
fire: function () {}
};
return (p);
},
removeProbe: function () {},
disable: function () {}
};
}
if (!PROVIDER) {
try {
var dtrace = require('dtrace-provider');
PROVIDER = dtrace.createDTraceProvider('node-fash');
} catch (e) {
PROVIDER = {
fire: function () {},
enable: function () {},
addProbe: function () {
var p = {
fire: function () {}
};
return (p);
},
removeProbe: function () {},
disable: function () {}
};
}
PROVIDER._fash_probes = {};
PROVIDER._fash_probes = {};
Object.keys(PROBES).forEach(function (p) {
var args = PROBES[p].splice(0);
args.unshift(p);
Object.keys(PROBES).forEach(function (p) {
var args = PROBES[p].splice(0);
args.unshift(p);
var probe = PROVIDER.addProbe.apply(PROVIDER, args);
PROVIDER._fash_probes[p] = probe;
});
var probe = PROVIDER.addProbe.apply(PROVIDER, args);
PROVIDER._fash_probes[p] = probe;
});
PROVIDER.enable();
}
PROVIDER.enable();
}
return (PROVIDER);
return (PROVIDER);
}();

@@ -24,3 +24,3 @@ {

],
"version": "2.4.0",
"version": "2.4.1",
"repository": {

@@ -63,10 +63,3 @@ "type": "git",

"fash": "bin/fash.js"
},
"config": {
"leveldb_test_algorithm": "sha256"
},
"scripts": {
"pretest": "./lint.sh",
"test": "./node_modules/.bin/nodeunit test/*.test.js"
}
}

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