Adding SSH executor
This commit is contained in:
60
libdaggy/include/daggy/executors/task/SSHTaskExecutor.hpp
Normal file
60
libdaggy/include/daggy/executors/task/SSHTaskExecutor.hpp
Normal file
@@ -0,0 +1,60 @@
|
||||
#pragma once
|
||||
|
||||
#include "ForkingTaskExecutor.hpp"
|
||||
#include "TaskExecutor.hpp"
|
||||
|
||||
namespace daggy::executors::task {
|
||||
class SSHTaskExecutor : public TaskExecutor
|
||||
{
|
||||
public:
|
||||
struct RemoteHost
|
||||
{
|
||||
size_t cores;
|
||||
size_t memoryMB;
|
||||
};
|
||||
|
||||
using Command = std::vector<std::string>;
|
||||
|
||||
explicit SSHTaskExecutor(std::unordered_map<std::string, RemoteHost> hosts);
|
||||
|
||||
// Validates the job to ensure that all required values are set and are of
|
||||
// the right type,
|
||||
bool validateTaskParameters(const ConfigValues &job) override;
|
||||
|
||||
std::vector<ConfigValues> expandTaskParameters(
|
||||
const ConfigValues &job, const ConfigValues &expansionValues) override;
|
||||
|
||||
// Runs the task
|
||||
TaskFuture execute(DAGRunID runID, const std::string &taskName,
|
||||
const Task &task) override;
|
||||
|
||||
bool stop(DAGRunID runID, const std::string &taskName) override;
|
||||
|
||||
std::string description() const override;
|
||||
|
||||
private:
|
||||
struct RunningTask
|
||||
{
|
||||
std::string host;
|
||||
size_t cores;
|
||||
size_t memoryMB;
|
||||
TaskFuture fut;
|
||||
TaskFuture feFuture;
|
||||
int sshRetries;
|
||||
DAGRunID runID;
|
||||
std::string taskName;
|
||||
Task task;
|
||||
};
|
||||
|
||||
std::unordered_map<std::string, RemoteHost> hosts_;
|
||||
ForkingTaskExecutor fe_;
|
||||
std::mutex hostGuard_;
|
||||
std::condition_variable hostCV_;
|
||||
std::deque<RunningTask> runningTasks_;
|
||||
|
||||
void monitor();
|
||||
std::atomic<bool> running_;
|
||||
std::thread monitorWorker_;
|
||||
};
|
||||
} // namespace daggy::executors::task
|
||||
|
||||
Reference in New Issue
Block a user