RStudio Launcher Plugin SDK  1.1.3
A software development kit for creating plugins that work the the RStudio Launcher.
QuickStartJobSource.hpp
1 /*
2  * QuickStartJobSource.hpp
3  *
4  * Copyright (C) 2020 by RStudio, PBC
5  *
6  * Unless you have received this program directly from RStudio pursuant to the terms of a commercial license agreement
7  * with RStudio, then this program is licensed to you under the following terms:
8  *
9  * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
10  * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
11  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
12  * permit persons to whom the Software is furnished to do so, subject to the following conditions:
13  *
14  * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
15  * Software.
16  *
17  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
18  * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
19  * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
20  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21  *
22  */
23 
24 #ifndef LAUNCHER_PLUGINS_QUICK_START_JOB_SOURCE_HPP
25 #define LAUNCHER_PLUGINS_QUICK_START_JOB_SOURCE_HPP
26 
27 #include <api/IJobSource.hpp>
28 
29 #include <jobs/AbstractJobRepository.hpp>
30 #include <jobs/JobStatusNotifier.hpp>
31 
32 #include "QuickStartJobStatusWatcher.hpp"
33 
34 namespace rstudio {
35 namespace launcher_plugins {
36 namespace quickstart {
37 
42 {
43 public:
52  const jobs::JobRepositoryPtr& in_jobRepository,
53  const jobs::JobStatusNotifierPtr& in_jobStatusNotifier);
54 
62  Error initialize() override;
63 
76  bool cancelJob(api::JobPtr in_job, bool& out_isComplete, std::string& out_statusMessage) override;
77 
96  const system::User& in_user,
97  api::JobSourceConfiguration& out_configuration) const override;
98 
107  Error getNetworkInfo(api::JobPtr in_job, api::NetworkInfo& out_networkInfo) const override;
108 
122  bool killJob(api::JobPtr in_job, bool& out_isComplete, std::string& out_statusMessage) override;
123 
137  bool resumeJob(api::JobPtr in_job, bool& out_isComplete, std::string& out_statusMessage) override;
138 
151  bool stopJob(api::JobPtr in_job, bool& out_isComplete, std::string& out_statusMessage) override;
152 
167  bool suspendJob(api::JobPtr in_job, bool& out_isComplete, std::string& out_statusMessage) override;
168 
180  Error submitJob(api::JobPtr io_job, bool& out_wasInvalidRequest) const override;
181 
195  api::OutputType in_outputType,
196  api::JobPtr in_job,
197  api::AbstractOutputStream::OnOutput in_onOutput,
199  api::AbstractOutputStream::OnError in_onError,
200  api::OutputStreamPtr& out_outputStream) override;
201 
212  api::ConstJobPtr in_job,
213  comms::AbstractLauncherCommunicatorPtr in_launcherCommunicator,
214  api::AbstractResourceStreamPtr& out_resourceStream) override;
215 
216 private:
217  QuickStartJobStatusWatcherPtr m_jobStatusWatcher;
218 };
219 
220 } // namespace quickstart
221 } // namespace launcher_plugins
222 } // namespace rstudio
223 
224 #endif
rstudio::launcher_plugins::api::NetworkInfo
Represents the network information for a job.
Definition: ResponseTypes.hpp:129
rstudio::launcher_plugins::quickstart::QuickStartJobSource::suspendJob
bool suspendJob(api::JobPtr in_job, bool &out_isComplete, std::string &out_statusMessage) override
Suspends a running job.
rstudio::launcher_plugins::quickstart::QuickStartJobSource::cancelJob
bool cancelJob(api::JobPtr in_job, bool &out_isComplete, std::string &out_statusMessage) override
Cancels a pending job.
rstudio::launcher_plugins::quickstart::QuickStartJobSource::submitJob
Error submitJob(api::JobPtr io_job, bool &out_wasInvalidRequest) const override
Submits a job to the Job Scheduling System.
rstudio::launcher_plugins::system::User
Class which represents a system user.
Definition: User.hpp:55
rstudio::launcher_plugins::quickstart::QuickStartJobSource::createResourceStream
Error createResourceStream(api::ConstJobPtr in_job, comms::AbstractLauncherCommunicatorPtr in_launcherCommunicator, api::AbstractResourceStreamPtr &out_resourceStream) override
Creates a resource utilization metric stream for the specified job.
rstudio::launcher_plugins::api::AbstractOutputStream::OnComplete
std::function< void(uint64_t)> OnComplete
Definition: AbstractOutputStream.hpp:66
rstudio::launcher_plugins::quickstart::QuickStartJobSource::getConfiguration
Error getConfiguration(const system::User &in_user, api::JobSourceConfiguration &out_configuration) const override
Gets the configuration and capabilities of this Job Source for the specified user.
rstudio::launcher_plugins::quickstart::QuickStartJobSource
Class which is responsible for running and retrieving information about jobs in the job scheduling sy...
Definition: QuickStartJobSource.hpp:41
rstudio::launcher_plugins::quickstart::QuickStartJobSource::QuickStartJobSource
QuickStartJobSource(const jobs::JobRepositoryPtr &in_jobRepository, const jobs::JobStatusNotifierPtr &in_jobStatusNotifier)
Constructor.
rstudio::launcher_plugins::quickstart::QuickStartJobSource::initialize
Error initialize() override
Initializes the Job Source.
rstudio::launcher_plugins::quickstart::QuickStartJobSource::getNetworkInfo
Error getNetworkInfo(api::JobPtr in_job, api::NetworkInfo &out_networkInfo) const override
Gets the network information for the specified job.
rstudio::launcher_plugins::quickstart::QuickStartJobSource::createOutputStream
Error createOutputStream(api::OutputType in_outputType, api::JobPtr in_job, api::AbstractOutputStream::OnOutput in_onOutput, api::AbstractOutputStream::OnComplete in_onComplete, api::AbstractOutputStream::OnError in_onError, api::OutputStreamPtr &out_outputStream) override
Creates an output stream for the specified job.
rstudio::launcher_plugins::quickstart::QuickStartJobSource::killJob
bool killJob(api::JobPtr in_job, bool &out_isComplete, std::string &out_statusMessage) override
Forcibly kills a running job.
rstudio::launcher_plugins::Error
Class which represents an error.
Definition: Error.hpp:174
rstudio::launcher_plugins::api::JobSourceConfiguration
Describes the capabilities and configuration of this Job Source.
Definition: IJobSource.hpp:77
rstudio::launcher_plugins::api::IJobSource
Generic interface for communicating with a Job Source. Implementation is plugin specific.
Definition: IJobSource.hpp:99
rstudio::launcher_plugins::quickstart::QuickStartJobSource::stopJob
bool stopJob(api::JobPtr in_job, bool &out_isComplete, std::string &out_statusMessage) override
Stops a running job.
rstudio::launcher_plugins::quickstart::QuickStartJobSource::resumeJob
bool resumeJob(api::JobPtr in_job, bool &out_isComplete, std::string &out_statusMessage) override
Resumes a suspended job.