1 | /* |
2 | * scan_manager.h |
3 | * |
4 | * Copyright (C) 2019 Aerospike, Inc. |
5 | * |
6 | * Portions may be licensed to Aerospike, Inc. under one or more contributor |
7 | * license agreements. |
8 | * |
9 | * This program is free software: you can redistribute it and/or modify it under |
10 | * the terms of the GNU Affero General Public License as published by the Free |
11 | * Software Foundation, either version 3 of the License, or (at your option) any |
12 | * later version. |
13 | * |
14 | * This program is distributed in the hope that it will be useful, but WITHOUT |
15 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
16 | * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more |
17 | * details. |
18 | * |
19 | * You should have received a copy of the GNU Affero General Public License |
20 | * along with this program. If not, see http://www.gnu.org/licenses/ |
21 | */ |
22 | |
23 | #pragma once |
24 | |
25 | //========================================================== |
26 | // Includes. |
27 | // |
28 | |
29 | #include <stdbool.h> |
30 | #include <stdint.h> |
31 | |
32 | #include "citrusleaf/cf_queue.h" |
33 | |
34 | #include "cf_mutex.h" |
35 | |
36 | |
37 | //========================================================== |
38 | // Forward declarations. |
39 | // |
40 | |
41 | struct as_mon_jobstat_s; |
42 | struct as_scan_job_s; |
43 | |
44 | |
45 | //========================================================== |
46 | // Typedefs & constants. |
47 | // |
48 | |
49 | typedef struct as_scan_manager_s { |
50 | cf_mutex lock; |
51 | cf_queue* active_jobs; |
52 | cf_queue* finished_jobs; |
53 | } as_scan_manager; |
54 | |
55 | |
56 | //========================================================== |
57 | // Globals. |
58 | // |
59 | |
60 | extern uint32_t g_n_threads; |
61 | |
62 | |
63 | //========================================================== |
64 | // Public API. |
65 | // |
66 | |
67 | void as_scan_manager_init(void); |
68 | int as_scan_manager_start_job(struct as_scan_job_s* _job); |
69 | void as_scan_manager_add_job_thread(struct as_scan_job_s* _job); |
70 | void as_scan_manager_add_max_job_threads(struct as_scan_job_s* _job); |
71 | void as_scan_manager_finish_job(struct as_scan_job_s* _job); |
72 | void as_scan_manager_abandon_job(struct as_scan_job_s* _job, int reason); |
73 | bool as_scan_manager_abort_job(uint64_t trid); |
74 | int as_scan_manager_abort_all_jobs(void); |
75 | void as_scan_manager_limit_finished_jobs(void); |
76 | struct as_mon_jobstat_s* as_scan_manager_get_job_info(uint64_t trid); |
77 | struct as_mon_jobstat_s* as_scan_manager_get_info(int* size); |
78 | int as_scan_manager_get_active_job_count(void); |
79 | |