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-2016 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
* Abort the scan if the cluster is not in a
788
* stable state.
789
*/
790
bool
fail_on_cluster_change
;
791
792
/**
793
* If the scan runs a UDF which results in a record deletion, leave a tombstone for the record.
794
* This prevents deleted records from reappearing after node failures.
795
* Valid for Aerospike Server Enterprise Edition only.
796
*
797
* Default: false (do not tombstone deleted records).
798
*/
799
bool
durable_delete
;
800
801
}
as_policy_scan
;
802
803
/**
804
* Info Policy
805
*
806
* @ingroup client_policies
807
*/
808
typedef
struct
as_policy_info_s {
809
810
/**
811
* Maximum time in milliseconds to wait for
812
* the operation to complete.
813
*/
814
uint32_t
timeout
;
815
816
/**
817
* Send request without any further processing.
818
*/
819
bool
send_as_is
;
820
821
/**
822
* Ensure the request is within allowable size limits.
823
*/
824
bool
check_bounds
;
825
826
}
as_policy_info
;
827
828
/**
829
* Batch Policy
830
*
831
* @ingroup client_policies
832
*/
833
typedef
struct
as_policy_batch_s {
834
835
/**
836
* Maximum time in milliseconds to wait for the operation to complete.
837
*/
838
uint32_t
timeout
;
839
840
/**
841
* Maximum number of retries when a transaction fails due to a network error.
842
* Used by synchronous commands only.
843
* Default: 1
844
*/
845
uint32_t
retry
;
846
847
/**
848
* Milliseconds to sleep between retries.
849
* Used by synchronous commands only.
850
* Default: 0 (do not sleep)
851
*/
852
uint32_t
sleep_between_retries
;
853
854
/**
855
* Should the client retry a command if the timeout is reached.
856
* Used by synchronous commands only.
857
* <p>
858
* Values:
859
* <ul>
860
* <li>
861
* false: Return error when the timeout has been reached. Note that retries can still occur if
862
* a command fails on a network error before the timeout has been reached.
863
* </li>
864
* <li>
865
* true: Retry command with same timeout when the timeout has been reached. The maximum number
866
* of retries is defined by `retry`.
867
* </li>
868
* </ul>
869
* Default: false
870
*/
871
bool
retry_on_timeout
;
872
873
/**
874
* Determine if batch commands to each server are run in parallel threads.
875
* <p>
876
* Values:
877
* <ul>
878
* <li>
879
* false: Issue batch commands sequentially. This mode has a performance advantage for small
880
* to medium sized batch sizes because commands can be issued in the main transaction thread.
881
* This is the default.
882
* </li>
883
* <li>
884
* true: Issue batch commands in parallel threads. This mode has a performance
885
* advantage for large batch sizes because each node can process the command immediately.
886
* The downside is extra threads will need to be created (or taken from
887
* a thread pool).
888
* </li>
889
* </ul>
890
*/
891
bool
concurrent
;
892
893
/**
894
* Use old batch direct protocol where batch reads are handled by direct low-level batch server
895
* database routines. The batch direct protocol can be faster when there is a single namespace,
896
* but there is one important drawback. The batch direct protocol will not proxy to a different
897
* server node when the mapped node has migrated a record to another node (resulting in not
898
* found record).
899
* <p>
900
* This can happen after a node has been added/removed from the cluster and there is a lag
901
* between records being migrated and client partition map update (once per second).
902
* <p>
903
* The new batch index protocol will perform this record proxy when necessary.
904
* Default: false (use new batch index protocol if server supports it)
905
*/
906
bool
use_batch_direct
;
907
908
/**
909
* Allow batch to be processed immediately in the server's receiving thread when the server
910
* deems it to be appropriate. If false, the batch will always be processed in separate
911
* transaction threads. This field is only relevant for the new batch index protocol.
912
* <p>
913
* For batch exists or batch reads of smaller sized records (<= 1K per record), inline
914
* processing will be significantly faster on "in memory" namespaces. The server disables
915
* inline processing on disk based namespaces regardless of this policy field.
916
* <p>
917
* Inline processing can introduce the possibility of unfairness because the server
918
* can process the entire batch before moving onto the next command.
919
* Default: true
920
*/
921
bool
allow_inline
;
922
923
/**
924
* Send set name field to server for every key in the batch for batch index protocol.
925
* This is only necessary when authentication is enabled and security roles are defined
926
* on a per set basis.
927
* Default: false
928
*/
929
bool
send_set_name
;
930
931
/**
932
* Should raw bytes be deserialized to as_list or as_map. Set to false for backup programs that
933
* just need access to raw bytes.
934
* Default: true
935
*/
936
bool
deserialize
;
937
938
}
as_policy_batch
;
939
940
/**
941
* Administration Policy
942
*
943
* @ingroup client_policies
944
*/
945
typedef
struct
as_policy_admin_s {
946
947
/**
948
* Maximum time in milliseconds to wait for
949
* the operation to complete.
950
*/
951
uint32_t
timeout
;
952
953
}
as_policy_admin
;
954
955
/**
956
* Struct of all policy values and operation policies.
957
*
958
* This is utilizes by as_config, to define global and default values
959
* for policies.
960
*
961
* @ingroup as_config_t
962
*/
963
typedef
struct
as_policies_s {
964
965
/***************************************************************************
966
* DEFAULT VALUES, IF SPECIFIC POLICY IS UNDEFINED
967
**************************************************************************/
968
969
/**
970
* Default timeout in milliseconds.
971
*
972
* Default: `AS_POLICY_TIMEOUT_DEFAULT`
973
*/
974
uint32_t
timeout
;
975
976
/**
977
* Default maximum number of retries when a transaction fails due to a network error.
978
*
979
* Default: `AS_POLICY_RETRY_DEFAULT`
980
*/
981
uint32_t
retry
;
982
983
/**
984
* Default milliseconds to sleep between retries.
985
*
986
* Default: `AS_POLICY_RETRY_SLEEP_DEFAULT`
987
*/
988
uint32_t
sleep_between_retries
;
989
990
/**
991
* Specifies the behavior for the key.
992
*
993
* Default: `AS_POLICY_KEY_DEFAULT`
994
*/
995
as_policy_key
key
;
996
997
/**
998
* Specifies the behavior for the generation
999
* value.
1000
*
1001
* Default: `AS_POLICY_GEN_DEFAULT`
1002
*/
1003
as_policy_gen
gen
;
1004
1005
/**
1006
* Specifies the behavior for the existence
1007
* of the record.
1008
*
1009
* Default: `AS_POLICY_EXISTS_DEFAULT`
1010
*/
1011
as_policy_exists
exists
;
1012
1013
/**
1014
* Specifies which replica to read.
1015
*
1016
* Default: `AS_POLICY_REPLICA_MASTER`
1017
*/
1018
as_policy_replica
replica
;
1019
1020
/**
1021
* Specifies the consistency level for reading.
1022
*
1023
* Default: `AS_POLICY_CONSISTENCY_LEVEL_ONE`
1024
*/
1025
as_policy_consistency_level
consistency_level
;
1026
1027
/**
1028
* Specifies the commit level for writing.
1029
*
1030
* Default: `AS_POLICY_COMMIT_LEVEL_ALL`
1031
*/
1032
as_policy_commit_level
commit_level
;
1033
1034
/***************************************************************************
1035
* SPECIFIC POLICIES
1036
**************************************************************************/
1037
1038
/**
1039
* The default read policy.
1040
*/
1041
as_policy_read
read
;
1042
1043
/**
1044
* The default write policy.
1045
*/
1046
as_policy_write
write
;
1047
1048
/**
1049
* The default operate policy.
1050
*/
1051
as_policy_operate
operate
;
1052
1053
/**
1054
* The default remove policy.
1055
*/
1056
as_policy_remove
remove
;
1057
1058
/**
1059
* The default apply policy.
1060
*/
1061
as_policy_apply
apply
;
1062
1063
/**
1064
* The default query policy.
1065
*/
1066
as_policy_query
query
;
1067
1068
/**
1069
* The default scan policy.
1070
*/
1071
as_policy_scan
scan
;
1072
1073
/**
1074
* The default info policy.
1075
*/
1076
as_policy_info
info
;
1077
1078
/**
1079
* The default batch policy.
1080
*/
1081
as_policy_batch
batch
;
1082
1083
/**
1084
* The default administration policy.
1085
*/
1086
as_policy_admin
admin
;
1087
1088
}
as_policies
;
1089
1090
/******************************************************************************
1091
* FUNCTIONS
1092
*****************************************************************************/
1093
1094
/**
1095
* Initialize as_policy_read to default values.
1096
*
1097
* @param p The policy to initialize.
1098
* @return The initialized policy.
1099
*
1100
* @relates as_policy_read
1101
*/
1102
static
inline
as_policy_read
*
1103
as_policy_read_init
(
as_policy_read
* p)
1104
{
1105
p->
timeout
=
AS_POLICY_TIMEOUT_DEFAULT
;
1106
p->
retry
=
AS_POLICY_RETRY_DEFAULT
;
1107
p->
sleep_between_retries
=
AS_POLICY_RETRY_SLEEP_DEFAULT
;
1108
p->
key
=
AS_POLICY_KEY_DEFAULT
;
1109
p->
replica
=
AS_POLICY_REPLICA_DEFAULT
;
1110
p->
consistency_level
=
AS_POLICY_CONSISTENCY_LEVEL_DEFAULT
;
1111
p->
retry_on_timeout
=
false
;
1112
p->
deserialize
=
true
;
1113
return
p;
1114
}
1115
1116
/**
1117
* Copy as_policy_read values.
1118
*
1119
* @param src The source policy.
1120
* @param trg The target policy.
1121
*
1122
* @relates as_policy_read
1123
*/
1124
static
inline
void
1125
as_policy_read_copy
(
as_policy_read
* src,
as_policy_read
* trg)
1126
{
1127
*trg = *src;
1128
}
1129
1130
/**
1131
* Initialize as_policy_write to default values.
1132
*
1133
* @param p The policy to initialize.
1134
* @return The initialized policy.
1135
*
1136
* @relates as_policy_write
1137
*/
1138
static
inline
as_policy_write
*
1139
as_policy_write_init
(
as_policy_write
* p)
1140
{
1141
p->
timeout
=
AS_POLICY_TIMEOUT_DEFAULT
;
1142
p->
retry
=
AS_POLICY_RETRY_DEFAULT
;
1143
p->
sleep_between_retries
=
AS_POLICY_RETRY_SLEEP_DEFAULT
;
1144
p->
compression_threshold
=
AS_POLICY_COMPRESSION_THRESHOLD_DEFAULT
;
1145
p->
key
=
AS_POLICY_KEY_DEFAULT
;
1146
p->
gen
=
AS_POLICY_GEN_DEFAULT
;
1147
p->
exists
=
AS_POLICY_EXISTS_DEFAULT
;
1148
p->
commit_level
=
AS_POLICY_COMMIT_LEVEL_DEFAULT
;
1149
p->
retry_on_timeout
=
false
;
1150
p->
durable_delete
=
false
;
1151
return
p;
1152
}
1153
1154
/**
1155
* Copy as_policy_write values.
1156
*
1157
* @param src The source policy.
1158
* @param trg The target policy.
1159
*
1160
* @relates as_policy_write
1161
*/
1162
static
inline
void
1163
as_policy_write_copy
(
as_policy_write
* src,
as_policy_write
* trg)
1164
{
1165
*trg = *src;
1166
}
1167
1168
/**
1169
* Initialize as_policy_operate to default values.
1170
*
1171
* @param p The policy to initialize.
1172
* @return The initialized policy.
1173
*
1174
* @relates as_policy_operate
1175
*/
1176
static
inline
as_policy_operate
*
1177
as_policy_operate_init
(
as_policy_operate
* p)
1178
{
1179
p->
timeout
=
AS_POLICY_TIMEOUT_DEFAULT
;
1180
p->
retry
=
AS_POLICY_RETRY_DEFAULT
;
1181
p->
sleep_between_retries
=
AS_POLICY_RETRY_SLEEP_DEFAULT
;
1182
p->
key
=
AS_POLICY_KEY_DEFAULT
;
1183
p->
gen
=
AS_POLICY_GEN_DEFAULT
;
1184
p->
replica
=
AS_POLICY_REPLICA_DEFAULT
;
1185
p->
consistency_level
=
AS_POLICY_CONSISTENCY_LEVEL_DEFAULT
;
1186
p->
commit_level
=
AS_POLICY_COMMIT_LEVEL_DEFAULT
;
1187
p->
retry_on_timeout
=
false
;
1188
p->
deserialize
=
true
;
1189
p->
durable_delete
=
false
;
1190
return
p;
1191
}
1192
1193
/**
1194
* Copy as_policy_operate values.
1195
*
1196
* @param src The source policy.
1197
* @param trg The target policy.
1198
*
1199
* @relates as_policy_operate
1200
*/
1201
static
inline
void
1202
as_policy_operate_copy
(
as_policy_operate
* src,
as_policy_operate
* trg)
1203
{
1204
*trg = *src;
1205
}
1206
1207
/**
1208
* Initialize as_policy_remove to default values.
1209
*
1210
* @param p The policy to initialize.
1211
* @return The initialized policy.
1212
*
1213
* @relates as_policy_remove
1214
*/
1215
static
inline
as_policy_remove
*
1216
as_policy_remove_init
(
as_policy_remove
* p)
1217
{
1218
p->
timeout
=
AS_POLICY_TIMEOUT_DEFAULT
;
1219
p->
retry
=
AS_POLICY_RETRY_DEFAULT
;
1220
p->
sleep_between_retries
=
AS_POLICY_RETRY_SLEEP_DEFAULT
;
1221
p->
key
=
AS_POLICY_KEY_DEFAULT
;
1222
p->
gen
=
AS_POLICY_GEN_DEFAULT
;
1223
p->
commit_level
=
AS_POLICY_COMMIT_LEVEL_DEFAULT
;
1224
p->
generation
= 0;
1225
p->
retry_on_timeout
=
false
;
1226
p->
durable_delete
=
false
;
1227
return
p;
1228
}
1229
1230
/**
1231
* Copy as_policy_remove values.
1232
*
1233
* @param src The source policy.
1234
* @param trg The target policy.
1235
*
1236
* @relates as_policy_remove
1237
*/
1238
static
inline
void
1239
as_policy_remove_copy
(
as_policy_remove
* src,
as_policy_remove
* trg)
1240
{
1241
*trg = *src;
1242
}
1243
1244
/**
1245
* Initialize as_policy_apply to default values.
1246
*
1247
* @param p The policy to initialize.
1248
* @return The initialized policy.
1249
*
1250
* @relates as_policy_apply
1251
*/
1252
static
inline
as_policy_apply
*
1253
as_policy_apply_init
(
as_policy_apply
* p)
1254
{
1255
p->
timeout
=
AS_POLICY_TIMEOUT_DEFAULT
;
1256
p->
retry
=
AS_POLICY_RETRY_DEFAULT
;
1257
p->
sleep_between_retries
=
AS_POLICY_RETRY_SLEEP_DEFAULT
;
1258
p->
key
=
AS_POLICY_KEY_DEFAULT
;
1259
p->
commit_level
=
AS_POLICY_COMMIT_LEVEL_DEFAULT
;
1260
p->
ttl
= 0;
// AS_RECORD_DEFAULT_TTL
1261
p->
retry_on_timeout
=
false
;
1262
p->
durable_delete
=
false
;
1263
return
p;
1264
}
1265
1266
/**
1267
* Copy as_policy_apply values.
1268
*
1269
* @param src The source policy.
1270
* @param trg The target policy.
1271
*
1272
* @relates as_policy_apply
1273
*/
1274
static
inline
void
1275
as_policy_apply_copy
(
as_policy_apply
* src,
as_policy_apply
* trg)
1276
{
1277
*trg = *src;
1278
}
1279
1280
/**
1281
* Initialize as_policy_info to default values.
1282
*
1283
* @param p The policy to initialize.
1284
* @return The initialized policy.
1285
*
1286
* @relates as_policy_info
1287
*/
1288
static
inline
as_policy_info
*
1289
as_policy_info_init
(
as_policy_info
* p)
1290
{
1291
p->
timeout
=
AS_POLICY_TIMEOUT_DEFAULT
;
1292
p->
send_as_is
=
true
;
1293
p->
check_bounds
=
true
;
1294
return
p;
1295
}
1296
1297
/**
1298
* Copy as_policy_info values.
1299
*
1300
* @param src The source policy.
1301
* @param trg The target policy.
1302
*
1303
* @relates as_policy_info
1304
*/
1305
static
inline
void
1306
as_policy_info_copy
(
as_policy_info
* src,
as_policy_info
* trg)
1307
{
1308
*trg = *src;
1309
}
1310
1311
/**
1312
* Initialize as_policy_batch to default values.
1313
*
1314
* @param p The policy to initialize.
1315
* @return The initialized policy.
1316
*
1317
* @relates as_policy_batch
1318
*/
1319
static
inline
as_policy_batch
*
1320
as_policy_batch_init
(
as_policy_batch
* p)
1321
{
1322
p->
timeout
=
AS_POLICY_TIMEOUT_DEFAULT
;
1323
p->
retry
=
AS_POLICY_RETRY_DEFAULT
;
1324
p->
sleep_between_retries
=
AS_POLICY_RETRY_SLEEP_DEFAULT
;
1325
p->
retry_on_timeout
=
false
;
1326
p->
concurrent
=
false
;
1327
p->
use_batch_direct
=
false
;
1328
p->
allow_inline
=
true
;
1329
p->
send_set_name
=
false
;
1330
p->
deserialize
=
true
;
1331
return
p;
1332
}
1333
1334
/**
1335
* Copy as_policy_batch values.
1336
*
1337
* @param src The source policy.
1338
* @param trg The target policy.
1339
*
1340
* @relates as_policy_batch
1341
*/
1342
static
inline
void
1343
as_policy_batch_copy
(
as_policy_batch
* src,
as_policy_batch
* trg)
1344
{
1345
*trg = *src;
1346
}
1347
1348
/**
1349
* Initialize as_policy_admin to default values.
1350
*
1351
* @param p The policy to initialize.
1352
* @return The initialized policy.
1353
*
1354
* @relates as_policy_admin
1355
*/
1356
static
inline
as_policy_admin
*
1357
as_policy_admin_init
(
as_policy_admin
* p)
1358
{
1359
p->
timeout
=
AS_POLICY_TIMEOUT_DEFAULT
;
1360
return
p;
1361
}
1362
1363
/**
1364
* Copy as_policy_admin values.
1365
*
1366
* @param src The source policy.
1367
* @param trg The target policy.
1368
*
1369
* @relates as_policy_admin
1370
*/
1371
static
inline
void
1372
as_policy_admin_copy
(
as_policy_admin
* src,
as_policy_admin
* trg)
1373
{
1374
*trg = *src;
1375
}
1376
1377
/**
1378
* Initialize as_policy_scan to default values.
1379
*
1380
* @param p The policy to initialize.
1381
* @return The initialized policy.
1382
*
1383
* @relates as_policy_scan
1384
*/
1385
static
inline
as_policy_scan
*
1386
as_policy_scan_init
(
as_policy_scan
* p)
1387
{
1388
p->
timeout
= 0;
1389
p->
fail_on_cluster_change
=
false
;
1390
p->
durable_delete
=
false
;
1391
return
p;
1392
}
1393
1394
/**
1395
* Copy as_policy_scan values.
1396
*
1397
* @param src The source policy.
1398
* @param trg The target policy.
1399
*
1400
* @relates as_policy_scan
1401
*/
1402
static
inline
void
1403
as_policy_scan_copy
(
as_policy_scan
* src,
as_policy_scan
* trg)
1404
{
1405
*trg = *src;
1406
}
1407
1408
/**
1409
* Initialize as_policy_query to default values.
1410
*
1411
* @param p The policy to initialize.
1412
* @return The initialized policy.
1413
*
1414
* @relates as_policy_query
1415
*/
1416
static
inline
as_policy_query
*
1417
as_policy_query_init
(
as_policy_query
* p)
1418
{
1419
p->
timeout
= 0;
1420
p->
deserialize
=
true
;
1421
return
p;
1422
}
1423
1424
/**
1425
* Copy as_policy_query values.
1426
*
1427
* @param src The source policy.
1428
* @param trg The target policy.
1429
*
1430
* @relates as_policy_query
1431
*/
1432
static
inline
void
1433
as_policy_query_copy
(
as_policy_query
* src,
as_policy_query
* trg)
1434
{
1435
*trg = *src;
1436
}
1437
1438
/**
1439
* Initialize as_policies to undefined values.
1440
* as_policies_resolve() will later be called resolve undefined values to global defaults.
1441
*
1442
* @param p The policies to undefine
1443
* @return The undefined policies.
1444
*
1445
* @relates as_policies
1446
*/
1447
as_policies
*
1448
as_policies_init
(
as_policies
* p);
1449
1450
/**
1451
* Resolve global policies (like timeout) with operational policies (like as_policy_read).
1452
*
1453
* @param p The policies to resolve
1454
*
1455
* @relates as_policies
1456
*/
1457
void
1458
as_policies_resolve
(
as_policies
* p);
1459
1460
#ifdef __cplusplus
1461
}
// end extern "C"
1462
#endif