ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anovi...@apache.org
Subject ignite git commit: IGNITE-843 Refactor serve to es6.
Date Fri, 12 Feb 2016 06:51:02 GMT
Repository: ignite
Updated Branches:
  refs/heads/ignite-843-rc2 2023470c3 -> fdf9ddc4e


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-rc2
Commit: fdf9ddc4e3a05bbf1e7e4d7a4fb676cc00866c93
Parents: 2023470
Author: Andrey <anovikov@gridgain.com>
Authored: Fri Feb 12 13:51:08 2016 +0700
Committer: Andrey <anovikov@gridgain.com>
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,


Mime
View raw message