-
Notifications
You must be signed in to change notification settings - Fork 122
/
AbortRemoteJob2.cpp
50 lines (38 loc) · 1.9 KB
/
AbortRemoteJob2.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// Mantid Repository : https://github.com/mantidproject/mantid
//
// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI,
// NScD Oak Ridge National Laboratory, European Spallation Source,
// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
// SPDX - License - Identifier: GPL - 3.0 +
#include "MantidRemoteAlgorithms/AbortRemoteJob2.h"
#include "MantidAPI/RemoteJobManagerFactory.h"
#include "MantidKernel/ConfigService.h"
#include "MantidKernel/FacilityInfo.h"
#include "MantidKernel/ListValidator.h"
#include "MantidKernel/MandatoryValidator.h"
namespace Mantid {
namespace RemoteAlgorithms {
// Register the algorithm into the Algorithm Factory
DECLARE_ALGORITHM(AbortRemoteJob2)
using namespace Mantid::Kernel;
using namespace Mantid::API;
// A reference to the logger is provided by the base class, it is called g_log.
void AbortRemoteJob2::init() {
// Unlike most algorithms, this one doesn't deal with workspaces....
auto requireValue = std::make_shared<MandatoryValidator<std::string>>();
// Compute Resources
std::vector<std::string> computes = Mantid::Kernel::ConfigService::Instance().getFacility().computeResources();
declareProperty("ComputeResource", "", std::make_shared<StringListValidator>(computes),
"The remote computer where the job is running", Direction::Input);
// The ID of the job we want to Abort
declareProperty("JobID", "", requireValue, "The ID of the job to abort", Direction::Input);
}
void AbortRemoteJob2::exec() {
const std::string comp = getPropertyValue("ComputeResource");
Mantid::API::IRemoteJobManager_sptr jobManager = Mantid::API::RemoteJobManagerFactory::Instance().create(comp);
std::string jid = getPropertyValue("JobID");
jobManager->abortRemoteJob(jid);
g_log.information() << "Aborted job with ID " << jid << " on the compute resource" << comp << '\n';
}
} // namespace RemoteAlgorithms
} // namespace Mantid