Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mongodb-core

Package Overview
Dependencies
Maintainers
1
Versions
177
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mongodb-core - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

14

HISTORY.md

@@ -1,2 +0,12 @@

1.0.0
------------
1.0.1 07-10-2014
----------------
- fullsetup is now defined as a primary and secondary being available allowing for all read preferences to be satisfied.
- fixed issue with replset_state logging.
1.0.1 07-10-2014
----------------
- Dependency issue solved
1.0.0 07-10-2014
----------------
- Initial release of mongodb-core

76

lib/tools/replset_manager.js

@@ -105,2 +105,3 @@ var f = require('util').format

process.stdout.write(".");
// Get the replicaset status

@@ -129,4 +130,5 @@ server.command('admin.$cmd', {"replSetGetStatus": 1}, function(err, result) {

if(ready && hasPrimary) {
// Get the ismaster
server.destroy();
return callback(null, null);
return callback(null, result.result);
}

@@ -142,5 +144,52 @@

//
// Check all hosts to locate the primary
var ensureIsMasterUp = function(configSet, callback) {
var members = configSet.members.slice(0);
var foundPrimary = false;
// Query the server
var queryServer = function(hosts, callback) {
if(foundPrimary) {
return callback(null, null);
}
if(hosts.length == 0 && !foundPrimary) {
return setTimeout(function() {
ensureIsMasterUp(configSet, callback);
}, 1000);
}
var hostString = hosts.shift().host;
var host = hostString.split(':')[0];
var port = parseInt(hostString.split(':')[1], 10);
var server = new Server({host: host, port: port, size: 1});
// Process result
var processResult = function(_s) {
_s.destroy();
if(_s.lastIsMaster().ismaster) foundPrimary = true;
queryServer(hosts, callback);
}
var connectFailed = function() {
server.destroy();
queryServer(hosts, callback);
}
server.once('connect', processResult);
server.once('error', connectFailed);
server.once('close', connectFailed);
server.once('timeout', connectFailed);
server.connect();
}
queryServer(members, function() {
if(foundPrimary) return callback(null, null);
setTimeout(ensureIsMasterUp(configSet, callback));
});
}
//
// Configure and ensure
var configureAndEnsure = function(options, callback) {
// console.log("------ configureAndEnsure --------------------------- 0")
if(typeof options == 'function') {

@@ -209,3 +258,2 @@ callback = options;

}
// console.log("------ configureAndEnsure --------------------------- 1")

@@ -221,5 +269,2 @@ // Set the key

// console.log("========================================================= attempting to connect")
// console.dir(opts)
// Let's pick one of the servers and run the command against it

@@ -239,5 +284,12 @@ server = new Server(opts);

if(options.override || err == null) {
// server.command('system.$cmd'
// , {ismaster:true}, function(err, r) {
return ensureUp(server, function(err, r) {
server.destroy();
callback(err, r);
if(err) return callback(err);
// Ensure IsMaster up across all the servers
ensureIsMasterUp(configSet, function(err, r) {
server.destroy();
callback(err, r);
});
});

@@ -292,4 +344,2 @@ }

// console.log("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ADDING")
// console.dir(opts)
// Create a server manager

@@ -303,7 +353,4 @@ serverManagers.push(new ServerManager(opts));

// console.log("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0")
// Start the server
serverManagers[i].start(startOpts, function(err) {
// console.log("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 1")
// console.dir(err)
if(err) throw err;

@@ -314,6 +361,4 @@ serversLeft = serversLeft - 1;

if(serversLeft == 0) {
// console.log("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 2")
// Configure the replicaset
configureAndEnsure(function() {
// console.log("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 3")
// Refresh view

@@ -500,3 +545,2 @@ getServerManagerByType('primary', function() {

options.purge = true;
// options.kill = true;
// No manager

@@ -503,0 +547,0 @@ if(manager == null) return callback(new Error("no downed secondary server found"));

@@ -380,3 +380,3 @@ var Logger = require('../connection/logger')

// Log information
if(logger.isInfo()) logger.info(f('[%s] updating replicaset state %s', id, JSON.stringify(replState)));
if(logger.isInfo()) logger.info(f('[%s] updating replicaset state %s', id, JSON.stringify(this)));

@@ -383,0 +383,0 @@ // It's a master set it

@@ -272,3 +272,3 @@ var inherits = require('util').inherits

highAvailabilityProcessRunning = true;
if(logger.isInfo()) logger.info(f('[%s] monitoring process running %s', id, JSON.stringify(replState)));
if(logger.isInfo()) logger.info(f('[%s] monitoring process running %s', id, JSON.stringify(replState)));

@@ -422,3 +422,3 @@ // Unique HA id to identify the current look running

// If no more initial servers and new scheduled servers to connect
if(initialConnectionServers.length == 0 && Object.keys(connectingServers).length == 0 && !fullsetup) {
if(replState.secondaries.length >= 1 && replState.primary != null && !fullsetup) {
fullsetup = true;

@@ -561,4 +561,5 @@ self.emit('fullsetup', self);

var events = ['error', 'close', 'timeout', 'connect'];
// Remove any non used handlers
['error', 'close', 'timeout', 'connect'].forEach(function(e) {
events.forEach(function(e) {
server.removeAllListeners(e);

@@ -599,2 +600,8 @@ })

}
// If no more initial servers and new scheduled servers to connect
if(replState.secondaries.length >= 1 && replState.primary != null && !fullsetup) {
fullsetup = true;
self.emit('fullsetup', self);
}
}

@@ -601,0 +608,0 @@

{
"name": "mongodb-core",
"version": "1.0.1",
"version": "1.0.2",
"description": "Core MongoDB driver functionality, no bells and whistles and meant for integration not end applications",

@@ -5,0 +5,0 @@ "main": "index.js",

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