zone_loader_inc.cc 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. // Copyright (C) 2012-2013 Internet Systems Consortium, Inc. ("ISC")
  2. //
  3. // Permission to use, copy, modify, and/or distribute this software for any
  4. // purpose with or without fee is hereby granted, provided that the above
  5. // copyright notice and this permission notice appear in all copies.
  6. //
  7. // THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
  8. // REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  9. // AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
  10. // INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  11. // LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
  12. // OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  13. // PERFORMANCE OF THIS SOFTWARE.
  14. namespace {
  15. const char* const ZoneLoader_doc = "\
  16. Class to load data into a data source client.\n\
  17. \n\
  18. This is a small wrapper class that is able to load data into a data\n\
  19. source. It can load either from another data source or from a master\n\
  20. file. The purpose of the class is only to hold the state for\n\
  21. incremental loading.\n\
  22. \n\
  23. The old content of zone is discarded and no journal is stored.\n\
  24. \n\
  25. ZoneLoader(destination, zone_name, master_file)\n\
  26. \n\
  27. Constructor from master file.\n\
  28. \n\
  29. This initializes the zone loader to load from a master file.\n\
  30. \n\
  31. Exceptions:\n\
  32. DataSourceError in case the zone does not exist in destination.\n\
  33. This class does not support creating brand new zones,\n\
  34. only loading data into them. In case a new zone is\n\
  35. needed, it must be created beforehand.\n\
  36. DataSourceError in case of other (possibly low-level) errors,\n\
  37. such as read-only data source or database error.\n\
  38. \n\
  39. Parameters:\n\
  40. destination (isc.datasrc.DataSourceClient) The data source into\n\
  41. which the loaded data should go.\n\
  42. zone_name (isc.dns.Name) The origin of the zone. The class is\n\
  43. implicit in the destination.\n\
  44. master_file (string) Path to the master file to read data from.\n\
  45. \n\
  46. ZoneLoader(destination, zone_name, source)\n\
  47. \n\
  48. Constructor from another data source.\n\
  49. \n\
  50. Parameters:\n\
  51. destination (isc.datasrc.DataSourceClient) The data source into\n\
  52. which the loaded data should go.\n\
  53. zone_name (isc.dns.Name) The origin of the zone. The class is\n\
  54. implicit in the destination.\n\
  55. source (isc.datasrc.DataSourceClient) The data source from\n\
  56. which the data would be read.\n\
  57. \n\
  58. Exceptions:\n\
  59. InvalidParameter in case the class of destination and source\n\
  60. differs.\n\
  61. NotImplemented in case the source data source client doesn't\n\
  62. provide an iterator.\n\
  63. DataSourceError in case the zone does not exist in destination.\n\
  64. This class does not support creating brand new zones,\n\
  65. only loading data into them. In case a new zone is\n\
  66. needed, it must be created beforehand.\n\
  67. DataSourceError in case the zone does not exist in the source.\n\
  68. DataSourceError in case of other (possibly low-level) errors,\n\
  69. such as read-only data source or database error.\n\
  70. \n\
  71. Parameters:\n\
  72. destination The data source into which the loaded data should\n\
  73. go.\n\
  74. zone_name The origin of the zone.\n\
  75. source The data source from which the data would be read.\n\
  76. \n\
  77. ";
  78. const char* const ZoneLoader_load_doc = "\
  79. load() -> None\n\
  80. \n\
  81. Perform the whole load.\n\
  82. \n\
  83. This performs the whole loading operation. It may take a long time.\n\
  84. \n\
  85. Exceptions:\n\
  86. InvalidOperation in case the loading was already completed before\n\
  87. this call.\n\
  88. DataSourceError in case some error (possibly low-level) happens.\n\
  89. MasterFileError when the master_file is badly formatted or some\n\
  90. similar problem is found when loading the master file.\n\
  91. \n\
  92. ";
  93. const char* const ZoneLoader_loadIncremental_doc = "\
  94. load_incremental(limit) -> bool\n\
  95. \n\
  96. Load up to limit RRs.\n\
  97. \n\
  98. This performs a part of the loading. In case there's enough data in\n\
  99. the source, it copies limit RRs. It can copy less RRs during the final\n\
  100. call (when there's less than limit left).\n\
  101. \n\
  102. This can be called repeatedly until the whole zone is loaded, having\n\
  103. pauses in the loading for some purposes (for example reporting\n\
  104. progress).\n\
  105. \n\
  106. Exceptions:\n\
  107. InvalidOperation in case the loading was already completed before\n\
  108. this call (by load() or by a load_incremental that\n\
  109. returned true).\n\
  110. DataSourceError in case some error (possibly low-level) happens.\n\
  111. MasterFileError when the master_file is badly formatted or some\n\
  112. similar problem is found when loading the master file.\n\
  113. \n\
  114. Parameters:\n\
  115. limit (integer) The maximum allowed number of RRs to be\n\
  116. loaded during this call.\n\
  117. \n\
  118. Return Value(s): True in case the loading is completed, false if\n\
  119. there's more to load.\n\
  120. \n\
  121. Note that if the limit is exactly the number of RRs available to be\n\
  122. loaded, the method will still return False, and True will be returned\n\
  123. on the next call (which will load 0 RRs). This is because the end of\n\
  124. iterator or master file is detected when reading past the end, not\n\
  125. when the last one is read.\n\
  126. ";
  127. const char* const ZoneLoader_getRRCount_doc = "\
  128. get_rr_count() -> integer\n\
  129. \n\
  130. Return the number of RRs loaded.\n\
  131. \n\
  132. This method returns the number of RRs loaded via this loader by the\n\
  133. time of the call. Before starting the load it will return 0. It will\n\
  134. return the total number of RRs of the zone on and after completing the\n\
  135. load.\n\
  136. \n\
  137. Exceptions:\n\
  138. None\n\
  139. \n\
  140. ";
  141. // Modifications
  142. // - double => float
  143. const char* const ZoneLoader_getProgress_doc = "\
  144. get_progress() -> float\n\
  145. \n\
  146. Return the current progress of the loader.\n\
  147. \n\
  148. This method returns the current estimated progress of loader as a\n\
  149. value between 0 and 1 (inclusive); it's 0 before starting the load,\n\
  150. and 1 at the completion, and a value between these (exclusive) in the\n\
  151. middle of loading. It's an implementation detail how to calculate the\n\
  152. progress, which may vary depending on how the loader is constructed\n\
  153. and may even be impossible to detect effectively.\n\
  154. \n\
  155. If the progress cannot be determined, this method returns a special\n\
  156. value of PROGRESS_UNKNOWN, which is not included in the range between\n\
  157. 0 and 1.\n\
  158. \n\
  159. As such, the application should use the return value only for\n\
  160. informational purposes such as logging. For example, it shouldn't be\n\
  161. used to determine whether loading is completed by comparing it to 1.\n\
  162. It should also expect the possibility of getting PROGRESS_UNKNOWN at\n\
  163. any call to this method; it shouldn't assume the specific way of\n\
  164. internal implementation as described below (which is provided for\n\
  165. informational purposes only).\n\
  166. \n\
  167. In this implementation, if the loader is constructed with a file name,\n\
  168. the progress value is measured by the number of characters read from\n\
  169. the zone file divided by the size of the zone file (with taking into\n\
  170. account any included files). Note that due to the possibility of\n\
  171. intermediate included files, the total file size cannot be fully fixed\n\
  172. until the completion of the load. And, due to this possibility, return\n\
  173. values from this method may not always increase monotonically.\n\
  174. \n\
  175. If it's constructed with another data source client, this method\n\
  176. always returns PROGRESS_UNKNOWN; in future, however, it may become\n\
  177. possible to return something more useful, e.g, based on the result of\n\
  178. get_rr_count() and the total number of RRs if the underlying data\n\
  179. source can provide the latter value efficiently.\n\
  180. \n\
  181. Exceptions:\n\
  182. None\n\
  183. \n\
  184. ";
  185. } // unnamed namespace