From 5475ef711216258f528e93f872227f40d2d00d90 Mon Sep 17 00:00:00 2001 From: coderfengyun Date: Mon, 31 Mar 2014 14:50:51 +0800 Subject: [PATCH] add try catch add try catch --- .../master/domain/service/TestPlanEngine.java | 45 ++++++++++--------- 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/Bench4Q-Master/src/main/java/org/bench4q/master/domain/service/TestPlanEngine.java b/Bench4Q-Master/src/main/java/org/bench4q/master/domain/service/TestPlanEngine.java index 0f5a61f6..2c9f684d 100644 --- a/Bench4Q-Master/src/main/java/org/bench4q/master/domain/service/TestPlanEngine.java +++ b/Bench4Q-Master/src/main/java/org/bench4q/master/domain/service/TestPlanEngine.java @@ -165,25 +165,30 @@ public class TestPlanEngine implements TaskCompleteCallback, public TestPlan pickATestPlan() { logger.info("enter pick"); - List criterions = new ArrayList(); - 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 testPlans = this.getTestPlanRepository() - .loadTestPlansBy(criterions, Order.desc("createDateTime")); - return testPlans.size() > 0 ? testPlans.get(0) : null; + try { + List criterions = new ArrayList(); + 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 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; + } } }