CIRunJobCluster.h 1.86 KB
Newer Older
1
2
3
#ifndef JOB_STAGE_REMOTE_H
#define JOB_STAGE_REMOTE_H

Pape, David (FWCC) - 139658's avatar
Pape, David (FWCC) - 139658 committed
4
#include "CIRunJob.h"
5

6
#include <map>
7
#include <string>
8

Pape, David (FWCC) - 139658's avatar
Pape, David (FWCC) - 139658 committed
9
#include "HPCJob.h"
10

11
12
13
/**
 * @brief Class to represent a job of the run stage to be executed distributedly on the cluster.
 *
14
 * This is meant for scripts of the substage "build_script". Non-cluster-related tasks are
Pape, David (FWCC) - 139658's avatar
Pape, David (FWCC) - 139658 committed
15
 * represented by \ref CIRunJobHead.
16
 */
Pape, David (FWCC) - 139658's avatar
Pape, David (FWCC) - 139658 committed
17
class CIRunJobCluster : public CIRunJob {
18

19
public:
20
21
22
    /**
     * @brief Constructor. Also registers #handler as signal handler for \c SIGTERM and sets
     *        #instance.
Pape, David (FWCC) - 139658's avatar
Pape, David (FWCC) - 139658 committed
23
24
25
     * @param[in] script Sets \ref CIRunJob::script.
     * @param[in] substage Sets \ref CIRunJob::substage.
     * @param[in] unifiedOutput Sets #UnifiedOutput.
26
     */
Pape, David (FWCC) - 139658's avatar
Pape, David (FWCC) - 139658 committed
27
28
    CIRunJobCluster(Environment *env, std::filesystem::path script, std::string subStage,
                    bool unifiedOutput = true);
29

30
31
32
    /**
     * @brief Simple destructor.
     */
Pape, David (FWCC) - 139658's avatar
Pape, David (FWCC) - 139658 committed
33
    ~CIRunJobCluster() override = default;
34

35
36
    /**
     * @brief Method used to execute the job.
37
     * @return The exit code of the job.
38
     */
Pape, David (FWCC) - 139658's avatar
Pape, David (FWCC) - 139658 committed
39
    int Run() override;
40
41

private:
42
43
    HPCJob *Job;        ///< A pointer to the corresponding HPC job for the cluster.
    bool UnifiedOutput; ///< Defines whether to unify stdout/stderr.
44

45
46
47
48
49
    /**
     * @brief Helper function, converting std::string.
     * @param[in] s The std::string to be converted.
     * @return The converted std::string.
     */
Pape, David (FWCC) - 139658's avatar
Pape, David (FWCC) - 139658 committed
50
    static std::string YmlToBash(std::string s);
51
52
53
54
    /**
     * @brief Signal handler, cancels #job on \c SIGTERM.
     * @param sig The received signal.
     */
Pape, David (FWCC) - 139658's avatar
Pape, David (FWCC) - 139658 committed
55
    static void Handler(int sig);
56

Pape, David (FWCC) - 139658's avatar
Pape, David (FWCC) - 139658 committed
57
    static inline CIRunJobCluster *Instance = nullptr; /**< A pointer to an instance of this class
58
                                                            that can be used by #Handler to find the
Pape, David (FWCC) - 139658's avatar
Pape, David (FWCC) - 139658 committed
59
                                                            object. */
60
61
62
};

#endif // JOB_STAGE_REMOTE_H