This commit is contained in:
crusader 2018-06-07 15:02:38 +09:00
parent c3ca0ea93b
commit 07e9f73e48
100 changed files with 1889 additions and 1881 deletions

13
.editorconfig Normal file
View File

@ -0,0 +1,13 @@
# Editor configuration, see http://editorconfig.org
root = true
[*]
charset = utf-8
indent_style = space
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true
[*.md]
max_line_length = off
trim_trailing_whitespace = false

View File

@ -1,3 +1,6 @@
{
"editor.tabSize": 2,
"editor.insertSpaces": true,
"java.configuration.updateBuildConfiguration": "automatic"
}

View File

@ -17,8 +17,10 @@ public class PageUtil {
}
public static PageRequest getPageRequest(PageParams pageParams) {
if(pageParams.getSortCol().isEmpty()) pageParams.setSortCol("id");
if(pageParams.getSortDirection().isEmpty()) pageParams.setSortDirection("descending");
if (pageParams.getSortCol().isEmpty())
pageParams.setSortCol("id");
if (pageParams.getSortDirection().isEmpty())
pageParams.setSortDirection("descending");
return new PageRequest(pageParams.getPageNo(), pageParams.getCountPerPage(),
new Sort(PageUtil.getSortDirection(pageParams.getSortDirection()), pageParams.getSortCol()));

View File

@ -7,10 +7,8 @@ import static io.grpc.Metadata.ASCII_STRING_MARSHALLER;
public class SessionMetadata {
/*
digits: 0-9
uppercase letters: A-Z (normalized to lower)
lowercase letters: a-z
special characters: -_.
* digits: 0-9 uppercase letters: A-Z (normalized to lower) lowercase letters:
* a-z special characters: -_.
*/
public static final String CLIENT_TYPE_KEY = "OVERFLOW_GRPC_CLIENT_TYPE";
@ -21,29 +19,34 @@ public class SessionMetadata {
public static final Context.Key<String> CTX_SESSION_ID_KEY = Context.key(SESSION_ID_KEY);
public static final Context.Key<String> CTX_TARGET_ID_KEY = Context.key(TARGET_ID_KEY);
public static final Metadata.Key<String> METADATA_CLIENT_TYPE_KEY = Metadata.Key.of(CLIENT_TYPE_KEY, ASCII_STRING_MARSHALLER);
public static final Metadata.Key<String> METADATA_SESSION_ID_KEY = Metadata.Key.of(SESSION_ID_KEY, ASCII_STRING_MARSHALLER);
public static final Metadata.Key<String> METADATA_TARGET_ID_KEY = Metadata.Key.of(TARGET_ID_KEY, ASCII_STRING_MARSHALLER);
public static final Metadata.Key<String> METADATA_CLIENT_TYPE_KEY = Metadata.Key.of(CLIENT_TYPE_KEY,
ASCII_STRING_MARSHALLER);
public static final Metadata.Key<String> METADATA_SESSION_ID_KEY = Metadata.Key.of(SESSION_ID_KEY,
ASCII_STRING_MARSHALLER);
public static final Metadata.Key<String> METADATA_TARGET_ID_KEY = Metadata.Key.of(TARGET_ID_KEY,
ASCII_STRING_MARSHALLER);
public static ClientType getClientType() {
return ClientType.valueOf(CTX_CLIENT_TYPE_KEY.get());
}
public static String getSessionID() {
return CTX_SESSION_ID_KEY.get();
}
public static String getTargetID() {
return CTX_TARGET_ID_KEY.get();
}
public static enum ClientType {
MEMBER("MEMBER"),
PROBE("PROBE");
MEMBER("MEMBER"), PROBE("PROBE");
final private String name;
private ClientType(String name) {
this.name = name;
}
public String toString() {
return name;
}

View File

@ -6,13 +6,9 @@ package com.loafle.overflow.central.commons.utils;
public class StringConvertor {
public static String intToIp(long i) {
return ((i >> 24 ) & 0xFF) + "." +
((i >> 16 ) & 0xFF) + "." +
((i >> 8 ) & 0xFF) + "." +
( i & 0xFF);
return ((i >> 24) & 0xFF) + "." + ((i >> 16) & 0xFF) + "." + ((i >> 8) & 0xFF) + "." + (i & 0xFF);
}
public static long ipToLong(String ipAddress) {
String[] ipAddressInArray = ipAddress.split("\\.");
@ -29,7 +25,6 @@ public class StringConvertor {
return result;
}
// https://github.com/Sovietaced/floodlight/blob/master/src/main/java/net/floodlightcontroller/util/MACAddress.java
public static final int MAC_ADDRESS_LENGTH = 6;
@ -38,8 +33,7 @@ public class StringConvertor {
String[] elements = address.split(":");
if (elements.length != MAC_ADDRESS_LENGTH) {
throw new IllegalArgumentException(
"Specified MAC Address must contain 12 hex digits" +
" separated pairwise by :'s.");
"Specified MAC Address must contain 12 hex digits" + " separated pairwise by :'s.");
}
byte[] addressInBytes = new byte[MAC_ADDRESS_LENGTH];

View File

@ -1,12 +1,9 @@
package com.loafle.overflow.central.module.apikey.dao;
import com.loafle.overflow.model.apikey.ApiKey;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
/**
* Created by root on 17. 6. 1.
*/

View File

@ -1,9 +1,7 @@
package com.loafle.overflow.central.module.apikey.service;
import com.loafle.overflow.central.module.apikey.dao.ApiKeyDAO;
import com.loafle.overflow.core.exception.OverflowException;
import com.loafle.overflow.model.apikey.ApiKey;
import com.loafle.overflow.service.central.apikey.ApiKeyService;
@ -16,11 +14,9 @@ import org.springframework.stereotype.Service;
@Service("ApiKeyService")
public class CentralApiKeyService implements ApiKeyService {
@Autowired
private ApiKeyDAO apiKeyDAO;
public ApiKey regist(ApiKey apiKey) throws OverflowException {
return this.apiKeyDAO.save(apiKey);

View File

@ -1,6 +1,5 @@
package com.loafle.overflow.central.module.domain.dao;
import com.loafle.overflow.model.domain.Domain;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

View File

@ -26,8 +26,6 @@ public class GenerateUtil {
@Autowired
private MetaSensorItemKeyService metaSensorItemKeyService;
private Map<Short, Map<Integer, MetaSensorItemKey>> mappingMap = null;
public Map<Integer, MetaSensorItemKey> initMappingMap(MetaCrawler metaCrawler) throws OverflowException {
@ -48,8 +46,6 @@ public class GenerateUtil {
return resultMap;
}
public Crawler getCrawler(MetaCrawler metaCrawler) throws OverflowException {
Crawler crawler = new Crawler();
@ -65,8 +61,7 @@ public class GenerateUtil {
|| metaCrawler.getId() == MetaCrawlerEnum.POSTGRESQL_CRAWLER.getValue()
|| metaCrawler.getId() == MetaCrawlerEnum.JMX_CRAWLER.getValue()) {
container = "java_proxy";
}
else {
} else {
container = "network_proxy";
}
@ -75,10 +70,8 @@ public class GenerateUtil {
return crawler;
}
public Map<String, List<MetaSensorItemKey>> sortItems(List<SensorItem> sensorItems, Map<Integer, MetaSensorItemKey> keyMap) throws OverflowException {
public Map<String, List<MetaSensorItemKey>> sortItems(List<SensorItem> sensorItems,
Map<Integer, MetaSensorItemKey> keyMap) throws OverflowException {
Map<String, List<MetaSensorItemKey>> metricMap = new HashMap<>();

View File

@ -1,6 +1,5 @@
package com.loafle.overflow.central.module.generator.service;
import com.loafle.overflow.central.commons.utils.StringConvertor;
import com.loafle.overflow.core.type.PortType;
import com.loafle.overflow.model.auth.AuthCrawler;
import com.loafle.overflow.model.infra.Infra;
@ -77,7 +76,8 @@ public class InfraHostGenerator {
private Target createTarget(InfraHost infraHost, Sensor dbSensor) throws Exception {
AuthCrawler authCrawler = this.authCrawlerService.readByMetaCrawlerIDAndTargetID(dbSensor.getMetaCrawler().getId(), dbSensor.getTarget().getId());
AuthCrawler authCrawler = this.authCrawlerService.readByMetaCrawlerIDAndTargetID(dbSensor.getMetaCrawler().getId(),
dbSensor.getTarget().getId());
if (authCrawler == null) {
return null;
@ -87,7 +87,9 @@ public class InfraHostGenerator {
Connection connection = new Connection();
connection.setIp(infraHost.getIpv4());
HashMap<String, String> optionMap = this.objectMapper.readValue(authCrawler.getAuthJson(), new TypeReference<Map<String, String>>(){});
HashMap<String, String> optionMap = this.objectMapper.readValue(authCrawler.getAuthJson(),
new TypeReference<Map<String, String>>() {
});
if (dbSensor.getMetaCrawler().getId() == MetaCrawlerEnum.WMI_CRAWLER.getValue()) {
connection.setPort(135);

View File

@ -86,7 +86,8 @@ public class InfraHostWMIGenerator {
String json = tempItemKey.getOption();
if (json != null && json.length() > 0) {
HashMap<String, String> optionMap = this.objectMapper.readValue(json, new TypeReference<Map<String, String>>(){});
HashMap<String, String> optionMap = this.objectMapper.readValue(json, new TypeReference<Map<String, String>>() {
});
Object obj = null;
obj = optionMap.get("appends");

View File

@ -1,6 +1,5 @@
package com.loafle.overflow.central.module.generator.service;
import com.loafle.overflow.central.commons.utils.StringConvertor;
import com.loafle.overflow.core.type.PortType;
import com.loafle.overflow.model.auth.AuthCrawler;
import com.loafle.overflow.model.infra.Infra;
@ -58,7 +57,6 @@ public class InfraServiceGenerator {
return null;
}
sensorConfig.setTarget(target);
// FIXME: Interval
@ -82,7 +80,8 @@ public class InfraServiceGenerator {
private Target createTarget(InfraService infraService, Sensor sensor) throws Exception {
AuthCrawler authCrawler = this.authCrawlerService.readByMetaCrawlerIDAndTargetID(sensor.getMetaCrawler().getId(), sensor.getTarget().getId());
AuthCrawler authCrawler = this.authCrawlerService.readByMetaCrawlerIDAndTargetID(sensor.getMetaCrawler().getId(),
sensor.getTarget().getId());
if (authCrawler == null) {
return null;
@ -97,7 +96,9 @@ public class InfraServiceGenerator {
target.setConnection(connection);
HashMap<String, String> optionMap = this.objectMapper.readValue(authCrawler.getAuthJson(), new TypeReference<Map<String, String>>(){});
HashMap<String, String> optionMap = this.objectMapper.readValue(authCrawler.getAuthJson(),
new TypeReference<Map<String, String>>() {
});
Map<String, Object> auth = new HashMap<>();

View File

@ -73,7 +73,8 @@ public class InfraServiceJMXGenerator {
List<String> arrayCol = null;
if (json != null && json.length() > 0) {
HashMap<String, String> optionMap = this.objectMapper.readValue(json, new TypeReference<Map<String, String>>(){});
HashMap<String, String> optionMap = this.objectMapper.readValue(json, new TypeReference<Map<String, String>>() {
});
Object obj = null;
obj = optionMap.get("aliases");

View File

@ -81,7 +81,8 @@ public class InfraServiceMysqlGenerator {
String json = tempItemKey.getOption();
if (json != null && json.length() > 0) {
HashMap<String, String> optionMap = this.objectMapper.readValue(json, new TypeReference<Map<String, String>>(){});
HashMap<String, String> optionMap = this.objectMapper.readValue(json, new TypeReference<Map<String, String>>() {
});
Object obj = null;
obj = optionMap.get("valueColumn");
@ -118,7 +119,8 @@ public class InfraServiceMysqlGenerator {
// return objectMapper.writeValueAsString(config);
}
// public void setQueryAndMapping(MetaCrawler metaCrawler, List<Keys> keysList, QueryInfo queryInfo, MappingInfo mappingInfo) {
// public void setQueryAndMapping(MetaCrawler metaCrawler, List<Keys> keysList,
// QueryInfo queryInfo, MappingInfo mappingInfo) {
//
// switch (metaCrawler.getId()) {
// case 11: // mysql

View File

@ -31,7 +31,6 @@ public class SensorConfigGenerator {
@Autowired
private InfraServiceGenerator infraServiceGenerator;
public String generate(Sensor sensor) throws Exception {
PageParams pageParams = new PageParams();
pageParams.setPageNo(0);
@ -60,6 +59,4 @@ public class SensorConfigGenerator {
return null;
}
}

View File

@ -4,10 +4,7 @@ import com.loafle.overflow.central.commons.utils.PageUtil;
import com.loafle.overflow.central.module.history.dao.HistoryDAO;
import com.loafle.overflow.core.exception.OverflowException;
import com.loafle.overflow.core.model.PageParams;
import com.loafle.overflow.model.domain.Domain;
import com.loafle.overflow.model.history.History;
import com.loafle.overflow.model.meta.MetaHistoryType;
import com.loafle.overflow.model.probe.Probe;
import com.loafle.overflow.service.central.history.HistoryService;
import org.springframework.beans.factory.annotation.Autowired;
@ -23,9 +20,10 @@ public class CentralHistoryService implements HistoryService {
return this.historyDAO.save(history);
}
public Page<History> readAllByProbeIDAndMetaHistoryTypeID(Long probeID, Integer metaHistoryTypeID, PageParams pageParams) throws OverflowException {
return this.historyDAO.findAllByProbeIdAndMetaHistoryTypeId(probeID, metaHistoryTypeID, PageUtil.getPageRequest(pageParams));
public Page<History> readAllByProbeIDAndMetaHistoryTypeID(Long probeID, Integer metaHistoryTypeID,
PageParams pageParams) throws OverflowException {
return this.historyDAO.findAllByProbeIdAndMetaHistoryTypeId(probeID, metaHistoryTypeID,
PageUtil.getPageRequest(pageParams));
}
public Page<History> readAllByProbeID(Long probeID, PageParams pageParams) throws OverflowException {
@ -36,8 +34,10 @@ public class CentralHistoryService implements HistoryService {
return this.historyDAO.findAllByDomainId(domainID, PageUtil.getPageRequest(pageParams));
}
public Page<History> readAllByDomainIDAndMetaHistoryTypeID(Long domainID, Integer metaHistoryTypeID, PageParams pageParams) throws OverflowException {
return this.historyDAO.findAllByDomainIdAndMetaHistoryTypeId(domainID, metaHistoryTypeID, PageUtil.getPageRequest(pageParams));
public Page<History> readAllByDomainIDAndMetaHistoryTypeID(Long domainID, Integer metaHistoryTypeID,
PageParams pageParams) throws OverflowException {
return this.historyDAO.findAllByDomainIdAndMetaHistoryTypeId(domainID, metaHistoryTypeID,
PageUtil.getPageRequest(pageParams));
}
}

View File

@ -1,6 +1,5 @@
package com.loafle.overflow.central.module.infra.service;
import com.loafle.overflow.central.module.infra.dao.InfraHostDAO;
import com.loafle.overflow.core.exception.OverflowException;
import com.loafle.overflow.model.infra.InfraHost;

View File

@ -278,14 +278,8 @@ public class CentralMemberService implements MemberService {
return this.domainMemberService.readAllMemberByDomainID(domainID);
}
private static final String PASSWORD_REGEXP = "(" +
"(?=.*[a-z])" +
"(?=.*\\d)" +
"(?=.*[A-Z])" +
"(?=.*[!@#$%^&*()_+\\-=\\[\\]{};':\"\\\\|,.<>\\/?])" +
"." +
"{6,40}" +
")";
private static final String PASSWORD_REGEXP = "(" + "(?=.*[a-z])" + "(?=.*\\d)" + "(?=.*[A-Z])"
+ "(?=.*[!@#$%^&*()_+\\-=\\[\\]{};':\"\\\\|,.<>\\/?])" + "." + "{6,40}" + ")";
private Pattern pattern = Pattern.compile(PASSWORD_REGEXP);
protected boolean isPasswordStrong(String pass) {

View File

@ -86,7 +86,8 @@ public class CentralMemberTotpService implements MemberTotpService {
String secret = key.getKey();
// List<Integer> scratchCodes = key.getScratchCodes();
// String otpAuthURL = GoogleAuthenticatorQRGenerator.getOtpAuthURL("overFlow", member.getEmail(), key);
// String otpAuthURL = GoogleAuthenticatorQRGenerator.getOtpAuthURL("overFlow",
// member.getEmail(), key);
URIBuilder uri = (new URIBuilder()).setScheme("otpauth").setHost("totp")
.setPath("/" + formatLabel("overFlow", member.getEmail())).setParameter("secret", key.getKey());

View File

@ -10,4 +10,3 @@ import org.springframework.stereotype.Repository;
@Repository
public interface MetaProbeStatusDAO extends JpaRepository<MetaProbeStatus, Short> {
}

View File

@ -16,5 +16,6 @@ import java.util.List;
public interface MetaSensorDisplayMappingDAO extends JpaRepository<MetaSensorDisplayMapping, Short> {
@Query("SELECT m.metaSensorItemKey from MetaSensorDisplayMapping m where m.metaSensorDisplayItem.id = :metaSensorDisplayItemId")
public List<MetaSensorItemKey> findAllMetaSensorItemKeyByMetaSensorDisplayItemId(@Param("metaSensorDisplayItemId") Long metaSensorDisplayItemId);
public List<MetaSensorItemKey> findAllMetaSensorItemKeyByMetaSensorDisplayItemId(
@Param("metaSensorDisplayItemId") Long metaSensorDisplayItemId);
}

View File

@ -2,7 +2,6 @@ package com.loafle.overflow.central.module.meta.service;
import com.loafle.overflow.central.module.meta.dao.MetaCrawlerInputItemDAO;
import com.loafle.overflow.core.exception.OverflowException;
import com.loafle.overflow.model.meta.MetaCrawler;
import com.loafle.overflow.model.meta.MetaCrawlerInputItem;
import com.loafle.overflow.service.central.meta.MetaCrawlerInputItemService;
import org.springframework.beans.factory.annotation.Autowired;

View File

@ -2,7 +2,6 @@ package com.loafle.overflow.central.module.meta.service;
import com.loafle.overflow.central.module.meta.dao.MetaProbePackageDAO;
import com.loafle.overflow.core.exception.OverflowException;
import com.loafle.overflow.model.meta.MetaProbeOs;
import com.loafle.overflow.model.meta.MetaProbePackage;
import com.loafle.overflow.service.central.meta.MetaProbePackageService;
import org.springframework.beans.factory.annotation.Autowired;

View File

@ -2,7 +2,6 @@ package com.loafle.overflow.central.module.meta.service;
import com.loafle.overflow.central.module.meta.dao.MetaSensorDisplayItemDAO;
import com.loafle.overflow.core.exception.OverflowException;
import com.loafle.overflow.model.meta.MetaCrawler;
import com.loafle.overflow.model.meta.MetaSensorDisplayItem;
import com.loafle.overflow.service.central.meta.MetaSensorDisplayItemService;
import org.springframework.beans.factory.annotation.Autowired;

View File

@ -2,7 +2,6 @@ package com.loafle.overflow.central.module.meta.service;
import com.loafle.overflow.central.module.meta.dao.MetaSensorDisplayMappingDAO;
import com.loafle.overflow.core.exception.OverflowException;
import com.loafle.overflow.model.meta.MetaSensorDisplayItem;
import com.loafle.overflow.model.meta.MetaSensorDisplayMapping;
import com.loafle.overflow.model.meta.MetaSensorItemKey;
import com.loafle.overflow.service.central.meta.MetaSensorDisplayMappingService;
@ -23,7 +22,8 @@ public class CentralMetaSensorDisplayMappingService implements MetaSensorDisplay
return this.mappingDAO.save(m);
}
public List<MetaSensorItemKey> readAllMetaSensorItemKeyByDisplayItemID(Long metaSensorDisplayItemID) throws OverflowException {
public List<MetaSensorItemKey> readAllMetaSensorItemKeyByDisplayItemID(Long metaSensorDisplayItemID)
throws OverflowException {
return this.mappingDAO.findAllMetaSensorItemKeyByMetaSensorDisplayItemId(metaSensorDisplayItemID);
}
}

View File

@ -2,7 +2,6 @@ package com.loafle.overflow.central.module.meta.service;
import com.loafle.overflow.central.module.meta.dao.MetaVendorCrawlerDAO;
import com.loafle.overflow.core.exception.OverflowException;
import com.loafle.overflow.model.meta.MetaInfraVendor;
import com.loafle.overflow.model.meta.MetaVendorCrawler;
import com.loafle.overflow.service.central.meta.MetaVendorCrawlerService;
import org.springframework.beans.factory.annotation.Autowired;

View File

@ -23,6 +23,9 @@ public interface NoAuthProbeDAO extends JpaRepository<NoAuthProbe, Long> {
// @Query("select m from Member m WHERE m.email = :#{#m2.email}")
// @Modifying(clearAutomatically = true)
// @Query("UPDATE NoAuthProbe n set n.connectDate = :connectDate, n.connectAddress = :connectAddress where n.tempProbeKey = :tempProbeKey")
// int saveConnect(@Param("tempProbeKey") String tempProbeKey, @Param("connectDate") Date connectDate, @Param("connectAddress") String connectAddress);
// @Query("UPDATE NoAuthProbe n set n.connectDate = :connectDate,
// n.connectAddress = :connectAddress where n.tempProbeKey = :tempProbeKey")
// int saveConnect(@Param("tempProbeKey") String tempProbeKey,
// @Param("connectDate") Date connectDate, @Param("connectAddress") String
// connectAddress);
}

View File

@ -4,7 +4,6 @@ import com.loafle.overflow.central.commons.utils.PageUtil;
import com.loafle.overflow.central.module.notification.dao.NotificationDAO;
import com.loafle.overflow.core.exception.OverflowException;
import com.loafle.overflow.core.model.PageParams;
import com.loafle.overflow.model.member.Member;
import com.loafle.overflow.model.notification.Notification;
import com.loafle.overflow.service.central.notification.NotificationService;

View File

@ -7,7 +7,6 @@ import org.springframework.stereotype.Repository;
import java.util.List;
/**
* Created by insanity on 17. 5. 29.
*/
@ -15,9 +14,12 @@ import java.util.List;
public interface ProbeDAO extends JpaRepository<Probe, Long> {
Probe findByProbeKey(String probeKey);
List<Probe> findAllByDomainIdOrderByIdDesc(Long domainID);
// @Modifying(clearAutomatically = true)
// @Query("UPDATE Probe p set p.connectDate = :connectDate, p.connectAddress = :connectAddress where p.probeKey = :probeKey")
// int saveConnect(@Param("probeKey") String probeKey, @Param("connectDate") Date connectDate, @Param("connectAddress") String connectAddress);
// @Query("UPDATE Probe p set p.connectDate = :connectDate, p.connectAddress =
// :connectAddress where p.probeKey = :probeKey")
// int saveConnect(@Param("probeKey") String probeKey, @Param("connectDate")
// Date connectDate, @Param("connectAddress") String connectAddress);
}

View File

@ -17,5 +17,6 @@ import java.util.List;
public interface SensorItemDependencyDAO extends JpaRepository<SensorItemDependency, Long> {
@Query("SELECT s.metaSensorItemKey from SensorItemDependency s where s.metaSensorDisplayItem.id = :metaSensorDisplayItemId")
List<MetaSensorItemKey> findAllMetaSensorItemKeyByMetaSensorDisplayItemId(@Param("metaSensorDisplayItemId") Long metaSensorDisplayItemId);
List<MetaSensorItemKey> findAllMetaSensorItemKeyByMetaSensorDisplayItemId(
@Param("metaSensorDisplayItemId") Long metaSensorDisplayItemId);
}

View File

@ -5,8 +5,6 @@ import com.loafle.overflow.central.module.generator.service.SensorConfigGenerato
import com.loafle.overflow.central.module.sensor.dao.SensorDAO;
import com.loafle.overflow.core.exception.OverflowException;
import com.loafle.overflow.core.model.PageParams;
import com.loafle.overflow.model.domain.Domain;
import com.loafle.overflow.model.infra.Infra;
import com.loafle.overflow.model.meta.MetaSensorStatus;
import com.loafle.overflow.model.probe.Probe;
import com.loafle.overflow.model.sensor.Sensor;
@ -77,7 +75,8 @@ public class CentralSensorService implements SensorService {
// if (dbInfra == null) {
// throw new OverflowException("", new Throwable());
// }
// return this.sensorDAO.findAllByTargetId(dbInfra.getTarget().getId(), PageUtil.getPageRequest(pageParams));
// return this.sensorDAO.findAllByTargetId(dbInfra.getTarget().getId(),
// PageUtil.getPageRequest(pageParams));
return null;
}
@ -111,7 +110,8 @@ public class CentralSensorService implements SensorService {
}
@Transactional
public Sensor registSensorConfig(Sensor sensor, List<SensorItem> sensorItemList, String etcJson) throws OverflowException {
public Sensor registSensorConfig(Sensor sensor, List<SensorItem> sensorItemList, String etcJson)
throws OverflowException {
this.targetService.increaseSensorCount(sensor.getTarget());
this.sensorDAO.save(sensor);
@ -134,6 +134,7 @@ public class CentralSensorService implements SensorService {
}
// public List<Sensor> readAllByTarget(Target target, PageParams pageParams) {
// return this.sensorDAO.findAllByTarget(target, PageUtil.getPageRequest(pageParams));
// return this.sensorDAO.findAllByTarget(target,
// PageUtil.getPageRequest(pageParams));
// }
}

View File

@ -14,7 +14,8 @@ public interface TargetDAO extends JpaRepository<Target, Long> {
Target findByInfraId(Long infraId);
// @Query("select t.infra from target t where t.infra.probe.id = :probeId")
// Page<Target> findForProbeId(@Param("probeId") Long probeId, Pageable pageRequest);
// Page<Target> findForProbeId(@Param("probeId") Long probeId, Pageable
// pageRequest);
Page<Target> findAllByInfraProbeId(Long probeId, Pageable pageRequest);
}

View File

@ -22,7 +22,8 @@
// * Created by snoop on 17. 6. 28.
// */
// @Service("TargetDiscoveryService")
// public class CentralTargetDiscoveryService implements TargetDiscoveryService {
// public class CentralTargetDiscoveryService implements TargetDiscoveryService
// {
// @Autowired
// private TargetService targetService;
@ -46,7 +47,8 @@
// private CentralInfraServiceService infraServiceService;
// @Transactional
// public boolean saveAllTarget(List<Host> hosts, Probe probe) throws OverflowException {
// public boolean saveAllTarget(List<Host> hosts, Probe probe) throws
// OverflowException {
// InfraHost infraHost = null;
@ -60,13 +62,15 @@
// return true;
// }
// private void createService(InfraHost infraHost, Port port, Probe probe) throws OverflowException {
// private void createService(InfraHost infraHost, Port port, Probe probe)
// throws OverflowException {
// MetaInfraType typeService = new MetaInfraType(7);
// String portType = "UDP";
// if (port.getPortType() == PortType.TLS || port.getPortType() == PortType.TCP || port.getPortType() == null) {
// if (port.getPortType() == PortType.TLS || port.getPortType() == PortType.TCP
// || port.getPortType() == null) {
// portType = "TCP";
// }
@ -75,13 +79,15 @@
// }
// // for(String key : port.getServices().keySet()) {
// for (com.loafle.overflow.model.discovery.Service service : port.getServiceList()) {
// for (com.loafle.overflow.model.discovery.Service service :
// port.getServiceList()) {
// // com.loafle.overflow.module.discovery.model.Service service =
// // port.getServices().get(key);
// InfraService dbInfraService = this.infraServiceService
// .readByInfraHostIDAndPortAndPortType(infraHost.getId(), port.getPortNumber(), portType);
// .readByInfraHostIDAndPortAndPortType(infraHost.getId(), port.getPortNumber(),
// portType);
// if (dbInfraService != null) {
// if (service.isTarget() && dbInfraService.getTarget() == null) {
@ -119,7 +125,8 @@
// }
// private void createPort(InfraHost infraHost, Host host, Probe probe) throws OverflowException {
// private void createPort(InfraHost infraHost, Host host, Probe probe) throws
// OverflowException {
// // if(host.getPorts() == null) {
// // return;
@ -140,11 +147,14 @@
// for (Port port : host.getPortList()) {
// // Port port = host.getPorts().get(key);
// if (port.getPortType() == PortType.TLS || port.getPortType() == PortType.TCP) {
// if (port.getPortType() == PortType.TLS || port.getPortType() == PortType.TCP)
// {
// portType = "TCP";
// }
// InfraOSPort dbInfraOSPort = this.infraOSPortService.readByInfraOSIDAndPortAndPortType(infraOS.getId(), port.getPortNumber(),
// InfraOSPort dbInfraOSPort =
// this.infraOSPortService.readByInfraOSIDAndPortAndPortType(infraOS.getId(),
// port.getPortNumber(),
// portType);
// if (dbInfraOSPort == null) {
// InfraOSPort infraOSPort = new InfraOSPort();
@ -165,7 +175,8 @@
// }
// }
// private InfraHost createAndReadHost(Host host, Probe probe) throws OverflowException {
// private InfraHost createAndReadHost(Host host, Probe probe) throws
// OverflowException {
// InfraHost infraHost = this.infraHostService.readByIp(host.getIpv4());
// if (infraHost != null) {

View File

@ -104,6 +104,7 @@ public class CentralTargetService implements TargetService {
return this.targetDAO.findAllByInfraProbeId(probeID, PageUtil.getPageRequest(pageParams));
// return null;
}
@Transactional
public List<Target> registDiscoveredTargets(Long probeId, List<Host> hosts, List<Service> services)
throws OverflowException {
@ -121,7 +122,8 @@ public class CentralTargetService implements TargetService {
InfraHost infraHost = this.registInfraHostByDiscoveredHost(host, probeId);
Target target = new Target();
target.setInfra(infraHost);
String displayName = (host.getIpv6() == null || host.getIpv6().trim().isEmpty()) ? host.getIpv6() : host.getIpv4();
String displayName = (host.getIpv6() == null || host.getIpv6().trim().isEmpty()) ? host.getIpv6()
: host.getIpv4();
target.setDisplayName(displayName);
targets.add(this.targetDAO.save(target));
}

View File

@ -34,13 +34,13 @@ public class ServiceProxy {
ServiceImpl serviceImpl = ctx.getBean(ServiceImpl.class);
server = NettyServerBuilder.forPort(port)
.addService(ServerInterceptors.intercept(serviceImpl, proxyServerInterceptor))
.build().start();
.addService(ServerInterceptors.intercept(serviceImpl, proxyServerInterceptor)).build().start();
logger.info("Server started, listening on " + port);
Runtime.getRuntime().addShutdownHook(new Thread() {
@Override
public void run() {
// Use stderr here since the logger may have been reset by its JVM shutdown hook.
// Use stderr here since the logger may have been reset by its JVM shutdown
// hook.
System.err.println("*** shutting down gRPC server since JVM is shutting down");
ServiceProxy.this.stop();
System.err.println("*** server shut down");
@ -105,4 +105,3 @@ public class ServiceProxy {
}
}

View File

@ -21,7 +21,6 @@ import javax.persistence.EntityManager;
import javax.sql.DataSource;
import java.util.Properties;
/**
* Created by root on 17. 6. 13.
*/
@ -69,8 +68,6 @@ public class JdbcConfiguration implements TransactionManagementConfigurer {
return entityManagerFactoryBean;
}
@Bean
@Qualifier(value = "transactionManager")
public PlatformTransactionManager annotationDrivenTransactionManager() {

View File

@ -57,7 +57,6 @@ public class MailConfiguration {
return javaMailProperties;
}
@Bean
public VelocityEngine getVelocityEngine() throws VelocityException, IOException {
Properties properties = new Properties();

View File

@ -41,7 +41,6 @@ public class RedisConfiguration {
JedisConnectionFactory jedisConFactory = new JedisConnectionFactory(redisStandaloneConfiguration,
jedisClientConfiguration.build());
// JedisConnectionFactory jedisConFactory = new JedisConnectionFactory();
// jedisConFactory.setHostName(host);
// jedisConFactory.setPort(port);