From cec74ae05a2ebdbc2d396cf2c5682ea3efb64719 Mon Sep 17 00:00:00 2001 From: geek Date: Tue, 23 May 2017 11:23:09 +0900 Subject: [PATCH] example json edit substring edit --- .../com/loafle/overflow/crawler/jmx/JmxCrawler.java | 2 +- src/test/java/com/loafle/AppTest.java | 4 ++-- src/test/resources/config/example.json | 12 ++++++------ 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/loafle/overflow/crawler/jmx/JmxCrawler.java b/src/main/java/com/loafle/overflow/crawler/jmx/JmxCrawler.java index 6c59c7f..404075c 100644 --- a/src/main/java/com/loafle/overflow/crawler/jmx/JmxCrawler.java +++ b/src/main/java/com/loafle/overflow/crawler/jmx/JmxCrawler.java @@ -130,7 +130,7 @@ public class JmxCrawler extends Crawler{ int start = s.indexOf("["); int end = s.lastIndexOf("]"); - s = s.substring(start,end); + s = s.substring(start+1,end); String [] slices = s.split(","); String returnData = ""; diff --git a/src/test/java/com/loafle/AppTest.java b/src/test/java/com/loafle/AppTest.java index 5027b49..df3c33c 100644 --- a/src/test/java/com/loafle/AppTest.java +++ b/src/test/java/com/loafle/AppTest.java @@ -3,14 +3,13 @@ package com.loafle; import static org.junit.Assert.*; import com.fasterxml.jackson.databind.ObjectMapper; -import com.loafle.overflow.crawler.Crawler; import com.loafle.overflow.crawler.config.*; import com.loafle.overflow.crawler.jmx.JmxCrawler; import com.loafle.overflow.crawler.result.OFResultSet; import org.junit.Test; import java.io.File; -import java.util.ArrayList; +import java.net.URL; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -25,6 +24,7 @@ public class AppTest { public void TestDoCrawler() throws Exception { ClassLoader classLoader = getClass().getClassLoader(); + URL url = classLoader.getResource("config/"); String path = classLoader.getResource("config/example.json").getFile(); ObjectMapper mapper = new ObjectMapper(); diff --git a/src/test/resources/config/example.json b/src/test/resources/config/example.json index 0b1112a..86b258f 100644 --- a/src/test/resources/config/example.json +++ b/src/test/resources/config/example.json @@ -21,23 +21,23 @@ "items" : [ { "keys" : [ - {"metric" : "net.connector[$0].localPort", "key" : "localPort"}, - {"metric" : "net.connector[$0].port", "key" : "port"}, - {"metric" : "net.connector[$0].protocol", "key" : "protocol"} + {"metric" : "net.connector[$0].requestCount", "key" : "requestCount"}, + {"metric" : "net.connector[$0].loadOnStartup", "key" : "loadOnStartup"}, + {"metric" : "net.connector[$0].errorCount", "key" : "errorCount"} ], "queryInfo" : { - "query": "*Catalina:type=Connector,*", + "query": "*Catalina:j2eeType=Servlet,*", "extend" : { "aliases" : [ { - "key": "port", + "key": "Catalina:j2eeType", "index":0 } ] } }, "mappingInfo" : { - "arrayColumns" : [ "portName" ] + "arrayColumns" : [ "Servlet" ] } } ]