Merge branch 'master' of https://github.com/lostcharlie/Bench4Q.git
This commit is contained in:
commit
4f98da003c
|
@ -9,8 +9,8 @@ import javax.xml.bind.annotation.XmlRootElement;
|
|||
|
||||
@XmlRootElement(name = "limitableFields")
|
||||
public class LimitableFieldsModel {
|
||||
private List<String> fieldsParent;
|
||||
private List<String> fields;
|
||||
|
||||
@XmlElementWrapper(name = "fieldList")
|
||||
@XmlElement(name = "field")
|
||||
public List<String> getFields() {
|
||||
|
@ -23,10 +23,31 @@ public class LimitableFieldsModel {
|
|||
|
||||
public LimitableFieldsModel() {
|
||||
this.fields = new ArrayList<String>();
|
||||
this.fields.add("memoryUsedPercent");
|
||||
this.fields.add("processorTimePercent");
|
||||
this.fields.add("userTimePercent");
|
||||
this.fields.add("privilegedTimePercent");
|
||||
this.fieldsParent = new ArrayList<String>();
|
||||
this.fields.add("MemoryUsedPercent");
|
||||
this.fieldsParent.add("org.bench4q.monitor.model.MemoryModel");
|
||||
this.fields.add("ProcessorTimePercent");
|
||||
this.fieldsParent.add("org.bench4q.monitor.model.ProcessorModel");
|
||||
this.fields.add("UserTimePercent");
|
||||
this.fieldsParent.add("org.bench4q.monitor.model.ProcessorModel");
|
||||
this.fields.add("PrivilegedTimePercent");
|
||||
this.fieldsParent.add("org.bench4q.monitor.model.ProcessorModel");
|
||||
}
|
||||
|
||||
public String validname(String name){
|
||||
for (int i = 0; i < this.fields.size(); i++){
|
||||
if (name.toUpperCase().equals(fields.get(i).toUpperCase()))
|
||||
return fieldsParent.get(i);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public List<String> getFieldsParent() {
|
||||
return fieldsParent;
|
||||
}
|
||||
|
||||
public void setFieldsParent(List<String> fieldsParent) {
|
||||
this.fieldsParent = fieldsParent;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
package org.bench4q.monitor.model;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.TimeZone;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
|
@ -97,21 +99,18 @@ public class MonitorMain extends SampleModel {
|
|||
for (int i = 0; i < list.size(); i++){
|
||||
String name = list.get(i).getName();
|
||||
double limit = list.get(i).getLimit();
|
||||
if (name.equals("memoryUsedPercent")){
|
||||
if (limit <= this.memoryModel.getMemoryUsedPercent())
|
||||
limitResult = true;
|
||||
}
|
||||
if (name.equals("processorTimePercent")){
|
||||
if (limit <= this.processorModel.getProcessorTimePercent())
|
||||
limitResult = true;
|
||||
}
|
||||
if (name.equals("userTimePercent")){
|
||||
if (limit <= this.processorModel.getUserTimePercent())
|
||||
limitResult = true;
|
||||
}
|
||||
if (name.equals("privilegedTimePercent")){
|
||||
if (limit <= this.processorModel.getPrivilegedTimePercent())
|
||||
limitResult = true;
|
||||
LimitableFieldsModel limitableFieldsModel = new LimitableFieldsModel();
|
||||
String parent = limitableFieldsModel.validname(name);
|
||||
if (parent !=""){
|
||||
try {
|
||||
Class<?> c = Class.forName(parent);
|
||||
Object obj=c.newInstance();
|
||||
Method mget=c.getMethod("get"+name);
|
||||
double currentvalue=(Double) mget.invoke(obj);
|
||||
if (currentvalue >= limit) limitResult = true;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
return limitResult;
|
||||
|
|
Loading…
Reference in New Issue