Return-Path: X-Original-To: apmail-ignite-commits-archive@minotaur.apache.org Delivered-To: apmail-ignite-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 2D21618A1C for ; Fri, 12 Feb 2016 09:54:28 +0000 (UTC) Received: (qmail 46770 invoked by uid 500); 12 Feb 2016 09:54:28 -0000 Delivered-To: apmail-ignite-commits-archive@ignite.apache.org Received: (qmail 46663 invoked by uid 500); 12 Feb 2016 09:54:27 -0000 Mailing-List: contact commits-help@ignite.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ignite.apache.org Delivered-To: mailing list commits@ignite.apache.org Received: (qmail 45995 invoked by uid 99); 12 Feb 2016 09:54:27 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 12 Feb 2016 09:54:27 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 4E524E6975; Fri, 12 Feb 2016 09:54:27 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: akuznetsov@apache.org To: commits@ignite.apache.org Date: Fri, 12 Feb 2016 09:54:40 -0000 Message-Id: <405a564d14674c0593d00acffc88f39f@git.apache.org> In-Reply-To: <236785f7c5b94341b0233635ee1b93a3@git.apache.org> References: <236785f7c5b94341b0233635ee1b93a3@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [14/29] ignite git commit: IGNITE-843 Refactor serve to es6. IGNITE-843 Refactor serve to es6. Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/fdf9ddc4 Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/fdf9ddc4 Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/fdf9ddc4 Branch: refs/heads/ignite-843-rc3 Commit: fdf9ddc4e3a05bbf1e7e4d7a4fb676cc00866c93 Parents: 2023470 Author: Andrey Authored: Fri Feb 12 13:51:08 2016 +0700 Committer: Andrey Committed: Fri Feb 12 13:51:08 2016 +0700 ---------------------------------------------------------------------- .../src/main/js/serve/agent.js | 112 +++++++++---------- .../src/main/js/serve/settings.js | 8 +- 2 files changed, 61 insertions(+), 59 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/fdf9ddc4/modules/control-center-web/src/main/js/serve/agent.js ---------------------------------------------------------------------- diff --git a/modules/control-center-web/src/main/js/serve/agent.js b/modules/control-center-web/src/main/js/serve/agent.js index 3470dfe..6c54ae1 100644 --- a/modules/control-center-web/src/main/js/serve/agent.js +++ b/modules/control-center-web/src/main/js/serve/agent.js @@ -24,7 +24,52 @@ module.exports = { inject: ['require(fs)', 'require(ws)', 'require(apache-ignite)', 'mongo'] }; -module.exports.factory = function (fs, ws, apacheIgnite, mongo) { +module.exports.factory = function(fs, ws, apacheIgnite, mongo) { + /** + * Creates an instance of server for Ignite. + */ + class AgentServer { + /** + * @this {AgentServer} + * @param {Agent} agent Connected agent + * @param {Boolean} demo Use demo node for request + */ + constructor(agent, demo) { + this._agent = agent; + this._demo = !!demo; + } + + /** + * Run http request + * + * @this {AgentServer} + * @param {cmd} cmd Command + * @param {callback} callback on finish + */ + runCommand(cmd, callback) { + const params = {cmd: cmd.name()}; + + for (const param of cmd._params) + params[param.key] = param.value; + + let body; + + let headers; + + let method = 'GET'; + + if (cmd._isPost()) { + body = cmd.postData(); + + method = 'POST'; + + headers = {JSONObject: 'application/json'}; + } + + this._agent.executeRest('ignite', params, this._demo, method, headers, body, callback); + } + } + class Agent { /** * @param {AgentManager} manager @@ -64,7 +109,7 @@ module.exports.factory = function (fs, ws, apacheIgnite, mongo) { resolve(res); }) ); - }; + } /** * @param {String} uri @@ -140,7 +185,7 @@ module.exports.factory = function (fs, ws, apacheIgnite, mongo) { }; this._invokeRmtMethod('executeRest', [uri, params, demo, method, headers, body], _cb); - }; + } /** * @param {?String} error @@ -178,7 +223,7 @@ module.exports.factory = function (fs, ws, apacheIgnite, mongo) { */ availableDrivers() { return this._runCommand('availableDrivers', []); - }; + } /** * Run http request @@ -207,7 +252,7 @@ module.exports.factory = function (fs, ws, apacheIgnite, mongo) { } this._wsSrv.send(JSON.stringify(msg)); - }; + } _rmtAuthMessage(msg) { const self = this; @@ -240,7 +285,7 @@ module.exports.factory = function (fs, ws, apacheIgnite, mongo) { } }); }); - }; + } _rmtCallRes(msg) { const callback = this._cbMap[msg.reqId]; @@ -251,59 +296,14 @@ module.exports.factory = function (fs, ws, apacheIgnite, mongo) { delete this._cbMap[msg.reqId]; callback(msg.error, msg.response); - }; + } /** * @returns {Ignite} */ ignite(demo) { return demo ? this._demo : this._cluster; - }; - } - - /** - * Creates an instance of server for Ignite. - */ - class AgentServer { - /** - * @this {AgentServer} - * @param {Agent} agent Connected agent - * @param {Boolean} demo Use demo node for request - */ - constructor(agent, demo) { - this._agent = agent; - this._demo = !!demo; } - - /** - * Run http request - * - * @this {AgentServer} - * @param {cmd} cmd Command - * @param {callback} callback on finish - */ - runCommand(cmd, callback) { - const params = {cmd: cmd.name()}; - - for (const param of cmd._params) - params[param.key] = param.value; - - let body; - - let headers; - - let method = 'GET'; - - if (cmd._isPost()) { - body = cmd.postData(); - - method = 'POST'; - - headers = {JSONObject: 'application/json'}; - } - - this._agent.executeRest('ignite', params, this._demo, method, headers, body, callback); - }; } class AgentManager { @@ -328,7 +328,7 @@ module.exports.factory = function (fs, ws, apacheIgnite, mongo) { const self = this; this._wsSrv.on('connection', (_wsSrv) => new Agent(_wsSrv, self)); - }; + } /** * @param userId @@ -346,7 +346,7 @@ module.exports.factory = function (fs, ws, apacheIgnite, mongo) { if (agents.length === 0) delete this._agents[userId]; } - }; + } /** * @param {ObjectId} userId @@ -362,7 +362,7 @@ module.exports.factory = function (fs, ws, apacheIgnite, mongo) { } agents.push(agent); - }; + } /** * @param {ObjectId} userId @@ -375,7 +375,7 @@ module.exports.factory = function (fs, ws, apacheIgnite, mongo) { return null; return agents[0]; - }; + } } return new AgentManager(); http://git-wip-us.apache.org/repos/asf/ignite/blob/fdf9ddc4/modules/control-center-web/src/main/js/serve/settings.js ---------------------------------------------------------------------- diff --git a/modules/control-center-web/src/main/js/serve/settings.js b/modules/control-center-web/src/main/js/serve/settings.js index 6e4b619..f3d19d9 100644 --- a/modules/control-center-web/src/main/js/serve/settings.js +++ b/modules/control-center-web/src/main/js/serve/settings.js @@ -15,6 +15,8 @@ * limitations under the License. */ +'use strict'; + // Fire me up! module.exports = { @@ -23,13 +25,13 @@ module.exports = { }; module.exports.factory = function(nconf, fs) { - nconf.file({'file': './serve/config/default.json'}); + nconf.file({file: './serve/config/default.json'}); /** * Normalize a port into a number, string, or false. */ const _normalizePort = function(val) { - var port = parseInt(val, 10); + const port = parseInt(val, 10); // named pipe if (isNaN(port)) @@ -52,7 +54,7 @@ module.exports.factory = function(nconf, fs) { passphrase: nconf.get('agent-server:keyPassphrase') } }, - server : { + server: { port: _normalizePort(nconf.get('server:port') || 80), SSLOptions: nconf.get('server:ssl') && { enable301Redirects: true,