add loadMonitorResults in history

This commit is contained in:
coderfengyun 2014-01-06 17:06:53 +08:00
parent 6a0b391faf
commit 65737b278e
1 changed files with 28 additions and 70 deletions

View File

@ -2,18 +2,15 @@ package org.bench4q.master.api;
import java.util.UUID;
import org.bench4q.master.service.communication.MonitorService;
import org.bench4q.master.service.infrastructure.MonitorResultService;
import org.bench4q.master.service.infrastructure.UserService;
import org.bench4q.share.models.master.MonitorLogicalDiskResponseModel;
import org.bench4q.share.models.master.MonitorMemoryResponseModel;
import org.bench4q.share.models.master.MonitorNetworkReponseModel;
import org.bench4q.share.models.master.MonitorProcessorResponseModel;
import org.bench4q.share.models.monitor.LogicalDiskModel;
import org.bench4q.share.models.monitor.MemoryModel;
import org.bench4q.share.models.monitor.NetworkInterfaceModel;
import org.bench4q.share.models.monitor.ProcessorModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
@ -22,37 +19,28 @@ import org.springframework.web.bind.annotation.ResponseBody;
@Controller
@RequestMapping(value = "/monitorController")
public class MonitorController extends BaseController {
private MonitorService monitorService;
private MonitorResultService monitorResultService;
public MonitorService getMonitorService() {
return monitorService;
private MonitorResultService getMonitorResultService() {
return monitorResultService;
}
@Autowired
public void setMonitorService(MonitorService monitorService) {
this.monitorService = monitorService;
private void setMonitorResultService(
MonitorResultService monitorResultService) {
this.monitorResultService = monitorResultService;
}
@RequestMapping(value = "/logicDiskMonitorSUTInfo", method = RequestMethod.GET)
@RequestMapping(value = "/logicDiskMonitorSUTInfo/{testPlanRunId}/{hostName}/{port}/{duationBegin}", method = RequestMethod.GET)
@ResponseBody
public MonitorLogicalDiskResponseModel logicDiskMonitorSUTInfo(
@RequestParam UUID testPlanRunId, @RequestParam String hostName,
@RequestParam int port) {
@PathVariable UUID testPlanRunId, @PathVariable String hostName,
@PathVariable int port, @PathVariable long duationBegin) {
if (!this.checkScope(UserService.NORAML_AUTHENTICATION)) {
return buildDiskResponseModel(false,
"you don't have the power to check the monitor", null);
return null;
}
return buildDiskResponseModel(true, "", this.getMonitorService()
.logicDisk(testPlanRunId, hostName, port));
}
private MonitorLogicalDiskResponseModel buildDiskResponseModel(
boolean success, String failCause, LogicalDiskModel logicalDiskModel) {
MonitorLogicalDiskResponseModel result = new MonitorLogicalDiskResponseModel();
result.setSuccess(success);
result.setFailCause(failCause);
result.setLogicalDiskModel(logicalDiskModel);
return result;
return this.getMonitorResultService().loadLogicalDiskResults(
testPlanRunId, hostName, port, duationBegin);
}
@RequestMapping(value = "/memorySUTInfo", method = { RequestMethod.GET,
@ -60,66 +48,36 @@ public class MonitorController extends BaseController {
@ResponseBody
public MonitorMemoryResponseModel memorySUTInfo(
@RequestParam UUID testPlanRunId, @RequestParam String hostName,
@RequestParam int port) {
@RequestParam int port, @RequestParam long duationBegin) {
if (!this.checkScope(UserService.NORAML_AUTHENTICATION)) {
return buildMemoryResponseModel(false, "no scope for memory ", null);
return null;
}
return buildMemoryResponseModel(true, "", this.getMonitorService()
.memory(testPlanRunId, hostName, port));
return this.getMonitorResultService().loadMemoryModels(testPlanRunId,
hostName, port, duationBegin);
}
private MonitorMemoryResponseModel buildMemoryResponseModel(
boolean success, String failCause, MemoryModel memoryModel) {
MonitorMemoryResponseModel result = new MonitorMemoryResponseModel();
result.setSuccess(success);
result.setFailCause(failCause);
result.setMemoryModel(memoryModel);
return result;
}
@RequestMapping(value = "/processorSUTInfo", method = { RequestMethod.GET,
RequestMethod.POST })
@RequestMapping(value = "/processorSUTInfo", method = { RequestMethod.GET })
@ResponseBody
public MonitorProcessorResponseModel processorSUTInfo(
@RequestParam UUID testPlanRunId, @RequestParam String hostName,
@RequestParam int port) {
@RequestParam int port, @RequestParam long duationBegin) {
if (!this.checkScope(UserService.NORAML_AUTHENTICATION)) {
return buildProcessorResponseModel(false, "no scope for processor",
null);
return null;
}
return buildProcessorResponseModel(true, "", this.getMonitorService()
.processor(testPlanRunId, hostName, port));
return this.getMonitorResultService().loadProcessorModels(
testPlanRunId, hostName, port, duationBegin);
}
private MonitorProcessorResponseModel buildProcessorResponseModel(
boolean success, String failCause, ProcessorModel processorModel) {
MonitorProcessorResponseModel resultModel = new MonitorProcessorResponseModel();
resultModel.setSuccess(success);
resultModel.setFailCause(failCause);
resultModel.setProcessorModel(processorModel);
return resultModel;
}
@RequestMapping(value = "/networkInfo", method = { RequestMethod.GET,
RequestMethod.POST })
@RequestMapping(value = "/networkInfo", method = { RequestMethod.GET })
@ResponseBody
public MonitorNetworkReponseModel networkInfo(
@RequestParam UUID testPlanRunId, @RequestParam String hostName,
@RequestParam int port) {
@RequestParam int port, @RequestParam long duationBegin) {
if (!this.checkScope(UserService.NORAML_AUTHENTICATION)) {
return buildNetworkResponseModel(false, "no scope for network",
null);
return null;
}
return buildNetworkResponseModel(true, "", this.getMonitorService()
.networkInterface(testPlanRunId, hostName, port));
return this.getMonitorResultService().loadNetworkInterfaceModels(
testPlanRunId, hostName, port, duationBegin);
}
private MonitorNetworkReponseModel buildNetworkResponseModel(
boolean success, String failCause, NetworkInterfaceModel model) {
MonitorNetworkReponseModel result = new MonitorNetworkReponseModel();
result.setSuccess(success);
result.setFailCause(failCause);
result.setModel(model);
return result;
}
}