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 A0DAE188A7 for ; Fri, 31 Jul 2015 06:11:42 +0000 (UTC) Received: (qmail 31308 invoked by uid 500); 31 Jul 2015 06:11:08 -0000 Delivered-To: apmail-ignite-commits-archive@ignite.apache.org Received: (qmail 31276 invoked by uid 500); 31 Jul 2015 06:11:08 -0000 Mailing-List: contact commits-help@ignite.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ignite.incubator.apache.org Delivered-To: mailing list commits@ignite.incubator.apache.org Received: (qmail 31267 invoked by uid 99); 31 Jul 2015 06:11:08 -0000 Received: from Unknown (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 31 Jul 2015 06:11:08 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id CEE2DC1311 for ; Fri, 31 Jul 2015 06:11:07 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.791 X-Spam-Level: * X-Spam-Status: No, score=1.791 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, T_RP_MATCHES_RCVD=-0.01, URIBL_BLOCKED=0.001] autolearn=disabled Received: from mx1-us-east.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id Mxyool3Sdv8f for ; Fri, 31 Jul 2015 06:10:53 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1-us-east.apache.org (ASF Mail Server at mx1-us-east.apache.org) with SMTP id AF10850644 for ; Fri, 31 Jul 2015 06:10:38 +0000 (UTC) Received: (qmail 26794 invoked by uid 99); 31 Jul 2015 06:10:38 -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, 31 Jul 2015 06:10:38 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 1EC60E7152; Fri, 31 Jul 2015 06:10:38 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: anovikov@apache.org To: commits@ignite.incubator.apache.org Date: Fri, 31 Jul 2015 06:11:23 -0000 Message-Id: <1aac8c299a9f469d8196a20596920629@git.apache.org> In-Reply-To: <15a4ae0dcd5d4fadb73d4015e6eee03b@git.apache.org> References: <15a4ae0dcd5d4fadb73d4015e6eee03b@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [47/50] [abbrv] incubator-ignite git commit: # ignite-1121 Sql tab # ignite-1121 Sql tab Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/e24f3b74 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/e24f3b74 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/e24f3b74 Branch: refs/heads/ignite-843 Commit: e24f3b74bdf6a3bb5171717537fb834532e4f0b3 Parents: 6ecf626 Author: Andrey Authored: Fri Jul 31 09:29:28 2015 +0700 Committer: Andrey Committed: Fri Jul 31 09:29:28 2015 +0700 ---------------------------------------------------------------------- .../src/main/js/agents/agent-manager.js | 283 +++++++++++++++++++ .../src/main/js/agents/agent-server.js | 90 ++++++ modules/control-center-web/src/main/js/app.js | 8 +- .../src/main/js/controllers/common-module.js | 26 +- .../src/main/js/controllers/sql-controller.js | 22 +- modules/control-center-web/src/main/js/db.js | 12 + .../src/main/js/keys/test.crt | 13 + .../src/main/js/keys/test.key | 18 ++ .../src/main/js/routes/agent.js | 84 ++++++ .../src/main/js/routes/notebooks.js | 102 +++++++ .../src/main/js/routes/sql.js | 4 +- .../src/main/js/views/includes/header.jade | 7 +- .../src/main/js/views/sql/sql.jade | 3 +- .../src/test/js/routes/agent.js | 94 ++++++ modules/nodejs/src/main/js/cluster-node.js | 23 +- modules/nodejs/src/main/js/ignite.js | 5 +- .../http/jetty/GridJettyJsonConfig.java | 3 + .../src/main/js/agents/agent-manager.js | 283 ------------------- .../src/main/js/agents/agent-server.js | 90 ------ .../src/main/js/keys/test.crt | 13 - .../src/main/js/keys/test.key | 18 -- .../src/main/js/routes/agent.js | 84 ------ .../src/test/js/routes/agent.js | 94 ------ 23 files changed, 778 insertions(+), 601 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e24f3b74/modules/control-center-web/src/main/js/agents/agent-manager.js ---------------------------------------------------------------------- diff --git a/modules/control-center-web/src/main/js/agents/agent-manager.js b/modules/control-center-web/src/main/js/agents/agent-manager.js new file mode 100644 index 0000000..10d3a56 --- /dev/null +++ b/modules/control-center-web/src/main/js/agents/agent-manager.js @@ -0,0 +1,283 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +var WebSocketServer = require('ws').Server; + +var apacheIgnite = require('apache-ignite'); + +var db = require('../db'); + +var AgentServer = require('./agent-server').AgentServer; + +/** + * @constructor + */ +function AgentManager(srv) { + this._clients = {}; + + this._server = srv; + + this._wss = new WebSocketServer({ server: this._server }); + + var self = this; + + this._wss.on('connection', function(ws) { + var client = new Client(ws, self); + }); +} + +/** + * @param userId + * @param {Client} client + */ +AgentManager.prototype._removeClient = function(userId, client) { + var connections = this._clients[userId]; + + if (connections) { + removeFromArray(connections, client); + + if (connections.length == 0) + delete this._clients[userId]; + } +}; + +/** + * @param userId + * @param {Client} client + */ +AgentManager.prototype._addClient = function(userId, client) { + var existingConnections = this._clients[userId]; + + if (!existingConnections) { + existingConnections = []; + + this._clients[userId] = existingConnections; + } + + existingConnections.push(client); +}; + +/** + * @param userId + * @return {Client} + */ +AgentManager.prototype.findClient = function(userId) { + var clientsList = this._clients[userId]; + + if (!clientsList) + return null; + + return clientsList[0]; +}; + +/** + * For tests only!!! + * @return {Client} + */ +AgentManager.prototype.getOneClient = function() { + for (var userId in this._clients) { + if (this._clients.hasOwnProperty(userId)) { + var m = this._clients[userId]; + + if (m.length > 0) + return m[0]; + } + } + + return null; +}; + + +/** + * @constructor + * @param {AgentManager} manager + * @param {WebSocket} ws + */ +function Client(ws, manager) { + var self = this; + + this._manager = manager; + this._ws = ws; + + ws.on('close', function() { + if (self.user) { + self._manager._removeClient(self.user._id, self); + } + }); + + ws.on('message', function (msg) { + self._handleMessage(JSON.parse(msg)) + }); + + this._restCounter = 0; + + this._cbMap = {}; +} + +/** + * @param {String|Object} msg + * @param {Function} cb + */ +Client.prototype.sendMessage = function(msg, cb) { + if (typeof msg == 'object') { + msg = JSON.stringify(msg); + } + + this._ws.send(msg, cb); +}; + +/** + * @param {String} path + * @param {Object} params + * @param {Function} cb + * @param {String} method + * @param {String} body + * @param {Object} headers + */ +Client.prototype.invokeRest = function(path, params, cb, method, body, headers) { + var self = this; + + if (typeof(params) != 'object') + throw "'params' argument must be an object"; + + if (typeof(cb) != 'function') + throw "callback must be a function"; + + if (body && typeof(body) != 'string') + throw "body must be a string"; + + if (headers && typeof(headers) != 'object') + throw "headers must be an object"; + + if (!method) + method = 'GET'; + else + method = method.toUpperCase(); + + if (method != 'GET' && method != 'POST') + throw "Unknown HTTP method: " + method; + + var reqId = this._restCounter++; + + this._cbMap[reqId] = cb; + + this.sendMessage({ + id: reqId, + type: 'RestRequest', + method: method, + params: params, + path: path, + body: body, + headers: headers + }, function(err) { + if (err) { + delete self._cbMap[reqId]; + + cb(err) + } + }) +}; + +/** + * @param {Object} msg + */ +Client.prototype._handleMessage = function(msg) { + var self = this; + + switch (msg.type) { + case 'AuthMessage': + var account = db.Account.findByUsername(msg.login, function(err, account) { + if (err) { + ws.send("{type: 'AuthResult', success: false}"); + } + else { + account.authenticate(msg.password, function(err, user, res) { + if (!user) { + self._ws.send(JSON.stringify({type: 'AuthResult', success: false, message: res.message})); + } + else { + self._ws.send("{type: 'AuthResult', success: true}"); + + self._user = account; + + self._manager._addClient(account._id, self); + + self._ignite = new apacheIgnite.Ignite(new AgentServer(self)); + } + }); + } + }); + + break; + + case 'RestResult': + var cb = this._cbMap[msg.requestId]; + + if (!cb) + break; + + delete this._cbMap[msg.requestId]; + + if (!msg.executed) { + cb(msg.message) + } + else { + cb(null, msg.code, msg.message) + } + + break; + + default: + this._ws.close() + } +}; + +/** + * @return {Ignite} + */ +Client.prototype.ignite = function() { + return this._ignite; +}; + +function removeFromArray(arr, val) { + var idx; + + while ((idx = arr.indexOf(val)) !== -1) { + arr.splice(idx, 1); + } +} + +exports.AgentManager = AgentManager; + +/** + * @type {AgentManager} + */ +var manager = null; + +exports.createManager = function(srv) { + if (manager) + throw "Agent manager already cleared!"; + + manager = new AgentManager(srv); +}; + +/** + * @return {AgentManager} + */ +exports.getAgentManager = function() { + return manager; +}; http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e24f3b74/modules/control-center-web/src/main/js/agents/agent-server.js ---------------------------------------------------------------------- diff --git a/modules/control-center-web/src/main/js/agents/agent-server.js b/modules/control-center-web/src/main/js/agents/agent-server.js new file mode 100644 index 0000000..31dee5a --- /dev/null +++ b/modules/control-center-web/src/main/js/agents/agent-server.js @@ -0,0 +1,90 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Creates an instance of server for Ignite + * + * @constructor + * @this {AgentServer} + * @param {Client} client connected client + */ +function AgentServer(client) { + this._client = client; +} + +/** + * Run http request + * + * @this {AgentServer} + * @param {Command} cmd Command + * @param {callback} callback on finish + */ +AgentServer.prototype.runCommand = function(cmd, callback) { + var params = {cmd: cmd.name()}; + + for (var p of cmd._params) { + params[p.key] = p.value; + } + + var body = undefined; + + var headers = undefined; + + if (cmd._isPost()) { + body = cmd.postData(); + + headers = {'Content-Length': body.length, 'JSONObject': 'application/json'}; + } + + this._client.invokeRest("ignite", params, function(error, code, message) { + if (error) { + callback(error); + return + } + + if (code !== 200) { + if (code === 401) { + callback.call(null, "Authentication failed. Status code 401."); + } + else { + callback.call(null, "Request failed. Status code " + code); + } + + return; + } + + var igniteResponse; + + try { + igniteResponse = JSON.parse(message); + } + catch (e) { + callback.call(null, e, null); + + return; + } + + if (igniteResponse.successStatus) { + callback.call(null, igniteResponse.error, null) + } + else { + callback.call(null, null, igniteResponse.response); + } + }, cmd._method(), body, headers); +}; + +exports.AgentServer = AgentServer; http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e24f3b74/modules/control-center-web/src/main/js/app.js ---------------------------------------------------------------------- diff --git a/modules/control-center-web/src/main/js/app.js b/modules/control-center-web/src/main/js/app.js index 930c798..7741822 100644 --- a/modules/control-center-web/src/main/js/app.js +++ b/modules/control-center-web/src/main/js/app.js @@ -26,6 +26,7 @@ var session = require('express-session'); var mongoStore = require('connect-mongo')(session); var publicRoutes = require('./routes/public'); +var notebooksRoutes = require('./routes/notebooks'); var clustersRouter = require('./routes/clusters'); var cachesRouter = require('./routes/caches'); var metadataRouter = require('./routes/metadata'); @@ -123,8 +124,11 @@ app.use('/configuration/clusters', clustersRouter); app.use('/configuration/caches', cachesRouter); app.use('/configuration/metadata', metadataRouter); app.use('/configuration/summary', summary); -app.use('/sql', sqlRouter); -app.use('/agent', agentRouter); + +app.use('/notebooks', mustAuthenticated, notebooksRoutes); +app.use('/sql', mustAuthenticated, sqlRouter); + +app.use('/agent', mustAuthenticated, agentRouter); // Catch 404 and forward to error handler. app.use(function (req, res, next) { http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e24f3b74/modules/control-center-web/src/main/js/controllers/common-module.js ---------------------------------------------------------------------- diff --git a/modules/control-center-web/src/main/js/controllers/common-module.js b/modules/control-center-web/src/main/js/controllers/common-module.js index df2ff19..8d3efed 100644 --- a/modules/control-center-web/src/main/js/controllers/common-module.js +++ b/modules/control-center-web/src/main/js/controllers/common-module.js @@ -481,4 +481,28 @@ controlCenterModule.controller('auth', [ $alert({placement: 'top', container: '#errors-container', title: $scope.errorMessage(data)}); }); }; - }]); \ No newline at end of file + }]); + +// Navigation bar controller. +controlCenterModule.controller('notebooks', ['$scope', '$http','$common', function ($scope, $http, $common) { + $scope.notebooks = []; + + // When landing on the page, get clusters and show them. + $http.post('/notebooks/list') + .success(function (data) { + $scope.notebooks = data; + + if ($scope.notebooks.length > 0) { + $scope.notebookDropdown = [ + { text: 'Create new notebook', href: '/notebooks/new', target: '_self' }, + { divider: true } + ]; + + for (notebook of $scope.notebooks) + $scope.notebookDropdown.push({text: notebook.name, href: '/sql/' + notebook._id, target: '_self'}); + } + }) + .error(function (errMsg) { + $common.showError(errMsg); + }); +}]); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e24f3b74/modules/control-center-web/src/main/js/controllers/sql-controller.js ---------------------------------------------------------------------- diff --git a/modules/control-center-web/src/main/js/controllers/sql-controller.js b/modules/control-center-web/src/main/js/controllers/sql-controller.js index b4b4335..1e67a08 100644 --- a/modules/control-center-web/src/main/js/controllers/sql-controller.js +++ b/modules/control-center-web/src/main/js/controllers/sql-controller.js @@ -15,7 +15,11 @@ * limitations under the License. */ -controlCenterModule.controller('sqlController', ['$scope', '$http', '$common', function ($scope, $http, $common) { +controlCenterModule.controller('sqlController', ['$scope', '$controller', '$http', '$common', + function ($scope, $controller, $http, $common) { + // Initialize the super class and extend it. + angular.extend(this, $controller('notebooks', {$scope: $scope})); + $scope.joinTip = $common.joinTip; $scope.pageSizes = [50, 100, 200, 400, 800, 1000]; @@ -26,6 +30,22 @@ controlCenterModule.controller('sqlController', ['$scope', '$http', '$common', f {value: 'LOCAL', label: 'LOCAL'} ]; + var loadNotebook = function() { + $http.post('/notebooks/get', {nodeId: $scope.nodeId}) + .success(function (notebook) { + $scope.notebook = notebook; + }) + .error(function (errMsg) { + $common.showError(errMsg); + }); + }; + + loadNotebook(); + + $scope.addParagraph = function(notebook) { + notebook.paragraphs.push({}); + }; + $scope.tabs = []; $scope.addTab = function() { http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e24f3b74/modules/control-center-web/src/main/js/db.js ---------------------------------------------------------------------- diff --git a/modules/control-center-web/src/main/js/db.js b/modules/control-center-web/src/main/js/db.js index 5232e24..401beff 100644 --- a/modules/control-center-web/src/main/js/db.js +++ b/modules/control-center-web/src/main/js/db.js @@ -355,6 +355,18 @@ var PersistenceSchema = new Schema({ // Define persistence model. exports.Persistence = mongoose.model('Persistence', PersistenceSchema); +// Define persistence schema. +var NotebookSchema = new Schema({ + space: {type: ObjectId, ref: 'Space'}, + name: String, + paragraph: [{ + query: String + }] +}); + +// Define persistence model. +exports.Notebook = mongoose.model('Notebook', NotebookSchema); + exports.upsert = function (model, data, cb) { if (data._id) { var id = data._id; http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e24f3b74/modules/control-center-web/src/main/js/keys/test.crt ---------------------------------------------------------------------- diff --git a/modules/control-center-web/src/main/js/keys/test.crt b/modules/control-center-web/src/main/js/keys/test.crt new file mode 100644 index 0000000..50c6d5c --- /dev/null +++ b/modules/control-center-web/src/main/js/keys/test.crt @@ -0,0 +1,13 @@ +-----BEGIN CERTIFICATE----- +MIIB6zCCAVQCCQDcAphbU6UcLjANBgkqhkiG9w0BAQsFADA6MRIwEAYDVQQDDAls +b2NhbGhvc3QxJDAiBgkqhkiG9w0BCQEWFXNldmRva2ltb3ZAYXBhY2hlLm9yZzAe +Fw0xNTA3MTQxMzAyNTNaFw0xODA2MjMxMzAyNTNaMDoxEjAQBgNVBAMMCWxvY2Fs +aG9zdDEkMCIGCSqGSIb3DQEJARYVc2V2ZG9raW1vdkBhcGFjaGUub3JnMIGfMA0G +CSqGSIb3DQEBAQUAA4GNADCBiQKBgQDP/zpJrdHqCj6lPpeFF6LQtzKef6UiyBBo +rbuOtCCgW8KMJJciluBWk2126qLt9smBN4jBpSNU3pq0r9gBMUTd/LSe7aY4D5ED +Pjp7XsypNVKeHaHbFi7KhfHy0LYxsWiNPmmHJv4dtYOp+pGK25rkXNfyJxxjgxN6 +wo34+MnZIQIDAQABMA0GCSqGSIb3DQEBCwUAA4GBAFk9XEjcdyihws+fVmdGGUFo +bVxI9YGH6agiNbU3WNF4B4VRzcPPW8z2mEo7eF9kgYmq/YzH4T8tgi/qkL/u8eZV +Wmi9bg6RThLN6/hj3wVoOFKykbDQ05FFdhIJXN5UOjPmxYM97EKqg6J0W2HAb8SG ++UekPnmAo/2HTKsLykH8 +-----END CERTIFICATE----- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e24f3b74/modules/control-center-web/src/main/js/keys/test.key ---------------------------------------------------------------------- diff --git a/modules/control-center-web/src/main/js/keys/test.key b/modules/control-center-web/src/main/js/keys/test.key new file mode 100644 index 0000000..1b395c0 --- /dev/null +++ b/modules/control-center-web/src/main/js/keys/test.key @@ -0,0 +1,18 @@ +-----BEGIN RSA PRIVATE KEY----- +Proc-Type: 4,ENCRYPTED +DEK-Info: DES-EDE3-CBC,6798185330CE2EE2 + +sOwkmD8rvjx11l09V26dJhLhl+SyPIhyeZ3TqHXrYCATKoXlzidT+uPu1jVYtrwr +nBLA6TrIDYRrBNlEsqGZ0cSvWTIczzVW1xZKHEJo5q2vUT/W8u/Q1QQtS3P3GeKF +dEzx496rpZqwwVw59GNbuIwyYoVvQf3iEXzfhplGmLPELYIplDFOLgNuXQyXSGx6 +rwKsCxXMLsDyrA6DCz0Odf08p2HvWk/s5Ne3DFcQlqRNtIrBVGD2O0/Fp8ZZ2I4E +Yn2OIIWJff3HanOjLOWKdN8YAn5UleNmlEUdIHeS5qaQ68mabOxLkSef9qglV+sd +FHTtUq0cG6t6nhxZBziexha6v1yl/xABAHHhNPOfak+HthWxRD4N9f1yFYAeTmkn +4kwBWoSUe12XRf2pGNqhEUKN/KhDmWk85wI55i/Cu2XmNoiBFlS9BXrRYU8uVCJw +KlxjKTDWl1opCyvxTDxJnMkt44ZT445LRePKVueGIIKSUIXNQypOE+C1I0CL0N2W +Ts3m9nthquvLeMx92k7b8yW69BER5uac3SIlGCOJObQXsHgyk8wYiyd/zLKfjctG +PXieaW81UKjp+GqWpvWPz3VqnKwoyUWeVOOTviurli6kYOrHuySTMqMb6hxJctw9 +grAQTT0UPiAKWcM7InLzZnRjco+v9QLLEokjVngXPba16K/CItFY16xuGlaFLW7Y +XTc67AkL8b76HBZelMjmCsqjvSoULhuMFwTOvUMm/mSM8rMoi9asrJRLQHRMWCST +/6RENPLzPlOMnNLBujpBbn8V3/aYzEZsHMI+6S3d27WYlTJIqpabSA== +-----END RSA PRIVATE KEY----- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e24f3b74/modules/control-center-web/src/main/js/routes/agent.js ---------------------------------------------------------------------- diff --git a/modules/control-center-web/src/main/js/routes/agent.js b/modules/control-center-web/src/main/js/routes/agent.js new file mode 100644 index 0000000..4646c28 --- /dev/null +++ b/modules/control-center-web/src/main/js/routes/agent.js @@ -0,0 +1,84 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +var router = require('express').Router(); +var agentManager = require('../agents/agent-manager'); + +var apacheIgnite = require('apache-ignite'); +var SqlFieldsQuery = apacheIgnite.SqlFieldsQuery; + +/* GET summary page. */ +router.post('/topology', function(req, res) { + var client = agentManager.getAgentManager().getOneClient(); + + if (!client) + return res.status(500).send("Client not found"); + + client.ignite().cluster().then(function (clusters) { + res.json(clusters.map(function (cluster) { + var caches = Object.keys(cluster._caches).map(function(key) { + return {"name" : key, "mode" : cluster._caches[key] } + }); + + return { nodeId: cluster._nodeId, caches: caches }; + })); + }, function (err) { + res.send(err); + }); +}); + +/* GET summary page. */ +router.post('/query', function(req, res) { + var client = agentManager.getAgentManager().getOneClient(); + + if (!client) + return res.status(500).send("Client not found"); + + // Create sql query. + var qry = new SqlFieldsQuery(req.body.query); + + // Set page size for query. + qry.setPageSize(req.body.pageSize); + + // Get query cursor. + client.ignite().cache(req.body.cacheName).query(qry).nextPage().then(function (cursor) { + res.json({meta: cursor.fieldsMetadata(), rows: cursor.page(), queryId: cursor.queryId()}); + }, function (err) { + res.status(500).send(err); + }); +}); + +/* GET summary page. */ +router.post('/next_page', function(req, res) { + var client = agentManager.getAgentManager().getOneClient(); + + if (!client) + return res.status(500).send("Client not found"); + + var cache = client.ignite().cache(req.body.cacheName); + + var cmd = cache._createCommand("qryfetch").addParam("qryId", req.body.queryId). + addParam("psz", req.body.pageSize); + + cache.__createPromise(cmd).then(function (page) { + res.json({rows: page["items"], last: page === null || page["last"]}); + }, function (err) { + res.status(500).send(err); + }); +}); + +module.exports = router; http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e24f3b74/modules/control-center-web/src/main/js/routes/notebooks.js ---------------------------------------------------------------------- diff --git a/modules/control-center-web/src/main/js/routes/notebooks.js b/modules/control-center-web/src/main/js/routes/notebooks.js new file mode 100644 index 0000000..5b7ac8e --- /dev/null +++ b/modules/control-center-web/src/main/js/routes/notebooks.js @@ -0,0 +1,102 @@ +/* + * + * * Licensed to the Apache Software Foundation (ASF) under one or more + * * contributor license agreements. See the NOTICE file distributed with + * * this work for additional information regarding copyright ownership. + * * The ASF licenses this file to You under the Apache License, Version 2.0 + * * (the "License"); you may not use this file except in compliance with + * * the License. You may obtain a copy of the License at + * * + * * http://www.apache.org/licenses/LICENSE-2.0 + * * + * * Unless required by applicable law or agreed to in writing, software + * * distributed under the License is distributed on an "AS IS" BASIS, + * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * * See the License for the specific language governing permissions and + * * limitations under the License. + * + */ + +var router = require('express').Router(); +var db = require('../db'); + +/** + * Get notebooks names accessed for user account. + * + * @param req Request. + * @param res Response. + */ +router.post('/list', function (req, res) { + var user_id = req.currentUserId(); + + // Get owned space and all accessed space. + db.Space.find({$or: [{owner: user_id}, {usedBy: {$elemMatch: {account: user_id}}}]}, function (err, spaces) { + if (err) + return res.status(500).send(err.message); + + var space_ids = spaces.map(function (value) { + return value._id; + }); + + // Get all metadata for spaces. + db.Notebook.find({space: {$in: space_ids}}).select('_id name').sort('name').exec(function (err, notebooks) { + if (err) + return res.status(500).send(err.message); + + res.json(notebooks); + }); + }); +}); + +/** + * Get notebook accessed for user account. + * + * @param req Request. + * @param res Response. + */ +router.post('/get', function (req, res) { + var user_id = req.currentUserId(); + + // Get owned space and all accessed space. + db.Space.find({$or: [{owner: user_id}, {usedBy: {$elemMatch: {account: user_id}}}]}, function (err, spaces) { + if (err) + return res.status(500).send(err.message); + + var space_ids = spaces.map(function (value) { + return value._id; + }); + + // Get all metadata for spaces. + db.Notebook.findOne({$or : [{space: {$in: space_ids}}, {_id: req.body.noteId}]}).exec(function (err, notebook) { + if (err) + return res.status(500).send(err.message); + + res.json(notebook); + }); + }); +}); + +/** + * Create new notebook for user account. + * + * @param req Request. + * @param res Response. + */ +router.get('/new', function (req, res) { + var user_id = req.currentUserId(); + + // Get owned space and all accessed space. + db.Space.findOne({owner: user_id}, function (err, space) { + if (err) + return res.status(500).send(err.message); + + (new db.Notebook({space: space.id, name: 'Notebook', paragraph: []})).save(function (err, notebook) { + if (err) + return res.status(500).send(err.message); + + return res.redirect('/sql/' + notebook._id); + }); + }); +}); + +module.exports = router; \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e24f3b74/modules/control-center-web/src/main/js/routes/sql.js ---------------------------------------------------------------------- diff --git a/modules/control-center-web/src/main/js/routes/sql.js b/modules/control-center-web/src/main/js/routes/sql.js index ce4565d..d11be69 100644 --- a/modules/control-center-web/src/main/js/routes/sql.js +++ b/modules/control-center-web/src/main/js/routes/sql.js @@ -17,8 +17,8 @@ var router = require('express').Router(); var db = require('../db'); -router.get('/', function(req, res) { - res.render('sql/sql'); +router.get('/:noteId', function (req, res) { + res.render('sql/sql', {noteId: req.params.noteId}); }); module.exports = router; http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e24f3b74/modules/control-center-web/src/main/js/views/includes/header.jade ---------------------------------------------------------------------- diff --git a/modules/control-center-web/src/main/js/views/includes/header.jade b/modules/control-center-web/src/main/js/views/includes/header.jade index bfd5275..49ea592 100644 --- a/modules/control-center-web/src/main/js/views/includes/header.jade +++ b/modules/control-center-web/src/main/js/views/includes/header.jade @@ -29,11 +29,14 @@ header.header(id='header') ul.nav.navbar-nav(ng-controller='activeLink' ng-show='user') +header-item('/configuration', '/configuration/clusters', 'Configuration') //+header-item('/monitoring', '/monitoring', 'Monitoring') - +header-item('/sql', '/sql', 'SQL') + li(ng-controller='notebooks') + a.dropdown-toggle(ng-hide='notebooks.length == 0' data-toggle='dropdown' bs-dropdown='notebookDropdown' data-placement='bottom-right') SQL + span.caret + a(ng-hide='notebooks.length > 0' ng-class='{active: isActive("/sql")}' href='/notebooks/new') SQL //+header-item('/deploy', '/deploy', 'Deploy') ul.nav.navbar-nav.pull-right li(ng-if='user') - a.dropdown-toggle(data-toggle='dropdown' bs-dropdown='userDropdown' data-placement='bottom-right') {{user.username}} + a.dropdown-toggle(data-toggle='dropdown' bs-dropdown='userDropdown' data-placement='bottom-right' data-ng-bind='::user.username') span.caret li.nav-login(ng-if='!user') a(ng-click='login()' href='#') Log In \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e24f3b74/modules/control-center-web/src/main/js/views/sql/sql.jade ---------------------------------------------------------------------- diff --git a/modules/control-center-web/src/main/js/views/sql/sql.jade b/modules/control-center-web/src/main/js/views/sql/sql.jade index 2ce6958..53e6639 100644 --- a/modules/control-center-web/src/main/js/views/sql/sql.jade +++ b/modules/control-center-web/src/main/js/views/sql/sql.jade @@ -11,6 +11,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. + extends ../templates/layout append scripts @@ -27,7 +28,7 @@ block container .docs-header h1 Connect to Ignite and Execute SQL Queries hr - .docs-body(ng-controller='sqlController') + .docs-body(ng-controller='sqlController' ng-init='noteId = #{JSON.stringify(noteId)};') - var tab = 'tabs[tabs.activeIdx]' .block-callout-parent.block-callout-border.margin-bottom-dflt http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e24f3b74/modules/control-center-web/src/test/js/routes/agent.js ---------------------------------------------------------------------- diff --git a/modules/control-center-web/src/test/js/routes/agent.js b/modules/control-center-web/src/test/js/routes/agent.js new file mode 100644 index 0000000..c8bfd82 --- /dev/null +++ b/modules/control-center-web/src/test/js/routes/agent.js @@ -0,0 +1,94 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +var request = require('supertest'), + should = require('should'), + app = require('../../app'), + fs = require('fs'), + https = require('https'), + config = require('../../helpers/configuration-loader.js'), + agentManager = require('../../agents/agent-manager'); + +/** + * Create HTTP server. + */ +/** + * Start agent server. + */ +var agentServer = https.createServer({ + key: fs.readFileSync(config.get('monitor:server:key')), + cert: fs.readFileSync(config.get('monitor:server:cert')), + passphrase: config.get('monitor:server:keyPassphrase') +}); + +agentServer.listen(config.get('monitor:server:port')); + +agentManager.createManager(agentServer); + +describe('request from agent', function() { + var agent = request.agent(app); + + before(function (done) { + this.timeout(10000); + + agent + .post('/login') + .send({email: 'anovikov@gridgain.com', password: 'extHB2aXgb'}) + .expect(302) + .end(function (err) { + if (err) + throw err; + + setTimeout(done, 5000); + }); + }); + + it('should return topology snapshot', function(done){ + agent + .post('/agent/topology') + .send({}) + .end(function(err, nodes) { + if (err) { + console.log(err.response.text); + + throw err; + } + + console.log(nodes); + + done(); + }); + }); + + //it('should query result', function(done){ + // agent + // .post('/agent/query') + // .send({ + // username: 'nva', + // password: 'nva.141', + // host: 'localhost', + // port: '5432', + // dbName: 'ggmonitor' + // }) + // .end(function(err, res) { + // if (err) + // throw err; + // + // done(); + // }); + //}); +}); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e24f3b74/modules/nodejs/src/main/js/cluster-node.js ---------------------------------------------------------------------- diff --git a/modules/nodejs/src/main/js/cluster-node.js b/modules/nodejs/src/main/js/cluster-node.js index 940f123..7ef4fb3 100644 --- a/modules/nodejs/src/main/js/cluster-node.js +++ b/modules/nodejs/src/main/js/cluster-node.js @@ -15,15 +15,17 @@ * limitations under the License. */ - /** - * @constructor - * @this{ClusterNode} - * @param {string} nodeId Node id - * @param {Object.} attr Node Attributes - */ -function ClusterNode(nodeId, attr) { +/** + * @constructor + * @this{ClusterNode} + * @param {string} nodeId Node id + * @param {Object.} attr Node Attributes + * @param {Object.} caches Node caches name, mode + */ +function ClusterNode(nodeId, attr, caches) { this._nodeId = nodeId; this._attr = attr; + this._caches = caches; } /** @@ -40,4 +42,11 @@ ClusterNode.prototype.attributes = function() { return this._attr; } +/** + * @returns {Object.} Node caches name, mode + */ +ClusterNode.prototype.caches = function() { + return this._caches; +} + exports.ClusterNode = ClusterNode \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e24f3b74/modules/nodejs/src/main/js/ignite.js ---------------------------------------------------------------------- diff --git a/modules/nodejs/src/main/js/ignite.js b/modules/nodejs/src/main/js/ignite.js index 5b68c23..47facc0 100644 --- a/modules/nodejs/src/main/js/ignite.js +++ b/modules/nodejs/src/main/js/ignite.js @@ -129,9 +129,8 @@ Ignite.prototype.cluster = function() { else { var nodes = []; - for (var node of res) { - nodes.push(new ClusterNode(node.nodeId, node.attributes)); - } + for (var node of res) + nodes.push(new ClusterNode(node.nodeId, node.attributes, node.caches)); resolve(nodes); } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e24f3b74/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/GridJettyJsonConfig.java ---------------------------------------------------------------------- diff --git a/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/GridJettyJsonConfig.java b/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/GridJettyJsonConfig.java index e36da80..ad6ee22 100644 --- a/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/GridJettyJsonConfig.java +++ b/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/GridJettyJsonConfig.java @@ -39,6 +39,9 @@ public class GridJettyJsonConfig extends JsonConfig { private static class ToStringJsonProcessor implements JsonValueProcessor { /** {@inheritDoc} */ @Override public Object processArrayValue(Object val, JsonConfig jsonCfg) { + if (val != null && val.getClass() == UUID.class) + return val.toString(); + throw new UnsupportedOperationException("Serialize array to string is not supported: " + val); } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e24f3b74/modules/web-control-center/src/main/js/agents/agent-manager.js ---------------------------------------------------------------------- diff --git a/modules/web-control-center/src/main/js/agents/agent-manager.js b/modules/web-control-center/src/main/js/agents/agent-manager.js deleted file mode 100644 index 10d3a56..0000000 --- a/modules/web-control-center/src/main/js/agents/agent-manager.js +++ /dev/null @@ -1,283 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -var WebSocketServer = require('ws').Server; - -var apacheIgnite = require('apache-ignite'); - -var db = require('../db'); - -var AgentServer = require('./agent-server').AgentServer; - -/** - * @constructor - */ -function AgentManager(srv) { - this._clients = {}; - - this._server = srv; - - this._wss = new WebSocketServer({ server: this._server }); - - var self = this; - - this._wss.on('connection', function(ws) { - var client = new Client(ws, self); - }); -} - -/** - * @param userId - * @param {Client} client - */ -AgentManager.prototype._removeClient = function(userId, client) { - var connections = this._clients[userId]; - - if (connections) { - removeFromArray(connections, client); - - if (connections.length == 0) - delete this._clients[userId]; - } -}; - -/** - * @param userId - * @param {Client} client - */ -AgentManager.prototype._addClient = function(userId, client) { - var existingConnections = this._clients[userId]; - - if (!existingConnections) { - existingConnections = []; - - this._clients[userId] = existingConnections; - } - - existingConnections.push(client); -}; - -/** - * @param userId - * @return {Client} - */ -AgentManager.prototype.findClient = function(userId) { - var clientsList = this._clients[userId]; - - if (!clientsList) - return null; - - return clientsList[0]; -}; - -/** - * For tests only!!! - * @return {Client} - */ -AgentManager.prototype.getOneClient = function() { - for (var userId in this._clients) { - if (this._clients.hasOwnProperty(userId)) { - var m = this._clients[userId]; - - if (m.length > 0) - return m[0]; - } - } - - return null; -}; - - -/** - * @constructor - * @param {AgentManager} manager - * @param {WebSocket} ws - */ -function Client(ws, manager) { - var self = this; - - this._manager = manager; - this._ws = ws; - - ws.on('close', function() { - if (self.user) { - self._manager._removeClient(self.user._id, self); - } - }); - - ws.on('message', function (msg) { - self._handleMessage(JSON.parse(msg)) - }); - - this._restCounter = 0; - - this._cbMap = {}; -} - -/** - * @param {String|Object} msg - * @param {Function} cb - */ -Client.prototype.sendMessage = function(msg, cb) { - if (typeof msg == 'object') { - msg = JSON.stringify(msg); - } - - this._ws.send(msg, cb); -}; - -/** - * @param {String} path - * @param {Object} params - * @param {Function} cb - * @param {String} method - * @param {String} body - * @param {Object} headers - */ -Client.prototype.invokeRest = function(path, params, cb, method, body, headers) { - var self = this; - - if (typeof(params) != 'object') - throw "'params' argument must be an object"; - - if (typeof(cb) != 'function') - throw "callback must be a function"; - - if (body && typeof(body) != 'string') - throw "body must be a string"; - - if (headers && typeof(headers) != 'object') - throw "headers must be an object"; - - if (!method) - method = 'GET'; - else - method = method.toUpperCase(); - - if (method != 'GET' && method != 'POST') - throw "Unknown HTTP method: " + method; - - var reqId = this._restCounter++; - - this._cbMap[reqId] = cb; - - this.sendMessage({ - id: reqId, - type: 'RestRequest', - method: method, - params: params, - path: path, - body: body, - headers: headers - }, function(err) { - if (err) { - delete self._cbMap[reqId]; - - cb(err) - } - }) -}; - -/** - * @param {Object} msg - */ -Client.prototype._handleMessage = function(msg) { - var self = this; - - switch (msg.type) { - case 'AuthMessage': - var account = db.Account.findByUsername(msg.login, function(err, account) { - if (err) { - ws.send("{type: 'AuthResult', success: false}"); - } - else { - account.authenticate(msg.password, function(err, user, res) { - if (!user) { - self._ws.send(JSON.stringify({type: 'AuthResult', success: false, message: res.message})); - } - else { - self._ws.send("{type: 'AuthResult', success: true}"); - - self._user = account; - - self._manager._addClient(account._id, self); - - self._ignite = new apacheIgnite.Ignite(new AgentServer(self)); - } - }); - } - }); - - break; - - case 'RestResult': - var cb = this._cbMap[msg.requestId]; - - if (!cb) - break; - - delete this._cbMap[msg.requestId]; - - if (!msg.executed) { - cb(msg.message) - } - else { - cb(null, msg.code, msg.message) - } - - break; - - default: - this._ws.close() - } -}; - -/** - * @return {Ignite} - */ -Client.prototype.ignite = function() { - return this._ignite; -}; - -function removeFromArray(arr, val) { - var idx; - - while ((idx = arr.indexOf(val)) !== -1) { - arr.splice(idx, 1); - } -} - -exports.AgentManager = AgentManager; - -/** - * @type {AgentManager} - */ -var manager = null; - -exports.createManager = function(srv) { - if (manager) - throw "Agent manager already cleared!"; - - manager = new AgentManager(srv); -}; - -/** - * @return {AgentManager} - */ -exports.getAgentManager = function() { - return manager; -}; http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e24f3b74/modules/web-control-center/src/main/js/agents/agent-server.js ---------------------------------------------------------------------- diff --git a/modules/web-control-center/src/main/js/agents/agent-server.js b/modules/web-control-center/src/main/js/agents/agent-server.js deleted file mode 100644 index 31dee5a..0000000 --- a/modules/web-control-center/src/main/js/agents/agent-server.js +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * Creates an instance of server for Ignite - * - * @constructor - * @this {AgentServer} - * @param {Client} client connected client - */ -function AgentServer(client) { - this._client = client; -} - -/** - * Run http request - * - * @this {AgentServer} - * @param {Command} cmd Command - * @param {callback} callback on finish - */ -AgentServer.prototype.runCommand = function(cmd, callback) { - var params = {cmd: cmd.name()}; - - for (var p of cmd._params) { - params[p.key] = p.value; - } - - var body = undefined; - - var headers = undefined; - - if (cmd._isPost()) { - body = cmd.postData(); - - headers = {'Content-Length': body.length, 'JSONObject': 'application/json'}; - } - - this._client.invokeRest("ignite", params, function(error, code, message) { - if (error) { - callback(error); - return - } - - if (code !== 200) { - if (code === 401) { - callback.call(null, "Authentication failed. Status code 401."); - } - else { - callback.call(null, "Request failed. Status code " + code); - } - - return; - } - - var igniteResponse; - - try { - igniteResponse = JSON.parse(message); - } - catch (e) { - callback.call(null, e, null); - - return; - } - - if (igniteResponse.successStatus) { - callback.call(null, igniteResponse.error, null) - } - else { - callback.call(null, null, igniteResponse.response); - } - }, cmd._method(), body, headers); -}; - -exports.AgentServer = AgentServer; http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e24f3b74/modules/web-control-center/src/main/js/keys/test.crt ---------------------------------------------------------------------- diff --git a/modules/web-control-center/src/main/js/keys/test.crt b/modules/web-control-center/src/main/js/keys/test.crt deleted file mode 100644 index 50c6d5c..0000000 --- a/modules/web-control-center/src/main/js/keys/test.crt +++ /dev/null @@ -1,13 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIB6zCCAVQCCQDcAphbU6UcLjANBgkqhkiG9w0BAQsFADA6MRIwEAYDVQQDDAls -b2NhbGhvc3QxJDAiBgkqhkiG9w0BCQEWFXNldmRva2ltb3ZAYXBhY2hlLm9yZzAe -Fw0xNTA3MTQxMzAyNTNaFw0xODA2MjMxMzAyNTNaMDoxEjAQBgNVBAMMCWxvY2Fs -aG9zdDEkMCIGCSqGSIb3DQEJARYVc2V2ZG9raW1vdkBhcGFjaGUub3JnMIGfMA0G -CSqGSIb3DQEBAQUAA4GNADCBiQKBgQDP/zpJrdHqCj6lPpeFF6LQtzKef6UiyBBo -rbuOtCCgW8KMJJciluBWk2126qLt9smBN4jBpSNU3pq0r9gBMUTd/LSe7aY4D5ED -Pjp7XsypNVKeHaHbFi7KhfHy0LYxsWiNPmmHJv4dtYOp+pGK25rkXNfyJxxjgxN6 -wo34+MnZIQIDAQABMA0GCSqGSIb3DQEBCwUAA4GBAFk9XEjcdyihws+fVmdGGUFo -bVxI9YGH6agiNbU3WNF4B4VRzcPPW8z2mEo7eF9kgYmq/YzH4T8tgi/qkL/u8eZV -Wmi9bg6RThLN6/hj3wVoOFKykbDQ05FFdhIJXN5UOjPmxYM97EKqg6J0W2HAb8SG -+UekPnmAo/2HTKsLykH8 ------END CERTIFICATE----- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e24f3b74/modules/web-control-center/src/main/js/keys/test.key ---------------------------------------------------------------------- diff --git a/modules/web-control-center/src/main/js/keys/test.key b/modules/web-control-center/src/main/js/keys/test.key deleted file mode 100644 index 1b395c0..0000000 --- a/modules/web-control-center/src/main/js/keys/test.key +++ /dev/null @@ -1,18 +0,0 @@ ------BEGIN RSA PRIVATE KEY----- -Proc-Type: 4,ENCRYPTED -DEK-Info: DES-EDE3-CBC,6798185330CE2EE2 - -sOwkmD8rvjx11l09V26dJhLhl+SyPIhyeZ3TqHXrYCATKoXlzidT+uPu1jVYtrwr -nBLA6TrIDYRrBNlEsqGZ0cSvWTIczzVW1xZKHEJo5q2vUT/W8u/Q1QQtS3P3GeKF -dEzx496rpZqwwVw59GNbuIwyYoVvQf3iEXzfhplGmLPELYIplDFOLgNuXQyXSGx6 -rwKsCxXMLsDyrA6DCz0Odf08p2HvWk/s5Ne3DFcQlqRNtIrBVGD2O0/Fp8ZZ2I4E -Yn2OIIWJff3HanOjLOWKdN8YAn5UleNmlEUdIHeS5qaQ68mabOxLkSef9qglV+sd -FHTtUq0cG6t6nhxZBziexha6v1yl/xABAHHhNPOfak+HthWxRD4N9f1yFYAeTmkn -4kwBWoSUe12XRf2pGNqhEUKN/KhDmWk85wI55i/Cu2XmNoiBFlS9BXrRYU8uVCJw -KlxjKTDWl1opCyvxTDxJnMkt44ZT445LRePKVueGIIKSUIXNQypOE+C1I0CL0N2W -Ts3m9nthquvLeMx92k7b8yW69BER5uac3SIlGCOJObQXsHgyk8wYiyd/zLKfjctG -PXieaW81UKjp+GqWpvWPz3VqnKwoyUWeVOOTviurli6kYOrHuySTMqMb6hxJctw9 -grAQTT0UPiAKWcM7InLzZnRjco+v9QLLEokjVngXPba16K/CItFY16xuGlaFLW7Y -XTc67AkL8b76HBZelMjmCsqjvSoULhuMFwTOvUMm/mSM8rMoi9asrJRLQHRMWCST -/6RENPLzPlOMnNLBujpBbn8V3/aYzEZsHMI+6S3d27WYlTJIqpabSA== ------END RSA PRIVATE KEY----- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e24f3b74/modules/web-control-center/src/main/js/routes/agent.js ---------------------------------------------------------------------- diff --git a/modules/web-control-center/src/main/js/routes/agent.js b/modules/web-control-center/src/main/js/routes/agent.js deleted file mode 100644 index 4646c28..0000000 --- a/modules/web-control-center/src/main/js/routes/agent.js +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -var router = require('express').Router(); -var agentManager = require('../agents/agent-manager'); - -var apacheIgnite = require('apache-ignite'); -var SqlFieldsQuery = apacheIgnite.SqlFieldsQuery; - -/* GET summary page. */ -router.post('/topology', function(req, res) { - var client = agentManager.getAgentManager().getOneClient(); - - if (!client) - return res.status(500).send("Client not found"); - - client.ignite().cluster().then(function (clusters) { - res.json(clusters.map(function (cluster) { - var caches = Object.keys(cluster._caches).map(function(key) { - return {"name" : key, "mode" : cluster._caches[key] } - }); - - return { nodeId: cluster._nodeId, caches: caches }; - })); - }, function (err) { - res.send(err); - }); -}); - -/* GET summary page. */ -router.post('/query', function(req, res) { - var client = agentManager.getAgentManager().getOneClient(); - - if (!client) - return res.status(500).send("Client not found"); - - // Create sql query. - var qry = new SqlFieldsQuery(req.body.query); - - // Set page size for query. - qry.setPageSize(req.body.pageSize); - - // Get query cursor. - client.ignite().cache(req.body.cacheName).query(qry).nextPage().then(function (cursor) { - res.json({meta: cursor.fieldsMetadata(), rows: cursor.page(), queryId: cursor.queryId()}); - }, function (err) { - res.status(500).send(err); - }); -}); - -/* GET summary page. */ -router.post('/next_page', function(req, res) { - var client = agentManager.getAgentManager().getOneClient(); - - if (!client) - return res.status(500).send("Client not found"); - - var cache = client.ignite().cache(req.body.cacheName); - - var cmd = cache._createCommand("qryfetch").addParam("qryId", req.body.queryId). - addParam("psz", req.body.pageSize); - - cache.__createPromise(cmd).then(function (page) { - res.json({rows: page["items"], last: page === null || page["last"]}); - }, function (err) { - res.status(500).send(err); - }); -}); - -module.exports = router; http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e24f3b74/modules/web-control-center/src/test/js/routes/agent.js ---------------------------------------------------------------------- diff --git a/modules/web-control-center/src/test/js/routes/agent.js b/modules/web-control-center/src/test/js/routes/agent.js deleted file mode 100644 index 6a7fa2c..0000000 --- a/modules/web-control-center/src/test/js/routes/agent.js +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -var request = require('supertest'), - should = require('should'), - app = require('../../app'), - fs = require('fs'), - https = require('https'), - config = require('../../helpers/configuration-loader.js'), - agentManager = require('../../agents/agent-manager'); - -/** - * Create HTTP server. - */ -/** - * Start agent server. - */ -var agentServer = https.createServer({ - key: fs.readFileSync(config.get('monitor:server:key')), - cert: fs.readFileSync(config.get('monitor:server:cert')), - passphrase: config.get('monitor:server:keyPassphrase') -}); - -agentServer.listen(config.get('monitor:server:port')); - -agentManager.createManager(agentServer); - -describe('request from agent', function() { - var agent = request.agent(app); - - before(function (done) { - this.timeout(10000); - - agent - .post('/login') - .send({email: 'anovikov@gridgain.com', password: 'extHB2aXgb'}) - .expect(302) - .end(function (err) { - if (err) - throw err; - - setTimeout(done, 5000); - }); - }); - - it('should return topology snapshot', function(done){ - agent - .post('/agent/topology') - .send({}) - .end(function(err, nodes) { - if (err) { - console.log(err.response.text); - - throw err; - } - - console.log(nodes); - - done(); - }); - }); - - //it('should query result', function(done){ - // agent - // .post('/agent/query') - // .send({ - // username: 'nva', - // password: 'nva.141', - // host: 'localhost', - // port: '5432', - // dbName: 'ggmonitor' - // }) - // .end(function(err, res) { - // if (err) - // throw err; - // - // done(); - // }); - //}); -}); \ No newline at end of file