RStudio Launcher Plugin SDK
1.1.3
A software development kit for creating plugins that work the the RStudio Launcher.
|
24 #ifndef LAUNCHER_PLUGINS_JOB_HPP
25 #define LAUNCHER_PLUGINS_JOB_HPP
32 #include <Noncopyable.hpp>
33 #include <Optional.hpp>
36 #include <system/DateTime.hpp>
37 #include <system/User.hpp>
38 #include <utils/MutexUtils.hpp>
41 namespace launcher_plugins {
49 namespace launcher_plugins {
54 struct AzureFileMountSource;
55 struct CephFsMountSource;
58 struct GlusterFsMountSource;
59 struct HostMountSource;
65 struct NfsMountSource;
67 struct PlacementConstraint;
70 typedef std::shared_ptr<Job> JobPtr;
71 typedef std::shared_ptr<const Job> ConstJobPtr;
73 typedef std::pair<std::string, std::string> EnvVariable;
74 typedef std::vector<EnvVariable> EnvironmentList;
75 typedef std::vector<ExposedPort> ExposedPortList;
76 typedef std::vector<JobConfig> JobConfigList;
77 typedef std::vector<JobPtr> JobList;
78 typedef std::vector<Mount> MountList;
79 typedef std::vector<PlacementConstraint> PlacementConstraintList;
80 typedef std::vector<ResourceLimit> ResourceLimitList;
197 Job(
Job&& in_other) noexcept;
269 bool matchesTags(
const std::set<std::string>& in_tags)
const;
378 PRIVATE_IMPL(m_impl);
460 explicit JobLock(JobPtr in_job);
469 explicit JobLock(ConstJobPtr in_job);
473 PRIVATE_IMPL(m_impl);
1004 explicit ResourceLimit(std::string in_limitType, std::string in_maxValue =
"", std::string in_defaultValue =
"");
1036 #define LOCK_JOB(in_job) \
1039 rstudio::launcher_plugins::api::JobLock jobLock(in_job); \
1042 #define LOCK_MUTEX_AND_JOB(in_lockType, in_mutexType, in_mutex, in_job) \
1045 in_lockType<in_mutexType> mutexLock(in_mutex); \
1046 rstudio::launcher_plugins::api::JobLock jobLock(in_job); \
1049 #define END_LOCK_JOB END_LOCK_MUTEX
1051 #define END_LOCK_MUTEX_AND_JOB END_LOCK_JOB
Optional< pid_t > Pid
Definition: Job.hpp:336
Optional< int > PublishedPort
Definition: Job.hpp:136
std::string Image
Definition: Job.hpp:103
HostMountSource & asHostMountSource()
Gets this MountSource as an HostMountSource.
json::Object toJson() const
Converts this ResourceLimit to a JSON object which represents it.
std::string Value
Definition: Job.hpp:446
static Error fromJson(const json::Object &in_json, GlusterFsMountSource &out_mountSource)
Constructs a GlusterFsMountSource from a JSON object which represents the mount source.
JobConfigList Config
Definition: Job.hpp:295
Struct which represents a custom placement constraint for the job.
Definition: Job.hpp:919
json::Object toJson() const
Converts this Mount to a JSON object which represents it.
Class which represents a specific type of JSON Value: a JSON object.
Definition: Json.hpp:687
system::User User
Definition: Job.hpp:369
json::Object toJson() const
Converts this NfsMountSource to a JSON object which represents it.
PlacementConstraintList PlacementConstraints
Definition: Job.hpp:339
json::Object toJson() const
Converts this PlacementConstraint to a JSON object which represents it.
Structure which represents a job.
Definition: Job.hpp:146
EnvironmentList Environment
Definition: Job.hpp:301
Optional< int > ExitCode
Definition: Job.hpp:315
std::string getSecretName() const
Gets the name of the Azure Secret used to connect to the Azure File Mount Source.
Class which represents a system user.
Definition: User.hpp:55
Represents an Azure File Mount Source.
Definition: Job.hpp:667
static Error fromJson(const json::Object &in_json, ResourceLimit &out_resourceLimit)
Constructs a ResourceLimit from a JSON object which represents the resource limit.
static const char *const MEMORY_SWAP
Definition: Job.hpp:989
std::vector< std::string > getMonitors() const
Gets the list of Ceph monitor addresses.
std::string getSecretRef() const
Gets the reference to the Ceph authentication secrets which override the Secret File.
json::Object SourceObject
Definition: Job.hpp:660
std::string Command
The shell command to run.
Definition: Job.hpp:292
JobLock(JobPtr in_job)
Constructor.
std::string getShareName() const
Gets the name of the share in Azure to be mounted.
std::string getPath() const
Gets the name of the GlusterFs volume mount.
bool IsReadOnly
Definition: Job.hpp:897
Type
Constants representing the support types of MountSource.
Definition: Job.hpp:480
std::string getSecretFile() const
Gets the location of the file which contains the Ceph keyring for authentication.
std::string getUser() const
Gets the user to mount the path as.
MountList Mounts
Definition: Job.hpp:330
Struct which represents an file system mount available to a job.
Definition: Job.hpp:875
std::string getPath() const
Gets the path on the current host to be mounted.
CephFsMountSource & asCephFsMountSource()
Gets this MountSource as an CephFsMountSource.
std::string StandardIn
Definition: Job.hpp:348
Type SourceType
Definition: Job.hpp:663
Optional< system::DateTime > LastUpdateTime
Definition: Job.hpp:327
Struct which represents a resource limit for a job.
Definition: Job.hpp:970
static const char *const CPU_COUNT
Definition: Job.hpp:980
static Error fromJson(const json::Object &in_json, Job &out_job)
Constructs a Job from a JSON object which represents the job.
NfsMountSource & asNfsMountSource()
Gets this MountSource as an NfsMountSource.
std::string Value
Definition: Job.hpp:1027
json::Object toJson() const
Converts this Container to a JSON object which represents it.
Optional< int > RunAsGroupId
Definition: Job.hpp:109
std::string Exe
The executable to run.
Definition: Job.hpp:312
RAII class for locking access to a Job object. Should be used every time a Job is modified.
Definition: Job.hpp:450
static Error fromJson(const json::Object &in_json, CephFsMountSource &out_mountSource)
Constructs a CephFsMountSource from a JSON object which represents the mount source.
Optional< Container > ContainerDetails
Definition: Job.hpp:298
std::string CustomType
Definition: Job.hpp:657
Optional< Type > ValueType
Definition: Job.hpp:443
std::string getPath() const
Gets the path on the NFS host to be mounted.
static const char *const MEMORY
Definition: Job.hpp:986
static Error fromJson(const json::Object &in_json, AzureFileMountSource &out_mountSource)
Constructs an AzureMountSource from a JSON object which represents the mount source.
Represents a Ceph File System Mount Source.
Definition: Job.hpp:708
ResourceLimitList ResourceLimits
Definition: Job.hpp:345
Job & operator=(const Job &in_other)
Assignment operator.
std::string MaxValue
Definition: Job.hpp:1030
GlusterFsMountSource & asGlusterFsMountSource()
Gets this MountSource as an GlusterFsMountSource.
json::Object toJson() const
Converts this Job to a JSON object which represents it.
std::string Protocol
Definition: Job.hpp:139
static Error fromJson(const json::Object &in_json, JobConfig &out_jobConfig)
Constructs a JobConfig from a JSON object which represents the job config.
static std::string stateToString(State in_status)
Converts a Job::State enum value into its string representation.
std::string Destination
Definition: Job.hpp:894
bool isPassthroughMountSource() const
Checks whether this MountSource is an PassthroughMountSource.
std::string WorkingDirectory
Definition: Job.hpp:372
State
Definition: Job.hpp:153
std::string StatusMessage
Definition: Job.hpp:360
json::Object toJson() const
Converts this ExposedPort to a JSON object which represents it.
Struct which represents the source path of an NFS Mount.
Definition: Job.hpp:477
Struct which represents an exposed port on a containerized job.
Definition: Job.hpp:116
std::string ResourceType
Definition: Job.hpp:1024
Represents an NFS Mount Source.
Definition: Job.hpp:835
Class which represents a date and time in UTC.
Definition: DateTime.hpp:244
Class which represents an error.
Definition: Error.hpp:174
std::vector< std::string > Arguments
Definition: Job.hpp:279
std::string Cluster
Definition: Job.hpp:282
static Error fromJson(const json::Object &in_json, NfsMountSource &out_mountSource)
Constructs an NfsMountSource from a JSON object which represents the mount source.
static Error fromJson(const json::Object &in_json, Container &out_container)
Constructs a Container from a JSON object which represents the container.
bool isNfsMountSource() const
Checks whether this MountSource is an NfsMountSource.
static const char *const CPU_TIME
Definition: Job.hpp:983
Optional< std::string > getJobConfigValue(const std::string &in_name) const
Gets a job configuration value, if it exists.
AzureFileMountSource & asAzureFileMountSource()
Gets this MountSource as an AzureFileMountSource.
Struct which represents a custom configuration setting for jobs launched with a given Plugin.
Definition: Job.hpp:387
std::set< std::string > Tags
Definition: Job.hpp:366
std::string Name
Definition: Job.hpp:963
std::string Id
Definition: Job.hpp:324
std::vector< int > SupplementalGroupIds
Definition: Job.hpp:112
static Error fromJson(const json::Object &in_json, MountSource &out_mountSource)
Constructs a MountSource from a JSON object which represents the mount source.
std::string Value
Definition: Job.hpp:966
Class which can be inherited from to disallow copying of its child classes.
Definition: Noncopyable.hpp:34
Type
Definition: Job.hpp:394
std::string Host
Definition: Job.hpp:321
system::DateTime SubmissionTime
Definition: Job.hpp:363
bool isCephFsMountSource() const
Checks whether this MountSource is an CephFsMountSource.
virtual ~MountSource()=default
Virtual destructor for inheritance.
bool isGlusterFsMountSource() const
Checks whether this MountSource is an GlusterFsMountSource.
json::Object toJson() const
Converts this JobConfig to a JSON object which represents it.
bool isAzureFileMountSource() const
Checks whether this MountSource is an AzureFileMountSource.
bool matchesTags(const std::set< std::string > &in_tags) const
Checks whether the job has all of the supplied tags.
static Error fromJson(const json::Object &in_json, PlacementConstraint &out_placementConstraint)
Constructs a PlacementConstraint from a JSON object which represents the placement constraint.
ResourceLimit()=default
Default constructor.
bool isHostMountSource() const
Checks whether this MountSource is an HostMountSource.
std::string getPath() const
Gets the path to mount.
std::string Name
Definition: Job.hpp:333
Struct which represents the container to use when launching a containerized job.
Definition: Job.hpp:83
std::string StandardErrFile
Definition: Job.hpp:351
State Status
Definition: Job.hpp:357
static Error stateFromString(const std::string &in_statusString, State &out_status)
Converts a status string into its equivalent Job::State enum value.
ExposedPortList ExposedPorts
Definition: Job.hpp:318
static Error fromJson(const json::Object &in_json, Mount &out_mount)
Constructs a Mount from a JSON object which represents the mount.
bool isCompleted() const
Checks whether the job has completed (i.e. the job's state is a completed state).
GlusterFsMountSource()
Constructor.
std::set< std::string > Queues
Definition: Job.hpp:342
std::string getEndpoints() const
Gets the name of the endpoints object that represents a Gluster cluster configuration.
PlacementConstraint()=default
Default constructor.
static Error fromJson(const json::Object &in_json, HostMountSource &out_mountSource)
Constructs a HostMountSource from a JSON object which represents the mount source.
std::string getHost() const
Gets the NFS host.
JobConfig()=default
Default constructor.
std::string DefaultValue
Definition: Job.hpp:1033
std::string Name
Definition: Job.hpp:440
MountSource Source
Definition: Job.hpp:900
Represents a path to mount on the same host as the Job.
Definition: Job.hpp:804
static Error fromJson(const json::Object &in_json, ExposedPort &out_exposedPort)
Constructs an ExposedPort from a JSON object which represents the exposed port.
int TargetPort
Definition: Job.hpp:142
std::string StandardOutFile
Definition: Job.hpp:354
Optional< int > RunAsUserId
Definition: Job.hpp:106