repl5_ruv.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. /** BEGIN COPYRIGHT BLOCK
  2. * Copyright (C) 2001 Sun Microsystems, Inc. Used by permission.
  3. * Copyright (C) 2005 Red Hat, Inc.
  4. * Copyright (C) 2010 Hewlett-Packard Development Company, L.P.
  5. * All rights reserved.
  6. *
  7. * License: GPL (version 3 or any later version).
  8. * See LICENSE for details.
  9. * END COPYRIGHT BLOCK **/
  10. #ifdef HAVE_CONFIG_H
  11. # include <config.h>
  12. #endif
  13. /* repl5_ruv.h - interface for replica update vector */
  14. #ifndef REPL5_RUV
  15. #define REPL5_RUV
  16. #include "slapi-private.h"
  17. #ifdef __cplusplus
  18. extern "C" {
  19. #endif
  20. typedef struct _ruv RUV;
  21. enum
  22. {
  23. RUV_SUCCESS=0,
  24. RUV_BAD_DATA,
  25. RUV_NOTFOUND,
  26. RUV_MEMORY_ERROR,
  27. RUV_NSPR_ERROR,
  28. RUV_BAD_FORMAT,
  29. RUV_UNKNOWN_ERROR,
  30. RUV_ALREADY_EXIST,
  31. RUV_CSNPL_ERROR,
  32. RUV_COVERS_CSN
  33. };
  34. /* return values from ruv_compare_ruv */
  35. enum
  36. {
  37. RUV_COMP_SUCCESS=0,
  38. RUV_COMP_NO_GENERATION, /* one or both of the RUVs is missing the replica generation */
  39. RUV_COMP_GENERATION_DIFFERS, /* the RUVs have different replica generations */
  40. /* one of the maxcsns in one of the RUVs is out of date with respect to the
  41. corresponding maxcsn in the corresponding replica in the other RUV */
  42. RUV_COMP_CSN_DIFFERS,
  43. RUV_COMP_RUV1_MISSING, /* ruv2 contains replicas not in ruv1 - CLEANRUV */
  44. RUV_COMP_RUV2_MISSING /* ruv1 contains replicas not in ruv2 */
  45. };
  46. /* used by ruv_replace_replica_purl_nolock */
  47. #define RUV_LOCK 1
  48. #define RUV_DONT_LOCK 0
  49. #define RUV_COMP_IS_FATAL(ruvcomp) (ruvcomp && (ruvcomp < RUV_COMP_RUV1_MISSING))
  50. typedef struct ruv_enum_data
  51. {
  52. CSN *csn;
  53. CSN *min_csn;
  54. } ruv_enum_data;
  55. typedef int (*FNEnumRUV) (const ruv_enum_data *element, void *arg);
  56. int ruv_init_new (const char *replGen, ReplicaId rid, const char *purl, RUV **ruv);
  57. int ruv_init_from_bervals(struct berval** vals, RUV **ruv);
  58. int ruv_init_from_slapi_attr(Slapi_Attr *attr, RUV **ruv);
  59. int ruv_init_from_slapi_attr_and_check_purl(Slapi_Attr *attr, RUV **ruv, ReplicaId *rid);
  60. RUV* ruv_dup (const RUV *ruv);
  61. void ruv_destroy (RUV **ruv);
  62. void ruv_copy_and_destroy (RUV **srcruv, RUV **destruv);
  63. int ruv_replace_replica_purl (RUV *ruv, ReplicaId rid, const char *replica_purl);
  64. int ruv_replace_replica_purl_nolock(RUV *ruv, ReplicaId rid, const char *replica_purl, int lock);
  65. int ruv_delete_replica (RUV *ruv, ReplicaId rid);
  66. int ruv_add_replica (RUV *ruv, ReplicaId rid, const char *replica_purl);
  67. int ruv_add_index_replica (RUV *ruv, ReplicaId rid, const char *replica_purl, int index);
  68. PRBool ruv_contains_replica (const RUV *ruv, ReplicaId rid);
  69. int ruv_get_largest_csn_for_replica(const RUV *ruv, ReplicaId rid, CSN **csn);
  70. int ruv_get_smallest_csn_for_replica(const RUV *ruv, ReplicaId rid, CSN **csn);
  71. int ruv_set_csns(RUV *ruv, const CSN *csn, const char *replica_purl);
  72. int ruv_set_csns_keep_smallest(RUV *ruv, const CSN *csn);
  73. int ruv_set_max_csn(RUV *ruv, const CSN *max_csn, const char *replica_purl);
  74. int ruv_set_max_csn_ext(RUV *ruv, const CSN *max_csn, const char *replica_purl, PRBool must_be_greater);
  75. int ruv_set_min_csn(RUV *ruv, const CSN *min_csn, const char *replica_purl);
  76. const char *ruv_get_purl_for_replica(const RUV *ruv, ReplicaId rid);
  77. char *ruv_get_replica_generation (const RUV *ruv);
  78. void ruv_set_replica_generation (RUV *ruv, const char *generation);
  79. PRBool ruv_covers_ruv(const RUV *covering_ruv, const RUV *covered_ruv);
  80. PRBool ruv_covers_csn(const RUV *ruv, const CSN *csn);
  81. PRBool ruv_covers_csn_strict(const RUV *ruv, const CSN *csn);
  82. PRBool ruv_covers_csn_cleanallruv(const RUV *ruv, const CSN *csn);
  83. int ruv_get_min_csn(const RUV *ruv, CSN **csn);
  84. int ruv_get_min_csn_ext(const RUV *ruv, CSN **csn, int ignore_cleaned_rid);
  85. int ruv_get_max_csn(const RUV *ruv, CSN **csn);
  86. int ruv_get_max_csn_ext(const RUV *ruv, CSN **csn, int ignore_cleaned_rid);
  87. int ruv_get_rid_max_csn(const RUV *ruv, CSN **csn, ReplicaId rid);
  88. int ruv_get_rid_max_csn_ext(const RUV *ruv, CSN **csn, ReplicaId rid, int ignore_cleaned_rid);
  89. int ruv_enumerate_elements (const RUV *ruv, FNEnumRUV fn, void *arg);
  90. Slapi_Value **ruv_last_modified_to_valuearray(RUV *ruv);
  91. Slapi_Value **ruv_to_valuearray(RUV *ruv);
  92. int ruv_to_smod(const RUV *ruv, Slapi_Mod *smod);
  93. int ruv_last_modified_to_smod(const RUV *ruv, Slapi_Mod *smod);
  94. int ruv_to_bervals(const RUV *ruv, struct berval ***bvals);
  95. PRInt32 ruv_replica_count (const RUV *ruv);
  96. char **ruv_get_referrals(const RUV *ruv);
  97. void ruv_dump(const RUV *ruv, char *ruv_name, PRFileDesc *prFile);
  98. int ruv_add_csn_inprogress (RUV *ruv, const CSN *csn);
  99. int ruv_cancel_csn_inprogress (RUV *ruv, const CSN *csn);
  100. int ruv_update_ruv (RUV *ruv, const CSN *csn, const char *replica_purl, PRBool isLocal);
  101. int ruv_move_local_supplier_to_first(RUV *ruv, ReplicaId rid);
  102. int ruv_get_first_id_and_purl(RUV *ruv, ReplicaId *rid, char **replica_purl );
  103. int ruv_local_contains_supplier(RUV *ruv, ReplicaId rid);
  104. /* returns true if the ruv has any csns, false otherwise - used for testing
  105. whether or not an RUV is empty */
  106. PRBool ruv_has_csns(const RUV *ruv);
  107. PRBool ruv_has_both_csns(const RUV *ruv);
  108. PRBool ruv_is_newer (Object *sruv, Object *cruv);
  109. void ruv_force_csn_update_from_ruv(RUV *src_ruv, RUV *tgt_ruv, char *msg, int logLevel);
  110. void ruv_force_csn_update (RUV *ruv, CSN *csn);
  111. void ruv_insert_dummy_min_csn (RUV *ruv);
  112. int ruv_compare_ruv(const RUV *ruv1, const char *ruv1name, const RUV *ruv2, const char *ruv2name, int strict, int loglevel);
  113. #ifdef __cplusplus
  114. }
  115. #endif
  116. #endif