seed.rst 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  1. .. _gwc_rest_seed:
  2. Seeding and Truncating
  3. ======================
  4. The GeoWebCache REST API provides a RESTful interface through which users can add or remove tiles from the cache on a per-layer basis.
  5. Operations
  6. ----------
  7. URL: ``/gwc/rest/seed/<layer>.<format>``
  8. .. list-table::
  9. :header-rows: 1
  10. * - Method
  11. - Action
  12. - Return Code
  13. - Formats
  14. * - GET
  15. - Return the status of the seeding threads
  16. - 200
  17. - JSON
  18. * - POST
  19. - Issue a seed or truncate task request
  20. - 200
  21. - XML, JSON
  22. * - PUT
  23. -
  24. - 405
  25. -
  26. * - DELETE
  27. -
  28. - 405
  29. -
  30. **Representations**:
  31. * :download:`XML <representations/seed_xml.txt>`
  32. * :download:`JSON <representations/seed_json.txt>`
  33. The examples below use the `cURL <http://curl.haxx.se/>`_ tool, though the examples apply to any HTTP-capable tool or library.
  34. Seeding
  35. ~~~~~~~
  36. The following XML request initiates a seeding task:
  37. .. code-block:: console
  38. curl -v -u admin:geoserver -XPOST -H "Content-type: text/xml" -d '<seedRequest><name>nurc:Arc_Sample</name><srs><number>4326</number></srs><zoomStart>1</zoomStart><zoomStop>12</zoomStop><format>image/png</format><type>truncate</type><threadCount>2</threadCount></seedRequest>' "http://localhost:8080/geoserver/gwc/rest/seed/nurc:Arc_Sample.xml"
  39. ::
  40. * About to connect() to localhost port 8080 (#0)
  41. * Trying 127.0.0.1... connected
  42. * Connected to localhost (127.0.0.1) port 8080 (#0)
  43. * Server auth using Basic with user 'admin'
  44. > POST /geoserver/gwc/rest/seed/nurc:Arc_Sample.xml HTTP/1.1
  45. > Authorization: Basic YWRtaW46Z2Vvc2VydmVy
  46. > User-Agent: curl/7.21.3 (x86_64-pc-linux-gnu) libcurl/7.21.3 OpenSSL/0.9.8o zlib/1.2.3.4 libidn/1.18
  47. > Host: localhost:8080
  48. > Accept: */*
  49. > Content-type: text/xml
  50. > Content-Length: 209
  51. >
  52. < HTTP/1.1 200 OK
  53. The following is a more complete XML fragment for a seed request, including parameter filters:
  54. .. code-block:: xml
  55. <?xml version="1.0" encoding="UTF-8"?>
  56. <seedRequest>
  57. <name>topp:states</name>
  58. <bounds>
  59. <coords>
  60. <double>-2495667.977678598</double>
  61. <double>-2223677.196231552</double>
  62. <double>3291070.6104286816</double>
  63. <double>959189.3312465074</double>
  64. </coords>
  65. </bounds>
  66. <!-- These are listed on http://localhost:8080/geoserver/gwc/demo -->
  67. <gridSetId>EPSG:2163</gridSetId>
  68. <zoomStart>0</zoomStart>
  69. <zoomStop>2</zoomStop>
  70. <format>image/png</format>
  71. <!-- type can be seed, reseed, or truncate -->
  72. <type>truncate</type>
  73. <!-- Number of seeding threads to run in parallel.
  74. If type == truncate only one thread will be used
  75. regardless of this parameter -->
  76. <threadCount>1</threadCount>
  77. <!-- Parameter filters -->
  78. <parameters>
  79. <entry>
  80. <string>STYLES</string>
  81. <string>pophatch</string>
  82. </entry>
  83. <entry>
  84. <string>CQL_FILTER</string>
  85. <string>TOTPOP > 10000</string>
  86. </entry>
  87. </parameters>
  88. </seedRequest>
  89. Truncating
  90. ~~~~~~~~~~
  91. The following XML request initiates a truncating task:
  92. .. code-block:: console
  93. curl -v -u admin:geoserver -XPOST -H "Content-type: application/json" -d "{'seedRequest':{'name':'topp:states','bounds':{'coords':{ 'double':['-124.0','22.0','66.0','72.0']}},'srs':{'number':4326},'zoomStart':1,'zoomStop':12,'format':'image\/png','type':'truncate','threadCount':4}}}" "http://localhost:8080/geoserver/gwc/rest/seed/nurc:Arc_Sample.json"
  94. ::
  95. * About to connect() to localhost port 8080 (#0)
  96. * Trying 127.0.0.1... connected
  97. * Connected to localhost (127.0.0.1) port 8080 (#0)
  98. * Server auth using Basic with user 'admin'
  99. > POST /geoserver/gwc/rest/seed/nurc:Arc_Sample.json HTTP/1.1
  100. > Authorization: Basic YWRtaW46Z2Vvc2VydmVy
  101. > User-Agent: curl/7.21.3 (x86_64-pc-linux-gnu) libcurl/7.21.3 OpenSSL/0.9.8o zlib/1.2.3.4 libidn/1.18
  102. > Host: localhost:8080
  103. > Accept: */*
  104. > Content-type: application/json
  105. > Content-Length: 205
  106. >
  107. < HTTP/1.1 200 OK
  108. < Date: Fri, 14 Oct 2011 22:09:21 GMT
  109. < Server: Noelios-Restlet-Engine/1.0..8
  110. < Transfer-Encoding: chunked
  111. <
  112. * Connection #0 to host localhost left intact
  113. * Closing connection #0
  114. Querying running tasks
  115. ----------------------
  116. URL: ``/gwc/rest/seed[/<layer>].json``
  117. .. list-table::
  118. :header-rows: 1
  119. * - Method
  120. - Action
  121. - Return Code
  122. - Formats
  123. * - GET
  124. - Get the global or per layer state of running and pending tasks
  125. - 200
  126. - JSON
  127. * - POST
  128. -
  129. - 405
  130. -
  131. * - PUT
  132. -
  133. - 405
  134. -
  135. * - DELETE
  136. -
  137. - 405
  138. -
  139. Getting current state of the seeding threads
  140. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  141. Sending a GET request to the ``/gwc/rest/seed.json`` resource returns a list of pending (scheduled) and running tasks for all the layers.
  142. Sending a GET request to the ``/gwc/rest/seed/<layer name>.json`` resource returns a list of pending (scheduled) and running tasks for that specific layer.
  143. The returned content is a JSON array of the form::
  144. {"long-array-array":[[<long>,<long>,<long>,<long>,<long>],...]}
  145. If there are no pending or running tasks, the returned array is empty::
  146. {"long-array-array":[]}
  147. The returned array of arrays contains one array per seeding/truncating task.
  148. The meaning of each long value in each thread array is::
  149. [tiles processed, total number of tiles to process, estimated remaining time (in seconds), Task ID, Task status]
  150. The returned ``Task Status`` value will be one of the following::
  151. -1 = ABORTED
  152. 0 = PENDING
  153. 1 = RUNNING
  154. 2 = DONE
  155. The example below returns the current state of tasks for the ``topp:states`` layer:
  156. .. code-block:: console
  157. curl -u <user>:<password> -v -XGET http://localhost:8080/geoserver/gwc/rest/seed/topp:states.json
  158. .. code-block:: json
  159. {"long-array-array":[[17888,44739250,18319,1,1],[17744,44739250,18468,2,1],[16608,44739250,19733,3,0],[0,1000,1000,4,0]]}
  160. In the above response, tasks ``1`` and ``2`` for the ``topp:states`` layer are running, and
  161. tasks ``3`` and ``4`` are in a pending state waiting for an available thread.
  162. The example below returns a list of tasks for all the layers.
  163. .. code-block:: console
  164. curl -u <user>:<password> -XGET http://localhost:8080/geoserver/gwc/rest/seed.json
  165. .. code-block:: json
  166. {"long-array-array":[[2240,327426,1564,2,1],[2368,327426,1477,3,1],[2272,327426,1541,4,1],[2176,327426,1611,5,1],[1056,15954794690,79320691,6,1],[1088,15954794690,76987729,7,1],[1040,15954794690,80541010,8,1],[1104,15954794690,75871965,9,1]]}
  167. Terminating running tasks
  168. -------------------------
  169. URL: ``/gwc/rest/seed[/<layer>]``
  170. .. list-table::
  171. :header-rows: 1
  172. * - Method
  173. - Action
  174. - Return Code
  175. - Formats
  176. * - GET
  177. -
  178. - 405
  179. -
  180. * - POST
  181. - Issue a kill running and/or pending tasks request
  182. - 200
  183. -
  184. * - PUT
  185. -
  186. - 405
  187. -
  188. * - DELETE
  189. -
  190. - 405
  191. -
  192. A POST request to the ``/gwc/rest/seed`` resource terminates pending and/or running tasks for **all layers**. A POST request to the ``/gwc/rest/seed/<layername>`` resource terminates pending and/or running tasks for a specific layer.
  193. It is possible to terminate individual or all pending and/or running tasks. Use the parameter ``kill_all`` with one of the following values: ``running``, ``pending``, or ``all``.
  194. .. note:: For backward compatibility, the ``kill_all`` parameter value ``1`` is also accepted and is equivalent to ``running``.
  195. The following request terminates all running seed and truncate tasks.
  196. .. code-block:: console
  197. curl -v -u admin:geoserver -d "kill_all=all" "http://localhost:8080/geoserver/gwc/rest/seed"
  198. ::
  199. * About to connect() to localhost port 8080 (#0)
  200. * Trying 127.0.0.1... connected
  201. < HTTP/1.1 200 OK
  202. < Date: Fri, 14 Oct 2011 22:23:04 GMT
  203. < Server: Noelios-Restlet-Engine/1.0..8
  204. < Content-Type: text/html; charset=ISO-8859-1
  205. < Content-Length: 426
  206. <
  207. <html>
  208. ...
  209. * Connection #0 to host localhost left intact
  210. * Closing connection #0