PageRenderTime 1482ms CodeModel.GetById 0ms RepoModel.GetById 1ms app.codeStats 0ms

/gmonitor/gmonitor-core/src/test/java/com/zdingke/gmonitor/test/TestMetricsCreate.java

https://gitlab.com/zhengdingke/gmonitor
Java | 88 lines | 70 code | 18 blank | 0 comment | 0 complexity | c94d492308d7ee8bd6dcfbe76bbd60dc MD5 | raw file
  1. package com.zdingke.gmonitor.test;
  2. import java.io.IOException;
  3. import org.junit.Test;
  4. import com.alibaba.fastjson.JSON;
  5. import com.alibaba.fastjson.JSONArray;
  6. import com.alibaba.fastjson.JSONObject;
  7. import com.zdingke.gmonitor.FlumeMetricsJson;
  8. import com.zdingke.gmonitor.KafkaMetricsJson;
  9. import com.zdingke.gmonitor.MetricsJson;
  10. import com.zdingke.gmonitor.StormMetricsJson;
  11. import com.zdingke.gmonitor.TomcatMetricsJson;
  12. import com.zdingke.gmonitor.ZookeeperMetricsJson;
  13. public class TestMetricsCreate {
  14. @Test
  15. public void testCreateJSONObj(){
  16. JSONObject settings = new JSONObject();
  17. settings.put("groupName", "kafka");
  18. settings.put("host", "10.104.151.80");
  19. settings.put("port", "8649");
  20. JSONObject write = new JSONObject();
  21. write.put("@class", "com.googlecode.jmxtrans.model.output.GangliaWriter");
  22. write.put("settions", settings);
  23. JSONArray outputWriters = new JSONArray();
  24. outputWriters.add(write);
  25. JSONArray attr = new JSONArray();
  26. attr.add("HeapMemoryUsage");
  27. JSONObject querie = new JSONObject();
  28. querie.put("outputWriters", outputWriters);
  29. querie.put("obj", "java.lang:type=Memory");
  30. querie.put("resultAlias", "m2.kafka.memory");
  31. querie.put("attr", attr);
  32. JSONArray queries = new JSONArray();
  33. queries.add(querie);
  34. JSONObject server = new JSONObject();
  35. server.put("port", "9999");
  36. server.put("host", "10.104.141.206");
  37. server.put("numQueryThreads", "1");
  38. server.put("queries", queries);
  39. JSONArray servers = new JSONArray();
  40. servers.add(server);
  41. JSONObject obj = new JSONObject();
  42. obj.put("servers", servers);
  43. System.out.println(JSON.toJSONString(obj, true));
  44. }
  45. @Test
  46. public void testStormJson() throws IOException {
  47. MetricsJson create = new StormMetricsJson("");
  48. create.createJsonFile();
  49. }
  50. @Test
  51. public void testKafkaJson() throws IOException {
  52. MetricsJson create = new KafkaMetricsJson("E:/eclipse/eclipse_pro/kingee_pro/bigdata/ganglia-metric/target/test-classes/unittest");
  53. create.createJsonFile();
  54. }
  55. @Test
  56. public void testFlumeJson() throws IOException {
  57. MetricsJson create = new FlumeMetricsJson("E:/eclipse/eclipse_pro/kingee_pro/bigdata/ganglia-metric/target/test-classes/unittest");
  58. create.createJsonFile();
  59. }
  60. @Test
  61. public void testZKJson() throws IOException {
  62. MetricsJson create = new ZookeeperMetricsJson("");
  63. create.createJsonFile();
  64. }
  65. @Test
  66. public void testTomcatJson() throws IOException {
  67. MetricsJson create = new TomcatMetricsJson("E:/eclipse/eclipse_pro/kingee_pro/bigdata/ganglia-metric/src/test/resources/test/");
  68. create.createJsonFile();
  69. }
  70. }