Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
f72126c964
2
pom.xml
2
pom.xml
|
@ -50,7 +50,7 @@
|
|||
<dependency>
|
||||
<groupId>com.loafle.overflow</groupId>
|
||||
<artifactId>commons-java</artifactId>
|
||||
<version>1.0.92-SNAPSHOT</version>
|
||||
<version>1.0.93-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.loafle.overflow.central.module.target.service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.loafle.overflow.central.commons.utils.PageUtil;
|
||||
|
@ -8,9 +9,17 @@ 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.infra.InfraHost;
|
||||
import com.loafle.overflow.model.meta.MetaInfraType;
|
||||
import com.loafle.overflow.model.meta.MetaTargetHostType;
|
||||
import com.loafle.overflow.model.meta.MetaTargetServiceType;
|
||||
import com.loafle.overflow.model.meta.MetaTargetType;
|
||||
import com.loafle.overflow.model.meta.MetaTargetTypeCategory;
|
||||
import com.loafle.overflow.model.probe.Probe;
|
||||
import com.loafle.overflow.model.target.Target;
|
||||
import com.loafle.overflow.service.central.infra.InfraService;
|
||||
import com.loafle.overflow.service.central.meta.MetaTargetHostTypeMappingService;
|
||||
import com.loafle.overflow.service.central.meta.MetaTargetServiceTypeService;
|
||||
import com.loafle.overflow.service.central.target.TargetService;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -26,7 +35,11 @@ public class CentralTargetService implements TargetService {
|
|||
@Autowired
|
||||
private TargetDAO targetDAO;
|
||||
@Autowired
|
||||
private InfraService infraService;
|
||||
@Autowired
|
||||
private CentralProbeService probeService;
|
||||
@Autowired
|
||||
private MetaTargetServiceTypeService metaTargetServiceTypeService;
|
||||
|
||||
@Transactional
|
||||
public Target regist(Target target, Long probeID) throws OverflowException {
|
||||
|
@ -68,7 +81,30 @@ public class CentralTargetService implements TargetService {
|
|||
}
|
||||
|
||||
@Transactional
|
||||
public List<Target> registAll(List<Target> targets, Long probeID) throws OverflowException {
|
||||
public List<Target> registAll(List<Long> infraIDs, Long probeID) throws OverflowException {
|
||||
List<Target> targets = new ArrayList<Target>();
|
||||
for (Long infraID : infraIDs) {
|
||||
Infra infra = this.infraService.read(infraID);
|
||||
if (null == infra) {
|
||||
throw new OverflowException(String.format("ID[%d] of Infra is not exist.", infraID));
|
||||
}
|
||||
String metaInfraTypeKey = infra.getMetaInfraType().getKey();
|
||||
Target target = new Target();
|
||||
target.setInfra(infra);
|
||||
target.setSensorCount(0);
|
||||
if (metaInfraTypeKey.equals(MetaInfraType.Enum.HOST.to().getKey())) {
|
||||
InfraHost infraHost = (InfraHost) infra;
|
||||
target.setMetaTargetType(MetaTargetHostType.Enum.UNKNOWN.to());
|
||||
target.setName(infraHost.getInfraHostIPs().get(0).getAddress());
|
||||
} else if (metaInfraTypeKey.equals(MetaInfraType.Enum.SERVICE.to().getKey())) {
|
||||
com.loafle.overflow.model.infra.InfraService infraService = (com.loafle.overflow.model.infra.InfraService) infra;
|
||||
target.setMetaTargetType(infraService.getMetaTargetServiceType());
|
||||
String name = infraService.getMetaTargetServiceType().getName() + " on "
|
||||
+ infraService.getInfraHostPort().getInfraHostIP().getAddress();
|
||||
target.setName(name);
|
||||
}
|
||||
targets.add(target);
|
||||
}
|
||||
List<Target> registered = this.targetDAO.saveAll(targets);
|
||||
Probe probe = this.probeService.read(probeID);
|
||||
if (null == probe) {
|
||||
|
@ -81,12 +117,4 @@ public class CentralTargetService implements TargetService {
|
|||
return registered;
|
||||
}
|
||||
|
||||
public List<Target> readAllByZoneID() throws OverflowException {
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<Target> readAllTargetByProbeID(Long probeID) throws OverflowException {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -21,10 +21,9 @@ import java.util.List;
|
|||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ActiveProfiles("test")
|
||||
@ContextConfiguration(classes = {AppConfigTest.class})
|
||||
@ContextConfiguration(classes = { AppConfigTest.class })
|
||||
public class CentralTargetServiceTest {
|
||||
|
||||
@Autowired
|
||||
|
@ -43,20 +42,20 @@ public class CentralTargetServiceTest {
|
|||
public void regist() {
|
||||
}
|
||||
|
||||
// List<Target> targets, Long probeID
|
||||
// List<Target> targets, Long probeID
|
||||
@Test
|
||||
public void registAll() throws OverflowException {
|
||||
List<Target> targets = new ArrayList<>();
|
||||
List<Sensor> sensors = new ArrayList<>();
|
||||
|
||||
|
||||
List<MetaCrawler> metaCrawlers = this.metaCrawlerService.readAll();
|
||||
List<MetaSensorStatus> metaSensorStatusList = this.metaSensorStatusService.readAll();
|
||||
// MetaSensorDisplayItem metaSensorDisplayItem = this.metaSensorDisplayItemService.read(Long.valueOf(1));
|
||||
// MetaSensorDisplayItem metaSensorDisplayItem =
|
||||
// this.metaSensorDisplayItemService.read(Long.valueOf(1));
|
||||
|
||||
Target target = new Target();
|
||||
target.setMetaTargetType(MetaTargetServiceType.Enum.UNKNOWN.to());
|
||||
target.setInfra(new com.loafle.overflow.model.infra.InfraService(Long.valueOf((long)3)));
|
||||
target.setInfra(new com.loafle.overflow.model.infra.InfraService(Long.valueOf((long) 3)));
|
||||
|
||||
Sensor sensor = new Sensor();
|
||||
sensor.setItemCount(0);
|
||||
|
@ -71,8 +70,9 @@ public class CentralTargetServiceTest {
|
|||
target.setSensors(sensors);
|
||||
|
||||
targets.add(target);
|
||||
List<Target> targetList = this.targetService.registAll(targets, Long.valueOf(1));
|
||||
// List<Target> targetList = this.targetService.registAll(targets,
|
||||
// Long.valueOf(1));
|
||||
|
||||
System.out.println("Target List Size: " + targetList.size());
|
||||
// System.out.println("Target List Size: " + targetList.size());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user