ing
This commit is contained in:
parent
0eda0683de
commit
2b4aeea3e6
6
pom.xml
6
pom.xml
|
@ -179,12 +179,6 @@
|
||||||
<version>1.0.0-SNAPSHOT</version>
|
<version>1.0.0-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.loafle.overflow</groupId>
|
|
||||||
<artifactId>crawler</artifactId>
|
|
||||||
<version>1.0.0-SNAPSHOT</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.loafle.overflow</groupId>
|
<groupId>com.loafle.overflow</groupId>
|
||||||
<artifactId>commons-java</artifactId>
|
<artifactId>commons-java</artifactId>
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
package com.loafle.overflow.central.module.generator.service;
|
package com.loafle.overflow.central.module.generator.service;
|
||||||
|
|
||||||
import com.loafle.overflow.core.exception.OverflowException;
|
import com.loafle.overflow.core.exception.OverflowException;
|
||||||
import com.loafle.overflow.crawler.config.Crawler;
|
|
||||||
import com.loafle.overflow.crawler.config.Keys;
|
|
||||||
import com.loafle.overflow.model.meta.MetaCrawler;
|
import com.loafle.overflow.model.meta.MetaCrawler;
|
||||||
import com.loafle.overflow.model.meta.MetaSensorItemKey;
|
import com.loafle.overflow.model.meta.MetaSensorItemKey;
|
||||||
import com.loafle.overflow.model.meta.type.MetaCrawlerEnum;
|
import com.loafle.overflow.model.meta.type.MetaCrawlerEnum;
|
||||||
import com.loafle.overflow.model.sensor.SensorItem;
|
import com.loafle.overflow.model.sensor.SensorItem;
|
||||||
|
import com.loafle.overflow.model.sensorconfig.Crawler;
|
||||||
|
import com.loafle.overflow.model.sensorconfig.Keys;
|
||||||
import com.loafle.overflow.service.central.meta.MetaSensorItemKeyService;
|
import com.loafle.overflow.service.central.meta.MetaSensorItemKeyService;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
|
@ -2,10 +2,7 @@ package com.loafle.overflow.central.module.generator.service;
|
||||||
|
|
||||||
import com.loafle.overflow.central.commons.utils.StringConvertor;
|
import com.loafle.overflow.central.commons.utils.StringConvertor;
|
||||||
import com.loafle.overflow.core.exception.OverflowException;
|
import com.loafle.overflow.core.exception.OverflowException;
|
||||||
import com.loafle.overflow.crawler.config.Config;
|
import com.loafle.overflow.core.type.PortType;
|
||||||
import com.loafle.overflow.crawler.config.Connection;
|
|
||||||
import com.loafle.overflow.crawler.config.Crawler;
|
|
||||||
import com.loafle.overflow.crawler.config.Schedule;
|
|
||||||
import com.loafle.overflow.model.auth.AuthCrawler;
|
import com.loafle.overflow.model.auth.AuthCrawler;
|
||||||
import com.loafle.overflow.model.infra.Infra;
|
import com.loafle.overflow.model.infra.Infra;
|
||||||
import com.loafle.overflow.model.infra.InfraHost;
|
import com.loafle.overflow.model.infra.InfraHost;
|
||||||
|
@ -13,6 +10,11 @@ import com.loafle.overflow.model.meta.MetaSensorItemKey;
|
||||||
import com.loafle.overflow.model.meta.type.MetaCrawlerEnum;
|
import com.loafle.overflow.model.meta.type.MetaCrawlerEnum;
|
||||||
import com.loafle.overflow.model.sensor.Sensor;
|
import com.loafle.overflow.model.sensor.Sensor;
|
||||||
import com.loafle.overflow.model.sensor.SensorItem;
|
import com.loafle.overflow.model.sensor.SensorItem;
|
||||||
|
import com.loafle.overflow.model.sensorconfig.Connection;
|
||||||
|
import com.loafle.overflow.model.sensorconfig.Crawler;
|
||||||
|
import com.loafle.overflow.model.sensorconfig.Schedule;
|
||||||
|
import com.loafle.overflow.model.sensorconfig.SensorConfig;
|
||||||
|
import com.loafle.overflow.model.sensorconfig.Target;
|
||||||
import com.loafle.overflow.service.central.auth.AuthCrawlerService;
|
import com.loafle.overflow.service.central.auth.AuthCrawlerService;
|
||||||
|
|
||||||
import org.codehaus.jackson.map.ObjectMapper;
|
import org.codehaus.jackson.map.ObjectMapper;
|
||||||
|
@ -43,36 +45,36 @@ public class InfraHostGenerator {
|
||||||
|
|
||||||
InfraHost infraHost = (InfraHost) infra;
|
InfraHost infraHost = (InfraHost) infra;
|
||||||
|
|
||||||
Config config = new Config();
|
SensorConfig sensorConfig = new SensorConfig();
|
||||||
config.setId(String.valueOf(dbSensor.getId()));
|
sensorConfig.setConfigID(String.valueOf(dbSensor.getId()));
|
||||||
|
|
||||||
com.loafle.overflow.crawler.config.Target target = this.createTarget(infraHost, dbSensor);
|
Target target = this.createTarget(infraHost, dbSensor);
|
||||||
|
|
||||||
if (target == null) {
|
if (target == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
config.setTarget(target);
|
sensorConfig.setTarget(target);
|
||||||
|
|
||||||
// FIXME: Interval
|
// FIXME: Interval
|
||||||
Schedule schedule = new Schedule();
|
Schedule schedule = new Schedule();
|
||||||
schedule.setInterval("5");
|
schedule.setInterval("5");
|
||||||
config.setSchedule(schedule);
|
sensorConfig.setSchedule(schedule);
|
||||||
|
|
||||||
Crawler crawler = this.generateUtil.getCrawler(dbSensor.getCrawler());
|
Crawler crawler = this.generateUtil.getCrawler(dbSensor.getCrawler());
|
||||||
config.setCrawler(crawler);
|
sensorConfig.setCrawler(crawler);
|
||||||
|
|
||||||
Map<Integer, MetaSensorItemKey> keyMap = this.generateUtil.initMappingMap(dbSensor.getCrawler());
|
Map<Integer, MetaSensorItemKey> keyMap = this.generateUtil.initMappingMap(dbSensor.getCrawler());
|
||||||
|
|
||||||
if (dbSensor.getCrawler().getId() == MetaCrawlerEnum.WMI_CRAWLER.getValue()) {
|
if (dbSensor.getCrawler().getId() == MetaCrawlerEnum.WMI_CRAWLER.getValue()) {
|
||||||
this.infraHostWMIGenerator.process(sensorItems, keyMap, dbSensor, config);
|
this.infraHostWMIGenerator.process(sensorItems, keyMap, dbSensor, sensorConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
ObjectMapper objectMapper = new ObjectMapper();
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
return objectMapper.writeValueAsString(config);
|
return objectMapper.writeValueAsString(sensorConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
private com.loafle.overflow.crawler.config.Target createTarget(InfraHost infraHost, Sensor dbSensor)
|
private Target createTarget(InfraHost infraHost, Sensor dbSensor)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
|
|
||||||
AuthCrawler authCrawler = this.authCrawlerService.readAuth(dbSensor.getCrawler(), dbSensor.getTarget());
|
AuthCrawler authCrawler = this.authCrawlerService.readAuth(dbSensor.getCrawler(), dbSensor.getTarget());
|
||||||
|
@ -81,7 +83,7 @@ public class InfraHostGenerator {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
com.loafle.overflow.crawler.config.Target target = new com.loafle.overflow.crawler.config.Target();
|
Target target = new Target();
|
||||||
Connection connection = new Connection();
|
Connection connection = new Connection();
|
||||||
connection.setIp(StringConvertor.intToIp(infraHost.getIp()));
|
connection.setIp(StringConvertor.intToIp(infraHost.getIp()));
|
||||||
|
|
||||||
|
@ -91,8 +93,8 @@ public class InfraHostGenerator {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (dbSensor.getCrawler().getId() == MetaCrawlerEnum.WMI_CRAWLER.getValue()) {
|
if (dbSensor.getCrawler().getId() == MetaCrawlerEnum.WMI_CRAWLER.getValue()) {
|
||||||
connection.setPort("135");
|
connection.setPort(135);
|
||||||
connection.setPortType("tcp");
|
connection.setPortType(PortType.TCP);
|
||||||
connection.setSsl(false);
|
connection.setSsl(false);
|
||||||
|
|
||||||
target.setConnection(connection);
|
target.setConnection(connection);
|
||||||
|
|
|
@ -1,9 +1,13 @@
|
||||||
package com.loafle.overflow.central.module.generator.service;
|
package com.loafle.overflow.central.module.generator.service;
|
||||||
|
|
||||||
import com.loafle.overflow.crawler.config.*;
|
|
||||||
import com.loafle.overflow.model.meta.MetaSensorItemKey;
|
import com.loafle.overflow.model.meta.MetaSensorItemKey;
|
||||||
import com.loafle.overflow.model.sensor.Sensor;
|
import com.loafle.overflow.model.sensor.Sensor;
|
||||||
import com.loafle.overflow.model.sensor.SensorItem;
|
import com.loafle.overflow.model.sensor.SensorItem;
|
||||||
|
import com.loafle.overflow.model.sensorconfig.Item;
|
||||||
|
import com.loafle.overflow.model.sensorconfig.Keys;
|
||||||
|
import com.loafle.overflow.model.sensorconfig.MappingInfo;
|
||||||
|
import com.loafle.overflow.model.sensorconfig.QueryInfo;
|
||||||
|
import com.loafle.overflow.model.sensorconfig.SensorConfig;
|
||||||
|
|
||||||
import org.codehaus.jackson.map.ObjectMapper;
|
import org.codehaus.jackson.map.ObjectMapper;
|
||||||
import org.codehaus.jackson.type.TypeReference;
|
import org.codehaus.jackson.type.TypeReference;
|
||||||
|
@ -25,7 +29,8 @@ public class InfraHostWMIGenerator {
|
||||||
@Autowired
|
@Autowired
|
||||||
private GenerateUtil generateUtil;
|
private GenerateUtil generateUtil;
|
||||||
|
|
||||||
public void process(List<SensorItem> sensorItems, Map<Integer, MetaSensorItemKey> keyMap, Sensor dbSensor, Config config) throws Exception {
|
public void process(List<SensorItem> sensorItems, Map<Integer, MetaSensorItemKey> keyMap, Sensor dbSensor,
|
||||||
|
SensorConfig sensorConfig) throws Exception {
|
||||||
|
|
||||||
Map<String, List<MetaSensorItemKey>> metricMap = null;
|
Map<String, List<MetaSensorItemKey>> metricMap = null;
|
||||||
metricMap = this.generateUtil.sortItems(sensorItems, keyMap);
|
metricMap = this.generateUtil.sortItems(sensorItems, keyMap);
|
||||||
|
@ -51,7 +56,6 @@ public class InfraHostWMIGenerator {
|
||||||
extendMap.put("nameSpace", "root/cimv2");
|
extendMap.put("nameSpace", "root/cimv2");
|
||||||
extendMap.put("wmicPath", "/home/snoop/temp/wmic");
|
extendMap.put("wmicPath", "/home/snoop/temp/wmic");
|
||||||
|
|
||||||
|
|
||||||
List<Keys> keysList = null;
|
List<Keys> keysList = null;
|
||||||
MetaSensorItemKey tempItemKey = null;
|
MetaSensorItemKey tempItemKey = null;
|
||||||
Keys keys = null;
|
Keys keys = null;
|
||||||
|
@ -76,13 +80,13 @@ public class InfraHostWMIGenerator {
|
||||||
keysList.add(this.generateUtil.createKeys(tempItemKey));
|
keysList.add(this.generateUtil.createKeys(tempItemKey));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
List<String> arrayColumns = null;
|
List<String> arrayColumns = null;
|
||||||
|
|
||||||
String json = tempItemKey.getOption();
|
String json = tempItemKey.getOption();
|
||||||
if (json != null && json.length() > 0) {
|
if (json != null && json.length() > 0) {
|
||||||
HashMap<String, Object> optionMap;
|
HashMap<String, Object> optionMap;
|
||||||
optionMap = new ObjectMapper().readValue(json, new TypeReference<HashMap<String,Object>>() {});
|
optionMap = new ObjectMapper().readValue(json, new TypeReference<HashMap<String, Object>>() {
|
||||||
|
});
|
||||||
|
|
||||||
Object obj = null;
|
Object obj = null;
|
||||||
obj = optionMap.get("appends");
|
obj = optionMap.get("appends");
|
||||||
|
@ -109,8 +113,7 @@ public class InfraHostWMIGenerator {
|
||||||
arrayColumns = (List<String>) obj;
|
arrayColumns = (List<String>) obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
stringBuffer.append(" FROM ");
|
stringBuffer.append(" FROM ");
|
||||||
stringBuffer.append(elems.getKey());
|
stringBuffer.append(elems.getKey());
|
||||||
}
|
}
|
||||||
|
@ -131,7 +134,7 @@ public class InfraHostWMIGenerator {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
config.setItems(itemList);
|
sensorConfig.setItems(itemList);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package com.loafle.overflow.central.module.generator.service;
|
package com.loafle.overflow.central.module.generator.service;
|
||||||
|
|
||||||
import com.loafle.overflow.central.commons.utils.StringConvertor;
|
import com.loafle.overflow.central.commons.utils.StringConvertor;
|
||||||
import com.loafle.overflow.crawler.config.*;
|
import com.loafle.overflow.core.type.PortType;
|
||||||
import com.loafle.overflow.model.auth.AuthCrawler;
|
import com.loafle.overflow.model.auth.AuthCrawler;
|
||||||
import com.loafle.overflow.model.infra.Infra;
|
import com.loafle.overflow.model.infra.Infra;
|
||||||
import com.loafle.overflow.model.infra.InfraService;
|
import com.loafle.overflow.model.infra.InfraService;
|
||||||
|
@ -9,6 +9,11 @@ import com.loafle.overflow.model.meta.MetaSensorItemKey;
|
||||||
import com.loafle.overflow.model.meta.type.MetaCrawlerEnum;
|
import com.loafle.overflow.model.meta.type.MetaCrawlerEnum;
|
||||||
import com.loafle.overflow.model.sensor.Sensor;
|
import com.loafle.overflow.model.sensor.Sensor;
|
||||||
import com.loafle.overflow.model.sensor.SensorItem;
|
import com.loafle.overflow.model.sensor.SensorItem;
|
||||||
|
import com.loafle.overflow.model.sensorconfig.Connection;
|
||||||
|
import com.loafle.overflow.model.sensorconfig.Crawler;
|
||||||
|
import com.loafle.overflow.model.sensorconfig.Schedule;
|
||||||
|
import com.loafle.overflow.model.sensorconfig.SensorConfig;
|
||||||
|
import com.loafle.overflow.model.sensorconfig.Target;
|
||||||
import com.loafle.overflow.service.central.auth.AuthCrawlerService;
|
import com.loafle.overflow.service.central.auth.AuthCrawlerService;
|
||||||
|
|
||||||
import org.codehaus.jackson.map.ObjectMapper;
|
import org.codehaus.jackson.map.ObjectMapper;
|
||||||
|
@ -42,8 +47,8 @@ public class InfraServiceGenerator {
|
||||||
public String process(Sensor dbSensor, List<SensorItem> sensorItems, Infra infra) throws Exception {
|
public String process(Sensor dbSensor, List<SensorItem> sensorItems, Infra infra) throws Exception {
|
||||||
com.loafle.overflow.model.infra.InfraService infraService = (com.loafle.overflow.model.infra.InfraService)infra;
|
com.loafle.overflow.model.infra.InfraService infraService = (com.loafle.overflow.model.infra.InfraService)infra;
|
||||||
|
|
||||||
Config config = new Config();
|
SensorConfig sensorConfig = new SensorConfig();
|
||||||
config.setId(String.valueOf(dbSensor.getId()));
|
sensorConfig.setConfigID(String.valueOf(dbSensor.getId()));
|
||||||
|
|
||||||
Target target = this.createTarget(infraService, dbSensor);
|
Target target = this.createTarget(infraService, dbSensor);
|
||||||
|
|
||||||
|
@ -52,26 +57,26 @@ public class InfraServiceGenerator {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
config.setTarget(target);
|
sensorConfig.setTarget(target);
|
||||||
|
|
||||||
// FIXME: Interval
|
// FIXME: Interval
|
||||||
Schedule schedule = new Schedule();
|
Schedule schedule = new Schedule();
|
||||||
schedule.setInterval("5");
|
schedule.setInterval("5");
|
||||||
config.setSchedule(schedule);
|
sensorConfig.setSchedule(schedule);
|
||||||
|
|
||||||
Crawler crawler = this.generateUtil.getCrawler(dbSensor.getCrawler());
|
Crawler crawler = this.generateUtil.getCrawler(dbSensor.getCrawler());
|
||||||
config.setCrawler(crawler);
|
sensorConfig.setCrawler(crawler);
|
||||||
|
|
||||||
Map<Integer, MetaSensorItemKey> keyMap = this.generateUtil.initMappingMap(dbSensor.getCrawler());
|
Map<Integer, MetaSensorItemKey> keyMap = this.generateUtil.initMappingMap(dbSensor.getCrawler());
|
||||||
|
|
||||||
if(dbSensor.getCrawler().getId() == MetaCrawlerEnum.MYSQL_CRAWLER.getValue()) {
|
if(dbSensor.getCrawler().getId() == MetaCrawlerEnum.MYSQL_CRAWLER.getValue()) {
|
||||||
this.infraServiceMysqlGenerator.process(sensorItems, keyMap, dbSensor, config);
|
this.infraServiceMysqlGenerator.process(sensorItems, keyMap, dbSensor, sensorConfig);
|
||||||
} else if (dbSensor.getCrawler().getId() == MetaCrawlerEnum.JMX_CRAWLER.getValue()) {
|
} else if (dbSensor.getCrawler().getId() == MetaCrawlerEnum.JMX_CRAWLER.getValue()) {
|
||||||
this.infraServiceJMXGenerator.process(sensorItems, keyMap, dbSensor, config);
|
this.infraServiceJMXGenerator.process(sensorItems, keyMap, dbSensor, sensorConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
ObjectMapper objectMapper = new ObjectMapper();
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
return objectMapper.writeValueAsString(config);
|
return objectMapper.writeValueAsString(sensorConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Target createTarget(InfraService infraService, Sensor sensor) throws Exception {
|
private Target createTarget(InfraService infraService, Sensor sensor) throws Exception {
|
||||||
|
@ -82,11 +87,11 @@ public class InfraServiceGenerator {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
Target target = new com.loafle.overflow.crawler.config.Target();
|
Target target = new Target();
|
||||||
Connection connection = new Connection();
|
Connection connection = new Connection();
|
||||||
connection.setIp(StringConvertor.intToIp(infraService.getHost().getIp()));
|
connection.setIp(StringConvertor.intToIp(infraService.getHost().getIp()));
|
||||||
connection.setPort(String.valueOf(infraService.getPort()));
|
connection.setPort(infraService.getPort());
|
||||||
connection.setPortType(infraService.getPortType());
|
connection.setPortType(PortType.valueOf(infraService.getPortType()));
|
||||||
connection.setSsl(infraService.isTlsType());
|
connection.setSsl(infraService.isTlsType());
|
||||||
|
|
||||||
target.setConnection(connection);
|
target.setConnection(connection);
|
||||||
|
@ -103,7 +108,7 @@ public class InfraServiceGenerator {
|
||||||
} else if (sensor.getCrawler().getId() == MetaCrawlerEnum.JMX_CRAWLER.getValue()) {
|
} else if (sensor.getCrawler().getId() == MetaCrawlerEnum.JMX_CRAWLER.getValue()) {
|
||||||
auth.put("id", optionMap.get("ID")); // FIXME: Auth Info
|
auth.put("id", optionMap.get("ID")); // FIXME: Auth Info
|
||||||
auth.put("pw", optionMap.get("PassWord")); // FIXME: Auth Info
|
auth.put("pw", optionMap.get("PassWord")); // FIXME: Auth Info
|
||||||
connection.setPort("9840");
|
connection.setPort(9840);
|
||||||
}
|
}
|
||||||
|
|
||||||
target.setAuth(auth);
|
target.setAuth(auth);
|
||||||
|
|
|
@ -1,9 +1,13 @@
|
||||||
package com.loafle.overflow.central.module.generator.service;
|
package com.loafle.overflow.central.module.generator.service;
|
||||||
|
|
||||||
import com.loafle.overflow.crawler.config.*;
|
|
||||||
import com.loafle.overflow.model.meta.MetaSensorItemKey;
|
import com.loafle.overflow.model.meta.MetaSensorItemKey;
|
||||||
import com.loafle.overflow.model.sensor.Sensor;
|
import com.loafle.overflow.model.sensor.Sensor;
|
||||||
import com.loafle.overflow.model.sensor.SensorItem;
|
import com.loafle.overflow.model.sensor.SensorItem;
|
||||||
|
import com.loafle.overflow.model.sensorconfig.Item;
|
||||||
|
import com.loafle.overflow.model.sensorconfig.Keys;
|
||||||
|
import com.loafle.overflow.model.sensorconfig.MappingInfo;
|
||||||
|
import com.loafle.overflow.model.sensorconfig.QueryInfo;
|
||||||
|
import com.loafle.overflow.model.sensorconfig.SensorConfig;
|
||||||
|
|
||||||
import org.codehaus.jackson.map.ObjectMapper;
|
import org.codehaus.jackson.map.ObjectMapper;
|
||||||
import org.codehaus.jackson.type.TypeReference;
|
import org.codehaus.jackson.type.TypeReference;
|
||||||
|
@ -24,7 +28,8 @@ public class InfraServiceJMXGenerator {
|
||||||
@Autowired
|
@Autowired
|
||||||
private GenerateUtil generateUtil;
|
private GenerateUtil generateUtil;
|
||||||
|
|
||||||
public void process(List<SensorItem> sensorItems, Map<Integer, MetaSensorItemKey> keyMap, Sensor dbSensor, Config config) throws Exception {
|
public void process(List<SensorItem> sensorItems, Map<Integer, MetaSensorItemKey> keyMap, Sensor dbSensor,
|
||||||
|
SensorConfig sensorConfig) throws Exception {
|
||||||
Map<String, List<MetaSensorItemKey>> metricMap = null;
|
Map<String, List<MetaSensorItemKey>> metricMap = null;
|
||||||
metricMap = this.generateUtil.sortItems(sensorItems, keyMap);
|
metricMap = this.generateUtil.sortItems(sensorItems, keyMap);
|
||||||
|
|
||||||
|
@ -66,7 +71,8 @@ public class InfraServiceJMXGenerator {
|
||||||
|
|
||||||
if (json != null && json.length() > 0) {
|
if (json != null && json.length() > 0) {
|
||||||
HashMap<String, Object> optionMap;
|
HashMap<String, Object> optionMap;
|
||||||
optionMap = new ObjectMapper().readValue(json, new TypeReference<HashMap<String,Object>>() {});
|
optionMap = new ObjectMapper().readValue(json, new TypeReference<HashMap<String, Object>>() {
|
||||||
|
});
|
||||||
|
|
||||||
Object obj = null;
|
Object obj = null;
|
||||||
obj = optionMap.get("aliases");
|
obj = optionMap.get("aliases");
|
||||||
|
@ -94,8 +100,7 @@ public class InfraServiceJMXGenerator {
|
||||||
item.setKeys(keysList);
|
item.setKeys(keysList);
|
||||||
itemList.add(item);
|
itemList.add(item);
|
||||||
}
|
}
|
||||||
config.setItems(itemList);
|
sensorConfig.setItems(itemList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,14 @@
|
||||||
package com.loafle.overflow.central.module.generator.service;
|
package com.loafle.overflow.central.module.generator.service;
|
||||||
|
|
||||||
import com.loafle.overflow.core.exception.OverflowException;
|
import com.loafle.overflow.core.exception.OverflowException;
|
||||||
import com.loafle.overflow.crawler.config.*;
|
|
||||||
import com.loafle.overflow.model.meta.MetaSensorItemKey;
|
import com.loafle.overflow.model.meta.MetaSensorItemKey;
|
||||||
import com.loafle.overflow.model.sensor.Sensor;
|
import com.loafle.overflow.model.sensor.Sensor;
|
||||||
import com.loafle.overflow.model.sensor.SensorItem;
|
import com.loafle.overflow.model.sensor.SensorItem;
|
||||||
|
import com.loafle.overflow.model.sensorconfig.Item;
|
||||||
|
import com.loafle.overflow.model.sensorconfig.Keys;
|
||||||
|
import com.loafle.overflow.model.sensorconfig.MappingInfo;
|
||||||
|
import com.loafle.overflow.model.sensorconfig.QueryInfo;
|
||||||
|
import com.loafle.overflow.model.sensorconfig.SensorConfig;
|
||||||
|
|
||||||
import org.codehaus.jackson.JsonParseException;
|
import org.codehaus.jackson.JsonParseException;
|
||||||
import org.codehaus.jackson.map.JsonMappingException;
|
import org.codehaus.jackson.map.JsonMappingException;
|
||||||
|
@ -28,8 +32,8 @@ public class InfraServiceMysqlGenerator {
|
||||||
@Autowired
|
@Autowired
|
||||||
private GenerateUtil generateUtil;
|
private GenerateUtil generateUtil;
|
||||||
|
|
||||||
public void process(List<SensorItem> sensorItems, Map<Integer, MetaSensorItemKey> keyMap, Sensor dbSensor, Config config) throws Exception {
|
public void process(List<SensorItem> sensorItems, Map<Integer, MetaSensorItemKey> keyMap, Sensor dbSensor,
|
||||||
|
SensorConfig sensorConfig) throws Exception {
|
||||||
|
|
||||||
// List<Keys> keysList = new ArrayList<>();
|
// List<Keys> keysList = new ArrayList<>();
|
||||||
// for(SensorItem sItem : sensorItems) {
|
// for(SensorItem sItem : sensorItems) {
|
||||||
|
@ -74,15 +78,14 @@ public class InfraServiceMysqlGenerator {
|
||||||
keysList.add(this.generateUtil.createKeys(tempItemKey));
|
keysList.add(this.generateUtil.createKeys(tempItemKey));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
List<String> keyColumns = null;
|
List<String> keyColumns = null;
|
||||||
String valueColumn = null;
|
String valueColumn = null;
|
||||||
|
|
||||||
String json = tempItemKey.getOption();
|
String json = tempItemKey.getOption();
|
||||||
if (json != null && json.length() > 0) {
|
if (json != null && json.length() > 0) {
|
||||||
HashMap<String, Object> optionMap;
|
HashMap<String, Object> optionMap;
|
||||||
optionMap = new ObjectMapper().readValue(json, new TypeReference<HashMap<String,Object>>() {});
|
optionMap = new ObjectMapper().readValue(json, new TypeReference<HashMap<String, Object>>() {
|
||||||
|
});
|
||||||
|
|
||||||
Object obj = null;
|
Object obj = null;
|
||||||
obj = optionMap.get("valueColumn");
|
obj = optionMap.get("valueColumn");
|
||||||
|
@ -112,8 +115,7 @@ public class InfraServiceMysqlGenerator {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
config.setItems(itemList);
|
sensorConfig.setItems(itemList);
|
||||||
|
|
||||||
|
|
||||||
// ObjectMapper objectMapper = new ObjectMapper();
|
// ObjectMapper objectMapper = new ObjectMapper();
|
||||||
//
|
//
|
||||||
|
|
Loading…
Reference in New Issue
Block a user