saCkpt.h 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. /*
  2. * Copyright (c) 2002-2005 MontaVista Software, Inc.
  3. *
  4. * All rights reserved.
  5. *
  6. * Author: Steven Dake (sdake@mvista.com)
  7. *
  8. * This software licensed under BSD license, the text of which follows:
  9. *
  10. * Redistribution and use in source and binary forms, with or without
  11. * modification, are permitted provided that the following conditions are met:
  12. *
  13. * - Redistributions of source code must retain the above copyright notice,
  14. * this list of conditions and the following disclaimer.
  15. * - Redistributions in binary form must reproduce the above copyright notice,
  16. * this list of conditions and the following disclaimer in the documentation
  17. * and/or other materials provided with the distribution.
  18. * - Neither the name of the MontaVista Software, Inc. nor the names of its
  19. * contributors may be used to endorse or promote products derived from this
  20. * software without specific prior written permission.
  21. *
  22. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  23. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  24. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  25. * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  26. * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  27. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  28. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  29. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  30. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  31. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
  32. * THE POSSIBILITY OF SUCH DAMAGE.
  33. */
  34. #ifndef SACKPT_H_DEFINED
  35. #define SACKPT_H_DEFINED
  36. #ifdef __cplusplus
  37. extern "C" {
  38. #endif
  39. typedef SaUint64T SaCkptHandleT;
  40. typedef SaUint64T SaCkptCheckpointHandleT;
  41. typedef SaUint64T SaCkptSectionIterationHandleT;
  42. #define SA_CKPT_WR_ALL_REPLICAS 0x01
  43. #define SA_CKPT_WR_ACTIVE_REPLICA 0x2
  44. #define SA_CKPT_WR_ACTIVE_REPLICA_WEAK 0x4
  45. #define SA_CKPT_CHECKPOINT_COLLOCATED 0x8
  46. typedef SaUint32T SaCkptCheckpointCreationFlagsT;
  47. typedef struct {
  48. SaCkptCheckpointCreationFlagsT creationFlags;
  49. SaSizeT checkpointSize;
  50. SaTimeT retentionDuration;
  51. SaUint32T maxSections;
  52. SaSizeT maxSectionSize;
  53. SaSizeT maxSectionIdSize;
  54. } SaCkptCheckpointCreationAttributesT;
  55. #define SA_CKPT_CHECKPOINT_READ 0x1
  56. #define SA_CKPT_CHECKPOINT_WRITE 0x2
  57. #define SA_CKPT_CHECKPOINT_CREATE 0x4
  58. typedef SaUint32T SaCkptCheckpointOpenFlagsT;
  59. #define SA_CKPT_DEFAULT_SECTION_ID { 0, 0 }
  60. #define SA_CKPT_GENERATED_SECTION_ID { 0, 0 }
  61. typedef struct {
  62. SaUint16T idLen;
  63. SaUint8T *id;
  64. } SaCkptSectionIdT;
  65. typedef struct {
  66. SaCkptSectionIdT *sectionId;
  67. SaTimeT expirationTime;
  68. } SaCkptSectionCreationAttributesT;
  69. typedef enum {
  70. SA_CKPT_SECTION_VALID = 1,
  71. SA_CKPT_SECTION_CORRUPTED = 2
  72. } SaCkptSectionStateT;
  73. typedef struct {
  74. SaCkptSectionIdT sectionId;
  75. SaTimeT expirationTime;
  76. SaSizeT sectionSize;
  77. SaCkptSectionStateT sectionState;
  78. SaTimeT lastUpdate;
  79. } SaCkptSectionDescriptorT;
  80. typedef enum {
  81. SA_CKPT_SECTIONS_FOREVER = 1,
  82. SA_CKPT_SECTIONS_LEQ_EXPIRATION_TIME = 2,
  83. SA_CKPT_SECTIONS_GEQ_EXPIRATION_TIME = 3,
  84. SA_CKPT_SECTIONS_CORRUPTED = 4,
  85. SA_CKPT_SECTIONS_ANY = 5
  86. } SaCkptSectionsChosenT;
  87. typedef SaUint64T SaOffsetT;
  88. typedef struct {
  89. SaCkptSectionIdT sectionId;
  90. void *dataBuffer;
  91. SaSizeT dataSize;
  92. SaOffsetT dataOffset;
  93. SaSizeT readSize;
  94. } SaCkptIOVectorElementT;
  95. typedef struct {
  96. SaCkptCheckpointCreationAttributesT checkpointCreationAttributes;
  97. SaUint32T numberOfSections;
  98. SaUint32T memoryUsed;
  99. } SaCkptCheckpointDescriptorT;
  100. typedef void (*SaCkptCheckpointOpenCallbackT) (
  101. SaInvocationT invocation,
  102. const SaCkptCheckpointHandleT checkpointHandle,
  103. SaAisErrorT error);
  104. typedef void (*SaCkptCheckpointSynchronizeCallbackT) (
  105. SaInvocationT invocation,
  106. SaAisErrorT error);
  107. typedef struct {
  108. SaCkptCheckpointOpenCallbackT saCkptCheckpointOpenCallback;
  109. SaCkptCheckpointSynchronizeCallbackT saCkptCheckpointSynchronizeCallback;
  110. } SaCkptCallbacksT;
  111. SaAisErrorT
  112. saCkptInitialize (
  113. SaCkptHandleT *ckptHandle,
  114. const SaCkptCallbacksT *callbacks,
  115. SaVersionT *version);
  116. SaAisErrorT
  117. saCkptSelectionObjectGet (
  118. SaCkptHandleT ckptHandle,
  119. SaSelectionObjectT *selectionObject);
  120. SaAisErrorT
  121. saCkptDispatch (
  122. SaCkptHandleT ckptHandle,
  123. SaDispatchFlagsT dispatchFlags);
  124. SaAisErrorT
  125. saCkptFinalize (
  126. SaCkptHandleT ckptHandle);
  127. SaAisErrorT
  128. saCkptCheckpointOpen (
  129. SaCkptHandleT ckptHandle,
  130. const SaNameT *checkpointName,
  131. const SaCkptCheckpointCreationAttributesT *checkpointCreationAttributes,
  132. SaCkptCheckpointOpenFlagsT checkpointOpenFlags,
  133. SaTimeT timeout,
  134. SaCkptCheckpointHandleT *checkpointHandle);
  135. SaAisErrorT
  136. saCkptCheckpointOpenAsync (
  137. SaCkptHandleT ckptHandle,
  138. SaInvocationT invocation,
  139. const SaNameT *checkpointName,
  140. const SaCkptCheckpointCreationAttributesT *checkpointCreationAttributes,
  141. SaCkptCheckpointOpenFlagsT checkpointOpenFlags);
  142. SaAisErrorT
  143. saCkptCheckpointClose (
  144. SaCkptCheckpointHandleT checkpointHandle);
  145. SaAisErrorT
  146. saCkptCheckpointUnlink (
  147. SaCkptCheckpointHandleT checkpointHandle,
  148. const SaNameT *checkpointName);
  149. SaAisErrorT
  150. saCkptCheckpointRetentionDurationSet (
  151. SaCkptCheckpointHandleT checkpointHandle,
  152. SaTimeT retentionDuration);
  153. SaAisErrorT
  154. saCkptActiveReplicaSet (
  155. const SaCkptCheckpointHandleT checkpointHandle);
  156. SaAisErrorT
  157. saCkptCheckpointStatusGet (
  158. SaCkptCheckpointHandleT checkpointHandle,
  159. SaCkptCheckpointDescriptorT *checkpointStatus);
  160. SaAisErrorT
  161. saCkptSectionCreate (
  162. SaCkptCheckpointHandleT checkpointHandle,
  163. SaCkptSectionCreationAttributesT *sectionCreationAttributes,
  164. const void *initialData,
  165. SaUint32T initialDataSize);
  166. SaAisErrorT
  167. saCkptSectionDelete (
  168. SaCkptCheckpointHandleT checkpointHandle,
  169. const SaCkptSectionIdT *sectionId);
  170. SaAisErrorT
  171. saCkptSectionExpirationTimeSet (
  172. SaCkptCheckpointHandleT checkpointHandle,
  173. const SaCkptSectionIdT *sectionId,
  174. SaTimeT expirationTime);
  175. SaAisErrorT
  176. saCkptSectionIterationInitialize (
  177. const SaCkptCheckpointHandleT checkpointHandle,
  178. SaCkptSectionsChosenT sectionsChosen,
  179. SaTimeT expirationTime,
  180. SaCkptSectionIterationHandleT *sectionIterationHandle);
  181. SaAisErrorT
  182. saCkptSectionIterationNext (
  183. SaCkptSectionIterationHandleT sectionIterationHandle,
  184. SaCkptSectionDescriptorT *sectionDescriptor);
  185. SaAisErrorT
  186. saCkptSectionIterationFinalize (
  187. SaCkptSectionIterationHandleT sectionIterationHandle);
  188. SaAisErrorT
  189. saCkptCheckpointWrite (
  190. SaCkptCheckpointHandleT checkpointHandle,
  191. const SaCkptIOVectorElementT *ioVector,
  192. SaUint32T numberOfElements,
  193. SaUint32T *erroneousVectorIndex);
  194. SaAisErrorT
  195. saCkptSectionOverwrite (
  196. SaCkptCheckpointHandleT checkpointHandle,
  197. const SaCkptSectionIdT *secitonId,
  198. const void *dataBuffer,
  199. SaSizeT dataSize);
  200. SaAisErrorT
  201. saCkptCheckpointRead (
  202. SaCkptCheckpointHandleT checkpointHandle,
  203. SaCkptIOVectorElementT *ioVector,
  204. SaUint32T numberOfElements,
  205. SaUint32T *erroneousVectorIndex);
  206. SaAisErrorT
  207. saCkptCheckpointSynchronize (
  208. SaCkptCheckpointHandleT checkpointHandle,
  209. SaTimeT timeout);
  210. SaAisErrorT
  211. saCkptCheckpointSynchronizeAsync (
  212. SaCkptCheckpointHandleT checkpointHandle,
  213. SaInvocationT invocation);
  214. #ifdef __cplusplus
  215. }
  216. #endif
  217. #endif /* SACKPT_H_DEFINED */