Apache Ignite C++ Client
Loading...
Searching...
No Matches
job_execution.h
1/*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18#pragma once
19
20#include "ignite/client/compute/job_state.h"
21#include "ignite/client/network/cluster_node.h"
22#include "ignite/common/detail/config.h"
23#include "ignite/common/ignite_result.h"
24#include "ignite/common/binary_object.h"
25#include "ignite/common/uuid.h"
26
27#include <memory>
28
29namespace ignite {
30
31namespace detail {
32class job_execution_impl;
33}
34
38class job_execution {
39public:
53
54 // Default
55 job_execution() = default;
56
62 explicit job_execution(std::shared_ptr<detail::job_execution_impl> impl)
63 : m_impl(std::move(impl)) {}
64
70 [[nodiscard]] IGNITE_API uuid get_id() const;
71
77 [[nodiscard]] IGNITE_API const cluster_node &get_node() const;
78
86 IGNITE_API void get_state_async(ignite_callback<std::optional<job_state>> callback);
87
95 IGNITE_API std::optional<job_state> get_state() {
96 return sync<std::optional<job_state>>(
97 [this](auto callback) mutable { get_state_async(std::move(callback)); });
98 }
99
107 IGNITE_API void get_result_async(ignite_callback<std::optional<binary_object>> callback);
108
116 IGNITE_API std::optional<binary_object> get_result() {
117 return sync<std::optional<binary_object>>(
118 [this](auto callback) mutable { get_result_async(std::move(callback)); });
119 }
120
126 IGNITE_API void cancel_async(ignite_callback<operation_result> callback);
127
134 return sync<operation_result>([this](auto callback) mutable { cancel_async(std::move(callback)); });
135 }
136
144 IGNITE_API void change_priority_async(std::int32_t priority, ignite_callback<operation_result> callback);
145
153 IGNITE_API operation_result change_priority(std::int32_t priority) {
154 return sync<operation_result>(
155 [this, priority](auto callback) mutable { change_priority_async(priority, std::move(callback)); });
156 }
157
158private:
160 std::shared_ptr<detail::job_execution_impl> m_impl{};
161};
162
163} // namespace ignite
Definition cluster_node.h:30
Definition job_execution.h:38
IGNITE_API void get_state_async(ignite_callback< std::optional< job_state > > callback)
Definition job_execution.cpp:31
IGNITE_API const cluster_node & get_node() const
Definition job_execution.cpp:27
IGNITE_API void change_priority_async(std::int32_t priority, ignite_callback< operation_result > callback)
Definition job_execution.cpp:43
IGNITE_API std::optional< job_state > get_state()
Definition job_execution.h:95
IGNITE_API uuid get_id() const
Definition job_execution.cpp:23
IGNITE_API void cancel_async(ignite_callback< operation_result > callback)
Definition job_execution.cpp:39
job_execution(std::shared_ptr< detail::job_execution_impl > impl)
Definition job_execution.h:62
IGNITE_API operation_result change_priority(std::int32_t priority)
Definition job_execution.h:153
IGNITE_API std::optional< binary_object > get_result()
Definition job_execution.h:116
IGNITE_API void get_result_async(ignite_callback< std::optional< binary_object > > callback)
Definition job_execution.cpp:35
IGNITE_API operation_result cancel()
Definition job_execution.h:133
operation_result
Definition job_execution.h:43
@ INVALID_STATE
The job has already finished.
Definition job_execution.h:48
@ NOT_FOUND
The job was not found (no longer exists due to exceeding the retention time limit).
Definition job_execution.h:51
@ SUCCESS
The job operation was successfully complete.
Definition job_execution.h:45
Universally unique identifier (UUID).
Definition uuid.h:32