parent
efb6e56141
commit
5475ef7112
|
@ -165,25 +165,30 @@ public class TestPlanEngine implements TaskCompleteCallback,
|
|||
|
||||
public TestPlan pickATestPlan() {
|
||||
logger.info("enter pick");
|
||||
List<Criterion> criterions = new ArrayList<Criterion>();
|
||||
Criterion notComplete = Restrictions.not(Restrictions.eq(
|
||||
"currentStatus", TestPlanStatus.Complete.name()));
|
||||
criterions.add(notComplete);
|
||||
Criterion notInRunning = Restrictions.not(Restrictions.eq(
|
||||
"currentStatus", TestPlanStatus.InRunning.name()));
|
||||
criterions.add(notInRunning);
|
||||
Criterion lessThanPoolAvailbleLoad = Restrictions.lt("requiredLoad",
|
||||
this.getHaPool().getCurrentAvailableLoad());
|
||||
criterions.add(lessThanPoolAvailbleLoad);
|
||||
Criterion lessThanMaxFailTimes = Restrictions.lt("failTimes",
|
||||
Main.MAX_FAIL_TIMES);
|
||||
criterions.add(lessThanMaxFailTimes);
|
||||
Criterion intervalGTMin_Interval = Restrictions.lt("lastRunningTime",
|
||||
new Date(System.currentTimeMillis()
|
||||
- Main.MIN_EXECUTE_INTERVAL_IN_SECONDS * 1000));
|
||||
criterions.add(intervalGTMin_Interval);
|
||||
List<TestPlan> testPlans = this.getTestPlanRepository()
|
||||
.loadTestPlansBy(criterions, Order.desc("createDateTime"));
|
||||
return testPlans.size() > 0 ? testPlans.get(0) : null;
|
||||
try {
|
||||
List<Criterion> criterions = new ArrayList<Criterion>();
|
||||
Criterion notComplete = Restrictions.not(Restrictions.eq(
|
||||
"currentStatus", TestPlanStatus.Complete.name()));
|
||||
criterions.add(notComplete);
|
||||
Criterion notInRunning = Restrictions.not(Restrictions.eq(
|
||||
"currentStatus", TestPlanStatus.InRunning.name()));
|
||||
criterions.add(notInRunning);
|
||||
Criterion lessThanPoolAvailbleLoad = Restrictions.lt(
|
||||
"requiredLoad", this.getHaPool().getCurrentAvailableLoad());
|
||||
criterions.add(lessThanPoolAvailbleLoad);
|
||||
Criterion lessThanMaxFailTimes = Restrictions.lt("failTimes",
|
||||
Main.MAX_FAIL_TIMES);
|
||||
criterions.add(lessThanMaxFailTimes);
|
||||
Criterion intervalGTMin_Interval = Restrictions.lt(
|
||||
"lastRunningTime", new Date(System.currentTimeMillis()
|
||||
- Main.MIN_EXECUTE_INTERVAL_IN_SECONDS * 1000));
|
||||
criterions.add(intervalGTMin_Interval);
|
||||
List<TestPlan> testPlans = this.getTestPlanRepository()
|
||||
.loadTestPlansBy(criterions, Order.desc("createDateTime"));
|
||||
return testPlans.size() > 0 ? testPlans.get(0) : null;
|
||||
} catch (Exception e) {
|
||||
logger.error(e, e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue