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
/**
449
* Force reads to be linearized for server namespaces that support CP mode.
450
* Default: false
451
*/
452
bool
linearize_read
;
453
454
}
as_policy_read
;
455
456
/**
457
* Write Policy
458
*
459
* @ingroup client_policies
460
*/
461
typedef
struct
as_policy_write_s {
462
463
/**
464
* Generic policy fields.
465
*/
466
as_policy_base
base
;
467
468
/**
469
* Specifies the behavior for the key.
470
*/
471
as_policy_key
key
;
472
473
/**
474
* Specifies the replica to be consulted for the read.
475
*/
476
as_policy_replica
replica
;
477
478
/**
479
* Specifies the number of replicas required to be committed successfully when writing
480
* before returning transaction succeeded.
481
*/
482
as_policy_commit_level
commit_level
;
483
484
/**
485
* Specifies the behavior for the generation value.
486
*/
487
as_policy_gen
gen
;
488
489
/**
490
* Specifies the behavior for the existence of the record.
491
*/
492
as_policy_exists
exists
;
493
494
/**
495
* Minimum record size beyond which it is compressed and sent to the server.
496
*/
497
uint32_t
compression_threshold
;
498
499
/**
500
* If the transaction results in a record deletion, leave a tombstone for the record.
501
* This prevents deleted records from reappearing after node failures.
502
* Valid for Aerospike Server Enterprise Edition only.
503
*
504
* Default: false (do not tombstone deleted records).
505
*/
506
bool
durable_delete
;
507
508
}
as_policy_write
;
509
510
/**
511
* Key Apply Policy
512
*
513
* @ingroup client_policies
514
*/
515
typedef
struct
as_policy_apply_s {
516
517
/**
518
* Generic policy fields.
519
*/
520
as_policy_base
base
;
521
522
/**
523
* Specifies the behavior for the key.
524
*/
525
as_policy_key
key
;
526
527
/**
528
* Specifies the replica to be consulted for the read.
529
*/
530
as_policy_replica
replica
;
531
532
/**
533
* Specifies the number of replicas required to be committed successfully when writing
534
* before returning transaction succeeded.
535
*/
536
as_policy_commit_level
commit_level
;
537
538
/**
539
* The time-to-live (expiration) of the record in seconds.
540
* There are also special values that can be set in the record TTL:
541
* (*) ZERO (defined as AS_RECORD_DEFAULT_TTL), which means that the
542
* record will adopt the default TTL value from the namespace.
543
* (*) 0xFFFFFFFF (also, -1 in a signed 32 bit int)
544
* (defined as AS_RECORD_NO_EXPIRE_TTL), which means that the record
545
* will get an internal "void_time" of zero, and thus will never expire.
546
* (*) 0xFFFFFFFE (also, -2 in a signed 32 bit int)
547
* (defined as AS_RECORD_NO_CHANGE_TTL), which means that the record
548
* ttl will not change when the record is updated.
549
*
550
* Note that the TTL value will be employed ONLY on write/update calls.
551
*/
552
uint32_t
ttl
;
553
554
/**
555
* Specifies the behavior for the generation value.
556
*/
557
as_policy_gen
gen
;
558
559
/**
560
* The expected generation of the record.
561
*/
562
uint16_t
gen_value
;
563
564
/**
565
* If the transaction results in a record deletion, leave a tombstone for the record.
566
* This prevents deleted records from reappearing after node failures.
567
* Valid for Aerospike Server Enterprise Edition only.
568
*
569
* Default: false (do not tombstone deleted records).
570
*/
571
bool
durable_delete
;
572
573
/**
574
* Force reads to be linearized for server namespaces that support CP mode.
575
* Default: false
576
*/
577
bool
linearize_read
;
578
579
}
as_policy_apply
;
580
581
/**
582
* Operate Policy
583
*
584
* @ingroup client_policies
585
*/
586
typedef
struct
as_policy_operate_s {
587
588
/**
589
* Generic policy fields.
590
*/
591
as_policy_base
base
;
592
593
/**
594
* Specifies the behavior for the key.
595
*/
596
as_policy_key
key
;
597
598
/**
599
* Specifies the replica to be consulted for the read.
600
*/
601
as_policy_replica
replica
;
602
603
/**
604
* Specifies the number of replicas consulted when reading for the desired consistency guarantee.
605
*/
606
as_policy_consistency_level
consistency_level
;
607
608
/**
609
* Specifies the number of replicas required to be committed successfully when writing
610
* before returning transaction succeeded.
611
*/
612
as_policy_commit_level
commit_level
;
613
614
/**
615
* Specifies the behavior for the generation value.
616
*/
617
as_policy_gen
gen
;
618
619
/**
620
* Should raw bytes representing a list or map be deserialized to as_list or as_map.
621
* Set to false for backup programs that just need access to raw bytes.
622
* Default: true
623
*/
624
bool
deserialize
;
625
626
/**
627
* If the transaction results in a record deletion, leave a tombstone for the record.
628
* This prevents deleted records from reappearing after node failures.
629
* Valid for Aerospike Server Enterprise Edition only.
630
*
631
* Default: false (do not tombstone deleted records).
632
*/
633
bool
durable_delete
;
634
635
/**
636
* Force reads to be linearized for server namespaces that support CP mode.
637
* Default: false
638
*/
639
bool
linearize_read
;
640
641
}
as_policy_operate
;
642
643
/**
644
* Remove Policy
645
*
646
* @ingroup client_policies
647
*/
648
typedef
struct
as_policy_remove_s {
649
650
/**
651
* Generic policy fields.
652
*/
653
as_policy_base
base
;
654
655
/**
656
* Specifies the behavior for the key.
657
*/
658
as_policy_key
key
;
659
660
/**
661
* Specifies the replica to be consulted for the read.
662
*/
663
as_policy_replica
replica
;
664
665
/**
666
* Specifies the number of replicas required to be committed successfully when writing
667
* before returning transaction succeeded.
668
*/
669
as_policy_commit_level
commit_level
;
670
671
/**
672
* Specifies the behavior for the generation value.
673
*/
674
as_policy_gen
gen
;
675
676
/**
677
* The generation of the record.
678
*/
679
uint16_t
generation
;
680
681
/**
682
* If the transaction results in a record deletion, leave a tombstone for the record.
683
* This prevents deleted records from reappearing after node failures.
684
* Valid for Aerospike Server Enterprise Edition only.
685
*
686
* Default: false (do not tombstone deleted records).
687
*/
688
bool
durable_delete
;
689
690
}
as_policy_remove
;
691
692
/**
693
* Batch Policy
694
*
695
* @ingroup client_policies
696
*/
697
typedef
struct
as_policy_batch_s {
698
699
/**
700
* Generic policy fields.
701
*/
702
as_policy_base
base
;
703
704
/**
705
* Specifies the number of replicas consulted when reading for the desired consistency guarantee.
706
*/
707
as_policy_consistency_level
consistency_level
;
708
709
/**
710
* Determine if batch commands to each server are run in parallel threads.
711
*
712
* Values:
713
* <ul>
714
* <li>
715
* false: Issue batch commands sequentially. This mode has a performance advantage for small
716
* to medium sized batch sizes because commands can be issued in the main transaction thread.
717
* This is the default.
718
* </li>
719
* <li>
720
* true: Issue batch commands in parallel threads. This mode has a performance
721
* advantage for large batch sizes because each node can process the command immediately.
722
* The downside is extra threads will need to be created (or taken from
723
* a thread pool).
724
* </li>
725
* </ul>
726
*/
727
bool
concurrent
;
728
729
/**
730
* Use old batch direct protocol where batch reads are handled by direct low-level batch server
731
* database routines. The batch direct protocol can be faster when there is a single namespace,
732
* but there is one important drawback. The batch direct protocol will not proxy to a different
733
* server node when the mapped node has migrated a record to another node (resulting in not
734
* found record).
735
*
736
* This can happen after a node has been added/removed from the cluster and there is a lag
737
* between records being migrated and client partition map update (once per second).
738
*
739
* The new batch index protocol will perform this record proxy when necessary.
740
* Default: false (use new batch index protocol if server supports it)
741
*/
742
bool
use_batch_direct
;
743
744
/**
745
* Allow batch to be processed immediately in the server's receiving thread when the server
746
* deems it to be appropriate. If false, the batch will always be processed in separate
747
* transaction threads. This field is only relevant for the new batch index protocol.
748
*
749
* For batch exists or batch reads of smaller sized records (<= 1K per record), inline
750
* processing will be significantly faster on "in memory" namespaces. The server disables
751
* inline processing on disk based namespaces regardless of this policy field.
752
*
753
* Inline processing can introduce the possibility of unfairness because the server
754
* can process the entire batch before moving onto the next command.
755
* Default: true
756
*/
757
bool
allow_inline
;
758
759
/**
760
* Send set name field to server for every key in the batch for batch index protocol.
761
* This is only necessary when authentication is enabled and security roles are defined
762
* on a per set basis.
763
* Default: false
764
*/
765
bool
send_set_name
;
766
767
/**
768
* Should raw bytes be deserialized to as_list or as_map. Set to false for backup programs that
769
* just need access to raw bytes.
770
* Default: true
771
*/
772
bool
deserialize
;
773
774
/**
775
* Force reads to be linearized for server namespaces that support CP mode.
776
* Default: false
777
*/
778
bool
linearize_read
;
779
780
}
as_policy_batch
;
781
782
/**
783
* Query Policy
784
*
785
* @ingroup client_policies
786
*/
787
typedef
struct
as_policy_query_s {
788
789
/**
790
* Generic policy fields.
791
*/
792
as_policy_base
base
;
793
794
/**
795
* Should raw bytes representing a list or map be deserialized to as_list or as_map.
796
* Set to false for backup programs that just need access to raw bytes.
797
* Default: true
798
*/
799
bool
deserialize
;
800
801
}
as_policy_query
;
802
803
/**
804
* Scan Policy
805
*
806
* @ingroup client_policies
807
*/
808
typedef
struct
as_policy_scan_s {
809
810
/**
811
* Generic policy fields.
812
*/
813
as_policy_base
base
;
814
815
/**
816
* Abort the scan if the cluster is not in a stable state.
817
*/
818
bool
fail_on_cluster_change
;
819
820
/**
821
* If the transaction results in a record deletion, leave a tombstone for the record.
822
* This prevents deleted records from reappearing after node failures.
823
* Valid for Aerospike Server Enterprise Edition only.
824
*
825
* Default: false (do not tombstone deleted records).
826
*/
827
bool
durable_delete
;
828
829
}
as_policy_scan
;
830
831
/**
832
* Info Policy
833
*
834
* @ingroup client_policies
835
*/
836
typedef
struct
as_policy_info_s {
837
838
/**
839
* Maximum time in milliseconds to wait for the operation to complete.
840
*/
841
uint32_t
timeout
;
842
843
/**
844
* Send request without any further processing.
845
*/
846
bool
send_as_is
;
847
848
/**
849
* Ensure the request is within allowable size limits.
850
*/
851
bool
check_bounds
;
852
853
}
as_policy_info
;
854
855
/**
856
* Administration Policy
857
*
858
* @ingroup client_policies
859
*/
860
typedef
struct
as_policy_admin_s {
861
862
/**
863
* Maximum time in milliseconds to wait for the operation to complete.
864
*/
865
uint32_t
timeout
;
866
867
}
as_policy_admin
;
868
869
/**
870
* Struct of all policy values and operation policies.
871
*
872
* This is utilized by as_config to define default values for policies.
873
*
874
* @ingroup as_config_t
875
*/
876
typedef
struct
as_policies_s {
877
878
/**
879
* The default read policy.
880
*/
881
as_policy_read
read
;
882
883
/**
884
* The default write policy.
885
*/
886
as_policy_write
write
;
887
888
/**
889
* The default operate policy.
890
*/
891
as_policy_operate
operate
;
892
893
/**
894
* The default remove policy.
895
*/
896
as_policy_remove
remove
;
897
898
/**
899
* The default apply policy.
900
*/
901
as_policy_apply
apply
;
902
903
/**
904
* The default batch policy.
905
*/
906
as_policy_batch
batch
;
907
908
/**
909
* The default scan policy.
910
*/
911
as_policy_scan
scan
;
912
913
/**
914
* The default query policy.
915
*/
916
as_policy_query
query
;
917
918
/**
919
* The default info policy.
920
*/
921
as_policy_info
info
;
922
923
/**
924
* The default administration policy.
925
*/
926
as_policy_admin
admin
;
927
928
}
as_policies
;
929
930
/******************************************************************************
931
* FUNCTIONS
932
*****************************************************************************/
933
934
/**
935
* Initialize as_policy_read to default values.
936
*
937
* @param p The policy to initialize.
938
* @return The initialized policy.
939
*
940
* @relates as_policy_read
941
*/
942
static
inline
as_policy_read
*
943
as_policy_read_init
(
as_policy_read
* p)
944
{
945
p->
base
.
socket_timeout
=
AS_POLICY_SOCKET_TIMEOUT_DEFAULT
;
946
p->
base
.
total_timeout
=
AS_POLICY_TOTAL_TIMEOUT_DEFAULT
;
947
p->
base
.
max_retries
=
AS_POLICY_MAX_RETRIES_DEFAULT
;
948
p->
base
.
sleep_between_retries
=
AS_POLICY_SLEEP_BETWEEN_RETRIES_DEFAULT
;
949
p->
key
=
AS_POLICY_KEY_DEFAULT
;
950
p->
replica
=
AS_POLICY_REPLICA_DEFAULT
;
951
p->
consistency_level
=
AS_POLICY_CONSISTENCY_LEVEL_DEFAULT
;
952
p->
deserialize
=
true
;
953
p->
linearize_read
=
false
;
954
return
p;
955
}
956
957
/**
958
* Copy as_policy_read values.
959
*
960
* @param src The source policy.
961
* @param trg The target policy.
962
*
963
* @relates as_policy_read
964
*/
965
static
inline
void
966
as_policy_read_copy
(
as_policy_read
* src,
as_policy_read
* trg)
967
{
968
*trg = *src;
969
}
970
971
/**
972
* Initialize as_policy_write to default values.
973
*
974
* @param p The policy to initialize.
975
* @return The initialized policy.
976
*
977
* @relates as_policy_write
978
*/
979
static
inline
as_policy_write
*
980
as_policy_write_init
(
as_policy_write
* p)
981
{
982
p->
base
.
socket_timeout
=
AS_POLICY_SOCKET_TIMEOUT_DEFAULT
;
983
p->
base
.
total_timeout
=
AS_POLICY_TOTAL_TIMEOUT_DEFAULT
;
984
p->
base
.
max_retries
=
AS_POLICY_MAX_RETRIES_DEFAULT
;
985
p->
base
.
sleep_between_retries
= 500;
986
p->
key
=
AS_POLICY_KEY_DEFAULT
;
987
p->
replica
=
AS_POLICY_REPLICA_DEFAULT
;
988
p->
commit_level
=
AS_POLICY_COMMIT_LEVEL_DEFAULT
;
989
p->
gen
=
AS_POLICY_GEN_DEFAULT
;
990
p->
exists
=
AS_POLICY_EXISTS_DEFAULT
;
991
p->
compression_threshold
=
AS_POLICY_COMPRESSION_THRESHOLD_DEFAULT
;
992
p->
durable_delete
=
false
;
993
return
p;
994
}
995
996
/**
997
* Copy as_policy_write values.
998
*
999
* @param src The source policy.
1000
* @param trg The target policy.
1001
*
1002
* @relates as_policy_write
1003
*/
1004
static
inline
void
1005
as_policy_write_copy
(
as_policy_write
* src,
as_policy_write
* trg)
1006
{
1007
*trg = *src;
1008
}
1009
1010
/**
1011
* Initialize as_policy_operate to default values.
1012
*
1013
* @param p The policy to initialize.
1014
* @return The initialized policy.
1015
*
1016
* @relates as_policy_operate
1017
*/
1018
static
inline
as_policy_operate
*
1019
as_policy_operate_init
(
as_policy_operate
* p)
1020
{
1021
p->
base
.
socket_timeout
=
AS_POLICY_SOCKET_TIMEOUT_DEFAULT
;
1022
p->
base
.
total_timeout
=
AS_POLICY_TOTAL_TIMEOUT_DEFAULT
;
1023
p->
base
.
max_retries
=
AS_POLICY_MAX_RETRIES_DEFAULT
;
1024
p->
base
.
sleep_between_retries
= 500;
1025
p->
key
=
AS_POLICY_KEY_DEFAULT
;
1026
p->
replica
=
AS_POLICY_REPLICA_DEFAULT
;
1027
p->
consistency_level
=
AS_POLICY_CONSISTENCY_LEVEL_DEFAULT
;
1028
p->
commit_level
=
AS_POLICY_COMMIT_LEVEL_DEFAULT
;
1029
p->
gen
=
AS_POLICY_GEN_DEFAULT
;
1030
p->
deserialize
=
true
;
1031
p->
durable_delete
=
false
;
1032
p->
linearize_read
=
false
;
1033
return
p;
1034
}
1035
1036
/**
1037
* Copy as_policy_operate values.
1038
*
1039
* @param src The source policy.
1040
* @param trg The target policy.
1041
*
1042
* @relates as_policy_operate
1043
*/
1044
static
inline
void
1045
as_policy_operate_copy
(
as_policy_operate
* src,
as_policy_operate
* trg)
1046
{
1047
*trg = *src;
1048
}
1049
1050
/**
1051
* Initialize as_policy_remove to default values.
1052
*
1053
* @param p The policy to initialize.
1054
* @return The initialized policy.
1055
*
1056
* @relates as_policy_remove
1057
*/
1058
static
inline
as_policy_remove
*
1059
as_policy_remove_init
(
as_policy_remove
* p)
1060
{
1061
p->
base
.
socket_timeout
=
AS_POLICY_SOCKET_TIMEOUT_DEFAULT
;
1062
p->
base
.
total_timeout
=
AS_POLICY_TOTAL_TIMEOUT_DEFAULT
;
1063
p->
base
.
max_retries
=
AS_POLICY_MAX_RETRIES_DEFAULT
;
1064
p->
base
.
sleep_between_retries
= 500;
1065
p->
key
=
AS_POLICY_KEY_DEFAULT
;
1066
p->
replica
=
AS_POLICY_REPLICA_DEFAULT
;
1067
p->
commit_level
=
AS_POLICY_COMMIT_LEVEL_DEFAULT
;
1068
p->
gen
=
AS_POLICY_GEN_DEFAULT
;
1069
p->
generation
= 0;
1070
p->
durable_delete
=
false
;
1071
return
p;
1072
}
1073
1074
/**
1075
* Copy as_policy_remove values.
1076
*
1077
* @param src The source policy.
1078
* @param trg The target policy.
1079
*
1080
* @relates as_policy_remove
1081
*/
1082
static
inline
void
1083
as_policy_remove_copy
(
as_policy_remove
* src,
as_policy_remove
* trg)
1084
{
1085
*trg = *src;
1086
}
1087
1088
/**
1089
* Initialize as_policy_apply to default values.
1090
*
1091
* @param p The policy to initialize.
1092
* @return The initialized policy.
1093
*
1094
* @relates as_policy_apply
1095
*/
1096
static
inline
as_policy_apply
*
1097
as_policy_apply_init
(
as_policy_apply
* p)
1098
{
1099
p->
base
.
socket_timeout
=
AS_POLICY_SOCKET_TIMEOUT_DEFAULT
;
1100
p->
base
.
total_timeout
=
AS_POLICY_TOTAL_TIMEOUT_DEFAULT
;
1101
p->
base
.
max_retries
=
AS_POLICY_MAX_RETRIES_DEFAULT
;
1102
p->
base
.
sleep_between_retries
= 500;
1103
p->
key
=
AS_POLICY_KEY_DEFAULT
;
1104
p->
replica
=
AS_POLICY_REPLICA_DEFAULT
;
1105
p->
commit_level
=
AS_POLICY_COMMIT_LEVEL_DEFAULT
;
1106
p->
ttl
= 0;
// AS_RECORD_DEFAULT_TTL
1107
p->
gen
=
AS_POLICY_GEN_DEFAULT
;
1108
p->
gen_value
= 0;
1109
p->
durable_delete
=
false
;
1110
p->
linearize_read
=
false
;
1111
return
p;
1112
}
1113
1114
/**
1115
* Copy as_policy_apply values.
1116
*
1117
* @param src The source policy.
1118
* @param trg The target policy.
1119
*
1120
* @relates as_policy_apply
1121
*/
1122
static
inline
void
1123
as_policy_apply_copy
(
as_policy_apply
* src,
as_policy_apply
* trg)
1124
{
1125
*trg = *src;
1126
}
1127
1128
/**
1129
* Initialize as_policy_batch to default values.
1130
*
1131
* @param p The policy to initialize.
1132
* @return The initialized policy.
1133
*
1134
* @relates as_policy_batch
1135
*/
1136
static
inline
as_policy_batch
*
1137
as_policy_batch_init
(
as_policy_batch
* p)
1138
{
1139
p->
base
.
socket_timeout
=
AS_POLICY_SOCKET_TIMEOUT_DEFAULT
;
1140
p->
base
.
total_timeout
=
AS_POLICY_TOTAL_TIMEOUT_DEFAULT
;
1141
p->
base
.
max_retries
=
AS_POLICY_MAX_RETRIES_DEFAULT
;
1142
p->
base
.
sleep_between_retries
=
AS_POLICY_SLEEP_BETWEEN_RETRIES_DEFAULT
;
1143
p->
consistency_level
=
AS_POLICY_CONSISTENCY_LEVEL_ONE
;
1144
p->
concurrent
=
false
;
1145
p->
use_batch_direct
=
false
;
1146
p->
allow_inline
=
true
;
1147
p->
send_set_name
=
false
;
1148
p->
deserialize
=
true
;
1149
p->
linearize_read
=
false
;
1150
return
p;
1151
}
1152
1153
/**
1154
* Copy as_policy_batch values.
1155
*
1156
* @param src The source policy.
1157
* @param trg The target policy.
1158
*
1159
* @relates as_policy_batch
1160
*/
1161
static
inline
void
1162
as_policy_batch_copy
(
as_policy_batch
* src,
as_policy_batch
* trg)
1163
{
1164
*trg = *src;
1165
}
1166
1167
/**
1168
* Initialize as_policy_scan to default values.
1169
*
1170
* @param p The policy to initialize.
1171
* @return The initialized policy.
1172
*
1173
* @relates as_policy_scan
1174
*/
1175
static
inline
as_policy_scan
*
1176
as_policy_scan_init
(
as_policy_scan
* p)
1177
{
1178
p->
base
.
socket_timeout
= 10000;
1179
p->
base
.
total_timeout
= 0;
1180
p->
base
.
max_retries
= 0;
1181
p->
base
.
sleep_between_retries
= 0;
1182
p->
fail_on_cluster_change
=
false
;
1183
p->
durable_delete
=
false
;
1184
return
p;
1185
}
1186
1187
/**
1188
* Copy as_policy_scan values.
1189
*
1190
* @param src The source policy.
1191
* @param trg The target policy.
1192
*
1193
* @relates as_policy_scan
1194
*/
1195
static
inline
void
1196
as_policy_scan_copy
(
as_policy_scan
* src,
as_policy_scan
* trg)
1197
{
1198
*trg = *src;
1199
}
1200
1201
/**
1202
* Initialize as_policy_query to default values.
1203
*
1204
* @param p The policy to initialize.
1205
* @return The initialized policy.
1206
*
1207
* @relates as_policy_query
1208
*/
1209
static
inline
as_policy_query
*
1210
as_policy_query_init
(
as_policy_query
* p)
1211
{
1212
p->
base
.
socket_timeout
= 10000;
1213
p->
base
.
total_timeout
= 0;
1214
p->
base
.
max_retries
= 0;
1215
p->
base
.
sleep_between_retries
= 0;
1216
p->
deserialize
=
true
;
1217
return
p;
1218
}
1219
1220
/**
1221
* Copy as_policy_query values.
1222
*
1223
* @param src The source policy.
1224
* @param trg The target policy.
1225
*
1226
* @relates as_policy_query
1227
*/
1228
static
inline
void
1229
as_policy_query_copy
(
as_policy_query
* src,
as_policy_query
* trg)
1230
{
1231
*trg = *src;
1232
}
1233
1234
/**
1235
* Initialize as_policy_info to default values.
1236
*
1237
* @param p The policy to initialize.
1238
* @return The initialized policy.
1239
*
1240
* @relates as_policy_info
1241
*/
1242
static
inline
as_policy_info
*
1243
as_policy_info_init
(
as_policy_info
* p)
1244
{
1245
p->
timeout
=
AS_POLICY_TOTAL_TIMEOUT_DEFAULT
;
1246
p->
send_as_is
=
true
;
1247
p->
check_bounds
=
true
;
1248
return
p;
1249
}
1250
1251
/**
1252
* Copy as_policy_info values.
1253
*
1254
* @param src The source policy.
1255
* @param trg The target policy.
1256
*
1257
* @relates as_policy_info
1258
*/
1259
static
inline
void
1260
as_policy_info_copy
(
as_policy_info
* src,
as_policy_info
* trg)
1261
{
1262
*trg = *src;
1263
}
1264
1265
/**
1266
* Initialize as_policy_admin to default values.
1267
*
1268
* @param p The policy to initialize.
1269
* @return The initialized policy.
1270
*
1271
* @relates as_policy_admin
1272
*/
1273
static
inline
as_policy_admin
*
1274
as_policy_admin_init
(
as_policy_admin
* p)
1275
{
1276
p->
timeout
=
AS_POLICY_TOTAL_TIMEOUT_DEFAULT
;
1277
return
p;
1278
}
1279
1280
/**
1281
* Copy as_policy_admin values.
1282
*
1283
* @param src The source policy.
1284
* @param trg The target policy.
1285
*
1286
* @relates as_policy_admin
1287
*/
1288
static
inline
void
1289
as_policy_admin_copy
(
as_policy_admin
* src,
as_policy_admin
* trg)
1290
{
1291
*trg = *src;
1292
}
1293
1294
/**
1295
* Initialize as_policies.
1296
*
1297
* @relates as_policies
1298
*/
1299
as_policies
*
1300
as_policies_init
(
as_policies
* p);
1301
1302
#ifdef __cplusplus
1303
}
// end extern "C"
1304
#endif