This commit is contained in:
insanity 2018-04-24 18:47:15 +09:00
parent 09544e1f28
commit 2f3fb05b67
15 changed files with 77 additions and 101 deletions

View File

@ -27,7 +27,7 @@ import java.util.*;
* Created by geek on 17. 6. 28. * Created by geek on 17. 6. 28.
*/ */
@Service("EmailAuthService") @Service("EmailAuthService")
public class CentralEmailAuthService { public class EmailAuthService {
@Autowired @Autowired
private EmailAuthDAO emailAuthDAO; private EmailAuthDAO emailAuthDAO;

View File

@ -1,12 +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.crawler.config.Crawler; import com.loafle.overflow.crawler.config.Crawler;
import com.loafle.overflow.crawler.config.Keys; import com.loafle.overflow.crawler.config.Keys;
import com.loafle.overflow.central.module.meta.model.MetaCrawler; import com.loafle.overflow.model.meta.MetaCrawler;
import com.loafle.overflow.central.module.meta.model.MetaSensorItemKey; import com.loafle.overflow.model.meta.MetaSensorItemKey;
import com.loafle.overflow.central.module.meta.service.MetaSensorItemKeyService; import com.loafle.overflow.model.meta.type.MetaCrawlerEnum;
import com.loafle.overflow.central.module.meta.type.MetaCrawlerEnum; import com.loafle.overflow.model.sensor.SensorItem;
import com.loafle.overflow.central.module.sensor.model.SensorItem; import com.loafle.overflow.service.central.meta.MetaSensorItemKeyService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -28,7 +30,7 @@ public class GenerateUtil {
private Map<Short, Map<Integer, MetaSensorItemKey>> mappingMap = null; private Map<Short, Map<Integer, MetaSensorItemKey>> mappingMap = null;
public Map<Integer, MetaSensorItemKey> initMappingMap(MetaCrawler metaCrawler) { public Map<Integer, MetaSensorItemKey> initMappingMap(MetaCrawler metaCrawler) throws OverflowException {
if(this.mappingMap == null) { if(this.mappingMap == null) {
this.mappingMap = new HashMap<>(); this.mappingMap = new HashMap<>();
@ -48,7 +50,7 @@ public class GenerateUtil {
public Crawler getCrawler(MetaCrawler metaCrawler) { public Crawler getCrawler(MetaCrawler metaCrawler) throws OverflowException {
Crawler crawler = new Crawler(); Crawler crawler = new Crawler();
crawler.setName(metaCrawler.getName()); crawler.setName(metaCrawler.getName());
@ -76,7 +78,7 @@ public class GenerateUtil {
public Map<String, List<MetaSensorItemKey>> sortItems(List<SensorItem> sensorItems, Map<Integer, MetaSensorItemKey> keyMap) { public Map<String, List<MetaSensorItemKey>> sortItems(List<SensorItem> sensorItems, Map<Integer, MetaSensorItemKey> keyMap) throws OverflowException {
Map<String, List<MetaSensorItemKey>> metricMap = new HashMap<>(); Map<String, List<MetaSensorItemKey>> metricMap = new HashMap<>();
@ -93,7 +95,7 @@ public class GenerateUtil {
return metricMap; return metricMap;
} }
public Keys createKeys(MetaSensorItemKey itemKey) { public Keys createKeys(MetaSensorItemKey itemKey) throws OverflowException {
Keys keys = new Keys(); Keys keys = new Keys();
keys.setKey(itemKey.getKey()); keys.setKey(itemKey.getKey());
keys.setMetric(itemKey.getItem().getKey()); keys.setMetric(itemKey.getItem().getKey());

View File

@ -1,24 +1,25 @@
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.core.exception.OverflowException;
import com.loafle.overflow.crawler.config.Config; import com.loafle.overflow.crawler.config.Config;
import com.loafle.overflow.crawler.config.Connection; import com.loafle.overflow.crawler.config.Connection;
import com.loafle.overflow.crawler.config.Crawler; import com.loafle.overflow.crawler.config.Crawler;
import com.loafle.overflow.crawler.config.Schedule; import com.loafle.overflow.crawler.config.Schedule;
import com.loafle.overflow.central.module.auth.model.AuthCrawler; import com.loafle.overflow.model.auth.AuthCrawler;
import com.loafle.overflow.central.module.auth.service.AuthCrawlerService; import com.loafle.overflow.model.infra.Infra;
import com.loafle.overflow.central.module.infra.model.Infra; import com.loafle.overflow.model.infra.InfraHost;
import com.loafle.overflow.central.module.infra.model.InfraHost; import com.loafle.overflow.model.meta.MetaSensorItemKey;
import com.loafle.overflow.central.module.meta.model.MetaSensorItemKey; import com.loafle.overflow.model.meta.type.MetaCrawlerEnum;
import com.loafle.overflow.central.module.meta.type.MetaCrawlerEnum; import com.loafle.overflow.model.sensor.Sensor;
import com.loafle.overflow.central.module.sensor.model.Sensor; import com.loafle.overflow.model.sensor.SensorItem;
import com.loafle.overflow.central.module.sensor.model.SensorItem; import com.loafle.overflow.service.central.auth.AuthCrawlerService;
import org.codehaus.jackson.map.ObjectMapper; import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.type.TypeReference; import org.codehaus.jackson.type.TypeReference;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.io.IOException;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -38,16 +39,16 @@ public class InfraHostGenerator {
@Autowired @Autowired
private AuthCrawlerService authCrawlerService; private AuthCrawlerService authCrawlerService;
public String process(Sensor dbSensor, List<SensorItem> sensorItems, Infra infra) throws IOException { public String process(Sensor dbSensor, List<SensorItem> sensorItems, Infra infra) throws Exception {
InfraHost infraHost = (InfraHost)infra; InfraHost infraHost = (InfraHost) infra;
Config config = new Config(); Config config = new Config();
config.setId(String.valueOf(dbSensor.getId())); config.setId(String.valueOf(dbSensor.getId()));
com.loafle.overflow.crawler.config.Target target = this.createTarget(infraHost, dbSensor); com.loafle.overflow.crawler.config.Target target = this.createTarget(infraHost, dbSensor);
if(target == null) { if (target == null) {
return null; return null;
} }
@ -63,7 +64,7 @@ public class InfraHostGenerator {
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, config);
} }
@ -71,11 +72,12 @@ public class InfraHostGenerator {
return objectMapper.writeValueAsString(config); return objectMapper.writeValueAsString(config);
} }
private com.loafle.overflow.crawler.config.Target createTarget(InfraHost infraHost, Sensor dbSensor) throws IOException { private com.loafle.overflow.crawler.config.Target createTarget(InfraHost infraHost, Sensor dbSensor)
throws Exception {
AuthCrawler authCrawler = this.authCrawlerService.readAuth(dbSensor.getCrawler(), dbSensor.getTarget()); AuthCrawler authCrawler = this.authCrawlerService.readAuth(dbSensor.getCrawler(), dbSensor.getTarget());
if(authCrawler == null) { if (authCrawler == null) {
return null; return null;
} }
@ -83,10 +85,12 @@ public class InfraHostGenerator {
Connection connection = new Connection(); Connection connection = new Connection();
connection.setIp(StringConvertor.intToIp(infraHost.getIp())); connection.setIp(StringConvertor.intToIp(infraHost.getIp()));
HashMap<String,String> optionMap; HashMap<String, String> optionMap;
optionMap = new ObjectMapper().readValue(authCrawler.getAuthJson(), new TypeReference<HashMap<String,String>>() {}); optionMap = new ObjectMapper().readValue(authCrawler.getAuthJson(),
new TypeReference<HashMap<String, String>>() {
});
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("tcp");
connection.setSsl(false); connection.setSsl(false);

View File

@ -1,9 +1,10 @@
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.crawler.config.*;
import com.loafle.overflow.central.module.meta.model.MetaSensorItemKey; import com.loafle.overflow.model.meta.MetaSensorItemKey;
import com.loafle.overflow.central.module.sensor.model.Sensor; import com.loafle.overflow.model.sensor.Sensor;
import com.loafle.overflow.central.module.sensor.model.SensorItem; import com.loafle.overflow.model.sensor.SensorItem;
import org.codehaus.jackson.map.ObjectMapper; import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.type.TypeReference; import org.codehaus.jackson.type.TypeReference;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -24,7 +25,7 @@ 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 IOException { public void process(List<SensorItem> sensorItems, Map<Integer, MetaSensorItemKey> keyMap, Sensor dbSensor, Config config) 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);

View File

@ -2,15 +2,15 @@ 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.crawler.config.*;
import com.loafle.overflow.central.module.auth.model.AuthCrawler; import com.loafle.overflow.model.auth.AuthCrawler;
import com.loafle.overflow.central.module.auth.service.AuthCrawlerService; import com.loafle.overflow.model.infra.Infra;
import com.loafle.overflow.central.module.infra.model.Infra; import com.loafle.overflow.model.infra.InfraService;
import com.loafle.overflow.central.module.infra.model.InfraService; import com.loafle.overflow.model.meta.MetaSensorItemKey;
import com.loafle.overflow.central.module.meta.model.MetaCrawler; import com.loafle.overflow.model.meta.type.MetaCrawlerEnum;
import com.loafle.overflow.central.module.meta.model.MetaSensorItemKey; import com.loafle.overflow.model.sensor.Sensor;
import com.loafle.overflow.central.module.meta.type.MetaCrawlerEnum; import com.loafle.overflow.model.sensor.SensorItem;
import com.loafle.overflow.central.module.sensor.model.Sensor; import com.loafle.overflow.service.central.auth.AuthCrawlerService;
import com.loafle.overflow.central.module.sensor.model.SensorItem;
import org.codehaus.jackson.map.ObjectMapper; import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.type.TypeReference; import org.codehaus.jackson.type.TypeReference;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -39,8 +39,8 @@ public class InfraServiceGenerator {
@Autowired @Autowired
private AuthCrawlerService authCrawlerService; private AuthCrawlerService authCrawlerService;
public String process(Sensor dbSensor, List<SensorItem> sensorItems, Infra infra) throws IOException { public String process(Sensor dbSensor, List<SensorItem> sensorItems, Infra infra) throws Exception {
com.loafle.overflow.central.module.infra.model.InfraService infraService = (com.loafle.overflow.central.module.infra.model.InfraService)infra; com.loafle.overflow.model.infra.InfraService infraService = (com.loafle.overflow.model.infra.InfraService)infra;
Config config = new Config(); Config config = new Config();
config.setId(String.valueOf(dbSensor.getId())); config.setId(String.valueOf(dbSensor.getId()));
@ -74,7 +74,7 @@ public class InfraServiceGenerator {
return objectMapper.writeValueAsString(config); return objectMapper.writeValueAsString(config);
} }
private Target createTarget(InfraService infraService, Sensor sensor) throws IOException { private Target createTarget(InfraService infraService, Sensor sensor) throws Exception {
AuthCrawler authCrawler = this.authCrawlerService.readAuth(sensor.getCrawler(), sensor.getTarget()); AuthCrawler authCrawler = this.authCrawlerService.readAuth(sensor.getCrawler(), sensor.getTarget());

View File

@ -1,15 +1,15 @@
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.crawler.config.*;
import com.loafle.overflow.central.module.meta.model.MetaSensorItemKey; import com.loafle.overflow.model.meta.MetaSensorItemKey;
import com.loafle.overflow.central.module.sensor.model.Sensor; import com.loafle.overflow.model.sensor.Sensor;
import com.loafle.overflow.central.module.sensor.model.SensorItem; import com.loafle.overflow.model.sensor.SensorItem;
import org.codehaus.jackson.map.ObjectMapper; import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.type.TypeReference; import org.codehaus.jackson.type.TypeReference;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
@ -24,7 +24,7 @@ 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 IOException { public void process(List<SensorItem> sensorItems, Map<Integer, MetaSensorItemKey> keyMap, Sensor dbSensor, Config config) 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);

View File

@ -1,9 +1,13 @@
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.crawler.config.*; import com.loafle.overflow.crawler.config.*;
import com.loafle.overflow.central.module.meta.model.MetaSensorItemKey; import com.loafle.overflow.model.meta.MetaSensorItemKey;
import com.loafle.overflow.central.module.sensor.model.Sensor; import com.loafle.overflow.model.sensor.Sensor;
import com.loafle.overflow.central.module.sensor.model.SensorItem; import com.loafle.overflow.model.sensor.SensorItem;
import org.codehaus.jackson.JsonParseException;
import org.codehaus.jackson.map.JsonMappingException;
import org.codehaus.jackson.map.ObjectMapper; import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.type.TypeReference; import org.codehaus.jackson.type.TypeReference;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -24,7 +28,7 @@ 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 IOException { public void process(List<SensorItem> sensorItems, Map<Integer, MetaSensorItemKey> keyMap, Sensor dbSensor, Config config) throws Exception {
// List<Keys> keysList = new ArrayList<>(); // List<Keys> keysList = new ArrayList<>();

View File

@ -1,11 +1,5 @@
package com.loafle.overflow.central.module.generator.service; package com.loafle.overflow.central.module.generator.service;
import com.loafle.overflow.central.commons.model.PageParams;
import com.loafle.overflow.central.module.infra.model.Infra;
import com.loafle.overflow.central.module.infra.service.InfraService;
import com.loafle.overflow.central.module.sensor.model.Sensor;
import com.loafle.overflow.central.module.sensor.model.SensorItem;
import com.loafle.overflow.central.module.sensor.service.SensorItemService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -13,6 +7,14 @@ import org.springframework.stereotype.Service;
import java.io.IOException; import java.io.IOException;
import java.util.List; import java.util.List;
import com.loafle.overflow.core.exception.OverflowException;
import com.loafle.overflow.core.model.PageParams;
import com.loafle.overflow.model.infra.Infra;
import com.loafle.overflow.model.sensor.Sensor;
import com.loafle.overflow.model.sensor.SensorItem;
import com.loafle.overflow.service.central.infra.InfraService;
import com.loafle.overflow.service.central.sensor.SensorItemService;
/** /**
* Created by snoop on 17. 9. 6. * Created by snoop on 17. 9. 6.
*/ */
@ -32,7 +34,7 @@ public class SensorConfigGenerator {
private InfraServiceGenerator infraServiceGenerator; private InfraServiceGenerator infraServiceGenerator;
public String generate(Sensor sensor) throws IOException { public String generate(Sensor sensor) throws OverflowException {
PageParams pageParams = new PageParams(); PageParams pageParams = new PageParams();
pageParams.setPageNo(0); pageParams.setPageNo(0);
pageParams.setCountPerPage(Integer.MAX_VALUE); pageParams.setCountPerPage(Integer.MAX_VALUE);

View File

@ -1,16 +0,0 @@
package com.loafle.overflow.central.module.infra.exception;
import com.loafle.overflow.central.commons.exception.OverflowRuntimeException;
/**
* Created by snoop on 17. 9. 14.
*/
public class InfraNotFoundException extends OverflowRuntimeException {
public InfraNotFoundException() {
super();
}
public InfraNotFoundException(String message) {
super(message);
}
}

View File

@ -2,7 +2,6 @@ package com.loafle.overflow.central.module.infra.service;
import com.loafle.overflow.central.commons.utils.PageUtil; import com.loafle.overflow.central.commons.utils.PageUtil;
import com.loafle.overflow.central.module.infra.dao.InfraDAO; import com.loafle.overflow.central.module.infra.dao.InfraDAO;
import com.loafle.overflow.central.module.probe.exception.ProbeNotFoundException;
import com.loafle.overflow.core.model.PageParams; import com.loafle.overflow.core.model.PageParams;
import com.loafle.overflow.model.domain.Domain; import com.loafle.overflow.model.domain.Domain;
import com.loafle.overflow.model.probe.Probe; import com.loafle.overflow.model.probe.Probe;

View File

@ -2,8 +2,6 @@ package com.loafle.overflow.central.module.member.service;
import com.loafle.overflow.central.commons.stereotype.WebappAPI; import com.loafle.overflow.central.commons.stereotype.WebappAPI;
import com.loafle.overflow.central.commons.utils.EmailSender; import com.loafle.overflow.central.commons.utils.EmailSender;
import com.loafle.overflow.central.module.email.service.EmailAuthService;
import com.loafle.overflow.central.module.member.dao.MemberDAO; import com.loafle.overflow.central.module.member.dao.MemberDAO;
import com.loafle.overflow.central.module.member.exception.*; import com.loafle.overflow.central.module.member.exception.*;

View File

@ -80,7 +80,7 @@ public class CentralNoAuthProbeService implements NoAuthProbeService{
} }
@WebappAPI @WebappAPI
public List<NoAuthProbe> acceptNoAuthProbe(NoAuthProbe noAuthProbe) throws IOException { public List<NoAuthProbe> acceptNoAuthProbe(NoAuthProbe noAuthProbe) throws OverflowException {
String memberEmail = SessionMetadata.getTargetID(); String memberEmail = SessionMetadata.getTargetID();
// Todo domain injection & member injection // Todo domain injection & member injection

View File

@ -1,8 +1,8 @@
package com.loafle.overflow.central.module.sensor.service; package com.loafle.overflow.central.module.sensor.service;
import com.loafle.overflow.central.module.meta.model.MetaSensorDisplayItem;
import com.loafle.overflow.central.module.meta.model.MetaSensorItemKey;
import com.loafle.overflow.central.module.sensor.dao.SensorItemDependencyDAO; import com.loafle.overflow.central.module.sensor.dao.SensorItemDependencyDAO;
import com.loafle.overflow.model.meta.MetaSensorDisplayItem;
import com.loafle.overflow.model.meta.MetaSensorItemKey;
import com.loafle.overflow.model.sensor.SensorItemDependency; import com.loafle.overflow.model.sensor.SensorItemDependency;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;

View File

@ -1,9 +1,9 @@
package com.loafle.overflow.central.module.sensor.service; package com.loafle.overflow.central.module.sensor.service;
import com.loafle.overflow.central.commons.model.PageParams;
import com.loafle.overflow.central.commons.utils.PageUtil; import com.loafle.overflow.central.commons.utils.PageUtil;
import com.loafle.overflow.central.module.sensor.dao.SensorDAO; import com.loafle.overflow.central.module.sensor.dao.SensorDAO;
import com.loafle.overflow.central.module.sensor.dao.SensorItemDAO; import com.loafle.overflow.central.module.sensor.dao.SensorItemDAO;
import com.loafle.overflow.core.model.PageParams;
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;

View File

@ -1,18 +0,0 @@
package com.loafle.overflow.central.module.target.exception;
import com.loafle.overflow.central.commons.exception.OverflowRuntimeException;
/**
* Created by snoop on 17. 9. 14.
*/
public class TargetNotFoundException extends OverflowRuntimeException {
private static final long serialVersionUID = 1L;
public TargetNotFoundException() {
super();
}
public TargetNotFoundException(String message) {
super(message);
}
}