|
@@ -5,7 +5,7 @@ import com.nokia.common.ssh.entity.SSHServer;
|
|
|
import com.nokia.common.ssh.entity.UserInfoImpl;
|
|
|
import com.nokia.common.ssh.exception.SSHUtilException;
|
|
|
import com.nokia.common.ssh.exception.ScpAckErrorException;
|
|
|
-import com.xxl.job.core.log.XxlJobLogger;
|
|
|
+import com.xxl.job.core.context.XxlJobHelper;
|
|
|
import lombok.Getter;
|
|
|
import lombok.Setter;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
@@ -148,13 +148,13 @@ public class SSHUtil {
|
|
|
channel.connect();
|
|
|
if (checkAck(inputStream) != 0) {
|
|
|
log.error("scpTo 执行失败");
|
|
|
- XxlJobLogger.log("scpTo 执行失败");
|
|
|
+ XxlJobHelper.log("scpTo 执行失败");
|
|
|
return false;
|
|
|
}
|
|
|
File sourceFile = new File(sourceFilePath);
|
|
|
if (sourceFile.isDirectory()) {
|
|
|
log.error("sourceFilePath 必须是文件");
|
|
|
- XxlJobLogger.log("sourceFilePath 必须是文件");
|
|
|
+ XxlJobHelper.log("sourceFilePath 必须是文件");
|
|
|
return false;
|
|
|
}
|
|
|
long fileSize = sourceFile.length();
|
|
@@ -163,7 +163,7 @@ public class SSHUtil {
|
|
|
outputStream.flush();
|
|
|
if (checkAck(inputStream) != 0) {
|
|
|
log.error("scpTo 执行失败");
|
|
|
- XxlJobLogger.log("scpTo 执行失败");
|
|
|
+ XxlJobHelper.log("scpTo 执行失败");
|
|
|
return false;
|
|
|
}
|
|
|
fileInputStream = new FileInputStream(sourceFile);
|
|
@@ -190,7 +190,7 @@ public class SSHUtil {
|
|
|
public boolean scpFrom(String sourceFilePath, String targetPath) throws JSchException, IOException, SSHUtilException {
|
|
|
try {
|
|
|
log.debug(sourceFilePath);
|
|
|
- XxlJobLogger.log(sourceFilePath);
|
|
|
+ XxlJobHelper.log(sourceFilePath);
|
|
|
session = getConnectSession();
|
|
|
// scp内置了两个参数 -t 和 -f ,这两个参数是隐藏的,不会被用户显式提供,
|
|
|
// 两个scp进程之间传输数据时,远端机器上的scp进程被本地scp进程启动起来时提供上去。
|
|
@@ -242,7 +242,7 @@ public class SSHUtil {
|
|
|
}
|
|
|
}
|
|
|
log.debug("filesize={}, file={}", filesize, file);
|
|
|
- XxlJobLogger.log("filesize={}, file={}", filesize, file);
|
|
|
+ XxlJobHelper.log("filesize={}, file={}", filesize, file);
|
|
|
// 发送 '0'
|
|
|
buf[0] = 0;
|
|
|
outputStream.write(buf, 0, 1);
|
|
@@ -251,7 +251,7 @@ public class SSHUtil {
|
|
|
File target = new File(targetPath);
|
|
|
if (target.isDirectory()) {
|
|
|
log.debug("{} 是目录,需要添加文件名", target.getAbsolutePath());
|
|
|
- XxlJobLogger.log("{} 是目录,需要添加文件名", target.getAbsolutePath());
|
|
|
+ XxlJobHelper.log("{} 是目录,需要添加文件名", target.getAbsolutePath());
|
|
|
target = new File(targetPath + File.separator + file);
|
|
|
}
|
|
|
|
|
@@ -281,7 +281,7 @@ public class SSHUtil {
|
|
|
outputStream.write(buf, 0, 1);
|
|
|
outputStream.flush();
|
|
|
log.debug("scp from {}@{}:{}{} to {} 完成", targetServer.getUser(), targetServer.getHost(), targetServer.getPort(), sourceFilePath, target.getAbsolutePath());
|
|
|
- XxlJobLogger.log("scp from {}@{}:{}{} to {} 完成", targetServer.getUser(), targetServer.getHost(), targetServer.getPort(), sourceFilePath, target.getAbsolutePath());
|
|
|
+ XxlJobHelper.log("scp from {}@{}:{}{} to {} 完成", targetServer.getUser(), targetServer.getHost(), targetServer.getPort(), sourceFilePath, target.getAbsolutePath());
|
|
|
return true;
|
|
|
} finally {
|
|
|
disconnect();
|
|
@@ -299,7 +299,7 @@ public class SSHUtil {
|
|
|
session.setConfig(properties);
|
|
|
session.connect();
|
|
|
log.debug("已连接到{}@{}:{}", targetServer.getUser(), targetServer.getHost(), targetServer.getPort());
|
|
|
- XxlJobLogger.log("已连接到{}@{}:{}", targetServer.getUser(), targetServer.getHost(), targetServer.getPort());
|
|
|
+ XxlJobHelper.log("已连接到{}@{}:{}", targetServer.getUser(), targetServer.getHost(), targetServer.getPort());
|
|
|
return session;
|
|
|
}
|
|
|
|
|
@@ -354,7 +354,7 @@ public class SSHUtil {
|
|
|
sb.append((char) c);
|
|
|
} while (c != '\n');
|
|
|
log.debug("checkAck发现错误消息: ack={}-msg={}", b, sb);
|
|
|
- XxlJobLogger.log("checkAck发现错误消息: ack={}-msg={}", b, sb);
|
|
|
+ XxlJobHelper.log("checkAck发现错误消息: ack={}-msg={}", b, sb);
|
|
|
if (b == 1 && sb.toString().endsWith("No such file or directory")) {
|
|
|
throw new NoSuchFileException(sb.toString());
|
|
|
} else {
|