hdfs_http_query.h 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. /**
  2. * Licensed to the Apache Software Foundation (ASF) under one
  3. * or more contributor license agreements. See the NOTICE file
  4. * distributed with this work for additional information
  5. * regarding copyright ownership. The ASF licenses this file
  6. * to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. #ifndef _HDFS_HTTP_QUERY_H_
  19. #define _HDFS_HTTP_QUERY_H_
  20. #include <unistd.h> /* for size_t */
  21. #include <inttypes.h> /* for int16_t */
  22. /**
  23. * Create the URL for a MKDIR request
  24. *
  25. * @param host The hostname of the NameNode
  26. * @param nnPort Port of the NameNode
  27. * @param path Path of the dir to create
  28. * @param user User name
  29. * @param url Holding the generated URL for MKDIR request
  30. * @return 0 on success and non-zero value on errors
  31. */
  32. int createUrlForMKDIR(const char *host, int nnPort,
  33. const char *path, const char *user,
  34. char **url) __attribute__ ((warn_unused_result));
  35. /**
  36. * Create the URL for a MKDIR (with mode) request
  37. *
  38. * @param host The hostname of the NameNode
  39. * @param nnPort Port of the NameNode
  40. * @param path Path of the dir to create
  41. * @param mode Mode of MKDIR
  42. * @param user User name
  43. * @param url Holding the generated URL for MKDIR request
  44. * @return 0 on success and non-zero value on errors
  45. */
  46. int createUrlForMKDIRwithMode(const char *host, int nnPort, const char *path,
  47. int mode, const char *user,
  48. char **url) __attribute__ ((warn_unused_result));
  49. /**
  50. * Create the URL for a RENAME request
  51. *
  52. * @param host The hostname of the NameNode
  53. * @param nnPort Port of the NameNode
  54. * @param srcpath Source path
  55. * @param dstpath Destination path
  56. * @param user User name
  57. * @param url Holding the generated URL for RENAME request
  58. * @return 0 on success and non-zero value on errors
  59. */
  60. int createUrlForRENAME(const char *host, int nnPort, const char *srcpath,
  61. const char *dstpath, const char *user,
  62. char **url) __attribute__ ((warn_unused_result));
  63. /**
  64. * Create the URL for a CHMOD request
  65. *
  66. * @param host The hostname of the NameNode
  67. * @param nnPort Port of the NameNode
  68. * @param path Target path
  69. * @param mode New mode for the file
  70. * @param user User name
  71. * @param url Holding the generated URL for CHMOD request
  72. * @return 0 on success and non-zero value on errors
  73. */
  74. int createUrlForCHMOD(const char *host, int nnPort, const char *path,
  75. int mode, const char *user,
  76. char **url) __attribute__ ((warn_unused_result));
  77. /**
  78. * Create the URL for a GETFILESTATUS request
  79. *
  80. * @param host The hostname of the NameNode
  81. * @param nnPort Port of the NameNode
  82. * @param path Path of the target file
  83. * @param user User name
  84. * @param url Holding the generated URL for GETFILESTATUS request
  85. * @return 0 on success and non-zero value on errors
  86. */
  87. int createUrlForGetFileStatus(const char *host, int nnPort,
  88. const char *path, const char *user,
  89. char **url) __attribute__ ((warn_unused_result));
  90. /**
  91. * Create the URL for a LISTSTATUS request
  92. *
  93. * @param host The hostname of the NameNode
  94. * @param nnPort Port of the NameNode
  95. * @param path Path of the directory for listing
  96. * @param user User name
  97. * @param url Holding the generated URL for LISTSTATUS request
  98. * @return 0 on success and non-zero value on errors
  99. */
  100. int createUrlForLS(const char *host, int nnPort,
  101. const char *path, const char *user,
  102. char **url) __attribute__ ((warn_unused_result));
  103. /**
  104. * Create the URL for a DELETE request
  105. *
  106. * @param host The hostname of the NameNode
  107. * @param nnPort Port of the NameNode
  108. * @param path Path of the file to be deletected
  109. * @param recursive Whether or not to delete in a recursive way
  110. * @param user User name
  111. * @param url Holding the generated URL for DELETE request
  112. * @return 0 on success and non-zero value on errors
  113. */
  114. int createUrlForDELETE(const char *host, int nnPort, const char *path,
  115. int recursive, const char *user,
  116. char **url) __attribute__ ((warn_unused_result));
  117. /**
  118. * Create the URL for a CHOWN request
  119. *
  120. * @param host The hostname of the NameNode
  121. * @param nnPort Port of the NameNode
  122. * @param path Path of the target
  123. * @param owner New owner
  124. * @param group New group
  125. * @param user User name
  126. * @param url Holding the generated URL for CHOWN request
  127. * @return 0 on success and non-zero value on errors
  128. */
  129. int createUrlForCHOWN(const char *host, int nnPort, const char *path,
  130. const char *owner, const char *group, const char *user,
  131. char **url) __attribute__ ((warn_unused_result));
  132. /**
  133. * Create the URL for a OPEN/READ request
  134. *
  135. * @param host The hostname of the NameNode
  136. * @param nnPort Port of the NameNode
  137. * @param path Path of the file to read
  138. * @param user User name
  139. * @param offset Offset for reading (the start position for this read)
  140. * @param length Length of the file to read
  141. * @param url Holding the generated URL for OPEN/READ request
  142. * @return 0 on success and non-zero value on errors
  143. */
  144. int createUrlForOPEN(const char *host, int nnPort, const char *path,
  145. const char *user, size_t offset, size_t length,
  146. char **url) __attribute__ ((warn_unused_result));
  147. /**
  148. * Create the URL for a UTIMES (update time) request
  149. *
  150. * @param host The hostname of the NameNode
  151. * @param nnPort Port of the NameNode
  152. * @param path Path of the file for updating time
  153. * @param mTime Modified time to set
  154. * @param aTime Access time to set
  155. * @param user User name
  156. * @param url Holding the generated URL for UTIMES request
  157. * @return 0 on success and non-zero value on errors
  158. */
  159. int createUrlForUTIMES(const char *host, int nnPort, const char *path,
  160. long unsigned mTime, long unsigned aTime,
  161. const char *user,
  162. char **url) __attribute__ ((warn_unused_result));
  163. /**
  164. * Create the URL for a WRITE/CREATE request (sent to NameNode)
  165. *
  166. * @param host The hostname of the NameNode
  167. * @param nnPort Port of the NameNode
  168. * @param path Path of the dir to create
  169. * @param user User name
  170. * @param replication Number of replication of the file
  171. * @param blockSize Size of the block for the file
  172. * @param url Holding the generated URL for WRITE request
  173. * @return 0 on success and non-zero value on errors
  174. */
  175. int createUrlForNnWRITE(const char *host, int nnPort, const char *path,
  176. const char *user, int16_t replication, size_t blockSize,
  177. char **url) __attribute__ ((warn_unused_result));
  178. /**
  179. * Create the URL for an APPEND request (sent to NameNode)
  180. *
  181. * @param host The hostname of the NameNode
  182. * @param nnPort Port of the NameNode
  183. * @param path Path of the file for appending
  184. * @param user User name
  185. * @param url Holding the generated URL for APPEND request
  186. * @return 0 on success and non-zero value on errors
  187. */
  188. int createUrlForNnAPPEND(const char *host, int nnPort,
  189. const char *path, const char *user,
  190. char **url) __attribute__ ((warn_unused_result));
  191. /**
  192. * Create the URL for a SETREPLICATION request
  193. *
  194. * @param host The hostname of the NameNode
  195. * @param nnPort Port of the NameNode
  196. * @param path Path of the target file
  197. * @param replication New replication number
  198. * @param user User name
  199. * @param url Holding the generated URL for SETREPLICATION request
  200. * @return 0 on success and non-zero value on errors
  201. */
  202. int createUrlForSETREPLICATION(const char *host, int nnPort, const char *path,
  203. int16_t replication, const char *user,
  204. char **url) __attribute__ ((warn_unused_result));
  205. /**
  206. * Create the URL for a GET_BLOCK_LOCATIONS request
  207. *
  208. * @param host The hostname of the NameNode
  209. * @param nnPort Port of the NameNode
  210. * @param path Path of the target file
  211. * @param offset The offset in the file
  212. * @param length Length of the file content
  213. * @param user User name
  214. * @param url Holding the generated URL for GET_BLOCK_LOCATIONS request
  215. * @return 0 on success and non-zero value on errors
  216. */
  217. int createUrlForGetBlockLocations(const char *host, int nnPort,
  218. const char *path, size_t offset,
  219. size_t length, const char *user,
  220. char **url) __attribute__ ((warn_unused_result));
  221. #endif //_HDFS_HTTP_QUERY_H_