repl5_ruv.h 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. /** BEGIN COPYRIGHT BLOCK
  2. * This Program is free software; you can redistribute it and/or modify it under
  3. * the terms of the GNU General Public License as published by the Free Software
  4. * Foundation; version 2 of the License.
  5. *
  6. * This Program is distributed in the hope that it will be useful, but WITHOUT
  7. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  8. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  9. *
  10. * You should have received a copy of the GNU General Public License along with
  11. * this Program; if not, write to the Free Software Foundation, Inc., 59 Temple
  12. * Place, Suite 330, Boston, MA 02111-1307 USA.
  13. *
  14. * In addition, as a special exception, Red Hat, Inc. gives You the additional
  15. * right to link the code of this Program with code not covered under the GNU
  16. * General Public License ("Non-GPL Code") and to distribute linked combinations
  17. * including the two, subject to the limitations in this paragraph. Non-GPL Code
  18. * permitted under this exception must only link to the code of this Program
  19. * through those well defined interfaces identified in the file named EXCEPTION
  20. * found in the source code files (the "Approved Interfaces"). The files of
  21. * Non-GPL Code may instantiate templates or use macros or inline functions from
  22. * the Approved Interfaces without causing the resulting work to be covered by
  23. * the GNU General Public License. Only Red Hat, Inc. may make changes or
  24. * additions to the list of Approved Interfaces. You must obey the GNU General
  25. * Public License in all respects for all of the Program code and other code used
  26. * in conjunction with the Program except the Non-GPL Code covered by this
  27. * exception. If you modify this file, you may extend this exception to your
  28. * version of the file, but you are not obligated to do so. If you do not wish to
  29. * provide this exception without modification, you must delete this exception
  30. * statement from your version and license this file solely under the GPL without
  31. * exception.
  32. *
  33. *
  34. * Copyright (C) 2001 Sun Microsystems, Inc. Used by permission.
  35. * Copyright (C) 2005 Red Hat, Inc.
  36. * Copyright (C) 2010 Hewlett-Packard Development Company, L.P.
  37. * All rights reserved.
  38. * END COPYRIGHT BLOCK **/
  39. #ifdef HAVE_CONFIG_H
  40. # include <config.h>
  41. #endif
  42. /* repl5_ruv.h - interface for replica update vector */
  43. #ifndef REPL5_RUV
  44. #define REPL5_RUV
  45. #include "slapi-private.h"
  46. #ifdef __cplusplus
  47. extern "C" {
  48. #endif
  49. typedef struct _ruv RUV;
  50. enum
  51. {
  52. RUV_SUCCESS=0,
  53. RUV_BAD_DATA,
  54. RUV_NOTFOUND,
  55. RUV_MEMORY_ERROR,
  56. RUV_NSPR_ERROR,
  57. RUV_BAD_FORMAT,
  58. RUV_UNKNOWN_ERROR,
  59. RUV_ALREADY_EXIST,
  60. RUV_CSNPL_ERROR,
  61. RUV_COVERS_CSN
  62. };
  63. /* return values from ruv_compare_ruv */
  64. enum
  65. {
  66. RUV_COMP_SUCCESS=0,
  67. RUV_COMP_NO_GENERATION, /* one or both of the RUVs is missing the replica generation */
  68. RUV_COMP_GENERATION_DIFFERS, /* the RUVs have different replica generations */
  69. /* one of the maxcsns in one of the RUVs is out of date with respect to the
  70. corresponding maxcsn in the corresponding replica in the other RUV */
  71. RUV_COMP_CSN_DIFFERS,
  72. RUV_COMP_RUV1_MISSING, /* ruv2 contains replicas not in ruv1 - CLEANRUV */
  73. RUV_COMP_RUV2_MISSING /* ruv1 contains replicas not in ruv2 */
  74. };
  75. /* used by ruv_replace_replica_purl_nolock */
  76. #define RUV_LOCK 1
  77. #define RUV_DONT_LOCK 0
  78. #define RUV_COMP_IS_FATAL(ruvcomp) (ruvcomp && (ruvcomp < RUV_COMP_RUV1_MISSING))
  79. typedef struct ruv_enum_data
  80. {
  81. CSN *csn;
  82. CSN *min_csn;
  83. } ruv_enum_data;
  84. typedef int (*FNEnumRUV) (const ruv_enum_data *element, void *arg);
  85. int ruv_init_new (const char *replGen, ReplicaId rid, const char *purl, RUV **ruv);
  86. int ruv_init_from_bervals(struct berval** vals, RUV **ruv);
  87. int ruv_init_from_slapi_attr(Slapi_Attr *attr, RUV **ruv);
  88. int ruv_init_from_slapi_attr_and_check_purl(Slapi_Attr *attr, RUV **ruv, ReplicaId *rid);
  89. RUV* ruv_dup (const RUV *ruv);
  90. void ruv_destroy (RUV **ruv);
  91. void ruv_copy_and_destroy (RUV **srcruv, RUV **destruv);
  92. int ruv_replace_replica_purl (RUV *ruv, ReplicaId rid, const char *replica_purl);
  93. int ruv_replace_replica_purl_nolock(RUV *ruv, ReplicaId rid, const char *replica_purl, int lock);
  94. int ruv_delete_replica (RUV *ruv, ReplicaId rid);
  95. int ruv_add_replica (RUV *ruv, ReplicaId rid, const char *replica_purl);
  96. int ruv_add_index_replica (RUV *ruv, ReplicaId rid, const char *replica_purl, int index);
  97. PRBool ruv_contains_replica (const RUV *ruv, ReplicaId rid);
  98. int ruv_get_largest_csn_for_replica(const RUV *ruv, ReplicaId rid, CSN **csn);
  99. int ruv_get_smallest_csn_for_replica(const RUV *ruv, ReplicaId rid, CSN **csn);
  100. int ruv_set_csns(RUV *ruv, const CSN *csn, const char *replica_purl);
  101. int ruv_set_csns_keep_smallest(RUV *ruv, const CSN *csn);
  102. int ruv_set_max_csn(RUV *ruv, const CSN *max_csn, const char *replica_purl);
  103. int ruv_set_max_csn_ext(RUV *ruv, const CSN *max_csn, const char *replica_purl, PRBool must_be_greater);
  104. int ruv_set_min_csn(RUV *ruv, const CSN *min_csn, const char *replica_purl);
  105. const char *ruv_get_purl_for_replica(const RUV *ruv, ReplicaId rid);
  106. char *ruv_get_replica_generation (const RUV *ruv);
  107. void ruv_set_replica_generation (RUV *ruv, const char *generation);
  108. PRBool ruv_covers_ruv(const RUV *covering_ruv, const RUV *covered_ruv);
  109. PRBool ruv_covers_csn(const RUV *ruv, const CSN *csn);
  110. PRBool ruv_covers_csn_strict(const RUV *ruv, const CSN *csn);
  111. PRBool ruv_covers_csn_cleanallruv(const RUV *ruv, const CSN *csn);
  112. int ruv_get_min_csn(const RUV *ruv, CSN **csn);
  113. int ruv_get_max_csn(const RUV *ruv, CSN **csn);
  114. int ruv_get_rid_max_csn(const RUV *ruv, CSN **csn, ReplicaId rid);
  115. int ruv_enumerate_elements (const RUV *ruv, FNEnumRUV fn, void *arg);
  116. Slapi_Value **ruv_last_modified_to_valuearray(RUV *ruv);
  117. Slapi_Value **ruv_to_valuearray(RUV *ruv);
  118. int ruv_to_smod(const RUV *ruv, Slapi_Mod *smod);
  119. int ruv_last_modified_to_smod(const RUV *ruv, Slapi_Mod *smod);
  120. int ruv_to_bervals(const RUV *ruv, struct berval ***bvals);
  121. PRInt32 ruv_replica_count (const RUV *ruv);
  122. char **ruv_get_referrals(const RUV *ruv);
  123. void ruv_dump(const RUV *ruv, char *ruv_name, PRFileDesc *prFile);
  124. int ruv_add_csn_inprogress (RUV *ruv, const CSN *csn);
  125. int ruv_cancel_csn_inprogress (RUV *ruv, const CSN *csn);
  126. int ruv_update_ruv (RUV *ruv, const CSN *csn, const char *replica_purl, PRBool isLocal);
  127. int ruv_move_local_supplier_to_first(RUV *ruv, ReplicaId rid);
  128. int ruv_get_first_id_and_purl(RUV *ruv, ReplicaId *rid, char **replica_purl );
  129. int ruv_local_contains_supplier(RUV *ruv, ReplicaId rid);
  130. /* returns true if the ruv has any csns, false otherwise - used for testing
  131. whether or not an RUV is empty */
  132. PRBool ruv_has_csns(const RUV *ruv);
  133. PRBool ruv_has_both_csns(const RUV *ruv);
  134. PRBool ruv_is_newer (Object *sruv, Object *cruv);
  135. void ruv_force_csn_update_from_ruv(RUV *src_ruv, RUV *tgt_ruv, char *msg, int logLevel);
  136. void ruv_force_csn_update (RUV *ruv, CSN *csn);
  137. void ruv_insert_dummy_min_csn (RUV *ruv);
  138. int ruv_compare_ruv(const RUV *ruv1, const char *ruv1name, const RUV *ruv2, const char *ruv2name, int strict, int loglevel);
  139. #ifdef __cplusplus
  140. }
  141. #endif
  142. #endif