Main Page
Related Pages
Modules
Data Structures
Files
File List
Globals
All
Data Structures
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
aerospike
as_policy.h
Go to the documentation of this file.
1
/*
2
* Copyright 2008-2017 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
/**
20
* @defgroup client_policies Client Policies
21
*
22
* Policies define the behavior of database operations.
23
*
24
* Policies fall into two groups: policy values and operation policies.
25
* A policy value is a single value which defines how the client behaves. An
26
* operation policy is a group of policy values which affect an operation.
27
*
28
* ## Policy Values
29
*
30
* The following are the policy values. For details, please see the documentation
31
* for each policy value
32
*
33
* - as_policy_key
34
* - as_policy_gen
35
* - as_policy_exists
36
* - as_policy_replica
37
* - as_policy_consistency_level
38
* - as_policy_commit_level
39
*
40
* ## Operation Policies
41
*
42
* The following are the operation policies. Operation policies are groups of
43
* policy values for a type of operation.
44
*
45
* - as_policy_batch
46
* - as_policy_info
47
* - as_policy_operate
48
* - as_policy_read
49
* - as_policy_remove
50
* - as_policy_query
51
* - as_policy_scan
52
* - as_policy_write
53
*/
54
55
#include <stdbool.h>
56
#include <stdint.h>
57
58
#ifdef __cplusplus
59
extern
"C"
{
60
#endif
61
62
/******************************************************************************
63
* MACROS
64
*****************************************************************************/
65
66
/**
67
* Default timeout value
68
*
69
* @ingroup client_policies
70
*/
71
#define AS_POLICY_TIMEOUT_DEFAULT 1000
72
73
/**
74
* Default number of retries when a transaction fails due to a network error.
75
*
76
* @ingroup client_policies
77
*/
78
#define AS_POLICY_RETRY_DEFAULT 1
79
80
/**
81
* Default milliseconds to sleep before a command retry.
82
*
83
* @ingroup client_policies
84
*/
85
#define AS_POLICY_RETRY_SLEEP_DEFAULT 0
86
87
/**
88
* Default value for compression threshold
89
*
90
* @ingroup client_policies
91
*/
92
#define AS_POLICY_COMPRESSION_THRESHOLD_DEFAULT 0
93
94
/**
95
* Default as_policy_gen value
96
*
97
* @ingroup client_policies
98
*/
99
#define AS_POLICY_GEN_DEFAULT AS_POLICY_GEN_IGNORE
100
101
/**
102
* Default as_policy_key value
103
*
104
* @ingroup client_policies
105
*/
106
#define AS_POLICY_KEY_DEFAULT AS_POLICY_KEY_DIGEST
107
108
/**
109
* Default as_policy_exists value
110
*
111
* @ingroup client_policies
112
*/
113
#define AS_POLICY_EXISTS_DEFAULT AS_POLICY_EXISTS_IGNORE
114
115
/**
116
* Default as_policy_replica value
117
*
118
* @ingroup client_policies
119
*/
120
#define AS_POLICY_REPLICA_DEFAULT AS_POLICY_REPLICA_MASTER
121
122
/**
123
* Default as_policy_consistency_level value for read
124
*
125
* @ingroup client_policies
126
*/
127
#define AS_POLICY_CONSISTENCY_LEVEL_DEFAULT AS_POLICY_CONSISTENCY_LEVEL_ONE
128
129
/**
130
* Default as_policy_commit_level value for write
131
*
132
* @ingroup client_policies
133
*/
134
#define AS_POLICY_COMMIT_LEVEL_DEFAULT AS_POLICY_COMMIT_LEVEL_ALL
135
136
/******************************************************************************
137
* TYPES
138
*****************************************************************************/
139
140
/**
141
* Retry Policy
142
*
143
* Specifies the behavior of failed operations.
144
*
145
* @ingroup client_policies
146
*/
147
typedef
enum
as_policy_retry_e {
148
149
/**
150
* Only attempt an operation once.
151
*/
152
AS_POLICY_RETRY_NONE
,
153
154
/**
155
* If an operation fails, attempt the operation
156
* one more time.
157
*/
158
AS_POLICY_RETRY_ONCE
,
159
160
}
as_policy_retry
;
161
162
/**
163
* Generation Policy
164
*
165
* Specifies the behavior of record modifications with regard to the
166
* generation value.
167
*
168
* @ingroup client_policies
169
*/
170
typedef
enum
as_policy_gen_e {
171
172
/**
173
* Write a record, regardless of generation.
174
*/
175
AS_POLICY_GEN_IGNORE
,
176
177
/**
178
* Write a record, ONLY if generations are equal
179
*/
180
AS_POLICY_GEN_EQ
,
181
182
/**
183
* Write a record, ONLY if local generation is
184
* greater-than remote generation
185
*/
186
AS_POLICY_GEN_GT
187
188
}
as_policy_gen
;
189
190
/**
191
* Key Policy
192
*
193
* Specifies the behavior for whether keys or digests
194
* should be sent to the cluster.
195
*
196
* @ingroup client_policies
197
*/
198
typedef
enum
as_policy_key_e {
199
200
/**
201
* Send the digest value of the key.
202
*
203
* This is the recommended mode of operation. This calculates the digest
204
* and send the digest to the server. The digest is only calculated on
205
* the client, and not on the server.
206
*/
207
AS_POLICY_KEY_DIGEST
,
208
209
/**
210
* Send the key, in addition to the digest value.
211
*
212
* If you want keys to be returned when scanning or querying, the keys must
213
* be stored on the server. This policy causes a write operation to store
214
* the key. Once a key is stored, the server will keep it - there is no
215
* need to use this policy on subsequent updates of the record.
216
*
217
* If this policy is used on read or delete operations, or on subsequent
218
* updates of a record with a stored key, the key sent will be compared
219
* with the key stored on the server. A mismatch will cause
220
* AEROSPIKE_ERR_RECORD_KEY_MISMATCH to be returned.
221
*/
222
AS_POLICY_KEY_SEND
,
223
224
}
as_policy_key
;
225
226
/**
227
* Existence Policy
228
*
229
* Specifies the behavior for writing the record
230
* depending whether or not it exists.
231
*
232
* @ingroup client_policies
233
*/
234
typedef
enum
as_policy_exists_e {
235
236
/**
237
* Write the record, regardless of existence. (i.e. create or update.)
238
*/
239
AS_POLICY_EXISTS_IGNORE
,
240
241
/**
242
* Create a record, ONLY if it doesn't exist.
243
*/
244
AS_POLICY_EXISTS_CREATE
,
245
246
/**
247
* Update a record, ONLY if it exists.
248
*/
249
AS_POLICY_EXISTS_UPDATE
,
250
251
/**
252
* Completely replace a record, ONLY if it exists.
253
*/
254
AS_POLICY_EXISTS_REPLACE
,
255
256
/**
257
* Completely replace a record if it exists, otherwise create it.
258
*/
259
AS_POLICY_EXISTS_CREATE_OR_REPLACE
260
261
}
as_policy_exists
;
262
263
/**
264
* Replica Policy
265
*
266
* Specifies which partition replica to read from.
267
*
268
* @ingroup client_policies
269
*/
270
typedef
enum
as_policy_replica_e {
271
272
/**
273
* Read from the partition master replica node.
274
*/
275
AS_POLICY_REPLICA_MASTER
,
276
277
/**
278
* Distribute reads across nodes containing key's master and replicated partition
279
* in round-robin fashion. Currently restricted to master and one prole.
280
*/
281
AS_POLICY_REPLICA_ANY
,
282
283
/**
284
* Always try node containing master partition first. If connection fails and
285
* `retry_on_timeout` is true, try node containing prole partition.
286
* Currently restricted to master and one prole.
287
*/
288
AS_POLICY_REPLICA_SEQUENCE
289
290
}
as_policy_replica
;
291
292
/**
293
* Consistency Level
294
*
295
* Specifies the number of replicas to be consulted
296
* in a read operation to provide the desired
297
* consistency guarantee.
298
*
299
* @ingroup client_policies
300
*/
301
typedef
enum
as_policy_consistency_level_e {
302
303
/**
304
* Involve a single replica in the operation.
305
*/
306
AS_POLICY_CONSISTENCY_LEVEL_ONE
,
307
308
/**
309
* Involve all replicas in the operation.
310
*/
311
AS_POLICY_CONSISTENCY_LEVEL_ALL
,
312
313
}
as_policy_consistency_level
;
314
315
/**
316
* Commit Level
317
*
318
* Specifies the number of replicas required to be successfully
319
* committed before returning success in a write operation
320
* to provide the desired consistency guarantee.
321
*
322
* @ingroup client_policies
323
*/
324
typedef
enum
as_policy_commit_level_e {
325
326
/**
327
* Return succcess only after successfully committing all replicas.
328
*/
329
AS_POLICY_COMMIT_LEVEL_ALL
,
330
331
/**
332
* Return succcess after successfully committing the master replica.
333
*/
334
AS_POLICY_COMMIT_LEVEL_MASTER
,
335
336
}
as_policy_commit_level
;
337
338
/**
339
* Write Policy
340
*
341
* @ingroup client_policies
342
*/
343
typedef
struct
as_policy_write_s {
344
345
/**
346
* Maximum time in milliseconds to wait for the operation to complete.
347
*/
348
uint32_t
timeout
;
349
350
/**
351
* Maximum number of retries when a transaction fails due to a network error.
352
* Used by synchronous commands only.
353
* Default: 1
354
*/
355
uint32_t
retry
;
356
357
/**
358
* Milliseconds to sleep between retries.
359
* Used by synchronous commands only.
360
* Default: 0 (do not sleep)
361
*/
362
uint32_t
sleep_between_retries
;
363
364
/**
365
* Minimum record size beyond which it is compressed and sent to the server.
366
*/
367
uint32_t
compression_threshold
;
368
369
/**
370
* Specifies the behavior for the key.
371
*/
372
as_policy_key
key
;
373
374
/**
375
* Specifies the behavior for the generation
376
* value.
377
*/
378
as_policy_gen
gen
;
379
380
/**
381
* Specifies the behavior for the existence
382
* of the record.
383
*/
384
as_policy_exists
exists
;
385
386
/**
387
* Specifies the number of replicas required
388
* to be committed successfully when writing
389
* before returning transaction succeeded.
390
*/
391
as_policy_commit_level
commit_level
;
392
393
/**
394
* Should the client retry a command if the timeout is reached.
395
* Used by synchronous commands only.
396
* <p>
397
* Values:
398
* <ul>
399
* <li>
400
* false: Return error when the timeout has been reached. Note that retries can still occur if
401
* a command fails on a network error before the timeout has been reached.
402
* </li>
403
* <li>
404
* true: Retry command with same timeout when the timeout has been reached. The maximum number
405
* of retries is defined by `retry`.
406
* </li>
407
* </ul>
408
* Default: false
409
*/
410
bool
retry_on_timeout
;
411
412
/**
413
* If the transaction results in a record deletion, leave a tombstone for the record.
414
* This prevents deleted records from reappearing after node failures.
415
* Valid for Aerospike Server Enterprise Edition only.
416
*
417
* Default: false (do not tombstone deleted records).
418
*/
419
bool
durable_delete
;
420
421
}
as_policy_write
;
422
423
/**
424
* Read Policy
425
*
426
* @ingroup client_policies
427
*/
428
typedef
struct
as_policy_read_s {
429
430
/**
431
* Maximum time in milliseconds to wait for the operation to complete.
432
*/
433
uint32_t
timeout
;
434
435
/**
436
* Maximum number of retries when a transaction fails due to a network error.
437
* Used by synchronous commands only.
438
* Default: 1
439
*/
440
uint32_t
retry
;
441
442
/**
443
* Milliseconds to sleep between retries.
444
* Used by synchronous commands only.
445
* Default: 0 (do not sleep)
446
*/
447
uint32_t
sleep_between_retries
;
448
449
/**
450
* Specifies the behavior for the key.
451
*/
452
as_policy_key
key
;
453
454
/**
455
* Specifies the replica to be consulted for the read.
456
*/
457
as_policy_replica
replica
;
458
459
/**
460
* Specifies the number of replicas consulted
461
* when reading for the desired consistency guarantee.
462
*/
463
as_policy_consistency_level
consistency_level
;
464
465
/**
466
* Should the client retry a command if the timeout is reached.
467
* Used by synchronous commands only.
468
* <p>
469
* Values:
470
* <ul>
471
* <li>
472
* false: Return error when the timeout has been reached. Note that retries can still occur if
473
* a command fails on a network error before the timeout has been reached.
474
* </li>
475
* <li>
476
* true: Retry command with same timeout when the timeout has been reached. The maximum number
477
* of retries is defined by `retry`.
478
* </li>
479
* </ul>
480
* Default: false
481
*/
482
bool
retry_on_timeout
;
483
484
/**
485
* Should raw bytes representing a list or map be deserialized to as_list or as_map.
486
* Set to false for backup programs that just need access to raw bytes.
487
* Default: true
488
*/
489
bool
deserialize
;
490
491
}
as_policy_read
;
492
493
/**
494
* Key Apply Policy
495
*
496
* @ingroup client_policies
497
*/
498
typedef
struct
as_policy_apply_s {
499
500
/**
501
* Maximum time in milliseconds to wait for the operation to complete.
502
*/
503
uint32_t
timeout
;
504
505
/**
506
* Maximum number of retries when a transaction fails due to a network error.
507
* Used by synchronous commands only.
508
* Default: 1
509
*/
510
uint32_t
retry
;
511
512
/**
513
* Milliseconds to sleep between retries.
514
* Used by synchronous commands only.
515
* Default: 0 (do not sleep)
516
*/
517
uint32_t
sleep_between_retries
;
518
519
/**
520
* Specifies the behavior for the key.
521
*/
522
as_policy_key
key
;
523
524
/**
525
* Specifies the number of replicas required
526
* to be committed successfully when writing
527
* before returning transaction succeeded.
528
*/
529
as_policy_commit_level
commit_level
;
530
531
/**
532
* The time-to-live (expiration) of the record in seconds.
533
* There are also special values that can be set in the record TTL:
534
* (*) ZERO (defined as AS_RECORD_DEFAULT_TTL), which means that the
535
* record will adopt the default TTL value from the namespace.
536
* (*) 0xFFFFFFFF (also, -1 in a signed 32 bit int)
537
* (defined as AS_RECORD_NO_EXPIRE_TTL), which means that the record
538
* will get an internal "void_time" of zero, and thus will never expire.
539
* (*) 0xFFFFFFFE (also, -2 in a signed 32 bit int)
540
* (defined as AS_RECORD_NO_CHANGE_TTL), which means that the record
541
* ttl will not change when the record is updated.
542
*
543
* Note that the TTL value will be employed ONLY on write/update calls.
544
*/
545
uint32_t
ttl
;
546
547
/**
548
* Should the client retry a command if the timeout is reached.
549
* Used by synchronous commands only.
550
* <p>
551
* Values:
552
* <ul>
553
* <li>
554
* false: Return error when the timeout has been reached. Note that retries can still occur if
555
* a command fails on a network error before the timeout has been reached.
556
* </li>
557
* <li>
558
* true: Retry command with same timeout when the timeout has been reached. The maximum number
559
* of retries is defined by `retry`.
560
* </li>
561
* </ul>
562
* Default: false
563
*/
564
bool
retry_on_timeout
;
565
566
/**
567
* If the transaction results in a record deletion, leave a tombstone for the record.
568
* This prevents deleted records from reappearing after node failures.
569
* Valid for Aerospike Server Enterprise Edition only.
570
*
571
* Default: false (do not tombstone deleted records).
572
*/
573
bool
durable_delete
;
574
575
}
as_policy_apply
;
576
577
/**
578
* Operate Policy
579
*
580
* @ingroup client_policies
581
*/
582
typedef
struct
as_policy_operate_s {
583
584
/**
585
* Maximum time in milliseconds to wait for the operation to complete.
586
*/
587
uint32_t
timeout
;
588
589
/**
590
* Maximum number of retries when a transaction fails due to a network error.
591
* Used by synchronous commands only.
592
* Default: 1
593
*/
594
uint32_t
retry
;
595
596
/**
597
* Milliseconds to sleep between retries.
598
* Used by synchronous commands only.
599
* Default: 0 (do not sleep)
600
*/
601
uint32_t
sleep_between_retries
;
602
603
/**
604
* Specifies the behavior for the key.
605
*/
606
as_policy_key
key
;
607
608
/**
609
* Specifies the behavior for the generation
610
* value.
611
*/
612
as_policy_gen
gen
;
613
614
/**
615
* Specifies the replica to be consulted for the read.
616
*/
617
as_policy_replica
replica
;
618
619
/**
620
* Specifies the number of replicas consulted
621
* when reading for the desired consistency guarantee.
622
*/
623
as_policy_consistency_level
consistency_level
;
624
625
/**
626
* Specifies the number of replicas required
627
* to be committed successfully when writing
628
* before returning transaction succeeded.
629
*/
630
as_policy_commit_level
commit_level
;
631
632
/**
633
* Should the client retry a command if the timeout is reached.
634
* Used by synchronous commands only.
635
* <p>
636
* Values:
637
* <ul>
638
* <li>
639
* false: Return error when the timeout has been reached. Note that retries can still occur if
640
* a command fails on a network error before the timeout has been reached.
641
* </li>
642
* <li>
643
* true: Retry command with same timeout when the timeout has been reached. The maximum number
644
* of retries is defined by `retry`.
645
* </li>
646
* </ul>
647
* Default: false
648
*/
649
bool
retry_on_timeout
;
650
651
/**
652
* Should raw bytes representing a list or map be deserialized to as_list or as_map.
653
* Set to false for backup programs that just need access to raw bytes.
654
* Default: true
655
*/
656
bool
deserialize
;
657
658
/**
659
* If the transaction results in a record deletion, leave a tombstone for the record.
660
* This prevents deleted records from reappearing after node failures.
661
* Valid for Aerospike Server Enterprise Edition only.
662
*
663
* Default: false (do not tombstone deleted records).
664
*/
665
bool
durable_delete
;
666
667
}
as_policy_operate
;
668
669
/**
670
* Remove Policy
671
*
672
* @ingroup client_policies
673
*/
674
typedef
struct
as_policy_remove_s {
675
676
/**
677
* Maximum time in milliseconds to wait for the operation to complete.
678
*/
679
uint32_t
timeout
;
680
681
/**
682
* Maximum number of retries when a transaction fails due to a network error.
683
* Used by synchronous commands only.
684
* Default: 1
685
*/
686
uint32_t
retry
;
687
688
/**
689
* Milliseconds to sleep between retries.
690
* Used by synchronous commands only.
691
* Default: 0 (do not sleep)
692
*/
693
uint32_t
sleep_between_retries
;
694
695
/**
696
* Specifies the behavior for the key.
697
*/
698
as_policy_key
key
;
699
700
/**
701
* Specifies the behavior for the generation
702
* value.
703
*/
704
as_policy_gen
gen
;
705
706
/**
707
* Specifies the number of replicas required
708
* to be committed successfully when writing
709
* before returning transaction succeeded.
710
*/
711
as_policy_commit_level
commit_level
;
712
713
/**
714
* The generation of the record.
715
*/
716
uint16_t
generation
;
717
718
/**
719
* Should the client retry a command if the timeout is reached.
720
* Used by synchronous commands only.
721
* <p>
722
* Values:
723
* <ul>
724
* <li>
725
* false: Return error when the timeout has been reached. Note that retries can still occur if
726
* a command fails on a network error before the timeout has been reached.
727
* </li>
728
* <li>
729
* true: Retry command with same timeout when the timeout has been reached. The maximum number
730
* of retries is defined by `retry`.
731
* </li>
732
* </ul>
733
* Default: false
734
*/
735
bool
retry_on_timeout
;
736
737
/**
738
* If the transaction results in a record deletion, leave a tombstone for the record.
739
* This prevents deleted records from reappearing after node failures.
740
* Valid for Aerospike Server Enterprise Edition only.
741
*
742
* Default: false (do not tombstone deleted records).
743
*/
744
bool
durable_delete
;
745
746
}
as_policy_remove
;
747
748
/**
749
* Query Policy
750
*
751
* @ingroup client_policies
752
*/
753
typedef
struct
as_policy_query_s {
754
755
/**
756
* Maximum time in milliseconds to wait for
757
* the operation to complete.
758
*
759
* The default (0) means do not timeout.
760
*/
761
uint32_t
timeout
;
762
763
/**
764
* Should raw bytes representing a list or map be deserialized to as_list or as_map.
765
* Set to false for backup programs that just need access to raw bytes.
766
* Default: true
767
*/
768
bool
deserialize
;
769
770
}
as_policy_query
;
771
772
/**
773
* Scan Policy
774
*
775
* @ingroup client_policies
776
*/
777
typedef
struct
as_policy_scan_s {
778
779
/**
780
* Maximum time in milliseconds to wait for the operation to complete.
781
*
782
* The default (0) means do not timeout.
783
*/
784
uint32_t
timeout
;
785
786
/**
787
* Maximum time in milliseconds to wait when polling socket for availability prior to
788
* performing an operation on the socket on the server side. Zero means there is no
789
* socket timeout.
790
*
791
* Default: 10000 ms
792
*/
793
uint32_t
socket_timeout
;
794
795
/**
796
* Abort the scan if the cluster is not in a
797
* stable state.
798
*/
799
bool
fail_on_cluster_change
;
800
801
/**
802
* If the scan runs a UDF which results in a record deletion, leave a tombstone for the record.
803
* This prevents deleted records from reappearing after node failures.
804
* Valid for Aerospike Server Enterprise Edition only.
805
*
806
* Default: false (do not tombstone deleted records).
807
*/
808
bool
durable_delete
;
809
810
}
as_policy_scan
;
811
812
/**
813
* Info Policy
814
*
815
* @ingroup client_policies
816
*/
817
typedef
struct
as_policy_info_s {
818
819
/**
820
* Maximum time in milliseconds to wait for
821
* the operation to complete.
822
*/
823
uint32_t
timeout
;
824
825
/**
826
* Send request without any further processing.
827
*/
828
bool
send_as_is
;
829
830
/**
831
* Ensure the request is within allowable size limits.
832
*/
833
bool
check_bounds
;
834
835
}
as_policy_info
;
836
837
/**
838
* Batch Policy
839
*
840
* @ingroup client_policies
841
*/
842
typedef
struct
as_policy_batch_s {
843
844
/**
845
* Maximum time in milliseconds to wait for the operation to complete.
846
*/
847
uint32_t
timeout
;
848
849
/**
850
* Maximum number of retries when a transaction fails due to a network error.
851
* Used by synchronous commands only.
852
* Default: 1
853
*/
854
uint32_t
retry
;
855
856
/**
857
* Milliseconds to sleep between retries.
858
* Used by synchronous commands only.
859
* Default: 0 (do not sleep)
860
*/
861
uint32_t
sleep_between_retries
;
862
863
/**
864
* Should the client retry a command if the timeout is reached.
865
* Used by synchronous commands only.
866
* <p>
867
* Values:
868
* <ul>
869
* <li>
870
* false: Return error when the timeout has been reached. Note that retries can still occur if
871
* a command fails on a network error before the timeout has been reached.
872
* </li>
873
* <li>
874
* true: Retry command with same timeout when the timeout has been reached. The maximum number
875
* of retries is defined by `retry`.
876
* </li>
877
* </ul>
878
* Default: false
879
*/
880
bool
retry_on_timeout
;
881
882
/**
883
* Determine if batch commands to each server are run in parallel threads.
884
* <p>
885
* Values:
886
* <ul>
887
* <li>
888
* false: Issue batch commands sequentially. This mode has a performance advantage for small
889
* to medium sized batch sizes because commands can be issued in the main transaction thread.
890
* This is the default.
891
* </li>
892
* <li>
893
* true: Issue batch commands in parallel threads. This mode has a performance
894
* advantage for large batch sizes because each node can process the command immediately.
895
* The downside is extra threads will need to be created (or taken from
896
* a thread pool).
897
* </li>
898
* </ul>
899
*/
900
bool
concurrent
;
901
902
/**
903
* Use old batch direct protocol where batch reads are handled by direct low-level batch server
904
* database routines. The batch direct protocol can be faster when there is a single namespace,
905
* but there is one important drawback. The batch direct protocol will not proxy to a different
906
* server node when the mapped node has migrated a record to another node (resulting in not
907
* found record).
908
* <p>
909
* This can happen after a node has been added/removed from the cluster and there is a lag
910
* between records being migrated and client partition map update (once per second).
911
* <p>
912
* The new batch index protocol will perform this record proxy when necessary.
913
* Default: false (use new batch index protocol if server supports it)
914
*/
915
bool
use_batch_direct
;
916
917
/**
918
* Allow batch to be processed immediately in the server's receiving thread when the server
919
* deems it to be appropriate. If false, the batch will always be processed in separate
920
* transaction threads. This field is only relevant for the new batch index protocol.
921
* <p>
922
* For batch exists or batch reads of smaller sized records (<= 1K per record), inline
923
* processing will be significantly faster on "in memory" namespaces. The server disables
924
* inline processing on disk based namespaces regardless of this policy field.
925
* <p>
926
* Inline processing can introduce the possibility of unfairness because the server
927
* can process the entire batch before moving onto the next command.
928
* Default: true
929
*/
930
bool
allow_inline
;
931
932
/**
933
* Send set name field to server for every key in the batch for batch index protocol.
934
* This is only necessary when authentication is enabled and security roles are defined
935
* on a per set basis.
936
* Default: false
937
*/
938
bool
send_set_name
;
939
940
/**
941
* Should raw bytes be deserialized to as_list or as_map. Set to false for backup programs that
942
* just need access to raw bytes.
943
* Default: true
944
*/
945
bool
deserialize
;
946
947
}
as_policy_batch
;
948
949
/**
950
* Administration Policy
951
*
952
* @ingroup client_policies
953
*/
954
typedef
struct
as_policy_admin_s {
955
956
/**
957
* Maximum time in milliseconds to wait for
958
* the operation to complete.
959
*/
960
uint32_t
timeout
;
961
962
}
as_policy_admin
;
963
964
/**
965
* Struct of all policy values and operation policies.
966
*
967
* This is utilizes by as_config, to define global and default values
968
* for policies.
969
*
970
* @ingroup as_config_t
971
*/
972
typedef
struct
as_policies_s {
973
974
/***************************************************************************
975
* DEFAULT VALUES, IF SPECIFIC POLICY IS UNDEFINED
976
**************************************************************************/
977
978
/**
979
* Default timeout in milliseconds.
980
*
981
* Default: `AS_POLICY_TIMEOUT_DEFAULT`
982
*/
983
uint32_t
timeout
;
984
985
/**
986
* Default maximum number of retries when a transaction fails due to a network error.
987
*
988
* Default: `AS_POLICY_RETRY_DEFAULT`
989
*/
990
uint32_t
retry
;
991
992
/**
993
* Default milliseconds to sleep between retries.
994
*
995
* Default: `AS_POLICY_RETRY_SLEEP_DEFAULT`
996
*/
997
uint32_t
sleep_between_retries
;
998
999
/**
1000
* Specifies the behavior for the key.
1001
*
1002
* Default: `AS_POLICY_KEY_DEFAULT`
1003
*/
1004
as_policy_key
key
;
1005
1006
/**
1007
* Specifies the behavior for the generation
1008
* value.
1009
*
1010
* Default: `AS_POLICY_GEN_DEFAULT`
1011
*/
1012
as_policy_gen
gen
;
1013
1014
/**
1015
* Specifies the behavior for the existence
1016
* of the record.
1017
*
1018
* Default: `AS_POLICY_EXISTS_DEFAULT`
1019
*/
1020
as_policy_exists
exists
;
1021
1022
/**
1023
* Specifies which replica to read.
1024
*
1025
* Default: `AS_POLICY_REPLICA_MASTER`
1026
*/
1027
as_policy_replica
replica
;
1028
1029
/**
1030
* Specifies the consistency level for reading.
1031
*
1032
* Default: `AS_POLICY_CONSISTENCY_LEVEL_ONE`
1033
*/
1034
as_policy_consistency_level
consistency_level
;
1035
1036
/**
1037
* Specifies the commit level for writing.
1038
*
1039
* Default: `AS_POLICY_COMMIT_LEVEL_ALL`
1040
*/
1041
as_policy_commit_level
commit_level
;
1042
1043
/***************************************************************************
1044
* SPECIFIC POLICIES
1045
**************************************************************************/
1046
1047
/**
1048
* The default read policy.
1049
*/
1050
as_policy_read
read
;
1051
1052
/**
1053
* The default write policy.
1054
*/
1055
as_policy_write
write
;
1056
1057
/**
1058
* The default operate policy.
1059
*/
1060
as_policy_operate
operate
;
1061
1062
/**
1063
* The default remove policy.
1064
*/
1065
as_policy_remove
remove
;
1066
1067
/**
1068
* The default apply policy.
1069
*/
1070
as_policy_apply
apply
;
1071
1072
/**
1073
* The default query policy.
1074
*/
1075
as_policy_query
query
;
1076
1077
/**
1078
* The default scan policy.
1079
*/
1080
as_policy_scan
scan
;
1081
1082
/**
1083
* The default info policy.
1084
*/
1085
as_policy_info
info
;
1086
1087
/**
1088
* The default batch policy.
1089
*/
1090
as_policy_batch
batch
;
1091
1092
/**
1093
* The default administration policy.
1094
*/
1095
as_policy_admin
admin
;
1096
1097
}
as_policies
;
1098
1099
/******************************************************************************
1100
* FUNCTIONS
1101
*****************************************************************************/
1102
1103
/**
1104
* Initialize as_policy_read to default values.
1105
*
1106
* @param p The policy to initialize.
1107
* @return The initialized policy.
1108
*
1109
* @relates as_policy_read
1110
*/
1111
static
inline
as_policy_read
*
1112
as_policy_read_init
(
as_policy_read
* p)
1113
{
1114
p->
timeout
=
AS_POLICY_TIMEOUT_DEFAULT
;
1115
p->
retry
=
AS_POLICY_RETRY_DEFAULT
;
1116
p->
sleep_between_retries
=
AS_POLICY_RETRY_SLEEP_DEFAULT
;
1117
p->
key
=
AS_POLICY_KEY_DEFAULT
;
1118
p->
replica
=
AS_POLICY_REPLICA_DEFAULT
;
1119
p->
consistency_level
=
AS_POLICY_CONSISTENCY_LEVEL_DEFAULT
;
1120
p->
retry_on_timeout
=
false
;
1121
p->
deserialize
=
true
;
1122
return
p;
1123
}
1124
1125
/**
1126
* Copy as_policy_read values.
1127
*
1128
* @param src The source policy.
1129
* @param trg The target policy.
1130
*
1131
* @relates as_policy_read
1132
*/
1133
static
inline
void
1134
as_policy_read_copy
(
as_policy_read
* src,
as_policy_read
* trg)
1135
{
1136
*trg = *src;
1137
}
1138
1139
/**
1140
* Initialize as_policy_write to default values.
1141
*
1142
* @param p The policy to initialize.
1143
* @return The initialized policy.
1144
*
1145
* @relates as_policy_write
1146
*/
1147
static
inline
as_policy_write
*
1148
as_policy_write_init
(
as_policy_write
* p)
1149
{
1150
p->
timeout
=
AS_POLICY_TIMEOUT_DEFAULT
;
1151
p->
retry
=
AS_POLICY_RETRY_DEFAULT
;
1152
p->
sleep_between_retries
=
AS_POLICY_RETRY_SLEEP_DEFAULT
;
1153
p->
compression_threshold
=
AS_POLICY_COMPRESSION_THRESHOLD_DEFAULT
;
1154
p->
key
=
AS_POLICY_KEY_DEFAULT
;
1155
p->
gen
=
AS_POLICY_GEN_DEFAULT
;
1156
p->
exists
=
AS_POLICY_EXISTS_DEFAULT
;
1157
p->
commit_level
=
AS_POLICY_COMMIT_LEVEL_DEFAULT
;
1158
p->
retry_on_timeout
=
false
;
1159
p->
durable_delete
=
false
;
1160
return
p;
1161
}
1162
1163
/**
1164
* Copy as_policy_write values.
1165
*
1166
* @param src The source policy.
1167
* @param trg The target policy.
1168
*
1169
* @relates as_policy_write
1170
*/
1171
static
inline
void
1172
as_policy_write_copy
(
as_policy_write
* src,
as_policy_write
* trg)
1173
{
1174
*trg = *src;
1175
}
1176
1177
/**
1178
* Initialize as_policy_operate to default values.
1179
*
1180
* @param p The policy to initialize.
1181
* @return The initialized policy.
1182
*
1183
* @relates as_policy_operate
1184
*/
1185
static
inline
as_policy_operate
*
1186
as_policy_operate_init
(
as_policy_operate
* p)
1187
{
1188
p->
timeout
=
AS_POLICY_TIMEOUT_DEFAULT
;
1189
p->
retry
=
AS_POLICY_RETRY_DEFAULT
;
1190
p->
sleep_between_retries
=
AS_POLICY_RETRY_SLEEP_DEFAULT
;
1191
p->
key
=
AS_POLICY_KEY_DEFAULT
;
1192
p->
gen
=
AS_POLICY_GEN_DEFAULT
;
1193
p->
replica
=
AS_POLICY_REPLICA_DEFAULT
;
1194
p->
consistency_level
=
AS_POLICY_CONSISTENCY_LEVEL_DEFAULT
;
1195
p->
commit_level
=
AS_POLICY_COMMIT_LEVEL_DEFAULT
;
1196
p->
retry_on_timeout
=
false
;
1197
p->
deserialize
=
true
;
1198
p->
durable_delete
=
false
;
1199
return
p;
1200
}
1201
1202
/**
1203
* Copy as_policy_operate values.
1204
*
1205
* @param src The source policy.
1206
* @param trg The target policy.
1207
*
1208
* @relates as_policy_operate
1209
*/
1210
static
inline
void
1211
as_policy_operate_copy
(
as_policy_operate
* src,
as_policy_operate
* trg)
1212
{
1213
*trg = *src;
1214
}
1215
1216
/**
1217
* Initialize as_policy_remove to default values.
1218
*
1219
* @param p The policy to initialize.
1220
* @return The initialized policy.
1221
*
1222
* @relates as_policy_remove
1223
*/
1224
static
inline
as_policy_remove
*
1225
as_policy_remove_init
(
as_policy_remove
* p)
1226
{
1227
p->
timeout
=
AS_POLICY_TIMEOUT_DEFAULT
;
1228
p->
retry
=
AS_POLICY_RETRY_DEFAULT
;
1229
p->
sleep_between_retries
=
AS_POLICY_RETRY_SLEEP_DEFAULT
;
1230
p->
key
=
AS_POLICY_KEY_DEFAULT
;
1231
p->
gen
=
AS_POLICY_GEN_DEFAULT
;
1232
p->
commit_level
=
AS_POLICY_COMMIT_LEVEL_DEFAULT
;
1233
p->
generation
= 0;
1234
p->
retry_on_timeout
=
false
;
1235
p->
durable_delete
=
false
;
1236
return
p;
1237
}
1238
1239
/**
1240
* Copy as_policy_remove values.
1241
*
1242
* @param src The source policy.
1243
* @param trg The target policy.
1244
*
1245
* @relates as_policy_remove
1246
*/
1247
static
inline
void
1248
as_policy_remove_copy
(
as_policy_remove
* src,
as_policy_remove
* trg)
1249
{
1250
*trg = *src;
1251
}
1252
1253
/**
1254
* Initialize as_policy_apply to default values.
1255
*
1256
* @param p The policy to initialize.
1257
* @return The initialized policy.
1258
*
1259
* @relates as_policy_apply
1260
*/
1261
static
inline
as_policy_apply
*
1262
as_policy_apply_init
(
as_policy_apply
* p)
1263
{
1264
p->
timeout
=
AS_POLICY_TIMEOUT_DEFAULT
;
1265
p->
retry
=
AS_POLICY_RETRY_DEFAULT
;
1266
p->
sleep_between_retries
=
AS_POLICY_RETRY_SLEEP_DEFAULT
;
1267
p->
key
=
AS_POLICY_KEY_DEFAULT
;
1268
p->
commit_level
=
AS_POLICY_COMMIT_LEVEL_DEFAULT
;
1269
p->
ttl
= 0;
// AS_RECORD_DEFAULT_TTL
1270
p->
retry_on_timeout
=
false
;
1271
p->
durable_delete
=
false
;
1272
return
p;
1273
}
1274
1275
/**
1276
* Copy as_policy_apply values.
1277
*
1278
* @param src The source policy.
1279
* @param trg The target policy.
1280
*
1281
* @relates as_policy_apply
1282
*/
1283
static
inline
void
1284
as_policy_apply_copy
(
as_policy_apply
* src,
as_policy_apply
* trg)
1285
{
1286
*trg = *src;
1287
}
1288
1289
/**
1290
* Initialize as_policy_info to default values.
1291
*
1292
* @param p The policy to initialize.
1293
* @return The initialized policy.
1294
*
1295
* @relates as_policy_info
1296
*/
1297
static
inline
as_policy_info
*
1298
as_policy_info_init
(
as_policy_info
* p)
1299
{
1300
p->
timeout
=
AS_POLICY_TIMEOUT_DEFAULT
;
1301
p->
send_as_is
=
true
;
1302
p->
check_bounds
=
true
;
1303
return
p;
1304
}
1305
1306
/**
1307
* Copy as_policy_info values.
1308
*
1309
* @param src The source policy.
1310
* @param trg The target policy.
1311
*
1312
* @relates as_policy_info
1313
*/
1314
static
inline
void
1315
as_policy_info_copy
(
as_policy_info
* src,
as_policy_info
* trg)
1316
{
1317
*trg = *src;
1318
}
1319
1320
/**
1321
* Initialize as_policy_batch to default values.
1322
*
1323
* @param p The policy to initialize.
1324
* @return The initialized policy.
1325
*
1326
* @relates as_policy_batch
1327
*/
1328
static
inline
as_policy_batch
*
1329
as_policy_batch_init
(
as_policy_batch
* p)
1330
{
1331
p->
timeout
=
AS_POLICY_TIMEOUT_DEFAULT
;
1332
p->
retry
=
AS_POLICY_RETRY_DEFAULT
;
1333
p->
sleep_between_retries
=
AS_POLICY_RETRY_SLEEP_DEFAULT
;
1334
p->
retry_on_timeout
=
false
;
1335
p->
concurrent
=
false
;
1336
p->
use_batch_direct
=
false
;
1337
p->
allow_inline
=
true
;
1338
p->
send_set_name
=
false
;
1339
p->
deserialize
=
true
;
1340
return
p;
1341
}
1342
1343
/**
1344
* Copy as_policy_batch values.
1345
*
1346
* @param src The source policy.
1347
* @param trg The target policy.
1348
*
1349
* @relates as_policy_batch
1350
*/
1351
static
inline
void
1352
as_policy_batch_copy
(
as_policy_batch
* src,
as_policy_batch
* trg)
1353
{
1354
*trg = *src;
1355
}
1356
1357
/**
1358
* Initialize as_policy_admin to default values.
1359
*
1360
* @param p The policy to initialize.
1361
* @return The initialized policy.
1362
*
1363
* @relates as_policy_admin
1364
*/
1365
static
inline
as_policy_admin
*
1366
as_policy_admin_init
(
as_policy_admin
* p)
1367
{
1368
p->
timeout
=
AS_POLICY_TIMEOUT_DEFAULT
;
1369
return
p;
1370
}
1371
1372
/**
1373
* Copy as_policy_admin values.
1374
*
1375
* @param src The source policy.
1376
* @param trg The target policy.
1377
*
1378
* @relates as_policy_admin
1379
*/
1380
static
inline
void
1381
as_policy_admin_copy
(
as_policy_admin
* src,
as_policy_admin
* trg)
1382
{
1383
*trg = *src;
1384
}
1385
1386
/**
1387
* Initialize as_policy_scan to default values.
1388
*
1389
* @param p The policy to initialize.
1390
* @return The initialized policy.
1391
*
1392
* @relates as_policy_scan
1393
*/
1394
static
inline
as_policy_scan
*
1395
as_policy_scan_init
(
as_policy_scan
* p)
1396
{
1397
p->
timeout
= 0;
1398
p->
socket_timeout
= 10000;
1399
p->
fail_on_cluster_change
=
false
;
1400
p->
durable_delete
=
false
;
1401
return
p;
1402
}
1403
1404
/**
1405
* Copy as_policy_scan values.
1406
*
1407
* @param src The source policy.
1408
* @param trg The target policy.
1409
*
1410
* @relates as_policy_scan
1411
*/
1412
static
inline
void
1413
as_policy_scan_copy
(
as_policy_scan
* src,
as_policy_scan
* trg)
1414
{
1415
*trg = *src;
1416
}
1417
1418
/**
1419
* Initialize as_policy_query to default values.
1420
*
1421
* @param p The policy to initialize.
1422
* @return The initialized policy.
1423
*
1424
* @relates as_policy_query
1425
*/
1426
static
inline
as_policy_query
*
1427
as_policy_query_init
(
as_policy_query
* p)
1428
{
1429
p->
timeout
= 0;
1430
p->
deserialize
=
true
;
1431
return
p;
1432
}
1433
1434
/**
1435
* Copy as_policy_query values.
1436
*
1437
* @param src The source policy.
1438
* @param trg The target policy.
1439
*
1440
* @relates as_policy_query
1441
*/
1442
static
inline
void
1443
as_policy_query_copy
(
as_policy_query
* src,
as_policy_query
* trg)
1444
{
1445
*trg = *src;
1446
}
1447
1448
/**
1449
* Initialize as_policies to undefined values.
1450
* as_policies_resolve() will later be called resolve undefined values to global defaults.
1451
*
1452
* @param p The policies to undefine
1453
* @return The undefined policies.
1454
*
1455
* @relates as_policies
1456
*/
1457
as_policies
*
1458
as_policies_init
(
as_policies
* p);
1459
1460
/**
1461
* Resolve global policies (like timeout) with operational policies (like as_policy_read).
1462
*
1463
* @param p The policies to resolve
1464
*
1465
* @relates as_policies
1466
*/
1467
void
1468
as_policies_resolve
(
as_policies
* p);
1469
1470
#ifdef __cplusplus
1471
}
// end extern "C"
1472
#endif