modify limitFieldModel and test
This commit is contained in:
parent
9f596fc2a2
commit
25e553a178
|
@ -1,8 +1,6 @@
|
|||
package org.bench4q.monitor.api;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
|
@ -32,7 +30,7 @@ public class MainController {
|
|||
|
||||
@RequestMapping(value = "/limitableFields")
|
||||
@ResponseBody
|
||||
public LimitableFieldsModel limitableFields() {
|
||||
public LimitableFieldsModel limitableFields() throws SigarException {
|
||||
return new LimitableFieldsModel();
|
||||
}
|
||||
|
||||
|
|
|
@ -7,6 +7,9 @@ import javax.xml.bind.annotation.XmlElement;
|
|||
import javax.xml.bind.annotation.XmlElementWrapper;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
import org.hyperic.sigar.SigarException;
|
||||
|
||||
|
||||
@XmlRootElement(name = "limitableFields")
|
||||
public class LimitableFieldsModel {
|
||||
private List<String> fieldsParent;
|
||||
|
@ -21,17 +24,19 @@ public class LimitableFieldsModel {
|
|||
this.fields = fields;
|
||||
}
|
||||
|
||||
public LimitableFieldsModel() {
|
||||
public LimitableFieldsModel() throws SigarException {
|
||||
this.fields = new ArrayList<String>();
|
||||
this.fieldsParent = new ArrayList<String>();
|
||||
String stringMemoryModel = new MemoryModel().getClass().getName();
|
||||
String stringProcessorModel = new ProcessorModel().getClass().getName();
|
||||
this.fields.add("MemoryUsedPercent");
|
||||
this.fieldsParent.add("org.bench4q.monitor.model.MemoryModel");
|
||||
this.fieldsParent.add(stringMemoryModel);
|
||||
this.fields.add("ProcessorTimePercent");
|
||||
this.fieldsParent.add("org.bench4q.monitor.model.ProcessorModel");
|
||||
this.fieldsParent.add(stringProcessorModel);
|
||||
this.fields.add("UserTimePercent");
|
||||
this.fieldsParent.add("org.bench4q.monitor.model.ProcessorModel");
|
||||
this.fieldsParent.add(stringProcessorModel);
|
||||
this.fields.add("PrivilegedTimePercent");
|
||||
this.fieldsParent.add("org.bench4q.monitor.model.ProcessorModel");
|
||||
this.fieldsParent.add(stringProcessorModel);
|
||||
}
|
||||
|
||||
public String validname(String name){
|
||||
|
@ -49,6 +54,6 @@ public class LimitableFieldsModel {
|
|||
public void setFieldsParent(List<String> fieldsParent) {
|
||||
this.fieldsParent = fieldsParent;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -108,6 +108,7 @@ public class MonitorMain extends SampleModel {
|
|||
Method mget=c.getMethod("get"+name);
|
||||
double currentvalue=(Double) mget.invoke(obj);
|
||||
if (currentvalue >= limit) limitResult = true;
|
||||
//System.out.println(name+": "+currentvalue);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
|
|
@ -3,15 +3,18 @@ package org.bench4q.monitor;
|
|||
import java.util.List;
|
||||
|
||||
import org.bench4q.monitor.model.LimitableFieldsModel;
|
||||
import org.hyperic.sigar.SigarException;
|
||||
import org.junit.Test;
|
||||
|
||||
public class Test_LimitableFieldsModel {
|
||||
@Test
|
||||
public void testLimitableFieldsModelGet(){
|
||||
public void testLimitableFieldsModelGet() throws SigarException{
|
||||
LimitableFieldsModel limitList = new LimitableFieldsModel();
|
||||
List<String> result = limitList.getFields();
|
||||
List<String> resultP = limitList.getFieldsParent();
|
||||
for (int i = 0; i < result.size(); i++){
|
||||
System.out.println(result.get(i).toString());
|
||||
System.out.println(resultP.get(i).toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -16,14 +16,14 @@ public class Test_MainControler {
|
|||
LimitModel.ParameterModel params2 = new LimitModel.ParameterModel();
|
||||
LimitModel.ParameterModel params3 = new LimitModel.ParameterModel();
|
||||
LimitModel.ParameterModel params4 = new LimitModel.ParameterModel();
|
||||
params1.setName("memoryUsedPercent");
|
||||
params1.setName("MemoryUsedPercent");
|
||||
params1.setLimit(100);
|
||||
params2.setName("processorTimePercent");
|
||||
params2.setLimit(10);
|
||||
params3.setName("userTimePercent");
|
||||
params2.setName("ProcessorTimePercent");
|
||||
params2.setLimit(100);
|
||||
params3.setName("UserTimePercent");
|
||||
params3.setLimit(100);
|
||||
params4.setName("privilegedTimePercent");
|
||||
params4.setLimit(100);
|
||||
params4.setName("PrivilegedTimePercent");
|
||||
params4.setLimit(20);
|
||||
List<LimitModel.ParameterModel> list = new ArrayList<LimitModel.ParameterModel>();
|
||||
list.add(params1);
|
||||
list.add(params2);
|
||||
|
|
Loading…
Reference in New Issue