You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

292 lines
7.4 KiB

11 years ago
  1. API
  2. ===================================
  3. Master server
  4. ###################################
  5. You can append to any HTTP API with &pretty=y to see a formatted json output.
  6. Assign a file key
  7. ***********************************
  8. .. code-block:: bash
  9. # Basic Usage:
  10. curl http://localhost:9333/dir/assign
  11. {"count":1,"fid":"3,01637037d6","url":"127.0.0.1:8080",
  12. "publicUrl":"localhost:8080"}
  13. # To assign with a specific replication type:
  14. curl "http://localhost:9333/dir/assign?replication=001"
  15. # To specify how many file ids to reserve
  16. curl "http://localhost:9333/dir/assign?count=5"
  17. # To assign a specific data center
  18. curl "http://localhost:9333/dir/assign?dataCenter=dc1"
  19. Lookup volume
  20. ***********************************
  21. We would need to find out whether the volumes have moved.
  22. .. code-block:: bash
  23. curl "http://localhost:9333/dir/lookup?volumeId=3&pretty=y"
  24. {
  25. "locations": [
  26. {
  27. "publicUrl": "localhost:8080",
  28. "url": "localhost:8080"
  29. }
  30. ]
  31. }
  32. # Other usages:
  33. # You can actually use the file id to lookup
  34. curl "http://localhost:9333/dir/lookup?volumeId=3,01637037d6"
  35. # If you know the collection, specify it since it will be a little faster
  36. curl "http://localhost:9333/dir/lookup?volumeId=3&collection=turbo"
  37. Force garbage collection
  38. ***********************************
  39. If your system has many deletions, the deleted file's disk space will not be synchronously re-claimed. There is a background job to check volume disk usage. If empty space is more than the threshold, default to 0.3, the vacuum job will make the volume readonly, create a new volume with only existing files, and switch on the new volume. If you are impatient or doing some testing, vacuum the unused spaces this way.
  40. .. code-block:: bash
  41. curl "http://localhost:9333/vol/vacuum"
  42. curl "http://localhost:9333/vol/vacuum?garbageThreshold=0.4"
  43. The garbageThreshold=0.4 is optional, and will not change the default threshold. You can start volume master with a different default garbageThreshold.
  44. Pre-Allocate Volumes
  45. ***********************************
  46. One volume servers one write a time. If you need to increase concurrency, you can pre-allocate lots of volumes.
  47. .. code-block:: bash
  48. curl "http://localhost:9333/vol/grow?replication=000&count=4"
  49. {"count":4}
  50. # specify a collection
  51. curl "http://localhost:9333/vol/grow?collection=turbo&count=4"
  52. # specify data center
  53. curl "http://localhost:9333/vol/grow?dataCenter=dc1&count=4"
  54. This generates 4 empty volumes.
  55. Check System Status
  56. ***********************************
  57. .. code-block:: bash
  58. curl "http://10.0.2.15:9333/cluster/status?pretty=y"
  59. {
  60. "IsLeader": true,
  61. "Leader": "10.0.2.15:9333",
  62. "Peers": [
  63. "10.0.2.15:9334",
  64. "10.0.2.15:9335"
  65. ]
  66. }
  67. curl "http://localhost:9333/dir/status?pretty=y"
  68. {
  69. "Topology": {
  70. "DataCenters": [
  71. {
  72. "Free": 3,
  73. "Id": "dc1",
  74. "Max": 7,
  75. "Racks": [
  76. {
  77. "DataNodes": [
  78. {
  79. "Free": 3,
  80. "Max": 7,
  81. "PublicUrl": "localhost:8080",
  82. "Url": "localhost:8080",
  83. "Volumes": 4
  84. }
  85. ],
  86. "Free": 3,
  87. "Id": "DefaultRack",
  88. "Max": 7
  89. }
  90. ]
  91. },
  92. {
  93. "Free": 21,
  94. "Id": "dc3",
  95. "Max": 21,
  96. "Racks": [
  97. {
  98. "DataNodes": [
  99. {
  100. "Free": 7,
  101. "Max": 7,
  102. "PublicUrl": "localhost:8081",
  103. "Url": "localhost:8081",
  104. "Volumes": 0
  105. }
  106. ],
  107. "Free": 7,
  108. "Id": "rack1",
  109. "Max": 7
  110. },
  111. {
  112. "DataNodes": [
  113. {
  114. "Free": 7,
  115. "Max": 7,
  116. "PublicUrl": "localhost:8082",
  117. "Url": "localhost:8082",
  118. "Volumes": 0
  119. },
  120. {
  121. "Free": 7,
  122. "Max": 7,
  123. "PublicUrl": "localhost:8083",
  124. "Url": "localhost:8083",
  125. "Volumes": 0
  126. }
  127. ],
  128. "Free": 14,
  129. "Id": "DefaultRack",
  130. "Max": 14
  131. }
  132. ]
  133. }
  134. ],
  135. "Free": 24,
  136. "Max": 28,
  137. "layouts": [
  138. {
  139. "collection": "",
  140. "replication": "000",
  141. "writables": [
  142. 1,
  143. 2,
  144. 3,
  145. 4
  146. ]
  147. }
  148. ]
  149. },
  150. "Version": "0.47"
  151. }
  152. Volume Server
  153. ###################################
  154. Upload File
  155. ***********************************
  156. .. code-block:: bash
  157. curl -F file=@/home/chris/myphoto.jpg http://127.0.0.1:8080/3,01637037d6
  158. {"size": 43234}
  159. The size returned is the size stored on Seaweed-FS, sometimes the file is automatically gzipped based on the mime type.
  160. Upload File Directly
  161. ***********************************
  162. .. code-block:: bash
  163. curl -F file=@/home/chris/myphoto.jpg http://localhost:9333/submit
  164. {"fid":"3,01fbe0dc6f1f38","fileName":"myphoto.jpg","fileUrl":"localhost:8080/3,01fbe0dc6f1f38","size":68231}
  165. This API is just for convenience. The master server would get an file id and store the file to the right volume server.
  166. It is a convenient API and does not support different parameters when assigning file id. (or you can add the support and send a push request.)
  167. Delete File
  168. ***********************************
  169. .. code-block:: bash
  170. curl -X DELETE http://127.0.0.1:8080/3,01637037d6
  171. Create а specific volume on a specific volume server
  172. *****************************************************
  173. .. code-block:: bash
  174. curl "http://localhost:8080/admin/assign_volume?replication=000&volume=3"
  175. This generates volume 3 on this volume server.
  176. If you use other replicationType, e.g. 001, you would need to do the same on other volume servers to create the mirroring volumes.
  177. Check Volume Server Status
  178. ***********************************
  179. .. code-block:: bash
  180. curl "http://localhost:8080/status?pretty=y"
  181. {
  182. "Version": "0.34",
  183. "Volumes": [
  184. {
  185. "Id": 1,
  186. "Size": 1319688,
  187. "RepType": "000",
  188. "Version": 2,
  189. "FileCount": 276,
  190. "DeleteCount": 0,
  191. "DeletedByteCount": 0,
  192. "ReadOnly": false
  193. },
  194. {
  195. "Id": 2,
  196. "Size": 1040962,
  197. "RepType": "000",
  198. "Version": 2,
  199. "FileCount": 291,
  200. "DeleteCount": 0,
  201. "DeletedByteCount": 0,
  202. "ReadOnly": false
  203. },
  204. {
  205. "Id": 3,
  206. "Size": 1486334,
  207. "RepType": "000",
  208. "Version": 2,
  209. "FileCount": 301,
  210. "DeleteCount": 2,
  211. "DeletedByteCount": 0,
  212. "ReadOnly": false
  213. },
  214. {
  215. "Id": 4,
  216. "Size": 8953592,
  217. "RepType": "000",
  218. "Version": 2,
  219. "FileCount": 320,
  220. "DeleteCount": 2,
  221. "DeletedByteCount": 0,
  222. "ReadOnly": false
  223. },
  224. {
  225. "Id": 5,
  226. "Size": 70815851,
  227. "RepType": "000",
  228. "Version": 2,
  229. "FileCount": 309,
  230. "DeleteCount": 1,
  231. "DeletedByteCount": 0,
  232. "ReadOnly": false
  233. },
  234. {
  235. "Id": 6,
  236. "Size": 1483131,
  237. "RepType": "000",
  238. "Version": 2,
  239. "FileCount": 301,
  240. "DeleteCount": 1,
  241. "DeletedByteCount": 0,
  242. "ReadOnly": false
  243. },
  244. {
  245. "Id": 7,
  246. "Size": 46797832,
  247. "RepType": "000",
  248. "Version": 2,
  249. "FileCount": 292,
  250. "DeleteCount": 0,
  251. "DeletedByteCount": 0,
  252. "ReadOnly": false
  253. }
  254. ]
  255. }