Loading...
Searching...
No Matches
as_job.h
Go to the documentation of this file.
1/*
2 * Copyright 2008-2018 Aerospike, Inc.
3 *
4 * Portions may be licensed to Aerospike, Inc. under one or more contributor
5 * license agreements.
6 *
7 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
8 * use this file except in compliance with the License. You may obtain a copy of
9 * the License at 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, WITHOUT
13 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14 * License for the specific language governing permissions and limitations under
15 * the License.
16 */
17#pragma once
18
19#include <aerospike/aerospike.h>
20
21#ifdef __cplusplus
22extern "C" {
23#endif
24
25/******************************************************************************
26 * TYPES
27 *****************************************************************************/
28
29/**
30 * The status of a particular background scan.
31 */
32typedef enum as_job_status_e {
33 /**
34 * The job status is undefined.
35 * This is likely due to the status not being properly checked.
36 */
38
39 /**
40 * The job is currently running.
41 */
43
44 /**
45 * The job completed successfully.
46 */
49
50/**
51 * Information about a particular background job.
52 */
53typedef struct as_job_info_s {
54 /**
55 * Status of the job.
56 */
58
59 /**
60 * Progress estimate for the job, as percentage.
61 */
62 uint32_t progress_pct;
63
64 /**
65 * How many records have been scanned.
66 */
67 uint32_t records_read;
69
70/******************************************************************************
71 * FUNCTIONS
72 *****************************************************************************/
73
74/**
75 * Wait for a background job to be completed by servers.
76 *
77 * ~~~~~~~~~~{.c}
78 * uint64_t job_id = 1234;
79 * aerospike_job_wait(&as, &err, NULL, "scan", job_id, 0);
80 * ~~~~~~~~~~
81 *
82 * @param as The aerospike instance to use for this operation.
83 * @param err The as_error to be populated if an error occurs.
84 * @param policy The policy to use for this operation. If NULL, then the default policy will be used.
85 * @param module Background module. Values: scan | query
86 * @param job_id Job ID.
87 * @param interval_ms Polling interval in milliseconds. If zero, 1000 ms is used.
88 *
89 * @return AEROSPIKE_OK on success. Otherwise an error occurred.
90 */
93 aerospike* as, as_error* err, const as_policy_info* policy, const char* module, uint64_t job_id,
94 uint32_t interval_ms
95 );
96
97/**
98 * Check the progress of a background job running on the database. The status
99 * of the job running on the datatabse will be populated in as_job_info.
100 *
101 * ~~~~~~~~~~{.c}
102 * uint64_t job_id = 1234;
103 * as_job_info job_info;
104 *
105 * if (aerospike_scan_info(&as, &err, NULL, "scan", job_id, &job_info) != AEROSPIKE_OK) {
106 * fprintf(stderr, "error(%d) %s at [%s:%d]", err.code, err.message, err.file, err.line);
107 * }
108 * else {
109 * printf("Scan id=%ll, status=%d percent=%d", job_id, job_info.status, job_info.progress_pct);
110 * }
111 * ~~~~~~~~~~
112 *
113 * @param as The aerospike instance to use for this operation.
114 * @param err The as_error to be populated if an error occurs.
115 * @param policy The policy to use for this operation. If NULL, then the default policy will be used.
116 * @param module Background module. Values: scan | query
117 * @param job_id Job ID.
118 * @param stop_if_in_progress Stop querying nodes if background job is still running.
119 * @param info Information about this background job, to be populated by this operation.
120 *
121 * @return AEROSPIKE_OK on success. Otherwise an error occurred.
122 */
125 aerospike* as, as_error* err, const as_policy_info* policy, const char* module, uint64_t job_id,
126 bool stop_if_in_progress, as_job_info * info
127 );
128
129#ifdef __cplusplus
130} // end extern "C"
131#endif
AS_EXTERN as_status aerospike_job_info(aerospike *as, as_error *err, const as_policy_info *policy, const char *module, uint64_t job_id, bool stop_if_in_progress, as_job_info *info)
as_job_status
Definition as_job.h:32
@ AS_JOB_STATUS_INPROGRESS
Definition as_job.h:42
@ AS_JOB_STATUS_UNDEF
Definition as_job.h:37
@ AS_JOB_STATUS_COMPLETED
Definition as_job.h:47
AS_EXTERN as_status aerospike_job_wait(aerospike *as, as_error *err, const as_policy_info *policy, const char *module, uint64_t job_id, uint32_t interval_ms)
as_status
Definition as_status.h:30
#define AS_EXTERN
Definition as_std.h:25
uint32_t progress_pct
Definition as_job.h:62
uint32_t records_read
Definition as_job.h:67
as_job_status status
Definition as_job.h:57