You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ea...@apache.org on 2017/06/26 17:36:25 UTC
[1/2] qpid-dispatch git commit: DISPATCH-747 Better handling of
connection errors
Repository: qpid-dispatch
Updated Branches:
refs/heads/master 2871701b5 -> 36766377d
DISPATCH-747 Better handling of connection errors
Project: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/commit/303c3973
Tree: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/tree/303c3973
Diff: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/diff/303c3973
Branch: refs/heads/master
Commit: 303c3973d602db20f74e4feabb4438d36c7c4469
Parents: 2871701
Author: Ernest Allen <ea...@redhat.com>
Authored: Mon Jun 26 13:34:19 2017 -0400
Committer: Ernest Allen <ea...@redhat.com>
Committed: Mon Jun 26 13:34:19 2017 -0400
----------------------------------------------------------------------
.../hawtio/src/main/webapp/plugin/js/qdrList.js | 13 ++--
.../src/main/webapp/plugin/js/qdrOverview.js | 10 ++--
.../src/main/webapp/plugin/js/qdrTopology.js | 9 +--
console/stand-alone/plugin/js/dispatchPlugin.js | 60 ++++++++++---------
console/stand-alone/plugin/js/qdrList.js | 12 ++--
console/stand-alone/plugin/js/qdrService.js | 62 ++++++++++++--------
console/stand-alone/plugin/js/qdrSettings.js | 33 +++++++----
console/stand-alone/plugin/js/qdrTopology.js | 13 ++--
8 files changed, 123 insertions(+), 89 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/303c3973/console/hawtio/src/main/webapp/plugin/js/qdrList.js
----------------------------------------------------------------------
diff --git a/console/hawtio/src/main/webapp/plugin/js/qdrList.js b/console/hawtio/src/main/webapp/plugin/js/qdrList.js
index 90426cd..835e938 100644
--- a/console/hawtio/src/main/webapp/plugin/js/qdrList.js
+++ b/console/hawtio/src/main/webapp/plugin/js/qdrList.js
@@ -142,10 +142,10 @@ var QDR = (function(QDR) {
return;
}
// we are currently connected. setup a handler to get notified if we are ever disconnected
- QDRService.addDisconnectAction( function () {
- QDRService.redirectWhenConnected("list")
- $scope.$apply();
- })
+ var onDisconnect = function () {
+ $timeout(function () { QDRService.redirectWhenConnected("list") })
+ }
+ QDRService.addDisconnectAction( onDisconnect )
$scope.nodes = []
var excludedEntities = ["management", "org.amqp.management", "operationalEntity", "entity", "configurationEntity", "dummy", "console"];
@@ -633,6 +633,7 @@ var QDR = (function(QDR) {
$scope.$on("$destroy", function( event ) {
//QDR.log.debug("scope destroyed for qdrList");
stopUpdating();
+ QDRService.delDisconnectAction( onDisconnect )
});
function gotMethodResponse (nodeName, entity, response, context) {
@@ -708,7 +709,7 @@ var QDR = (function(QDR) {
var serviceReady = false;
$scope.largeNetwork = QDRService.isLargeNetwork()
$scope.showExpandCollapseTree = function () {
- QDR.log.info("showExpandCollapseTree returning " + !QDRService.isMSIE())
+ //QDR.log.info("showExpandCollapseTree returning " + !QDRService.isMSIE())
return !QDRService.isMSIE()
}
// called after we know for sure the schema is fetched and the routers are all ready
@@ -719,7 +720,7 @@ var QDR = (function(QDR) {
$scope.nodes = QDRService.nodeList().sort(function (a, b) { return a.name.toLowerCase() > b.name.toLowerCase()});
// unable to get node list? Bail.
if ($scope.nodes.length == 0) {
- $location.path("/" + QDR.pluginName + "/connect")
+ $location.path(QDR.pluginRoot + "/connect")
$location.search('org', "list");
}
if (!angular.isDefined($scope.selectedNode)) {
http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/303c3973/console/hawtio/src/main/webapp/plugin/js/qdrOverview.js
----------------------------------------------------------------------
diff --git a/console/hawtio/src/main/webapp/plugin/js/qdrOverview.js b/console/hawtio/src/main/webapp/plugin/js/qdrOverview.js
index e17f6e2..93dc0c6 100644
--- a/console/hawtio/src/main/webapp/plugin/js/qdrOverview.js
+++ b/console/hawtio/src/main/webapp/plugin/js/qdrOverview.js
@@ -1384,9 +1384,10 @@ QDR.log.debug("setting linkFields to [] in selectMode")
}
// we are currently connected. setup a handler to get notified if we are ever disconnected
- QDRService.addDisconnectAction( function () {
- $timeout( function () {QDRService.redirectWhenConnected("overview")} )
- })
+ var onDisconnect = function () {
+ $timeout(function () { QDRService.redirectWhenConnected("overview") })
+ }
+ QDRService.addDisconnectAction( onDisconnect )
/* --------------------------------------------------
*
@@ -1665,8 +1666,7 @@ QDR.log.debug("newly created node needs to be activated")
initTreeAndGrid();
$scope.$on("$destroy", function( event ) {
clearTimeout(tickTimer)
- //QDRService.stopUpdating()
- //QDRService.delUpdatedAction("overview")
+ QDRService.delDisconnectAction( onDisconnect )
});
}]);
http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/303c3973/console/hawtio/src/main/webapp/plugin/js/qdrTopology.js
----------------------------------------------------------------------
diff --git a/console/hawtio/src/main/webapp/plugin/js/qdrTopology.js b/console/hawtio/src/main/webapp/plugin/js/qdrTopology.js
index edd59d5..871d0c8 100644
--- a/console/hawtio/src/main/webapp/plugin/js/qdrTopology.js
+++ b/console/hawtio/src/main/webapp/plugin/js/qdrTopology.js
@@ -292,10 +292,10 @@ QDR.log.debug("attr.description " + attr.description)
return;
}
// we are currently connected. setup a handler to get notified if we are ever disconnected
- QDRService.addDisconnectAction(function() {
- QDRService.redirectWhenConnected("topology");
- $scope.$apply();
- })
+ var onDisconnect = function () {
+ $timeout(function () { QDRService.redirectWhenConnected("topology") })
+ }
+ QDRService.addDisconnectAction( onDisconnect )
var urlPrefix = $location.absUrl();
urlPrefix = urlPrefix.split("#")[0]
@@ -2118,6 +2118,7 @@ QDR.log.debug("attr.description " + attr.description)
QDRService.stopUpdating();
QDRService.delUpdatedAction("normalsStats");
QDRService.delUpdatedAction("topology");
+ QDRService.delDisconnectAction( onDisconnect )
d3.select("#SVG_ID").remove();
window.removeEventListener('resize', resize);
});
http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/303c3973/console/stand-alone/plugin/js/dispatchPlugin.js
----------------------------------------------------------------------
diff --git a/console/stand-alone/plugin/js/dispatchPlugin.js b/console/stand-alone/plugin/js/dispatchPlugin.js
index 4b049f5..9bb3aa4 100644
--- a/console/stand-alone/plugin/js/dispatchPlugin.js
+++ b/console/stand-alone/plugin/js/dispatchPlugin.js
@@ -206,12 +206,10 @@ QDR.log.info("setting location.search to org=null")
}
QDR.queue = d3.queue;
- QDRService.initProton();
QDRService.addUpdatedAction("initChartService", function() {
QDRService.delUpdatedAction("initChartService")
QDRChartService.init(); // initialize charting service after we are connected
});
-
var settings = angular.fromJson(localStorage[QDR.SETTINGS_KEY]) || {autostart: false, address: 'localhost', port: 5673}
if (!QDRService.connected) {
// attempt to connect to the host:port that served this page
@@ -224,42 +222,48 @@ QDR.log.info("setting location.search to org=null")
QDR.log.info("was not connected. setting org to overview")
$location.search("org", "overview")
}
-
- QDRService.testConnect({address: host, port: port}, 10000, function (e) {
+ var connectOptions = {address: host, port: port}
+ QDRService.testConnect(connectOptions, 10000, function (e) {
if (e.error) {
- QDR.log.debug("failed to auto-connect to " + host + ":" + port)
+ QDR.log.info("failed to auto-connect to " + host + ":" + port)
// the connect page should rneder
$timeout(function () {
$location.path('/connect')
$location.search('org', org)
})
} else {
- QDRService.addConnectAction(function() {
- QDRService.getSchema(function () {
- QDR.log.debug("got schema after connection")
- QDRService.addUpdatedAction("initialized", function () {
- QDRService.delUpdatedAction("initialized")
- QDR.log.debug("got initial topology")
- $timeout(function() {
-QDR.log.info("after initialization org was " + org + " and location.path() was " + $location.path())
- if (org === '' || org === 'connect') {
- org = localStorage[QDR.LAST_LOCATION] || "/overview"
- if (org === '/')
- org = "/overview"
-QDR.log.info("after initialization org was loaded from localStorage and is now " + org)
+QDR.log.info("testConnect succeeded using address:port of browser")
+ QDRService.getSchema(function () {
+ QDR.log.debug("got schema after connection")
+ QDRService.addUpdatedAction("initialized", function () {
+ QDRService.delUpdatedAction("initialized")
+ QDR.log.debug("got initial topology")
+ $timeout(function() {
+ QDR.log.info("after initialization org was " + org + " and location.path() was " + $location.path())
+ if (org === '' || org === 'connect') {
+ org = localStorage[QDR.LAST_LOCATION] || "/overview"
+ if (org === '/')
+ org = "/overview"
+ QDR.log.info("after initialization org was loaded from localStorage and is now " + org)
+ } else {
+ if (org && $location.path() !== '/connect') {
+ org = $location.path().substr(1)
}
-QDR.log.info("after initialization going to " + org)
- $location.path(org)
- $location.search('org', null)
- $location.replace()
- })
+ }
+ QDR.log.info("after initialization going to " + org)
+ $location.path(org)
+ $location.search('org', null)
+ $location.replace()
})
- QDR.log.debug("requesting a topology")
- QDRService.setUpdateEntities([])
- QDRService.topology.get()
})
- });
- QDRService.connect(e)
+ QDR.log.info("requesting a topology")
+ QDRService.setUpdateEntities([])
+ QDRService.topology.get()
+ })
+ $timeout( function () {
+ QDR.log.info("calling connect")
+ QDRService.connect(e)
+ })
}
})
}
http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/303c3973/console/stand-alone/plugin/js/qdrList.js
----------------------------------------------------------------------
diff --git a/console/stand-alone/plugin/js/qdrList.js b/console/stand-alone/plugin/js/qdrList.js
index 727d0cb..b0c78d2 100644
--- a/console/stand-alone/plugin/js/qdrList.js
+++ b/console/stand-alone/plugin/js/qdrList.js
@@ -141,11 +141,14 @@ var QDR = (function(QDR) {
QDRService.redirectWhenConnected("list");
return;
}
+ var onDisconnect = function () {
+QDR.log.info("we were just disconnected while on the list page. Setting org to redirect back once we are connected again")
+ $timeout( function () {
+ QDRService.redirectWhenConnected("list")
+ })
+ }
// we are currently connected. setup a handler to get notified if we are ever disconnected
- QDRService.addDisconnectAction( function () {
- QDRService.redirectWhenConnected("list")
- $scope.$apply();
- })
+ QDRService.addDisconnectAction( onDisconnect )
$scope.nodes = []
var excludedEntities = ["management", "org.amqp.management", "operationalEntity", "entity", "configurationEntity", "dummy", "console"];
@@ -637,6 +640,7 @@ var QDR = (function(QDR) {
$scope.$on("$destroy", function( event ) {
//QDR.log.debug("scope destroyed for qdrList");
stopUpdating();
+ QDRService.delDisconnectAction( onDisconnect )
});
function gotMethodResponse (nodeName, entity, response, context) {
http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/303c3973/console/stand-alone/plugin/js/qdrService.js
----------------------------------------------------------------------
diff --git a/console/stand-alone/plugin/js/qdrService.js b/console/stand-alone/plugin/js/qdrService.js
index b894029..1e57f03 100644
--- a/console/stand-alone/plugin/js/qdrService.js
+++ b/console/stand-alone/plugin/js/qdrService.js
@@ -62,6 +62,13 @@ var QDR = (function(QDR) {
self.disconnectActions.push(action);
}
},
+ delDisconnectAction: function(action) {
+ if (angular.isFunction(action)) {
+ var index = self.disconnectActions.indexOf(action)
+ if (index >= 0)
+ self.disconnectActions.splice(index, 1)
+ }
+ },
addUpdatedAction: function(key, action) {
if (angular.isFunction(action)) {
self.updatedActions[key] = action;
@@ -74,11 +81,11 @@ var QDR = (function(QDR) {
executeConnectActions: function() {
self.connectActions.forEach(function(action) {
- //QDR.log.debug("executing connect action " + action);
try {
action.apply();
} catch (e) {
// in case the page that registered the handler has been unloaded
+ QDR.log.info(e.message)
}
});
self.connectActions = [];
@@ -106,7 +113,7 @@ console.dump(e)
}
},
redirectWhenConnected: function(org) {
- $location.path("/connect")
+ $location.path(QDR.pluginRoot + "/connect")
$location.search('org', org);
},
@@ -182,15 +189,18 @@ console.dump(e)
var org = $location.search()
if (org)
org = org.org
- //QDR.log.info('onSubscription: org is ' + org)
if (org && org.length > 0 && org !== "connect") {
- //QDR.log.info('going to ' + org)
self.getSchema(function () {
self.setUpdateEntities([])
self.topology.get()
- $location.path(org)
- $location.search('org', null)
- $location.replace()
+ self.addUpdatedAction('onSub', function () {
+ self.delUpdatedAction('onSub')
+ $timeout( function () {
+ $location.path(QDR.pluginRoot + '/' + org)
+ $location.search('org', null)
+ $location.replace()
+ })
+ })
});
}
},
@@ -219,9 +229,6 @@ console.dump(e)
QDR.log.info("stopUpdating called")
},
- initProton: function() {
- //QDR.log.debug("*************QDR init proton called ************");
- },
cleanUp: function() {},
error: function(line) {
if (line.num) {
@@ -941,48 +948,54 @@ console.dump(e)
disconnect: function() {
self.connection.close();
+ self.connected = false
self.errorText = "Disconnected."
},
connectionTimer: null,
testConnect: function (options, timeout, callback) {
- clearTimeout(self.connectionTimer)
var connection;
+ var allowDelete = true;
var reconnect = angular.isDefined(options.reconnect) ? options.reconnect : false
var baseAddress = options.address + ':' + options.port;
var protocol = "ws"
if ($location.protocol() === "https")
protocol = "wss"
- QDR.log.debug("testConnect called with reconnect " + reconnect + " using " + protocol + " protocol")
+ QDR.log.info("testConnect called with reconnect " + reconnect + " using " + protocol + " protocol")
try {
- var ws = self.rhea.websocket_connect(WebSocket);
- connection = self.rhea.connect({
+ var ws = self.rhea.websocket_connect(WebSocket);
+ connection = self.rhea.connect({
connection_details: ws(protocol + "://" + baseAddress, ["binary"]),
reconnect: reconnect,
- properties: {
- console_identifier: 'Dispatch console'
+ properties: {
+ console_identifier: 'Dispatch console'
+ }
}
- });
+ );
} catch (e) {
QDR.log.debug("exception caught on test connect " + e)
self.errorText = "Connection failed "
callback({error: e})
return
}
- self.connectionTimer = setTimeout(function () {
- connection.close()
- callback({error: "timedout"})
- }, timeout)
+ // called when initial connecting fails, and when connection is dropped after connecting
+ connection.on('disconnected', function(context) {
+ if (allowDelete) {
+ delete connection
+ connection.options.reconnect = false
+ //QDR.log.info("connection.on(disconnected) called")
+ callback({error: "failed to connect"})
+ }
+ })
connection.on("connection_open", function (context) {
- clearTimeout(self.connectionTimer)
+ allowDelete = false;
callback({connection: connection, context: context})
})
},
connect: function(options) {
var connection;
- clearTimeout(self.connectionTimer)
self.topologyInitialized = false;
if (!self.connected) {
var okay = {
@@ -1011,8 +1024,8 @@ console.dump(e)
self.connection = connection;
self.sender = sender;
self.receiver = receiver;
- self.onSubscription();
self.gotTopology = false;
+ self.onSubscription();
}
}
var onDisconnect = function() {
@@ -1080,7 +1093,6 @@ console.dump(e)
}
QDR.log.debug("****** calling rhea.connect ********")
- var connection;
if (!options.connection) {
QDR.log.debug("rhea.connect was not passed an existing connection")
options.reconnect = true
http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/303c3973/console/stand-alone/plugin/js/qdrSettings.js
----------------------------------------------------------------------
diff --git a/console/stand-alone/plugin/js/qdrSettings.js b/console/stand-alone/plugin/js/qdrSettings.js
index 7ea34ad..3f0c109 100644
--- a/console/stand-alone/plugin/js/qdrSettings.js
+++ b/console/stand-alone/plugin/js/qdrSettings.js
@@ -60,14 +60,19 @@ var QDR = (function(QDR) {
$scope.connect = function() {
if (QDRService.connected) {
- QDRService.disconnect();
+ $timeout( function () {
+ QDRService.disconnect();
+ })
return;
}
if ($scope.settings.$valid) {
$scope.connectionError = false;
$scope.connecting = true;
- $timeout(doConnect) // timeout so connecting animation can display
+ // timeout so connecting animation can display
+ $timeout(function () {
+ doConnect()
+ })
}
}
@@ -77,20 +82,22 @@ var QDR = (function(QDR) {
if (!$scope.formEntity.port)
$scope.formEntity.port = 5673
+ var failed = function() {
+ $timeout(function() {
+ QDR.log.debug("disconnect action called");
+ $scope.connecting = false;
+ $scope.connectionErrorText = QDRService.errorText;
+ $scope.connectionError = true;
+ })
+ }
+ QDRService.addDisconnectAction(failed);
QDRService.addConnectAction(function() {
- QDRService.addDisconnectAction(function() {
- $timeout(function() {
- QDR.log.debug("disconnect action called");
- $scope.connecting = false;
- $scope.connectionErrorText = QDRService.errorText;
- $scope.connectionError = true;
- })
- });
+ QDRService.delDisconnectAction(failed)
QDRService.getSchema(function () {
- QDR.log.debug("got schema after connection")
+ QDR.log.info("got schema after connection")
QDRService.addUpdatedAction("initialized", function () {
QDRService.delUpdatedAction("initialized")
- QDR.log.debug("got initial topology")
+ QDR.log.info("got initial topology")
$timeout(function() {
$scope.connecting = false;
if ($location.path().startsWith(QDR.pluginRoot)) {
@@ -104,7 +111,7 @@ var QDR = (function(QDR) {
}
})
})
- QDR.log.debug("requesting a topology")
+ QDR.log.info("requesting a topology")
QDRService.setUpdateEntities([])
QDRService.topology.get()
})
http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/303c3973/console/stand-alone/plugin/js/qdrTopology.js
----------------------------------------------------------------------
diff --git a/console/stand-alone/plugin/js/qdrTopology.js b/console/stand-alone/plugin/js/qdrTopology.js
index f95755f..8853d4f 100644
--- a/console/stand-alone/plugin/js/qdrTopology.js
+++ b/console/stand-alone/plugin/js/qdrTopology.js
@@ -293,10 +293,13 @@ var QDR = (function(QDR) {
return;
}
// we are currently connected. setup a handler to get notified if we are ever disconnected
- QDRService.addDisconnectAction(function() {
- QDRService.redirectWhenConnected("topology");
- $scope.$apply();
- })
+ var onDisconnect = function () {
+QDR.log.info("we were just disconnected while on the topology page. Setting org to redirect back once we are connected again")
+ $timeout(function () {
+ QDRService.redirectWhenConnected("topology")
+ })
+ }
+ QDRService.addDisconnectAction( onDisconnect )
var urlPrefix = $location.absUrl();
urlPrefix = urlPrefix.split("#")[0]
@@ -2132,6 +2135,8 @@ var QDR = (function(QDR) {
QDRService.stopUpdating();
QDRService.delUpdatedAction("normalsStats");
QDRService.delUpdatedAction("topology");
+ QDRService.delDisconnectAction( onDisconnect )
+
d3.select("#SVG_ID").remove();
window.removeEventListener('resize', resize);
});
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[2/2] qpid-dispatch git commit: DISPATCH-747 Handle connection error
on overview page
Posted by ea...@apache.org.
DISPATCH-747 Handle connection error on overview page
Project: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/commit/36766377
Tree: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/tree/36766377
Diff: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/diff/36766377
Branch: refs/heads/master
Commit: 36766377da5ae0b02d06036cfe27d9463c73bf99
Parents: 303c397
Author: Ernest Allen <ea...@redhat.com>
Authored: Mon Jun 26 13:34:58 2017 -0400
Committer: Ernest Allen <ea...@redhat.com>
Committed: Mon Jun 26 13:34:58 2017 -0400
----------------------------------------------------------------------
console/stand-alone/plugin/js/qdrOverview.js | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/36766377/console/stand-alone/plugin/js/qdrOverview.js
----------------------------------------------------------------------
diff --git a/console/stand-alone/plugin/js/qdrOverview.js b/console/stand-alone/plugin/js/qdrOverview.js
index 06da097..3c30642 100644
--- a/console/stand-alone/plugin/js/qdrOverview.js
+++ b/console/stand-alone/plugin/js/qdrOverview.js
@@ -1569,10 +1569,13 @@ QDR.log.debug("setting linkFields to [] in selectMode")
}
// we are currently connected. setup a handler to get notified if we are ever disconnected
- QDRService.addDisconnectAction( function () {
- QDRService.redirectWhenConnected("overview")
- $scope.$apply();
- })
+ var onDisconnect = function () {
+QDR.log.info("we were just disconnected while on the overview page. Setting org to redirect back once we are connected again")
+ $timeout(function () {
+ QDRService.redirectWhenConnected("overview")
+ })
+ }
+ QDRService.addDisconnectAction( onDisconnect )
/* --------------------------------------------------
*
@@ -1856,8 +1859,8 @@ QDR.log.debug("newly created node needs to be activated")
initTreeAndGrid();
$scope.$on("$destroy", function( event ) {
clearTimeout(tickTimer)
+ QDRService.delDisconnectAction( onDisconnect )
//QDRService.stopUpdating()
- //QDRService.delUpdatedAction("overview")
});
}]);
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org