From a50c29cc104c825cb6aa89b211bce9c8f235d9f6 Mon Sep 17 00:00:00 2001 From: crusader Date: Fri, 15 Jun 2018 12:26:26 +0900 Subject: [PATCH] ing --- pom.xml | 2 +- .../service/CentralInfraHostPortService.java | 12 +++++-- .../infra/service/CentralInfraService.java | 36 ++++--------------- 3 files changed, 17 insertions(+), 33 deletions(-) diff --git a/pom.xml b/pom.xml index b6f4987..0bf06e1 100644 --- a/pom.xml +++ b/pom.xml @@ -51,7 +51,7 @@ com.loafle.overflow commons-java - 1.0.71-SNAPSHOT + 1.0.72-SNAPSHOT diff --git a/src/main/java/com/loafle/overflow/central/module/infra/service/CentralInfraHostPortService.java b/src/main/java/com/loafle/overflow/central/module/infra/service/CentralInfraHostPortService.java index 49b0793..7a193cf 100644 --- a/src/main/java/com/loafle/overflow/central/module/infra/service/CentralInfraHostPortService.java +++ b/src/main/java/com/loafle/overflow/central/module/infra/service/CentralInfraHostPortService.java @@ -55,8 +55,8 @@ public class CentralInfraHostPortService implements InfraHostPortService { public InfraHostPort regist(InfraHostPort infraHostPort) throws OverflowException { infraHostPort = this.validate(infraHostPort); - if (null == infraHostPort.getInfraHost()) { - throw new OverflowException("InfraHost is not valid"); + if (null == infraHostPort.getInfraHostIP()) { + throw new OverflowException("InfraHostIP is not valid"); } return this.infraHostPortDAO.save(infraHostPort); @@ -66,6 +66,11 @@ public class CentralInfraHostPortService implements InfraHostPortService { return this.infraHostPortDAO.findById(id).get(); } + public InfraHostPort readByInfraHostIPIDAndMetaPortTypeKeyAndPort(Long infraHostIPID, String metaPortTypeKey, + Integer port) throws OverflowException { + return this.infraHostPortDAO.findByInfraHostIdAndMetaPortTypeKeyAndPort(infraHostIPID, metaPortTypeKey, port); + } + public InfraHostPort readByInfraHostIDAndMetaPortTypeKeyAndPort(Long infraHostID, String metaPortTypeKey, Integer port) throws OverflowException { return this.infraHostPortDAO.findByInfraHostIdAndMetaPortTypeKeyAndPort(infraHostID, metaPortTypeKey, port); @@ -73,6 +78,7 @@ public class CentralInfraHostPortService implements InfraHostPortService { public InfraHostPort readByInfraHostInfraZoneIDAndMetaPortTypeKeyAndPort(Long infraHostInfraZoneID, String metaPortTypeKey, Integer port) throws OverflowException { - return this.infraHostPortDAO.findByInfraHostInfraZoneIdAndMetaPortTypeKeyAndPort(infraHostInfraZoneID, metaPortTypeKey, port); + return this.infraHostPortDAO.findByInfraHostInfraZoneIdAndMetaPortTypeKeyAndPort(infraHostInfraZoneID, + metaPortTypeKey, port); } } 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 c9bf701..9ecf175 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 @@ -14,17 +14,12 @@ import com.loafle.overflow.model.discovery.Port; import com.loafle.overflow.model.discovery.Zone; import com.loafle.overflow.model.infra.Infra; import com.loafle.overflow.model.infra.InfraHost; -import com.loafle.overflow.model.infra.InfraHostApplication; -import com.loafle.overflow.model.infra.InfraHostDaemon; import com.loafle.overflow.model.infra.InfraHostIP; -import com.loafle.overflow.model.infra.InfraHostMachine; import com.loafle.overflow.model.infra.InfraHostOS; import com.loafle.overflow.model.infra.InfraHostPort; import com.loafle.overflow.model.infra.InfraZone; import com.loafle.overflow.model.meta.MetaCryptoType; -import com.loafle.overflow.model.meta.MetaIPType; import com.loafle.overflow.model.meta.MetaInfraType; -import com.loafle.overflow.model.meta.MetaPortType; import com.loafle.overflow.model.meta.MetaTargetHostType; import com.loafle.overflow.model.meta.MetaTargetZoneType; import com.loafle.overflow.service.central.infra.InfraService; @@ -39,7 +34,6 @@ import inet.ipaddr.IPAddress; import inet.ipaddr.IPAddressString; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; @Service("InfraService") @@ -248,11 +242,10 @@ public class CentralInfraService implements InfraService { infraHostIP.getMetaIPType().getName())); } - infraHostPort.setInfraHost(infraHost); + infraHostPort.setInfraHostIP(infraHostIP); infraHostPort = this.infraHostPortService.regist(infraHostPort); com.loafle.overflow.model.infra.InfraService infraService = new com.loafle.overflow.model.infra.InfraService(); - infraService.setInfraHostIP(infraHostIP); infraService.setInfraHostPort(infraHostPort); infraService.setMetaCryptoType(metaCryptoType); @@ -307,27 +300,21 @@ public class CentralInfraService implements InfraService { infraHost.setProbe(new Probe(probeID)); infraHost.setInfraZone(new InfraZone(infraZoneID)); infraHost.setMetaInfraType(MetaInfraType.Enum.HOST.to()); - infraHost.setMetaTargetHostType(MetaTargetHostType.Enum.UNKNOWN.to()); - - infraHost = this.infraHostDAO.save(infraHost); - - InfraHostMachine infraHostMachine = oriInfraHost.getInfraHostMachine(); - if (null != infraHostMachine) { - infraHostMachine.setInfraHost(infraHost); - this.infraHostMachineService.regist(infraHostMachine); - } + infraHost.setInfraHostMachine(oriInfraHost.getInfraHostMachine()); InfraHostOS infraHostOS = oriInfraHost.getInfraHostOS(); + infraHost.setInfraHostOS(infraHostOS); if (null != infraHostOS) { // MetaTargetHostType metaTargetHostType = // this.metaTargetHostTypeService.readByInfraHostOS(infraHostOS); infraHost.setMetaTargetHostType(MetaTargetHostType.Enum.UNKNOWN.to()); - infraHost = this.infraHostDAO.save(infraHost); + } else { + infraHost.setMetaTargetHostType(MetaTargetHostType.Enum.UNKNOWN.to()); - infraHostOS.setInfraHost(infraHost); - this.infraHostOSService.regist(infraHostOS); } + infraHost = this.infraHostDAO.save(infraHost); + if (null != oriInfraHost.getInfraHostIPs()) { for (InfraHostIP infraHostIP : oriInfraHost.getInfraHostIPs()) { infraHostIP = this.infraHostIPService.validate(infraHostIP); @@ -339,15 +326,6 @@ public class CentralInfraService implements InfraService { throw new OverflowException("InfraHostIPs is not valid"); } - if (null != oriInfraHost.getInfraHostPorts()) { - for (InfraHostPort infraHostPort : oriInfraHost.getInfraHostPorts()) { - infraHostPort = this.infraHostPortService.validate(infraHostPort); - infraHostPort.setInfraHost(infraHost); - - this.infraHostPortService.regist(infraHostPort); - } - } - return infraHost; }