Repository: ignite Updated Branches: refs/heads/master fe824a0e2 -> 594aac83c
IGNITE-10031 REST: Added "caches" parameter to "top" command to include/exclude information about caches. Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/594aac83 Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/594aac83 Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/594aac83 Branch: refs/heads/master Commit: 594aac83c39eec1d12f2e9cef0ed9af35e9a9dba Parents: fe824a0 Author: Alexey Kuznetsov <[email protected]> Authored: Mon Oct 29 16:01:12 2018 +0700 Committer: Alexey Kuznetsov <[email protected]> Committed: Mon Oct 29 16:01:12 2018 +0700 ---------------------------------------------------------------------- .../JettyRestProcessorAbstractSelfTest.java | 41 ++++++++++++++++++++ .../top/GridTopologyCommandHandler.java | 28 +++++++------ .../rest/request/GridRestTopologyRequest.java | 19 ++++++++- .../http/jetty/GridJettyRestHandler.java | 3 ++ .../app/modules/agent/AgentManager.service.js | 2 +- .../console/agent/handlers/ClusterListener.java | 1 + 6 files changed, 80 insertions(+), 14 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/594aac83/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/JettyRestProcessorAbstractSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/JettyRestProcessorAbstractSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/JettyRestProcessorAbstractSelfTest.java index a972bc3..703f50d 100644 --- a/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/JettyRestProcessorAbstractSelfTest.java +++ b/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/JettyRestProcessorAbstractSelfTest.java @@ -1428,6 +1428,25 @@ public abstract class JettyRestProcessorAbstractSelfTest extends JettyRestProces assertEquals(publicCache.getConfiguration(CacheConfiguration.class).getCacheMode(), cacheMode); } } + + // Test that caches not included. + ret = content(null, GridRestCommand.TOPOLOGY, + "attr", "false", + "mtr", "false", + "caches", "false" + ); + + info("Topology command result: " + ret); + + res = jsonResponse(ret); + + assertEquals(gridCount(), res.size()); + + for (JsonNode node : res) { + assertTrue(node.get("attributes").isNull()); + assertTrue(node.get("metrics").isNull()); + assertTrue(node.get("caches").isNull()); + } } /** @@ -1447,6 +1466,12 @@ public abstract class JettyRestProcessorAbstractSelfTest extends JettyRestProces assertTrue(res.get("attributes").isObject()); assertTrue(res.get("metrics").isObject()); + JsonNode caches = res.get("caches"); + + assertTrue(caches.isArray()); + assertFalse(caches.isNull()); + assertEquals(grid(0).context().cache().publicCaches().size(), caches.size()); + ret = content(null, GridRestCommand.NODE, "attr", "false", "mtr", "false", @@ -1472,6 +1497,22 @@ public abstract class JettyRestProcessorAbstractSelfTest extends JettyRestProces res = jsonResponse(ret); assertTrue(res.isNull()); + + // Check that caches not included. + ret = content(null, GridRestCommand.NODE, + "id", grid(0).localNode().id().toString(), + "attr", "false", + "mtr", "false", + "caches", "false" + ); + + info("Topology command result: " + ret); + + res = jsonResponse(ret); + + assertTrue(res.get("attributes").isNull()); + assertTrue(res.get("metrics").isNull()); + assertTrue(res.get("caches").isNull()); } /** http://git-wip-us.apache.org/repos/asf/ignite/blob/594aac83/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/top/GridTopologyCommandHandler.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/top/GridTopologyCommandHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/top/GridTopologyCommandHandler.java index 0390936..edcb374 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/top/GridTopologyCommandHandler.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/top/GridTopologyCommandHandler.java @@ -97,6 +97,7 @@ public class GridTopologyCommandHandler extends GridRestCommandHandlerAdapter { boolean mtr = req0.includeMetrics(); boolean attr = req0.includeAttributes(); + boolean caches = req0.includeCaches(); switch (req.command()) { case TOPOLOGY: { @@ -107,7 +108,7 @@ public class GridTopologyCommandHandler extends GridRestCommandHandlerAdapter { new ArrayList<>(allNodes.size()); for (ClusterNode node : allNodes) - top.add(createNodeBean(node, mtr, attr)); + top.add(createNodeBean(node, mtr, attr, caches)); res.setResponse(top); @@ -143,7 +144,7 @@ public class GridTopologyCommandHandler extends GridRestCommandHandlerAdapter { }); if (node != null) - res.setResponse(createNodeBean(node, mtr, attr)); + res.setResponse(createNodeBean(node, mtr, attr, caches)); else res.setResponse(null); @@ -196,14 +197,15 @@ public class GridTopologyCommandHandler extends GridRestCommandHandlerAdapter { } /** - * Creates node bean out of grid node. Notice that cache attribute is handled separately. + * Creates node bean out of cluster node. Notice that cache attribute is handled separately. * - * @param node Grid node. - * @param mtr {@code true} to add metrics. - * @param attr {@code true} to add attributes. + * @param node Cluster node. + * @param mtr Whether to include node metrics. + * @param attr Whether to include node attributes. + * @param caches Whether to include node caches. * @return Grid Node bean. */ - private GridClientNodeBean createNodeBean(ClusterNode node, boolean mtr, boolean attr) { + private GridClientNodeBean createNodeBean(ClusterNode node, boolean mtr, boolean attr, boolean caches) { assert node != null; GridClientNodeBean nodeBean = new GridClientNodeBean(); @@ -216,14 +218,16 @@ public class GridTopologyCommandHandler extends GridRestCommandHandlerAdapter { nodeBean.setTcpAddresses(nonEmptyList(node.<Collection<String>>attribute(ATTR_REST_TCP_ADDRS))); nodeBean.setTcpHostNames(nonEmptyList(node.<Collection<String>>attribute(ATTR_REST_TCP_HOST_NAMES))); - Map<String, CacheConfiguration> nodeCaches = ctx.discovery().nodePublicCaches(node); + if (caches) { + Map<String, CacheConfiguration> nodeCaches = ctx.discovery().nodePublicCaches(node); - Collection<GridClientCacheBean> caches = new ArrayList<>(nodeCaches.size()); + Collection<GridClientCacheBean> cacheBeans = new ArrayList<>(nodeCaches.size()); - for (CacheConfiguration ccfg : nodeCaches.values()) - caches.add(createCacheBean(ccfg)); + for (CacheConfiguration ccfg : nodeCaches.values()) + cacheBeans.add(createCacheBean(ccfg)); - nodeBean.setCaches(caches); + nodeBean.setCaches(cacheBeans); + } if (mtr) { ClusterMetrics metrics = node.metrics(); http://git-wip-us.apache.org/repos/asf/ignite/blob/594aac83/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/request/GridRestTopologyRequest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/request/GridRestTopologyRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/request/GridRestTopologyRequest.java index b028367..fadd178 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/request/GridRestTopologyRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/request/GridRestTopologyRequest.java @@ -36,6 +36,9 @@ public class GridRestTopologyRequest extends GridRestRequest { /** Include node attributes flag. */ private boolean includeAttrs; + /** Include caches flag. With default value for compatibility. */ + private boolean includeCaches = true; + /** * @return Include metrics flag. */ @@ -65,6 +68,20 @@ public class GridRestTopologyRequest extends GridRestRequest { } /** + * @return Include caches flag. + */ + public boolean includeCaches() { + return includeCaches; + } + + /** + * @param includeCaches Include caches flag. + */ + public void includeCaches(boolean includeCaches) { + this.includeCaches = includeCaches; + } + + /** * @return Node identifier, if specified, {@code null} otherwise. */ public UUID nodeId() { @@ -96,4 +113,4 @@ public class GridRestTopologyRequest extends GridRestRequest { @Override public String toString() { return S.toString(GridRestTopologyRequest.class, this, super.toString()); } -} \ No newline at end of file +} http://git-wip-us.apache.org/repos/asf/ignite/blob/594aac83/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/GridJettyRestHandler.java ---------------------------------------------------------------------- diff --git a/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/GridJettyRestHandler.java b/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/GridJettyRestHandler.java index 03bed69..c0a4fe1 100644 --- a/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/GridJettyRestHandler.java +++ b/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/GridJettyRestHandler.java @@ -689,6 +689,9 @@ public class GridJettyRestHandler extends AbstractHandler { restReq0.includeMetrics(Boolean.parseBoolean((String)params.get("mtr"))); restReq0.includeAttributes(Boolean.parseBoolean((String)params.get("attr"))); + String caches = (String)params.get("caches"); + restReq0.includeCaches(caches == null || Boolean.parseBoolean(caches)); + restReq0.nodeIp((String)params.get("ip")); restReq0.nodeId(uuidValue("id", params)); http://git-wip-us.apache.org/repos/asf/ignite/blob/594aac83/modules/web-console/frontend/app/modules/agent/AgentManager.service.js ---------------------------------------------------------------------- diff --git a/modules/web-console/frontend/app/modules/agent/AgentManager.service.js b/modules/web-console/frontend/app/modules/agent/AgentManager.service.js index 8f02177..7226cff 100644 --- a/modules/web-console/frontend/app/modules/agent/AgentManager.service.js +++ b/modules/web-console/frontend/app/modules/agent/AgentManager.service.js @@ -542,7 +542,7 @@ export default class AgentManager { * @returns {Promise} */ topology(attr = false, mtr = false) { - return this._executeOnCluster('node:rest', {cmd: 'top', attr, mtr}); + return this._executeOnCluster('node:rest', {cmd: 'top', attr, mtr, caches: false}); } /** http://git-wip-us.apache.org/repos/asf/ignite/blob/594aac83/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/agent/handlers/ClusterListener.java ---------------------------------------------------------------------- diff --git a/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/agent/handlers/ClusterListener.java b/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/agent/handlers/ClusterListener.java index 98a7d0f..6985837 100644 --- a/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/agent/handlers/ClusterListener.java +++ b/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/agent/handlers/ClusterListener.java @@ -426,6 +426,7 @@ public class ClusterListener implements AutoCloseable { params.put("cmd", "top"); params.put("attr", true); params.put("mtr", full); + params.put("caches", false); return restCommand(params); }
