From f65d2bb7d7a82ddb5085916571d471509da96b84 Mon Sep 17 00:00:00 2001 From: Ryann Date: Mon, 30 Oct 2017 15:12:07 -0500 Subject: [PATCH 1/8] Update manager.js --- lib/manager.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/manager.js b/lib/manager.js index bb9c0db..11c6816 100644 --- a/lib/manager.js +++ b/lib/manager.js @@ -38,7 +38,7 @@ var ProcessManager = exports.ProcessManager = function(options){ self._persistency = null; if (options.persistencyOptions) { - self._persistency = new Persistency(options.persistencyOptions); + self._persistency = new Persistency(options.persistencyOptions.url, options.persistencyOptions.options); self._doneLoadingHandler = options.persistencyOptions.doneLoading; self._doneSavingHandler = options.persistencyOptions.doneSaving; } @@ -640,4 +640,4 @@ ProcessManager.prototype.getDefinitionNames = function(callback){ */ ProcessManager.prototype.createServer = function(options, restifyOptions){ return rest.createServer(this, options, restifyOptions); -}; \ No newline at end of file +}; From b6d43dea37d080e87c4a9df64387fa42d33688d7 Mon Sep 17 00:00:00 2001 From: Ryann Date: Mon, 30 Oct 2017 15:14:03 -0500 Subject: [PATCH 2/8] Update persistency.js Pass in URL --- lib/persistency/persistency.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/lib/persistency/persistency.js b/lib/persistency/persistency.js index e2fa31b..8ad0707 100644 --- a/lib/persistency/persistency.js +++ b/lib/persistency/persistency.js @@ -10,19 +10,18 @@ var MongoDBPersistency = require('./mongodb.js').Persistency; * @param {{uri: String, uri: String}} options * @constructor */ -var Persistency = exports.Persistency = function(options) { +var Persistency = exports.Persistency = function(url, options) { var isMongoDbUri; - var uri = options ? options.uri : null; - if (uri) { - isMongoDbUri = uri.indexOf('mongodb://') === 0; + if (url) { + isMongoDbUri = url.indexOf('mongodb://') === 0; if (isMongoDbUri) { - this.implementation = new MongoDBPersistency(uri, options); + this.implementation = new MongoDBPersistency(url, options); } else { - this.implementation = new FilePersistency(uri); + this.implementation = new FilePersistency(url); } } else { - throw new Error("Persistency options must contain an uri property."); + throw new Error("Persistency options must contain a uri property."); } }; From 357f755d7089ce7b95aa0e90fbd7ec9f18e166b4 Mon Sep 17 00:00:00 2001 From: Ryann Date: Mon, 30 Oct 2017 15:15:55 -0500 Subject: [PATCH 3/8] Update mongodb.js passing in url now --- lib/persistency/mongodb.js | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/lib/persistency/mongodb.js b/lib/persistency/mongodb.js index c5e5c26..0dd17d7 100644 --- a/lib/persistency/mongodb.js +++ b/lib/persistency/mongodb.js @@ -31,11 +31,11 @@ var waitingForConnectionEventEmitters = {}; var connectionEventName = 'connectionEventName'; /** - * @param {String} uri + * @param {String} url * @param {*} options * @constructor */ -var Persistency = exports.Persistency = function(uri, options) { +var Persistency = exports.Persistency = function(url, options) { this.options = options || defaultOptions; this.options.server = this.options.server || defaultOptions.server; @@ -45,10 +45,10 @@ var Persistency = exports.Persistency = function(uri, options) { this._trace = function() {}; } - if (uri) { - this.uri = uri; + if (url) { + this.url = url; } else { - throw new Error("MongoDB: Persistency: requires uri to db"); + throw new Error("MongoDB: Persistency: requires url to db"); } }; @@ -110,11 +110,11 @@ Persistency.prototype._execute = function(dbCall, argument, done) { } else { waitingForConnection = self._waitingForConnection(); if (waitingForConnection) { - self._trace("Waiting for connection. URI: " + self.uri); + self._trace("Waiting for connection. URL: " + self.url); waitingForConnection.on(connectionEventName, function(error, db) { if (error) { self._resetConnection(); - self._trace("ERROR: Stopped waiting for connection. URI: " + self.uri + " Error: " + error); + self._trace("ERROR: Stopped waiting for connection. URL: " + self.url + " Error: " + error); done(error); } else { self._trace("Stopped waiting. Got connection '" + db.databaseName + "'."); @@ -123,12 +123,12 @@ Persistency.prototype._execute = function(dbCall, argument, done) { }); } else { self._setWaitingForConnection(); - self._trace("Trying to get connection for URI: " + self.uri + " ..."); + self._trace("Trying to get connection for URL: " + self.url + " ..."); self._connect(function(error, db) { var waitingForConnection = self._waitingForConnection(); if(error) { - self._trace("ERROR: Could not get connection. URI: " + self.uri + " Error: " + error); + self._trace("ERROR: Could not get connection. URL: " + self.url + " Error: " + error); waitingForConnection.emit(connectionEventName, error); // we do this to stop waiting self._resetConnection(); if (db){ @@ -139,7 +139,7 @@ Persistency.prototype._execute = function(dbCall, argument, done) { done(error); } } else { - self._trace("Got connection '" + db.databaseName + "' URI: " + self.uri); + self._trace("Got connection '" + db.databaseName + "' URL: " + self.url); self._setConnection(db); waitingForConnection.emit(connectionEventName, null, db); dbCall.call(self, db, argument, done); @@ -158,7 +158,7 @@ Persistency.prototype._connect = function(done) { * @private */ Persistency.prototype._getConnection = function() { - return uniqueDbConnections[this.uri]; + return uniqueDbConnections[this.url]; }; /** @@ -166,7 +166,7 @@ Persistency.prototype._getConnection = function() { * @private */ Persistency.prototype._setConnection = function(connection) { - uniqueDbConnections[this.uri] = connection; + uniqueDbConnections[this.url] = connection; }; /** @@ -174,22 +174,22 @@ Persistency.prototype._setConnection = function(connection) { * @private */ Persistency.prototype._waitingForConnection = function() { - return waitingForConnectionEventEmitters[this.uri]; + return waitingForConnectionEventEmitters[this.url]; }; /** * @private */ Persistency.prototype._setWaitingForConnection = function() { - waitingForConnectionEventEmitters[this.uri] = new EventEmitter(); + waitingForConnectionEventEmitters[this.url] = new EventEmitter(); }; /** * @private */ Persistency.prototype._resetConnection = function() { - delete uniqueDbConnections[this.uri]; - delete waitingForConnectionEventEmitters[this.uri]; + delete uniqueDbConnections[this.url]; + delete waitingForConnectionEventEmitters[this.url]; }; /** From 45fe7eea56173915b75bc080a9aa2acafb4beac2 Mon Sep 17 00:00:00 2001 From: Ryann Date: Mon, 30 Oct 2017 15:24:49 -0500 Subject: [PATCH 4/8] Update mongodb.js fixed url --- lib/persistency/mongodb.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/persistency/mongodb.js b/lib/persistency/mongodb.js index 0dd17d7..c339e5f 100644 --- a/lib/persistency/mongodb.js +++ b/lib/persistency/mongodb.js @@ -150,7 +150,7 @@ Persistency.prototype._execute = function(dbCall, argument, done) { }; Persistency.prototype._connect = function(done) { - MongoClient.connect(this.uri, this.options, done); + MongoClient.connect(this.url, this.options, done); }; /** From 66659ee827aac9e056bb61046bc41f501fa36693 Mon Sep 17 00:00:00 2001 From: Ryann Date: Mon, 30 Oct 2017 15:27:46 -0500 Subject: [PATCH 5/8] Update mongodb.js top level options --- lib/persistency/mongodb.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/persistency/mongodb.js b/lib/persistency/mongodb.js index c339e5f..ca26655 100644 --- a/lib/persistency/mongodb.js +++ b/lib/persistency/mongodb.js @@ -37,7 +37,7 @@ var connectionEventName = 'connectionEventName'; */ var Persistency = exports.Persistency = function(url, options) { this.options = options || defaultOptions; - this.options.server = this.options.server || defaultOptions.server; + Object.assign(this.options, this.options.server || defaultOptions.server) if (this.options.logger) { this._trace = this.options.logger.trace || function() {}; From fed381a57715ad39fd93ff8ea59d59398d0656fc Mon Sep 17 00:00:00 2001 From: Ryann Date: Mon, 30 Oct 2017 19:16:35 -0500 Subject: [PATCH 6/8] Update mongodb.js udpated default options --- lib/persistency/mongodb.js | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/lib/persistency/mongodb.js b/lib/persistency/mongodb.js index ca26655..706b90c 100644 --- a/lib/persistency/mongodb.js +++ b/lib/persistency/mongodb.js @@ -8,15 +8,13 @@ var EventEmitter = require('events').EventEmitter; // details see http://mongodb.github.io/node-mongodb-native/driver-articles/mongoclient.html var defaultOptions = { - "server": { - // if we set this to true, we will try to reconnect even if the url is wrong. - // So we can never close the connection if something went wrong - // If this were true, the connectionNOK test will fail. - "auto_reconnect": false, - "poolSize": 10, - "socketOptions": { - "connectTimeoutMS": 5000 - } + // if we set this to true, we will try to reconnect even if the url is wrong. + // So we can never close the connection if something went wrong + // If this were true, the connectionNOK test will fail. + "auto_reconnect": false, + "poolSize": 10, + "socketOptions": { + "connectTimeoutMS": 5000 } }; From 705da4d942cc7952bad1e133cc9b198b69595663 Mon Sep 17 00:00:00 2001 From: Ryann Date: Mon, 30 Oct 2017 19:23:53 -0500 Subject: [PATCH 7/8] Update mongodb.js defaultOptions fixed --- lib/persistency/mongodb.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/persistency/mongodb.js b/lib/persistency/mongodb.js index 706b90c..38bbe33 100644 --- a/lib/persistency/mongodb.js +++ b/lib/persistency/mongodb.js @@ -11,11 +11,9 @@ var defaultOptions = { // if we set this to true, we will try to reconnect even if the url is wrong. // So we can never close the connection if something went wrong // If this were true, the connectionNOK test will fail. - "auto_reconnect": false, - "poolSize": 10, - "socketOptions": { - "connectTimeoutMS": 5000 - } + "autoReconnect": false, + "poolSize": 10, + "socketTimeoutMS": 5000 }; /* From fb06f06e4753a5bdd426a3fc70d5b06ef724b48e Mon Sep 17 00:00:00 2001 From: Ryann Date: Mon, 30 Oct 2017 19:58:17 -0500 Subject: [PATCH 8/8] Update persistency.test.js test updates --- test/public/manager/persistency.test.js | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/test/public/manager/persistency.test.js b/test/public/manager/persistency.test.js index d34e461..379ab0b 100644 --- a/test/public/manager/persistency.test.js +++ b/test/public/manager/persistency.test.js @@ -13,8 +13,8 @@ require("../../../lib/history.js").setDummyTimestampFunction(); exports.testCreatePersistentFlatProcess = function(test) { var bpmnProcess; - var persistencyUri = path.join(__dirname, '../../resources/persistency/testPersistentProcess'); - fileUtils.cleanDirectorySync(persistencyUri); + var persistencyURL = path.join(__dirname, '../../resources/persistency/testPersistentProcess'); + fileUtils.cleanDirectorySync(persistencyURL); var savedState = function(error, savedData) { test.ok(error === null, "testCreatePersistentFlatProcess: no error saving."); @@ -95,11 +95,10 @@ exports.testCreatePersistentFlatProcess = function(test) { var fileName = path.join(__dirname, "../../resources/projects/simple/taskExampleProcess.bpmn"); var persistencyOptions = { - uri: persistencyUri, doneSaving: savedState }; - var manager = new Manager({ + var manager = new Manager(persistencyURL, { bpmnFilePath: fileName, persistencyOptions: persistencyOptions }); @@ -116,17 +115,12 @@ exports.testCreatePersistentFlatProcess = function(test) { exports.testLoadPersistentFlatProcess = function(test){ - var persistencyUri = path.join(__dirname, '../../resources/persistency/testPersistentProcess'); + var persistencyURL = path.join(__dirname, '../../resources/persistency/testPersistentProcess'); var fileName = path.join(__dirname, "../../resources/projects/simple/taskExampleProcess.bpmn"); - var persistencyOptions = { - uri: persistencyUri - }; - - var manager = new Manager({ - bpmnFilePath: fileName, - persistencyOptions: persistencyOptions + var manager = new Manager(persistencyURL, { + bpmnFilePath: fileName });