From 6ab5dca343ac3c34f64a26246d16ab4bb3030539 Mon Sep 17 00:00:00 2001 From: wangyu096 Date: Thu, 1 Feb 2024 10:40:56 +0800 Subject: [PATCH] =?UTF-8?q?feature:=20Job=20=E6=94=AF=E6=8C=81=E5=AE=B9?= =?UTF-8?q?=E5=99=A8=E6=89=A7=E8=A1=8C=20-=20=E8=84=9A=E6=9C=AC=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1=20#2631?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../execute/engine/util/JobSrcFileUtils.java | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/backend/job-execute/service-job-execute/src/main/java/com/tencent/bk/job/execute/engine/util/JobSrcFileUtils.java b/src/backend/job-execute/service-job-execute/src/main/java/com/tencent/bk/job/execute/engine/util/JobSrcFileUtils.java index c9f2874cad..eca86529a6 100644 --- a/src/backend/job-execute/service-job-execute/src/main/java/com/tencent/bk/job/execute/engine/util/JobSrcFileUtils.java +++ b/src/backend/job-execute/service-job-execute/src/main/java/com/tencent/bk/job/execute/engine/util/JobSrcFileUtils.java @@ -63,17 +63,26 @@ public static Map buildSourceDestPathMapping(Set src String standardTargetDir = FilePathUtils.standardizedDirPath(targetDir); long currentTime = System.currentTimeMillis(); for (JobFile srcFile : srcFiles) { - // 本地文件的源ip是本机ip,展开源文件IP地址宏采用"0.0.0.0" - String destDirPath = MacroUtil.resolveFileSrcIpMacro(standardTargetDir, - srcFile.getFileType() == TaskFileTypeEnum.LOCAL ? "0_0.0.0.0" : - srcFile.getExecuteObject().getHost().getBkCloudId() + "_" - + srcFile.getExecuteObject().getHost().getPrimaryIp()); + String destDirPath = resolveFileSrcIp(standardTargetDir, srcFile); destDirPath = MacroUtil.resolveDate(destDirPath, currentTime); addSourceDestPathMapping(sourceDestPathMap, srcFile, destDirPath, targetFileName); } return sourceDestPathMap; } + + private static String resolveFileSrcIp(String targetFilePath, JobFile srcFile) { + // 本地文件的源ip是本机ip,展开源文件IP地址宏采用"0.0.0.0" + String resolvedTargetPath = targetFilePath; + if (srcFile.getExecuteObject().isHostExecuteObject()) { + resolvedTargetPath = MacroUtil.resolveFileSrcIpMacro(targetFilePath, + srcFile.getFileType() == TaskFileTypeEnum.LOCAL ? "0_0.0.0.0" : + srcFile.getExecuteObject().getHost().getBkCloudId() + "_" + + srcFile.getExecuteObject().getHost().getPrimaryIp()); + } + return resolvedTargetPath; + } + private static void addSourceDestPathMapping(Map sourceDestPathMap, JobFile sourceFile, String destDirPath,