Main Page
Modules
Data Structures
Files
File List
Globals
All
Data Structures
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
src
include
citrusleaf
cl_types.h
Go to the documentation of this file.
1
/******************************************************************************
2
* Copyright 2008-2013 by Aerospike.
3
*
4
* Permission is hereby granted, free of charge, to any person obtaining a copy
5
* of this software and associated documentation files (the "Software"), to
6
* deal in the Software without restriction, including without limitation the
7
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8
* sell copies of the Software, and to permit persons to whom the Software is
9
* furnished to do so, subject to the following conditions:
10
*
11
* The above copyright notice and this permission notice shall be included in
12
* all copies or substantial portions of the Software.
13
*
14
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20
* IN THE SOFTWARE.
21
*****************************************************************************/
22
#pragma once
23
24
#include <
citrusleaf/cl_object.h
>
25
26
#include <inttypes.h>
27
#include <stdbool.h>
28
#include <netinet/in.h>
29
30
/**
31
* Hack for the sake of XDS. XDS includes the main CF libs.
32
* We do not want to include them again from client API
33
*/
34
#ifndef XDS
35
#include <citrusleaf/cf_atomic.h>
36
// #include <citrusleaf/cf_log.h>
37
#include <citrusleaf/cf_ll.h>
38
#include <citrusleaf/cf_clock.h>
39
#include <citrusleaf/cf_vector.h>
40
#include <citrusleaf/cf_queue.h>
41
#include <citrusleaf/cf_digest.h>
42
#include <citrusleaf/cf_shash.h>
43
#include <citrusleaf/cf_rchash.h>
44
#endif
45
46
/******************************************************************************
47
* CONSTANTS
48
******************************************************************************/
49
50
#define STACK_BUF_SZ (1024 * 16) // provide a safe number for your system - linux tends to have 8M stacks these days
51
#define DEFAULT_PROGRESS_TIMEOUT 50
52
#define NODE_NAME_SIZE 20
53
#define CL_BINNAME_SIZE 15
54
#define CL_MAX_NUM_FUNC_ARGC 10
55
56
/******************************************************************************
57
* TYPES
58
******************************************************************************/
59
60
typedef
struct
cl_conn_s
cl_conn
;
61
62
// These numbers match with proto.h on the server (AS_PROTO_RESULT_FAIL....)
63
64
typedef
enum
cl_rv_e {
65
66
// negative = client
67
// positive = server
68
69
70
CITRUSLEAF_FAIL_ASYNCQ_FULL
= -3,
71
CITRUSLEAF_FAIL_TIMEOUT
= -2,
72
CITRUSLEAF_FAIL_CLIENT
= -1,
// an out of memory or similar locally
73
74
CITRUSLEAF_OK
= 0,
75
CITRUSLEAF_FAIL_UNKNOWN
= 1,
// unknown failure on the server side
76
77
// record not found
78
// currently only used for reads, but with REPLACE ONLY op will be pertinent.
79
CITRUSLEAF_FAIL_NOTFOUND
= 2,
80
81
// can be a read or write error
82
CITRUSLEAF_FAIL_GENERATION
= 3,
// likely a CAS write, and the write failed
83
84
// bad parameter response from server
85
CITRUSLEAF_FAIL_PARAMETER
= 4,
// you passed in bad parameters
86
87
// digest/record exists when attempting to CREATE ONLY
88
// SCOPE: WRITE ONLY
89
CITRUSLEAF_FAIL_KEY_EXISTS
= 5,
90
91
// @todo ??
92
CITRUSLEAF_FAIL_BIN_EXISTS
= 6,
93
94
// cluster errors
95
CITRUSLEAF_FAIL_CLUSTER_KEY_MISMATCH
= 7,
96
CITRUSLEAF_FAIL_PARTITION_OUT_OF_SPACE
= 8,
97
98
// collapsible timeout, server timeout is based on client-sent value
99
// for the most part
100
CITRUSLEAF_FAIL_SERVERSIDE_TIMEOUT
= 9,
101
102
// xdr errors
103
CITRUSLEAF_FAIL_NOXDS
= 10,
104
105
// server (node) not avaialble (??)
106
CITRUSLEAF_FAIL_UNAVAILABLE
= 11,
107
108
// bin operation cannot be performed on bin b/c of its type
109
// SCOPE: WRITE ONLY
110
CITRUSLEAF_FAIL_INCOMPATIBLE_TYPE
= 12,
// specified operation cannot be performed on that data type
111
112
// record is larger than the write block (1MB)
113
// SCOPE: WRITE ONLY
114
CITRUSLEAF_FAIL_RECORD_TOO_BIG
= 13,
115
116
// hot key - essentially the record's transaction proc queue is full
117
CITRUSLEAF_FAIL_KEY_BUSY
= 14,
118
119
// scan was aborted ... but why?
120
CITRUSLEAF_FAIL_SCAN_ABORT
= 15,
121
122
// Server does not (yet) support this function
123
CITRUSLEAF_FAIL_UNSUPPORTED_FEATURE
= 16,
124
125
// Bin-level replace-only supported on server but not on client.
126
CITRUSLEAF_FAIL_BIN_NOT_FOUND
= 17,
127
128
// Storage device(s) can't keep up with the current write load.
129
CITRUSLEAF_FAIL_DEVICE_OVERLOAD
= 18,
130
131
// ???
132
CITRUSLEAF_FAIL_INVALID_DATA
= 99,
133
134
// UDF RANGE 100-110
135
CITRUSLEAF_FAIL_UDF_BAD_RESPONSE
= 100,
136
137
// Secondary Index Query Codes 200 - 230
138
CITRUSLEAF_FAIL_INDEX_FOUND
= 200,
139
CITRUSLEAF_FAIL_INDEX_NOTFOUND
= 201,
140
CITRUSLEAF_FAIL_INDEX_OOM
= 202,
141
CITRUSLEAF_FAIL_INDEX_NOTREADABLE
= 203,
142
CITRUSLEAF_FAIL_INDEX_GENERIC
= 204,
143
CITRUSLEAF_FAIL_INDEX_NAME_MAXLEN
= 205,
144
CITRUSLEAF_FAIL_INDEX_MAXCOUNT
= 206,
145
146
CITRUSLEAF_FAIL_QUERY_ABORTED
= 210,
147
CITRUSLEAF_FAIL_QUERY_QUEUEFULL
= 211,
148
CITRUSLEAF_FAIL_QUERY_TIMEOUT
= 212,
149
CITRUSLEAF_FAIL_QUERY_GENERIC
= 213
150
}
cl_rv
;
151
152
typedef
enum
cl_rvclient_e {
153
CITRUSLEAF_FAIL_DC_DOWN
= 1,
154
CITRUSLEAF_FAIL_DC_UP
= 2
155
}
cl_rvclient
;
156
157
158
typedef
enum
cl_operator_type_e {
159
CL_OP_WRITE
,
// 0
160
CL_OP_READ
,
// 1
161
CL_OP_INCR
,
// 2
162
CL_OP_MC_INCR
,
// 3
163
CL_OP_PREPEND
,
// 4
164
CL_OP_APPEND
,
// 5
165
CL_OP_MC_PREPEND
,
// 6
166
CL_OP_MC_APPEND
,
// 7
167
CL_OP_TOUCH
,
// 8
168
CL_OP_MC_TOUCH
// 9
169
}
cl_operator
;
170
171
/**
172
* A bin is the bin name, and the value set or gotten
173
*/
174
typedef
struct
cl_bin_s {
175
char
bin_name[
CL_BINNAME_SIZE
];
176
cl_object
object
;
177
}
cl_bin
;
178
179
/**
180
* A record structure containing the most common fileds of a record
181
*/
182
typedef
struct
cl_rec_s {
183
cf_digest
digest
;
184
uint32_t
generation
;
185
uint32_t
record_voidtime
;
186
cl_bin
*
bins
;
187
int
n_bins
;
188
}
cl_rec
;
189
190
/**
191
* Structure used by functions which want to return a bunch of records
192
*/
193
typedef
struct
cl_batchresult_s {
194
pthread_mutex_t
lock
;
195
int
numrecs
;
196
cl_rec
*
records
;
197
}
cl_batchresult
;
198
199
/**
200
* An operation is the bin, plus the operator (write, read, add, etc)
201
* This structure is used for the more complex 'operate' call,
202
* which can specify simultaneous operations on multiple bins
203
*/
204
typedef
struct
cl_operation_s {
205
cl_bin
bin
;
206
cl_operator
op
;
207
}
cl_operation
;
208
209
/**
210
* Structure to map the internal address to the external address
211
*/
212
typedef
struct
cl_addrmap
{
213
char
*
orig
;
214
char
*
alt
;
215
}
cl_addrmap
;
216
217
/**
218
* Callback function type used by batch and scan
219
*/
220
typedef
int (*
citrusleaf_get_many_cb
) (
char
*
ns
, cf_digest *keyd,
char
*set,
221
int
result, uint32_t
generation
, uint32_t ttl,
cl_bin
*bins,
222
uint16_t n_bins,
void
*udata);
223
224
/******************************************************************************
225
* FUNCTIONS
226
******************************************************************************/
227
228
void
citrusleaf_bins_free
(
cl_bin
* bins,
int
n_bins);
229
int
citrusleaf_copy_bins
(
cl_bin
** destbins,
cl_bin
* srcbins,
int
n_bins);
230
CITRUSLEAF_FAIL_KEY_BUSY
Definition:
cl_types.h:117
cl_operation
Definition:
cl_types.h:204
CL_OP_MC_INCR
Definition:
cl_types.h:162
CITRUSLEAF_FAIL_SERVERSIDE_TIMEOUT
Definition:
cl_types.h:100
as_scan::ns
as_namespace ns
Definition:
src/include/aerospike/as_scan.h:334
CITRUSLEAF_FAIL_SCAN_ABORT
Definition:
cl_types.h:120
CITRUSLEAF_FAIL_TIMEOUT
Definition:
cl_types.h:71
CL_OP_APPEND
Definition:
cl_types.h:164
cl_rv
cl_rv
Definition:
cl_types.h:64
cl_rvclient
cl_rvclient
Definition:
cl_types.h:152
generation
uint32_t generation
Definition:
src/include/citrusleaf/cf_proto.h:61
CITRUSLEAF_FAIL_BIN_NOT_FOUND
Definition:
cl_types.h:126
CITRUSLEAF_FAIL_ASYNCQ_FULL
Definition:
cl_types.h:70
cl_bin
Definition:
cl_types.h:174
CL_OP_TOUCH
Definition:
cl_types.h:167
CITRUSLEAF_FAIL_UNSUPPORTED_FEATURE
Definition:
cl_types.h:123
CL_OP_MC_APPEND
Definition:
cl_types.h:166
citrusleaf_copy_bins
int citrusleaf_copy_bins(cl_bin **destbins, cl_bin *srcbins, int n_bins)
CITRUSLEAF_FAIL_INDEX_NOTFOUND
Definition:
cl_types.h:139
CITRUSLEAF_FAIL_BIN_EXISTS
Definition:
cl_types.h:92
cl_rec::record_voidtime
uint32_t record_voidtime
Definition:
cl_types.h:185
CITRUSLEAF_FAIL_PARTITION_OUT_OF_SPACE
Definition:
cl_types.h:96
CITRUSLEAF_FAIL_NOXDS
Definition:
cl_types.h:103
CITRUSLEAF_FAIL_RECORD_TOO_BIG
Definition:
cl_types.h:114
CITRUSLEAF_OK
Definition:
cl_types.h:74
CITRUSLEAF_FAIL_UDF_BAD_RESPONSE
Definition:
cl_types.h:135
CITRUSLEAF_FAIL_KEY_EXISTS
Definition:
cl_types.h:89
cl_batchresult::lock
pthread_mutex_t lock
Definition:
cl_types.h:194
cl_conn
struct cl_conn_s cl_conn
Definition:
cl_types.h:60
CITRUSLEAF_FAIL_QUERY_ABORTED
Definition:
cl_types.h:146
cl_object
Definition:
cl_object.h:61
cl_operation::op
cl_operator op
Definition:
cl_types.h:206
CITRUSLEAF_FAIL_DC_DOWN
Definition:
cl_types.h:153
cl_rec::n_bins
int n_bins
Definition:
cl_types.h:187
CL_OP_MC_PREPEND
Definition:
cl_types.h:165
cl_addrmap::alt
char * alt
Definition:
cl_types.h:214
CITRUSLEAF_FAIL_UNAVAILABLE
Definition:
cl_types.h:106
CITRUSLEAF_FAIL_QUERY_QUEUEFULL
Definition:
cl_types.h:147
CITRUSLEAF_FAIL_NOTFOUND
Definition:
cl_types.h:79
CITRUSLEAF_FAIL_UNKNOWN
Definition:
cl_types.h:75
CITRUSLEAF_FAIL_INVALID_DATA
Definition:
cl_types.h:132
CL_OP_READ
Definition:
cl_types.h:160
CITRUSLEAF_FAIL_CLIENT
Definition:
cl_types.h:72
cl_batchresult::records
cl_rec * records
Definition:
cl_types.h:196
CITRUSLEAF_FAIL_PARAMETER
Definition:
cl_types.h:85
cl_addrmap::orig
char * orig
Definition:
cl_types.h:213
cl_object.h
cl_bin::object
cl_object object
Definition:
cl_types.h:176
cl_rec::generation
uint32_t generation
Definition:
cl_types.h:184
CITRUSLEAF_FAIL_CLUSTER_KEY_MISMATCH
Definition:
cl_types.h:95
CL_OP_MC_TOUCH
Definition:
cl_types.h:168
CITRUSLEAF_FAIL_QUERY_GENERIC
Definition:
cl_types.h:149
citrusleaf_bins_free
void citrusleaf_bins_free(cl_bin *bins, int n_bins)
CITRUSLEAF_FAIL_INDEX_MAXCOUNT
Definition:
cl_types.h:144
CL_OP_INCR
Definition:
cl_types.h:161
CITRUSLEAF_FAIL_GENERATION
Definition:
cl_types.h:82
CITRUSLEAF_FAIL_INDEX_NAME_MAXLEN
Definition:
cl_types.h:143
CITRUSLEAF_FAIL_DC_UP
Definition:
cl_types.h:154
CL_OP_WRITE
Definition:
cl_types.h:159
CL_OP_PREPEND
Definition:
cl_types.h:163
CITRUSLEAF_FAIL_QUERY_TIMEOUT
Definition:
cl_types.h:148
CITRUSLEAF_FAIL_DEVICE_OVERLOAD
Definition:
cl_types.h:129
citrusleaf_get_many_cb
int(* citrusleaf_get_many_cb)(char *ns, cf_digest *keyd, char *set, int result, uint32_t generation, uint32_t ttl, cl_bin *bins, uint16_t n_bins, void *udata)
Definition:
cl_types.h:220
cl_operator
cl_operator
Definition:
cl_types.h:158
cl_rec
Definition:
cl_types.h:182
CITRUSLEAF_FAIL_INDEX_OOM
Definition:
cl_types.h:140
cl_rec::bins
cl_bin * bins
Definition:
cl_types.h:186
cl_rec::digest
cf_digest digest
Definition:
cl_types.h:183
cl_operation::bin
cl_bin bin
Definition:
cl_types.h:205
cl_batchresult
Definition:
cl_types.h:193
cl_addrmap
Definition:
cl_types.h:212
cl_batchresult::numrecs
int numrecs
Definition:
cl_types.h:195
CITRUSLEAF_FAIL_INCOMPATIBLE_TYPE
Definition:
cl_types.h:110
CL_BINNAME_SIZE
#define CL_BINNAME_SIZE
Definition:
cl_types.h:53
CITRUSLEAF_FAIL_INDEX_GENERIC
Definition:
cl_types.h:142
CITRUSLEAF_FAIL_INDEX_NOTREADABLE
Definition:
cl_types.h:141
CITRUSLEAF_FAIL_INDEX_FOUND
Definition:
cl_types.h:138