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