You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by an...@apache.org on 2015/10/19 13:22:25 UTC

ignite git commit: IGNITE-1673 Show proper message if node missing on sql.

Repository: ignite
Updated Branches:
  refs/heads/ignite-843-rc1 7fc27c0d7 -> 7c5c2df74


IGNITE-1673 Show proper message if node missing on sql.


Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/7c5c2df7
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/7c5c2df7
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/7c5c2df7

Branch: refs/heads/ignite-843-rc1
Commit: 7c5c2df74d3a22dd7680bfe5aea34034e18bbb99
Parents: 7fc27c0
Author: Andrey <an...@gridgain.com>
Authored: Mon Oct 19 18:22:43 2015 +0700
Committer: Andrey <an...@gridgain.com>
Committed: Mon Oct 19 18:22:43 2015 +0700

----------------------------------------------------------------------
 .../ignite/agent/handlers/RestExecutor.java     |  6 ++
 .../src/main/js/agents/agent-server.js          | 10 ++-
 .../src/main/js/controllers/common-module.js    | 71 ++++++++++++--------
 .../main/js/controllers/metadata-controller.js  |  5 +-
 .../src/main/js/controllers/sql-controller.js   | 29 +++-----
 .../src/main/js/routes/agent.js                 |  4 +-
 .../main/js/views/templates/agent-download.jade | 26 ++++---
 7 files changed, 87 insertions(+), 64 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/7c5c2df7/modules/control-center-agent/src/main/java/org/apache/ignite/agent/handlers/RestExecutor.java
----------------------------------------------------------------------
diff --git a/modules/control-center-agent/src/main/java/org/apache/ignite/agent/handlers/RestExecutor.java b/modules/control-center-agent/src/main/java/org/apache/ignite/agent/handlers/RestExecutor.java
index 2cd8d61..2d4d154 100644
--- a/modules/control-center-agent/src/main/java/org/apache/ignite/agent/handlers/RestExecutor.java
+++ b/modules/control-center-agent/src/main/java/org/apache/ignite/agent/handlers/RestExecutor.java
@@ -19,6 +19,7 @@ package org.apache.ignite.agent.handlers;
 
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
+import java.net.ConnectException;
 import java.net.URISyntaxException;
 import java.nio.charset.Charset;
 import java.util.List;
@@ -157,6 +158,11 @@ public class RestExecutor {
 
             return new RestResult(resp.getStatusLine().getStatusCode(), new String(out.toByteArray(), charset));
         }
+        catch (ConnectException e) {
+            log.log(Level.FINE, "Failed connect to node and execute REST command [uri=" + builder.build() + "]");
+
+            return new RestResult(404, "Failed connect to node and execute REST command.");
+        }
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/7c5c2df7/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
index 2efe531..76bdeb4 100644
--- a/modules/control-center-web/src/main/js/agents/agent-server.js
+++ b/modules/control-center-web/src/main/js/agents/agent-server.js
@@ -63,12 +63,10 @@ AgentServer.prototype.runCommand = function(cmd, callback) {
         }
 
         if (code !== 200) {
-            if (code === 401) {
-                callback.call(null, "Authentication failed. Status code 401.");
-            }
-            else {
-                callback.call(null, "Request failed. Status code " + code);
-            }
+            if (code === 401)
+                callback.call(null, "Authentication failed. Status code: 401.");
+            else
+                callback.call(null, (message ? message : "Request failed.") +  " Status code: " + code);
 
             return;
         }

