1. 添加部分swagger文档
This commit is contained in:
@@ -31,6 +31,10 @@ public class StateChangeService {
|
||||
|
||||
State newState = StateEnum.getStateByNum(stateNum);
|
||||
|
||||
if (newState == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!originalState.handle(newState, commandService, taskService, taskId)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -77,13 +77,7 @@ public class StateHandler {
|
||||
throw new IllegalArgumentException("static rules are empty, need to choose at least one static rule");
|
||||
}
|
||||
|
||||
try {
|
||||
commandService.createCommands(staticTaskCommandInfos);
|
||||
} catch (DorisStartException e) {
|
||||
e.taskId = taskId;
|
||||
throw e;
|
||||
}
|
||||
|
||||
commandService.createCommands(staticTaskCommandInfos);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.realtime.protection.server.task.status.states;
|
||||
|
||||
import com.realtime.protection.configuration.exception.DorisStartException;
|
||||
import com.realtime.protection.configuration.utils.enums.StateEnum;
|
||||
import com.realtime.protection.configuration.utils.status.State;
|
||||
import com.realtime.protection.server.command.CommandService;
|
||||
import com.realtime.protection.server.task.TaskService;
|
||||
import com.realtime.protection.server.task.status.StateHandler;
|
||||
|
||||
public class GeneratingState extends StateHandler implements State {
|
||||
@Override
|
||||
public Boolean handle(State newState, CommandService commandService, TaskService taskService, Long taskId) throws DorisStartException {
|
||||
return switch(StateEnum.getStateEnumByState(newState)) {
|
||||
case RUNNING, GENERATING -> true;
|
||||
case FAILED -> handleFailed(commandService, taskId);
|
||||
default -> throw new IllegalStateException("Unexpected value: " + StateEnum.getStateEnumByState(newState));
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,7 @@ public class PendingState extends StateHandler implements State {
|
||||
@Override
|
||||
public Boolean handle(State newState, CommandService commandService, TaskService taskService, Long taskId) throws DorisStartException {
|
||||
return switch (StateEnum.getStateEnumByState(newState)) {
|
||||
case RUNNING -> handleStart(taskService, commandService, taskId);
|
||||
case GENERATING -> handleStart(taskService, commandService, taskId);
|
||||
case FAILED -> handleFailed(commandService, taskId);
|
||||
default -> throw new IllegalStateException("Unexpected value: " + StateEnum.getStateEnumByState(newState));
|
||||
};
|
||||
|
||||
@@ -10,7 +10,7 @@ public class RunningState extends StateHandler implements State {
|
||||
@Override
|
||||
public Boolean handle(State newState, CommandService commandService, TaskService taskService, Long taskId) {
|
||||
return switch(StateEnum.getStateEnumByState(newState)) {
|
||||
case RUNNING -> true;
|
||||
case RUNNING, GENERATING -> true;
|
||||
case PAUSED -> handlePause(commandService, taskId);
|
||||
case STOP -> handleStop(commandService, taskId);
|
||||
case FINISHED -> handleFinish(commandService, taskId);
|
||||
|
||||
Reference in New Issue
Block a user