diff --git a/Bench4Q-Master/src/main/java/org/bench4q/master/api/AgentController.java b/Bench4Q-Master/src/main/java/org/bench4q/master/api/AgentController.java index b38ea7bd..efe34303 100644 --- a/Bench4Q-Master/src/main/java/org/bench4q/master/api/AgentController.java +++ b/Bench4Q-Master/src/main/java/org/bench4q/master/api/AgentController.java @@ -10,14 +10,14 @@ import org.bench4q.master.domain.service.UserService; import org.bench4q.share.models.master.AgentModel; import org.bench4q.share.models.master.AgentResponseModel; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; +import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; -@Component +@Controller @RequestMapping("/agentManage") public class AgentController extends BaseController { private AgentService agentService; diff --git a/Bench4Q-Master/src/main/java/org/bench4q/master/domain/entity/Monitor.java b/Bench4Q-Master/src/main/java/org/bench4q/master/domain/entity/Monitor.java index b659b6c3..5eb83e48 100644 --- a/Bench4Q-Master/src/main/java/org/bench4q/master/domain/entity/Monitor.java +++ b/Bench4Q-Master/src/main/java/org/bench4q/master/domain/entity/Monitor.java @@ -24,6 +24,7 @@ import org.bench4q.master.domain.factory.TestPlanFactory; import org.bench4q.master.domain.valueobject.datastatistics.TestMonitorSampler; import org.bench4q.master.exception.ExceptionLog; import org.bench4q.master.helper.ApplicationContextHelper; +import org.bench4q.share.helper.MarshalHelper; import org.bench4q.share.models.monitor.MemoryModel; import org.bench4q.share.models.monitor.MonitorMain; import org.bench4q.share.models.monitor.NetworkInterfaceModel; @@ -32,6 +33,7 @@ import org.bench4q.share.models.monitor.ProcessModel; import org.bench4q.share.models.monitor.ProcessModelChild; import org.bench4q.share.models.monitor.ProcessorModel; import org.bench4q.share.models.monitor.ProcessorModelChild; + @Entity @Table(name = "monitor") public class Monitor { @@ -118,6 +120,8 @@ public class Monitor { try { MonitorMain monitorMain = getTestMonitorSampler().getMonitorResult( hostName, port); + + System.out.println(MarshalHelper.tryMarshal(monitorMain)); List monitorResults = this.getTestPlanFactory() .createMonitorResultListWithOutId(monitorMain, testPlan, this, monitorMain.getSamplingTime()); @@ -128,7 +132,8 @@ public class Monitor { return null; } } - public List createFinishedResult(){ + + public List createFinishedResult() { try { MonitorMain monitorMain = createFinishedMonitorMain(); List monitorResults = this.getTestPlanFactory() @@ -140,51 +145,58 @@ public class Monitor { logger.error(ExceptionLog.getStackTrace(e)); return null; } - + } - private MonitorMain createFinishedMonitorMain(){ - MonitorMain monitorMain=new MonitorMain(); - Date date=new Date(); + + private MonitorMain createFinishedMonitorMain() { + MonitorMain monitorMain = new MonitorMain(); + Date date = new Date(); monitorMain.setSamplingTime(date); monitorMain.setFinished(true); monitorMain.setMemoryModel(createFinishedMemoryModel(date)); - monitorMain.setNetworkInterfaceModel(createFinishedNetworkInterfaceModel(date)); + monitorMain + .setNetworkInterfaceModel(createFinishedNetworkInterfaceModel(date)); monitorMain.setProcessorModel(createFinishedProcessorModel(date)); monitorMain.setPhysicalDiskModel(createFinishedPhysicalDiskModel(date)); monitorMain.setProcessModel(createFinishedProcessModel(date)); return monitorMain; - - + } - private ProcessorModel createFinishedProcessorModel(Date date){ - ProcessorModel processorModel=new ProcessorModel(); + + private ProcessorModel createFinishedProcessorModel(Date date) { + ProcessorModel processorModel = new ProcessorModel(); processorModel.setSamplingTime(date); processorModel.setFinished(true); - processorModel.setProcessorModelList(new LinkedList()); + processorModel + .setProcessorModelList(new LinkedList()); processorModel.setCpuInstanceList(new LinkedList()); return processorModel; } - private MemoryModel createFinishedMemoryModel(Date date){ - MemoryModel memoryModel=new MemoryModel(); + + private MemoryModel createFinishedMemoryModel(Date date) { + MemoryModel memoryModel = new MemoryModel(); memoryModel.setFinished(true); memoryModel.setSamplingTime(date); return memoryModel; } - private PhysicalDiskModel createFinishedPhysicalDiskModel(Date date){ - PhysicalDiskModel physicalDiskModel=new PhysicalDiskModel(); + + private PhysicalDiskModel createFinishedPhysicalDiskModel(Date date) { + PhysicalDiskModel physicalDiskModel = new PhysicalDiskModel(); physicalDiskModel.setFinished(true); physicalDiskModel.setSamplingTime(date); return physicalDiskModel; } - private NetworkInterfaceModel createFinishedNetworkInterfaceModel(Date date){ - NetworkInterfaceModel networkInterfaceModel=new NetworkInterfaceModel(); + + private NetworkInterfaceModel createFinishedNetworkInterfaceModel(Date date) { + NetworkInterfaceModel networkInterfaceModel = new NetworkInterfaceModel(); networkInterfaceModel.setFinished(true); networkInterfaceModel.setSamplingTime(date); return networkInterfaceModel; } - private ProcessModel createFinishedProcessModel(Date date){ - - ProcessModel processModel=new ProcessModel(); + + private ProcessModel createFinishedProcessModel(Date date) { + + ProcessModel processModel = new ProcessModel(); processModel.setProcessModelList(new LinkedList()); processModel.setProcessNameList(new LinkedList()); processModel.setFinished(true); diff --git a/Bench4Q-Master/src/main/java/org/bench4q/master/domain/factory/TestPlanFactory.java b/Bench4Q-Master/src/main/java/org/bench4q/master/domain/factory/TestPlanFactory.java index cfd1e904..f91e0b10 100644 --- a/Bench4Q-Master/src/main/java/org/bench4q/master/domain/factory/TestPlanFactory.java +++ b/Bench4Q-Master/src/main/java/org/bench4q/master/domain/factory/TestPlanFactory.java @@ -189,8 +189,8 @@ public class TestPlanFactory { try { fields[i].setAccessible(true); - String content=MarshalHelper.marshal( - fields[i].getType(), fields[i].get(scriptResultModel)); + String content = MarshalHelper.marshal(fields[i].getType(), + fields[i].get(scriptResultModel)); testPlanScriptResult.setResultContent(content); } catch (IllegalArgumentException | IllegalAccessException | JAXBException e) { @@ -222,7 +222,7 @@ public class TestPlanFactory { fields[i].getType(), fields[i].get(monitorMain))); } catch (IllegalArgumentException | IllegalAccessException | JAXBException e) { - Logger.getLogger(MonitorResult.class).info( + Logger.getLogger(this.getClass()).info( ExceptionLog.getStackTrace(e)); return null; } diff --git a/Bench4Q-Master/src/main/java/org/bench4q/master/domain/repository/AgentRepository.java b/Bench4Q-Master/src/main/java/org/bench4q/master/domain/repository/AgentRepository.java index 1ad29771..78b9140a 100644 --- a/Bench4Q-Master/src/main/java/org/bench4q/master/domain/repository/AgentRepository.java +++ b/Bench4Q-Master/src/main/java/org/bench4q/master/domain/repository/AgentRepository.java @@ -166,6 +166,7 @@ public class AgentRepository extends AbstractRepositoty { return session.createCriteria(Agent.class) .addOrder(Order.desc("remainLoad")).list(); } catch (Exception e) { + e.printStackTrace(); return null; } finally { releaseSession(session); diff --git a/Bench4Q-Master/src/main/java/org/bench4q/master/infrastructure/communication/impl/MonitorMessengerImpl.java b/Bench4Q-Master/src/main/java/org/bench4q/master/infrastructure/communication/impl/MonitorMessengerImpl.java index 95253f22..58aeeb57 100644 --- a/Bench4Q-Master/src/main/java/org/bench4q/master/infrastructure/communication/impl/MonitorMessengerImpl.java +++ b/Bench4Q-Master/src/main/java/org/bench4q/master/infrastructure/communication/impl/MonitorMessengerImpl.java @@ -95,6 +95,19 @@ public class MonitorMessengerImpl implements MonitorMessenger { } public MonitorMain monitorModel(String hostName, int port) { - return this.getMonitorModel(hostName, port, MonitorMain.class, "all"); + MonitorMain monitorMain = this.getMonitorModel(hostName, port, + MonitorMain.class, "all"); + monitorMain.getMemoryModel().setSamplingTime( + monitorMain.getSamplingTime()); + monitorMain.getNetworkInterfaceModel().setSamplingTime( + monitorMain.getSamplingTime()); + monitorMain.getPhysicalDiskModel().setSamplingTime( + monitorMain.getSamplingTime()); + monitorMain.getProcessModel().setSamplingTime( + monitorMain.getSamplingTime()); + monitorMain.getProcessorModel().setSamplingTime( + monitorMain.getSamplingTime()); + + return monitorMain; } }