|
|
@ -39,10 +39,11 @@ import java.util.EnumSet; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import lombok.SneakyThrows; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
|
|
|
|
|
|
|
|
@Slf4j |
|
|
|
@Slf4j |
|
|
|
public class RemoteExecutor { |
|
|
|
public class RemoteExecutor implements AutoCloseable { |
|
|
|
|
|
|
|
|
|
|
|
static final String REMOTE_SHELL_HOME = "/tmp/dolphinscheduler-remote-shell-%s/"; |
|
|
|
static final String REMOTE_SHELL_HOME = "/tmp/dolphinscheduler-remote-shell-%s/"; |
|
|
|
static final String STATUS_TAG_MESSAGE = "DOLPHINSCHEDULER-REMOTE-SHELL-TASK-STATUS-"; |
|
|
|
static final String STATUS_TAG_MESSAGE = "DOLPHINSCHEDULER-REMOTE-SHELL-TASK-STATUS-"; |
|
|
@ -50,9 +51,9 @@ public class RemoteExecutor { |
|
|
|
|
|
|
|
|
|
|
|
protected Map<String, String> taskOutputParams = new HashMap<>(); |
|
|
|
protected Map<String, String> taskOutputParams = new HashMap<>(); |
|
|
|
|
|
|
|
|
|
|
|
SshClient sshClient; |
|
|
|
private SshClient sshClient; |
|
|
|
ClientSession session; |
|
|
|
private ClientSession session; |
|
|
|
SSHConnectionParam sshConnectionParam; |
|
|
|
private SSHConnectionParam sshConnectionParam; |
|
|
|
|
|
|
|
|
|
|
|
public RemoteExecutor(SSHConnectionParam sshConnectionParam) { |
|
|
|
public RemoteExecutor(SSHConnectionParam sshConnectionParam) { |
|
|
|
|
|
|
|
|
|
|
@ -205,6 +206,18 @@ public class RemoteExecutor { |
|
|
|
return String.format(REMOTE_SHELL_HOME, sshConnectionParam.getUser()); |
|
|
|
return String.format(REMOTE_SHELL_HOME, sshConnectionParam.getUser()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@SneakyThrows |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void close() { |
|
|
|
|
|
|
|
if (session != null && session.isOpen()) { |
|
|
|
|
|
|
|
session.close(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (sshClient != null && sshClient.isStarted()) { |
|
|
|
|
|
|
|
sshClient.close(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static class COMMAND { |
|
|
|
static class COMMAND { |
|
|
|
|
|
|
|
|
|
|
|
private COMMAND() { |
|
|
|
private COMMAND() { |
|
|
|