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 2020/03/13 14:29:43 UTC
[qpid-dispatch] branch master updated: DISPATCH-1599: Added edge
routers to console's Routers page. Also added edge routers to the details
page
This is an automated email from the ASF dual-hosted git repository.
eallen pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/qpid-dispatch.git
The following commit(s) were added to refs/heads/master by this push:
new 1e1e83f DISPATCH-1599: Added edge routers to console's Routers page. Also added edge routers to the details page
1e1e83f is described below
commit 1e1e83f70b103c69f1fe619261184f406a3299f5
Author: Ernest Allen <ea...@redhat.com>
AuthorDate: Fri Mar 13 10:29:24 2020 -0400
DISPATCH-1599: Added edge routers to console's Routers page. Also added edge routers to the details page
---
console/react/src/details/detailsTablePage.js | 12 +++--
console/react/src/details/routerSelect.js | 37 +++++++++++--
.../react/src/overview/dataSources/routerData.js | 63 +++++++++++++++-------
console/react/src/overview/overviewTable.js | 15 +++---
4 files changed, 93 insertions(+), 34 deletions(-)
diff --git a/console/react/src/details/detailsTablePage.js b/console/react/src/details/detailsTablePage.js
index 8d1fbc9..ce61093 100644
--- a/console/react/src/details/detailsTablePage.js
+++ b/console/react/src/details/detailsTablePage.js
@@ -89,6 +89,7 @@ class DetailTablesPage extends React.Component {
};
componentWillUnmount = () => {
+ this.unmounted = true;
if (this.timer) {
clearInterval(this.timer);
}
@@ -101,11 +102,12 @@ class DetailTablesPage extends React.Component {
update = () => {
this.mapRows().then(
rows => {
- this.setState({ rows, lastUpdated: new Date() }, () => {
- if (this.props.details) {
- this.props.lastUpdated(this.state.lastUpdated);
- }
- });
+ if (!this.unmounted)
+ this.setState({ rows, lastUpdated: new Date() }, () => {
+ if (this.props.details) {
+ this.props.lastUpdated(this.state.lastUpdated);
+ }
+ });
},
error => {
console.log(`detailsTablePage: ${error}`);
diff --git a/console/react/src/details/routerSelect.js b/console/react/src/details/routerSelect.js
index 7658fff..f829e75 100644
--- a/console/react/src/details/routerSelect.js
+++ b/console/react/src/details/routerSelect.js
@@ -48,14 +48,43 @@ class RouterSelect extends React.Component {
this.nodeIdList = this.props.service.management.topology.nodeIdList();
this.nameToId = {};
const routers = [];
- this.nodeIdList.forEach(id => {
+ this.nodeIdList.forEach((id, i) => {
const name = utils.nameFromId(id);
this.nameToId[name] = id;
routers.push(name);
+ // find any edge routers connected to this router
+ this.props.service.management.topology.fetchEntities(
+ id,
+ [{ entity: "connection", attrs: ["role", "container"] }],
+ ids => {
+ for (let rid in ids) {
+ const connections = utils.flattenAll(ids[rid].connection);
+ // add edge routers
+ const edgeIds = connections
+ .filter(c => c.role === "edge")
+ .map(c => ({
+ name: c.container,
+ id: utils.idFromName(c.container, "_edge")
+ }));
+ edgeIds.forEach(e => {
+ const edgeName = `${name}-${e.name}`;
+ routers.push(edgeName);
+ this.nameToId[edgeName] = e.id;
+ });
+ }
+ // last one? then done
+ if (i === this.nodeIdList.length - 1 && !this.unmounted) {
+ this.setState({ routers, selectedOption: routers[0] }, () => {
+ this.props.handleRouterSelected(this.nameToId[routers[0]]);
+ });
+ }
+ }
+ );
});
- this.setState({ routers, selectedOption: routers[0] }, () => {
- this.props.handleRouterSelected(this.nameToId[routers[0]]);
- });
+ };
+
+ componentWillUnmount = () => {
+ this.unmounted = true;
};
render() {
diff --git a/console/react/src/overview/dataSources/routerData.js b/console/react/src/overview/dataSources/routerData.js
index f88aecd..1d403e0 100644
--- a/console/react/src/overview/dataSources/routerData.js
+++ b/console/react/src/overview/dataSources/routerData.js
@@ -67,34 +67,61 @@ class RouterData {
doFetch = (page, perPage) => {
return new Promise(resolve => {
this.service.management.topology.fetchAllEntities(
- [{ entity: "connection", attrs: ["role"] }, { entity: "router" }],
+ [{ entity: "connection", attrs: ["role", "container"] }, { entity: "router" }],
nodes => {
// we have all the data now in the nodes object
let allRouterFields = [];
+ const lastNode = Object.keys(nodes)[Object.keys(nodes).length - 1];
for (let node in nodes) {
- let connections = 0;
- for (let i = 0; i < nodes[node]["connection"].results.length; ++i) {
- // we only requested "role" so it will be at results[0]
- if (nodes[node]["connection"].results[i][0] !== "inter-router")
- ++connections;
- }
- let routerRow = {
- connections,
- nodeId: node,
- id: this.service.utilities.nameFromId(node)
- };
- nodes[node]["router"].attributeNames.forEach((routerAttr, i) => {
- if (routerAttr !== "id") {
- routerRow[routerAttr] = nodes[node]["router"].results[0][i];
+ const connections = this.service.utilities.flattenAll(nodes[node].connection);
+ allRouterFields.push(this.routerFields(nodes, node, connections));
+ // add edge routers
+ const edgeIds = connections
+ .filter(c => c.role === "edge")
+ .map(c => this.service.utilities.idFromName(c.container, "_edge"));
+ this.service.management.topology.fetchEntities(
+ edgeIds,
+ [
+ { entity: "connection", attrs: ["role", "container"] },
+ { entity: "router" }
+ ],
+ edges => {
+ for (let edge in edges) {
+ const connections = this.service.utilities.flattenAll(
+ edges[edge].connection
+ );
+ allRouterFields.push(this.routerFields(edges, edge, connections));
+ }
+ if (node === lastNode) {
+ resolve({ data: allRouterFields, page, perPage });
+ }
}
- });
- allRouterFields.push(routerRow);
+ );
}
- resolve({ data: allRouterFields, page, perPage });
}
);
});
};
+
+ routerFields = (nodes, nodeId, connections) => {
+ const routerData = nodes[nodeId].router;
+ let connectionCount = 0;
+ connections.forEach(connection => {
+ if (connection.role !== "inter-router" && connection.role !== "edge")
+ ++connectionCount;
+ });
+ let routerRow = {
+ connections: connectionCount,
+ nodeId,
+ id: this.service.utilities.nameFromId(nodeId)
+ };
+ routerData.attributeNames.forEach((routerAttr, i) => {
+ if (routerAttr !== "id") {
+ routerRow[routerAttr] = routerData.results[0][i];
+ }
+ });
+ return routerRow;
+ };
}
export default RouterData;
diff --git a/console/react/src/overview/overviewTable.js b/console/react/src/overview/overviewTable.js
index e14b010..b63f0e1 100644
--- a/console/react/src/overview/overviewTable.js
+++ b/console/react/src/overview/overviewTable.js
@@ -116,13 +116,14 @@ class OverviewTable extends React.Component {
// the results arrived, don't call setState
if (!this.mounted) return;
const { rows, page, total, allRows } = sliced;
- this.setState({
- rows,
- page,
- perPage,
- total,
- allRows
- });
+ if (this.mounted)
+ this.setState({
+ rows,
+ page,
+ perPage,
+ total,
+ allRows
+ });
this.props.lastUpdated(new Date());
});
};
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org