http://git-wip-us.apache.org/repos/asf/ignite/blob/7c5c2df7/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 908415f..1330cbd 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
@@ -1942,8 +1942,6 @@ consoleModule.controller('agent-download', [
         // Pre-fetch modal dialogs.
         var _agentDownloadModal = $modal({scope: $scope, templateUrl: '/agent/download', show: false, backdrop: 'static'});
 
-        _agentDownloadModal.skipDialogShowing = false;
-
         var _agentDownloadHide = _agentDownloadModal.hide;
 
         /**
@@ -1952,19 +1950,17 @@ consoleModule.controller('agent-download', [
         _agentDownloadModal.hide = function () {
             $common.hideAlert();
 
-            _agentDownloadModal.skipDialogShowing = true;
-
             _agentDownloadHide();
         };
 
         /**
          * Close dialog and go by specified link.
          */
-        $scope.goHome = function () {
-            if ($window.location == _agentDownloadModal.homeLink)
+        $scope.goBack = function () {
+            if ($window.location == _agentDownloadModal.backLink)
                 $window.location.reload();
             else
-                $window.location = _agentDownloadModal.homeLink;
+                $window.location = _agentDownloadModal.backLink;
 
             $scope.checkConnection = false;
 
@@ -1991,27 +1987,26 @@ consoleModule.controller('agent-download', [
          * @param status Error code.
          */
         var _handleException = function (errMsg, status) {
-            if (_agentDownloadModal.skipDialogShowing)
-                _agentDownloadModal.skipDialogShowing = false;
+            if (_agentDownloadModal.skipSingleError)
+                _agentDownloadModal.skipSingleError = false;
             else if (!_agentDownloadModal.$isShown)
                 _agentDownloadModal.$promise.then(_agentDownloadModal.show);
 
-            if (status != 503)
+            $scope.nodeFailedConnection = status == 404;
+
+            if (status == 500)
                 $common.showError(errMsg, 'top-right', 'body', true);
         };
 
         /**
          * Start interval to agent listening.
-         *
-         * @param skipFirst If <code>true</code> first invoke will be missed.
          */
-        function _startInterval(skipFirst) {
+        function _startInterval() {
             _agentDownloadModal.updatePromise = $interval(function () {
                 _tryWithAgent();
             }, 5000, 0, false);
 
-            if (!skipFirst)
-                _tryWithAgent();
+            _tryWithAgent();
         }
 
         /**
@@ -2025,16 +2020,16 @@ consoleModule.controller('agent-download', [
          * Try to access agent and execute specified function.
          */
         function _tryWithAgent() {
-            $http.post('/agent/ping', undefined, {timeout: 3000})
-                .success(function () {
-                    _agentDownloadModal.skipDialogShowing = true;
+            $http.post(_agentDownloadModal.checkUrl, undefined, {timeout: 3000})
+                .success(function (result) {
+                    _agentDownloadModal.skipSingleError = true;
 
                     _agentDownloadModal.hide();
 
-                    if (_agentDownloadModal.simpleExecution)
+                    if (_agentDownloadModal.awaitFirstSuccess)
                         _stopInterval();
 
-                    _agentDownloadModal.checkFn(_agentDownloadModal.hide, _handleException);
+                    _agentDownloadModal.checkFn(result, _agentDownloadModal.hide, _handleException);
                 })
                 .error(function (errMsg, status) {
                     _handleException(errMsg, status);
@@ -2042,20 +2037,42 @@ consoleModule.controller('agent-download', [
         }
 
         /**
-         * Start listening of agent by ping.
+         * Start awaiting agent start using ping.
          *
          * @param checkFn Function to execute by timer when agent available.
-         * @param simpleExecution When <code>true</code> checkFn will invoke to first success only.
-         * @param homeLink Link to move on "Back to configuration" button click.
          */
-        $scope.startAgentListening = function (checkFn, simpleExecution, homeLink) {
-            _agentDownloadModal.skipDialogShowing = false;
+        $scope.awaitAgent = function (checkFn) {
+            _agentDownloadModal.skipSingleError = false;
+
+            _agentDownloadModal.checkUrl = '/agent/ping';
+
+            _agentDownloadModal.checkFn = checkFn;
+
+            // Stop refresh after first success.
+            _agentDownloadModal.awaitFirstSuccess = true;
+
+            _agentDownloadModal.backLink = '/configuration/metadata';
+
+            $scope.agentDownloadBackTo = 'Metadata';
+
+            _startInterval();
+        };
+
+        /**
+         * Start listening topology from node.
+         *
+         * @param checkFn Function to execute by timer when agent available.
+         */
+        $scope.startTopologyListening = function (checkFn) {
+            _agentDownloadModal.skipSingleError = false;
+
+            _agentDownloadModal.checkUrl = '/agent/topology';
 
             _agentDownloadModal.checkFn = checkFn;
 
-            _agentDownloadModal.simpleExecution = simpleExecution;
+            _agentDownloadModal.backLink = '/';
 
-            _agentDownloadModal.homeLink = homeLink || '/';
+            $scope.agentDownloadBackTo = 'Configuration';
 
             _startInterval();
         };

http://git-wip-us.apache.org/repos/asf/ignite/blob/7c5c2df7/modules/control-center-web/src/main/js/controllers/metadata-controller.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/controllers/metadata-controller.js b/modules/control-center-web/src/main/js/controllers/metadata-controller.js
index ad5883e..2c0cdfa 100644
--- a/modules/control-center-web/src/main/js/controllers/metadata-controller.js
+++ b/modules/control-center-web/src/main/js/controllers/metadata-controller.js
@@ -33,7 +33,6 @@ consoleModule.controller('metadataController', [
 
             $scope.agentGoal = 'load metadata from database schema';
             $scope.agentTestDriveOption = '--test-drive-metadata';
-            $scope.agentDownloadBackTo = 'Metadata';
 
             $scope.joinTip = $common.joinTip;
             $scope.getModel = $common.getModel;
@@ -257,7 +256,7 @@ consoleModule.controller('metadataController', [
                 $scope.loadMeta.action = 'drivers';
                 $scope.loadMeta.loadingOptions = LOADING_JDBC_DRIVERS;
 
-                $scope.startAgentListening(function (onSuccess, onException) {
+                $scope.awaitAgent(function (result, onSuccess, onException) {
                     loadMetaModal.show();
 
                     $loading.start('loadingMetadataFromDb');
@@ -303,7 +302,7 @@ consoleModule.controller('metadataController', [
                                 $loading.finish('loadingMetadataFromDb');
                             });
                     }
-                }, true, '/configuration/metadata');
+                });
             };
 
             function _loadSchemas() {

http://git-wip-us.apache.org/repos/asf/ignite/blob/7c5c2df7/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 2a3f123..8d91abd 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
@@ -24,7 +24,6 @@ consoleModule.controller('sqlController',
 
     $scope.agentGoal = 'execute sql statements';
     $scope.agentTestDriveOption = '--test-drive-sql';
-    $scope.agentDownloadBackTo = 'Configuration';
 
     $scope.joinTip = $common.joinTip;
 
@@ -197,7 +196,7 @@ consoleModule.controller('sqlController',
                 if (!notebook.paragraphs || notebook.paragraphs.length == 0)
                     $scope.addParagraph();
 
-                $scope.startAgentListening(getTopology);
+                $scope.startTopologyListening(getTopology);
             })
             .error(function () {
                 $scope.notebook = undefined;
@@ -350,27 +349,21 @@ consoleModule.controller('sqlController',
             });
     };
 
-    function getTopology(onSuccess, onException) {
-        $http.post('/agent/topology')
-            .success(function (caches) {
-                onSuccess();
+    function getTopology(caches, onSuccess) {
+        onSuccess();
 
-                var oldCaches = $scope.caches;
+        var oldCaches = $scope.caches;
 
-                $scope.caches = _.sortBy(caches, 'name');
+        $scope.caches = _.sortBy(caches, 'name');
 
-                _.forEach(caches, function (cache) {
-                    var old = _.find(oldCaches, { name: cache.name });
+        _.forEach(caches, function (cache) {
+            var old = _.find(oldCaches, { name: cache.name });
 
-                    if (old && old.metadata)
-                        cache.metadata = old.metadata;
-                });
+            if (old && old.metadata)
+                cache.metadata = old.metadata;
+        });
 
-                _setActiveCache();
-            })
-            .error(function (err, status) {
-                onException(err, status);
-            });
+        _setActiveCache();
     }
 
     var _columnFilter = function(paragraph) {

http://git-wip-us.apache.org/repos/asf/ignite/blob/7c5c2df7/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
index 7d1592f..3c6c55d 100644
--- a/modules/control-center-web/src/main/js/routes/agent.js
+++ b/modules/control-center-web/src/main/js/routes/agent.js
@@ -98,7 +98,9 @@ router.post('/topology', function (req, res) {
                 return cache.name;
             }));
         }, function (err) {
-            res.status(500).send(err);
+            var mStatusCode = /.*Status code:\s+(\d+)(?:\s|$)/g.exec(err);
+
+            res.status(mStatusCode[1] ? mStatusCode[1] : 500).send(err);
         });
     }
 });

http://git-wip-us.apache.org/repos/asf/ignite/blob/7c5c2df7/modules/control-center-web/src/main/js/views/templates/agent-download.jade
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/views/templates/agent-download.jade b/modules/control-center-web/src/main/js/views/templates/agent-download.jade
index c0ee9b0..a692b0e 100644
--- a/modules/control-center-web/src/main/js/views/templates/agent-download.jade
+++ b/modules/control-center-web/src/main/js/views/templates/agent-download.jade
@@ -16,25 +16,23 @@
     .modal-dialog
         .modal-content
             #errors-container.modal-header.header
-                h4.modal-title Connection to Ignite Web Agent is not established
-            .agent-download
+                h4.modal-title(ng-if='!nodeFailedConnection') Connection to Ignite Web Agent is not established
+                h4.modal-title(ng-if='nodeFailedConnection') Connection to Ignite Node is not established
+            .agent-download(ng-if='!nodeFailedConnection')
                 p Please download and run&nbsp;
                     a(href='javascript:void(0)' ng-click='downloadAgent()') ignite-web-agent
-                    | &nbsp;in order to {{::agentGoal}}.
+                    | &nbsp;in order to {{::agentGoal}}
                 p For installation:
                 ul
                     li Download and unzip&nbsp;
                         b ignite-web-agent
-                        | .
                     li For list of options, run&nbsp;
                         b ignite-web-agent.{sh|bat} --help
-                        | .
                     li To test drive, run&nbsp;
                         b ignite-web-agent.{sh|bat} {{::agentTestDriveOption}}
-                        | .
                     li Refer to&nbsp;
                         b README.txt
-                        | &nbsp;for more information.
+                        | &nbsp;for more information
                 .modal-advanced-options
                     i.fa.fa-chevron-circle-up(ng-show='agentLoad.showToken' ng-click='agentLoad.showToken = ! agentLoad.showToken')
                     i.fa.fa-chevron-circle-down(ng-show='!agentLoad.showToken' ng-click='agentLoad.showToken = ! agentLoad.showToken')
@@ -43,6 +41,16 @@
                     label.labelField Security token: {{user.token}}
                     i.tipLabel.fa.fa-clipboard(ng-click-copy='{{user.token}}' bs-tooltip='' data-title='Copy security token to clipboard')
                     i.tipLabel.fa.fa-question-circle(ng-if=lines bs-tooltip='' data-title='The security token is used for authorization of web agent')
+            .agent-download(ng-if='nodeFailedConnection')
+                p Connection to Ignite Web Agent is established but agent failed to connect to Ignite Node
+                p Please check the following:
+                ul
+                    li Ignite Grid is up and running
+                    li In agent settings check URI for connect to Ignite REST server
+                    li Check agent logs for errors
+                    li Refer to&nbsp;
+                        b README.txt
+                        | &nbsp; in agent folder for more information
             .modal-footer
-                button.btn.btn-default(ng-click='goHome()') Back to {{::agentDownloadBackTo}}
-                button.btn.btn-primary(ng-click='downloadAgent()') Download zip
+                button.btn.btn-default(ng-click='goBack()') Back to {{::agentDownloadBackTo}}
+                button.btn.btn-primary(ng-if='!nodeFailedConnection' ng-click='downloadAgent()') Download zip