aif修改。重新执行逻辑修改
This commit is contained in:
parent
269250692a
commit
9ce08b82ef
@ -57,7 +57,10 @@ public class SerialDispatcher implements BaseDispatcher {
|
|||||||
if (context != null) {
|
if (context != null) {
|
||||||
taskRunContext= (TaskRunContext) context;
|
taskRunContext= (TaskRunContext) context;
|
||||||
context.setContextDef(pipTask);
|
context.setContextDef(pipTask);
|
||||||
|
// 之前错误的节点从错误出执行的时候会变成 这个新的状态
|
||||||
|
if (ContextStateEnum.ERROR_EXECUTE_READY.getCode().equals(context.getState().get())) {
|
||||||
context.setEndTime(null);
|
context.setEndTime(null);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// 防止运行停止以后添加节点,以及到达之前未执行的节点 ,todo 删除节点的同时也要删除上下文
|
// 防止运行停止以后添加节点,以及到达之前未执行的节点 ,todo 删除节点的同时也要删除上下文
|
||||||
taskRunContext = new TaskRunContext(pipTask,stageRunContext,new HashMap<>());
|
taskRunContext = new TaskRunContext(pipTask,stageRunContext,new HashMap<>());
|
||||||
|
@ -14,6 +14,7 @@ public enum ContextStateEnum {
|
|||||||
HAPPY_ENDING(4,"执行成功"),
|
HAPPY_ENDING(4,"执行成功"),
|
||||||
BAD_ENDING(5,"执行失败"),
|
BAD_ENDING(5,"执行失败"),
|
||||||
SKIP_TO(6,"跳过"),
|
SKIP_TO(6,"跳过"),
|
||||||
|
//如果状态依然为执行失败,开始重新执行就会直接因为存在执行错误而结束,所以从错误处重新执行引入了这个新状态
|
||||||
ERROR_EXECUTE_READY(7,"从错误处执行准备完毕")
|
ERROR_EXECUTE_READY(7,"从错误处执行准备完毕")
|
||||||
;
|
;
|
||||||
|
|
||||||
|
@ -143,6 +143,7 @@ public class AFLSlotCompileWorker extends DockerWorker {
|
|||||||
String user = machineInfo.getUsername();
|
String user = machineInfo.getUsername();
|
||||||
append(context, "AFL编译完毕");
|
append(context, "AFL编译完毕");
|
||||||
List<String> fileNameList = null;
|
List<String> fileNameList = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
JSch jsch = new JSch();
|
JSch jsch = new JSch();
|
||||||
Session session = jsch.getSession(user, host, 22);
|
Session session = jsch.getSession(user, host, 22);
|
||||||
@ -151,27 +152,70 @@ public class AFLSlotCompileWorker extends DockerWorker {
|
|||||||
session.connect();
|
session.connect();
|
||||||
ChannelSftp sftpChannel = (ChannelSftp) session.openChannel("sftp");
|
ChannelSftp sftpChannel = (ChannelSftp) session.openChannel("sftp");
|
||||||
sftpChannel.connect();
|
sftpChannel.connect();
|
||||||
Vector<ChannelSftp.LsEntry> files = sftpChannel.ls(path);
|
|
||||||
fileNameList = new ArrayList<>(files.size());
|
// 递归获取文件列表
|
||||||
for (ChannelSftp.LsEntry file : files) {
|
fileNameList = getFilesRecursively(sftpChannel, path, path);
|
||||||
if (!file.getAttrs().isDir()&&!file.getFilename().contains(".")) {
|
|
||||||
fileNameList.add(file.getFilename());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
sftpChannel.disconnect();
|
sftpChannel.disconnect();
|
||||||
session.disconnect();
|
session.disconnect();
|
||||||
} catch (JSchException | SftpException e) {
|
} catch (JSchException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!CollectionUtils.isEmpty(fileNameList) && context != null) {
|
if (!CollectionUtils.isEmpty(fileNameList) && context != null) {
|
||||||
Map<String, Object> taskProperties = context.getGlobalVariables();
|
|
||||||
// 放入全局上下文中
|
// 放入全局上下文中
|
||||||
append(context, "AFL编译完毕:" + JSON.toJSONString(fileNameList));
|
append(context, "AFL编译完毕:" + JSON.toJSONString(fileNameList));
|
||||||
|
|
||||||
return fileNameList;
|
return fileNameList;
|
||||||
}
|
}
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 递归获取文件夹下的所有文件
|
||||||
|
* @param sftpChannel SFTP通道
|
||||||
|
* @param currentPath 当前路径
|
||||||
|
* @param basePath 基础路径(用于计算相对路径)
|
||||||
|
* @return 相对路径文件列表
|
||||||
|
*/
|
||||||
|
private List<String> getFilesRecursively(ChannelSftp sftpChannel, String currentPath, String basePath) {
|
||||||
|
List<String> fileList = new ArrayList<>();
|
||||||
|
|
||||||
|
try {
|
||||||
|
Vector<ChannelSftp.LsEntry> entries = sftpChannel.ls(currentPath);
|
||||||
|
|
||||||
|
for (ChannelSftp.LsEntry entry : entries) {
|
||||||
|
String fileName = entry.getFilename();
|
||||||
|
|
||||||
|
// 跳过 . 和 .. 目录
|
||||||
|
if (".".equals(fileName) || "..".equals(fileName)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
String fullPath = currentPath + "/" + fileName;
|
||||||
|
String relativePath = fullPath.substring(basePath.length());
|
||||||
|
|
||||||
|
// 去掉开头的斜杠
|
||||||
|
if (relativePath.startsWith("/")) {
|
||||||
|
relativePath = relativePath.substring(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (entry.getAttrs().isDir()) {
|
||||||
|
// 如果是目录,递归获取子目录中的文件
|
||||||
|
List<String> subFiles = getFilesRecursively(sftpChannel, fullPath, basePath);
|
||||||
|
fileList.addAll(subFiles);
|
||||||
|
} else {
|
||||||
|
// 如果是文件,检查是否没有扩展名(可能是二进制文件)
|
||||||
|
if (!fileName.contains(".")) {
|
||||||
|
fileList.add(relativePath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (SftpException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
return fileList;
|
||||||
|
}
|
||||||
public String getSourceName(String fileName){
|
public String getSourceName(String fileName){
|
||||||
int dotIndex = fileName.lastIndexOf(".");
|
int dotIndex = fileName.lastIndexOf(".");
|
||||||
if (dotIndex!=-1) {
|
if (dotIndex!=-1) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user