From 343b2f1f5839f79db711c183a505ec2bb1a65db1 Mon Sep 17 00:00:00 2001 From: insanity Date: Wed, 20 Jun 2018 19:34:26 +0900 Subject: [PATCH] services --- pom.xml | 2 +- .../central/module/infra/dao/InfraDAO.java | 2 ++ .../infra/service/CentralInfraService.java | 18 ++++++++++++------ .../service/CentralMetaTargetTypeService.java | 1 - .../target/service/CentralTargetService.java | 2 ++ 5 files changed, 17 insertions(+), 8 deletions(-) diff --git a/pom.xml b/pom.xml index 25f5ea0..e9be65f 100644 --- a/pom.xml +++ b/pom.xml @@ -50,7 +50,7 @@ com.loafle.overflow commons-java - 1.0.87-SNAPSHOT + 1.0.88-SNAPSHOT diff --git a/src/main/java/com/loafle/overflow/central/module/infra/dao/InfraDAO.java b/src/main/java/com/loafle/overflow/central/module/infra/dao/InfraDAO.java index f0a0a5e..28fe119 100644 --- a/src/main/java/com/loafle/overflow/central/module/infra/dao/InfraDAO.java +++ b/src/main/java/com/loafle/overflow/central/module/infra/dao/InfraDAO.java @@ -22,4 +22,6 @@ public interface InfraDAO extends JpaRepository { Page findAllByProbeIdIn(List probeIds, Pageable pageable); Page findAllByProbeDomainId(Long probeDomainId, Pageable pageable); + + List findAllByMetaInfraTypeKeyAndProbeId(String metaInfraTypeKey, Long probeId); } \ No newline at end of file diff --git a/src/main/java/com/loafle/overflow/central/module/infra/service/CentralInfraService.java b/src/main/java/com/loafle/overflow/central/module/infra/service/CentralInfraService.java index beaeb9b..7fe93a3 100644 --- a/src/main/java/com/loafle/overflow/central/module/infra/service/CentralInfraService.java +++ b/src/main/java/com/loafle/overflow/central/module/infra/service/CentralInfraService.java @@ -153,12 +153,13 @@ public class CentralInfraService implements InfraService { InfraHostIP eInfraHostIP = this.infraHostIPService.readByInfraHostInfraZoneIDAndMetaIPTypeKeyAndAddress( infraZone.getId(), infraHostIP.getMetaIPType().getKey(), host.getAddress()); if (null != eInfraHostIP) { - return eInfraHostIP.getInfraHost(); + throw new OverflowException(String.format("IP[%s(%s)] of Zone[%s] is exist already", host.getAddress(), + infraHostIP.getMetaIPType().getName(), infraZone.getNetwork())); } InfraHost infraHost = new InfraHost(); - infraHost.setMetaInfraType(MetaInfraType.Enum.HOST.to()); - infraHost.setProbe(probe); + infraZone.setMetaInfraType(MetaInfraType.Enum.HOST.to()); + infraZone.setProbe(probe); infraHost.setInfraZone(infraZone); infraHost.setMetaTargetHostType(MetaTargetHostType.Enum.UNKNOWN.to()); @@ -247,8 +248,6 @@ public class CentralInfraService implements InfraService { com.loafle.overflow.model.infra.InfraService infraService = new com.loafle.overflow.model.infra.InfraService(); infraService.setInfraHostPort(infraHostPort); infraService.setMetaCryptoType(metaCryptoType); - infraService.setMetaInfraType(MetaInfraType.Enum.SERVICE.to()); - infraService.setProbe(probe); return this.infraServiceDAO.save(infraService); } @@ -355,6 +354,12 @@ public class CentralInfraService implements InfraService { return this.infraDAO.findAllByProbeDomainId(domainID); } + @Override + public List readAllByMetaInfraTypeKeyAndProbeID(String metaInfraTypeKey, Long probeID) + throws OverflowException { + return this.infraDAO.findAllByMetaInfraTypeKeyAndProbeId(metaInfraTypeKey, probeID); + } + public List readAllInfraZoneByProbeDomainID(Long probeDomainID) throws OverflowException { return null; } @@ -367,4 +372,5 @@ public class CentralInfraService implements InfraService { throws OverflowException { return this.infraServiceDAO.findAllByInfraHostPortId(infraHostPortID); } -} + +} \ No newline at end of file diff --git a/src/main/java/com/loafle/overflow/central/module/meta/service/CentralMetaTargetTypeService.java b/src/main/java/com/loafle/overflow/central/module/meta/service/CentralMetaTargetTypeService.java index 63186f4..ac8cbcb 100644 --- a/src/main/java/com/loafle/overflow/central/module/meta/service/CentralMetaTargetTypeService.java +++ b/src/main/java/com/loafle/overflow/central/module/meta/service/CentralMetaTargetTypeService.java @@ -2,7 +2,6 @@ package com.loafle.overflow.central.module.meta.service; import com.loafle.overflow.central.module.meta.dao.MetaTargetTypeDAO; import com.loafle.overflow.core.exception.OverflowException; -import com.loafle.overflow.model.meta.MetaInfraType; import com.loafle.overflow.model.meta.MetaTargetType; import com.loafle.overflow.service.central.meta.MetaTargetTypeService; diff --git a/src/main/java/com/loafle/overflow/central/module/target/service/CentralTargetService.java b/src/main/java/com/loafle/overflow/central/module/target/service/CentralTargetService.java index 0474f04..084b238 100644 --- a/src/main/java/com/loafle/overflow/central/module/target/service/CentralTargetService.java +++ b/src/main/java/com/loafle/overflow/central/module/target/service/CentralTargetService.java @@ -7,6 +7,8 @@ import com.loafle.overflow.central.module.probe.service.CentralProbeService; import com.loafle.overflow.central.module.target.dao.TargetDAO; 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.meta.MetaInfraType; import com.loafle.overflow.model.probe.Probe; import com.loafle.overflow.model.target.Target; import com.loafle.overflow.service.central.target.TargetService;