-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: modify default planName (#342)
- Loading branch information
Showing
9 changed files
with
143 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...schedule/eventBus/PlanAutoRerunEvent.java → ...schedule/eventbus/PlanAutoRerunEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package com.arextest.schedule.eventBus; | ||
package com.arextest.schedule.eventbus; | ||
|
||
import lombok.Data; | ||
|
||
|
68 changes: 68 additions & 0 deletions
68
...dule-web-api/src/main/java/com/arextest/schedule/eventbus/PlanAutoReturnEventService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package com.arextest.schedule.eventbus; | ||
|
||
import com.arextest.schedule.exceptions.PlanRunningException; | ||
import com.arextest.schedule.model.CommonResponse; | ||
import com.arextest.schedule.model.ReplayPlan; | ||
import com.arextest.schedule.model.ReplayStatusType; | ||
import com.arextest.schedule.model.plan.ReRunReplayPlanRequest; | ||
import com.arextest.schedule.progress.ProgressEvent; | ||
import com.arextest.schedule.service.PlanProduceService; | ||
import com.google.common.eventbus.AsyncEventBus; | ||
import com.google.common.eventbus.Subscribe; | ||
import javax.annotation.Resource; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.beans.factory.InitializingBean; | ||
import org.springframework.context.annotation.Lazy; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Slf4j | ||
@Component | ||
public class PlanAutoReturnEventService implements InitializingBean { | ||
|
||
private static final String AUTO_OPERATOR = "Auto"; | ||
|
||
@Resource | ||
private AsyncEventBus autoRerunAsyncEventBus; | ||
|
||
@Lazy | ||
@Resource | ||
private PlanProduceService planProduceService; | ||
|
||
@Lazy | ||
@Resource | ||
private ProgressEvent progressEvent; | ||
|
||
@Override | ||
public void afterPropertiesSet() throws Exception { | ||
autoRerunAsyncEventBus.register(this); | ||
} | ||
|
||
public void postRerunAsyncEvent(PlanAutoRerunEvent event) { | ||
autoRerunAsyncEventBus.post(event); | ||
} | ||
|
||
@Subscribe | ||
public void planAutoRerun(PlanAutoRerunEvent event) { | ||
ReRunReplayPlanRequest request = new ReRunReplayPlanRequest(); | ||
request.setPlanId(event.getPlanId()); | ||
request.setOperator(AUTO_OPERATOR); | ||
try { | ||
CommonResponse response = planProduceService.reRunPlan(request); | ||
if (response.getResult() != 1) { | ||
LOGGER.error("Auto rerun plan fail, planId: {}", event.getPlanId()); | ||
finishPlan(event.getPlanId()); | ||
} | ||
} catch (PlanRunningException e) { | ||
LOGGER.error("Auto rerun plan fail, planId: {}", event.getPlanId(), e); | ||
finishPlan(event.getPlanId()); | ||
} | ||
} | ||
|
||
private void finishPlan(String planId) { | ||
ReplayPlan replayPlan = new ReplayPlan(); | ||
replayPlan.setId(planId); | ||
progressEvent.onReplayPlanFinish(replayPlan, ReplayStatusType.FINISHED); | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.