From 88145de833483a0622bbeab6488931f7b46fd1af Mon Sep 17 00:00:00 2001 From: BoykoAlex Date: Mon, 11 Nov 2019 16:55:12 -0500 Subject: [PATCH] Replace deprectaed stats with micrometer metrics --- .../ide/si/view/SIDiagramGenerator.java | 37 +++++++++++++++---- .../view/json/SpringIntegrationNodeJson.java | 26 +++++++------ 2 files changed, 43 insertions(+), 20 deletions(-) diff --git a/headless-services/sprotty-si-view/src/main/java/org/springframework/ide/si/view/SIDiagramGenerator.java b/headless-services/sprotty-si-view/src/main/java/org/springframework/ide/si/view/SIDiagramGenerator.java index 7368c5ef4..c3e2cc0a7 100644 --- a/headless-services/sprotty-si-view/src/main/java/org/springframework/ide/si/view/SIDiagramGenerator.java +++ b/headless-services/sprotty-si-view/src/main/java/org/springframework/ide/si/view/SIDiagramGenerator.java @@ -53,8 +53,10 @@ public class SIDiagramGenerator implements DiagramGenerator { "publish-subscribe-channel", "null-channel" ); - - private String labelProperty = "stats.sendCount"; + + private String edgeSourceLabelProperty = "sendTimers.successes.count"; + + private String edgeTargetLabelProperty = "receiveCounters.successes"; @Autowired GraphDataProvider graphDataProvider; @@ -111,14 +113,15 @@ public class SIDiagramGenerator implements DiagramGenerator { String sourceId = link.getFrom()+""; String targetId = link.getTo()+""; - SEdge e = createEdge(id, sourceId, targetId, getEdgeLabel(nodesById.get(sourceId)), link.getType()); + SEdge e = createEdge(id, sourceId, targetId, getEdgeLabel(nodesById.get(sourceId), edgeSourceLabelProperty), + getEdgeLabel(nodesById.get(targetId), edgeTargetLabelProperty), link.getType()); children.add(e); } return graph; } - private String getEdgeLabel(SpringIntegrationNodeJson springIntegrationNode) { + private String getEdgeLabel(SpringIntegrationNodeJson springIntegrationNode, String labelProperty) { JsonElement json = gson.toJsonTree(springIntegrationNode); for (String prop : labelProperty.split("\\.")) { if (json instanceof JsonObject) { @@ -263,7 +266,7 @@ public class SIDiagramGenerator implements DiagramGenerator { } } - private static SEdge createEdge(String id, String sourceId, String targetId, String labelStr, String linkType) { + private static SEdge createEdge(String id, String sourceId, String targetId, String sourceLabelStr, String targetLabelStr, String linkType) { SEdge edge = new SEdge(); edge.setId(id); edge.setType("edge:straight"); @@ -286,7 +289,7 @@ public class SIDiagramGenerator implements DiagramGenerator { break; } - if (StringUtil.hasText(labelStr)) { + if (StringUtil.hasText(sourceLabelStr)) { SLabel label = new SLabel(); label.setType("node:label"); EdgePlacement edgePlacement = new EdgePlacement(); @@ -294,8 +297,25 @@ public class SIDiagramGenerator implements DiagramGenerator { edgePlacement.setPosition(0.0); edgePlacement.setSide(Side.right); label.setEdgePlacement(edgePlacement); - label.setId(id + "-label1"); - label.setText(labelStr); + label.setId(id + "-source-label"); + label.setText(sourceLabelStr); + + label.setPosition(new Point(20,30)); + ArrayList children = new ArrayList<>(); + children.add(label); + edge.setChildren(children); + } + + if (StringUtil.hasText(targetLabelStr)) { + SLabel label = new SLabel(); + label.setType("node:label"); + EdgePlacement edgePlacement = new EdgePlacement(); + edgePlacement.setRotate(true); + edgePlacement.setPosition(1.0); + edgePlacement.setSide(Side.left); + label.setEdgePlacement(edgePlacement); + label.setId(id + "-target-label"); + label.setText(targetLabelStr); label.setPosition(new Point(20,30)); ArrayList children = new ArrayList<>(); @@ -303,6 +323,7 @@ public class SIDiagramGenerator implements DiagramGenerator { edge.setChildren(children); } + return edge; } diff --git a/headless-services/sprotty-si-view/src/main/java/org/springframework/ide/si/view/json/SpringIntegrationNodeJson.java b/headless-services/sprotty-si-view/src/main/java/org/springframework/ide/si/view/json/SpringIntegrationNodeJson.java index d04a5cda4..09f717470 100644 --- a/headless-services/sprotty-si-view/src/main/java/org/springframework/ide/si/view/json/SpringIntegrationNodeJson.java +++ b/headless-services/sprotty-si-view/src/main/java/org/springframework/ide/si/view/json/SpringIntegrationNodeJson.java @@ -7,7 +7,6 @@ public class SpringIntegrationNodeJson extends PrettyJson { private int nodeId; private String name; - private JsonElement stats; private String componentType; private JsonObject properties; @@ -15,8 +14,10 @@ public class SpringIntegrationNodeJson extends PrettyJson { private String output; private String errors; - private String[] routes; + private JsonElement sendTimers; + private JsonElement receiveCounters; + private String[] routes; public int getNodeId() { return nodeId; @@ -30,12 +31,6 @@ public class SpringIntegrationNodeJson extends PrettyJson { public void setName(String name) { this.name = name; } - public JsonElement getStats() { - return stats; - } - public void setStats(JsonObject stats) { - this.stats = stats; - } public String getComponentType() { return componentType; } @@ -72,9 +67,16 @@ public class SpringIntegrationNodeJson extends PrettyJson { public void setRoutes(String[] routes) { this.routes = routes; } - public void setStats(JsonElement stats) { - this.stats = stats; + public JsonElement getSendTimers() { + return sendTimers; + } + public void setSendTimers(JsonElement sendTimers) { + this.sendTimers = sendTimers; + } + public JsonElement getReceiveCounters() { + return receiveCounters; + } + public void setReceiveCounters(JsonElement receiveCounters) { + this.receiveCounters = receiveCounters; } - - }