diskquota.rst 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. .. _gwc_rest_diskquota:
  2. Disk Quota
  3. ==========
  4. The GeoWebCache REST API provides a RESTful interface through which users can configure the disk usage limits and expiration policies for a GeoWebCache instance.
  5. Operations
  6. ----------
  7. URL: ``/gwc/rest/diskquota.<format>``
  8. .. list-table::
  9. :header-rows: 1
  10. * - Method
  11. - Action
  12. - Return Code
  13. - Formats
  14. * - GET
  15. - Return the global disk quota configuration
  16. - 200
  17. - XML, JSON
  18. * - POST
  19. -
  20. - 405
  21. -
  22. * - PUT
  23. - Modify the global disk quota configuration
  24. - 200
  25. - XML, JSON
  26. * - DELETE
  27. -
  28. - 405
  29. -
  30. **Representations**:
  31. * :download:`XML <representations/diskquota_xml.txt>`
  32. * :download:`JSON <representations/diskquota_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. Retrieving the current configuration
  35. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  36. The following returns the current disk quota configuration in **XML** format:
  37. .. code-block:: console
  38. curl -u admin:geoserver -v -XGET http://localhost:8080/geoserver/gwc/rest/diskquota.xml
  39. ::
  40. < HTTP/1.1 200 OK
  41. < Date: Mon, 21 Mar 2011 13:50:49 GMT
  42. < Server: Noelios-Restlet-Engine/1.0..8
  43. < Content-Type: text/xml; charset=ISO-8859-1
  44. < Content-Length: 422
  45. <
  46. <gwcQuotaConfiguration>
  47. <enabled>true</enabled>
  48. <diskBlockSize>2048</diskBlockSize>
  49. <cacheCleanUpFrequency>5</cacheCleanUpFrequency>
  50. <cacheCleanUpUnits>SECONDS</cacheCleanUpUnits>
  51. <maxConcurrentCleanUps>5</maxConcurrentCleanUps>
  52. <globalExpirationPolicyName>LRU</globalExpirationPolicyName>
  53. <globalQuota>
  54. <value>100</value>
  55. <units>MiB</units>
  56. </globalQuota>
  57. <layerQuotas/>
  58. </gwcQuotaConfiguration>
  59. The following returns the current disk quota configuration in **JSON** format:
  60. .. code-block:: xml
  61. curl -u admin:geoserver -v -XGET http://localhost:8080/geoserver/gwc/rest/diskquota.json
  62. ::
  63. < HTTP/1.1 200 OK
  64. < Date: Mon, 21 Mar 2011 13:53:42 GMT
  65. < Server: Noelios-Restlet-Engine/1.0..8
  66. < Content-Type: application/json; charset=ISO-8859-1
  67. < Content-Length: 241
  68. <
  69. * Connection #0 to host localhost left intact
  70. * Closing connection #0
  71. {"gwcQuotaConfiguration":{"diskBlockSize":2048,"enabled":true,"maxConcurrentCleanUps":5,"cacheCleanUpFrequency":5,"globalExpirationPolicyName":"LRU","globalQuota":{"value":"100","units":"MiB"},"cacheCleanUpUnits":"SECONDS"}}
  72. Changing configuration
  73. ~~~~~~~~~~~~~~~~~~~~~~
  74. .. note::
  75. The request body for PUT should contain only the desired properties to be modified. For example, the following will only change the maxConcurrentCleanups property in XML format:
  76. .. code-block:: xml
  77. <gwcQuotaConfiguration><maxConcurrentCleanUps>2</maxConcurrentCleanUps></gwcQuotaConfiguration>
  78. The following will only change the diskBlockSize, enabled, and globalQuota properties in JSON format:
  79. .. code-block:: json
  80. {"gwcQuotaConfiguration":{"diskBlockSize":2048,"enabled":true,"globalQuota":{"value":"100","units":"MiB"}}
  81. The following XML example successfully enables the quota and sets the globalQuota size:
  82. .. code-block:: console
  83. curl -v -u admin:geoserver "http://localhost:8090/geoserver/gwc/rest/diskquota.xml" -X PUT -d "<gwcQuotaConfiguration><enabled>true</enabled><globalQuota><value>100</value><units>GiB</units></globalQuota></gwcQuotaConfiguration>"
  84. ::
  85. < HTTP/1.1 200 OK
  86. < Date: Fri, 18 Mar 2011 20:59:31 GMT
  87. < Server: Noelios-Restlet-Engine/1.0..8
  88. < Content-Type: text/xml; charset=ISO-8859-1
  89. < Content-Length: 422
  90. <
  91. <gwcQuotaConfiguration>
  92. <enabled>true</enabled>
  93. <diskBlockSize>2048</diskBlockSize>
  94. <cacheCleanUpFrequency>5</cacheCleanUpFrequency>
  95. <cacheCleanUpUnits>SECONDS</cacheCleanUpUnits>
  96. <maxConcurrentCleanUps>5</maxConcurrentCleanUps>
  97. <globalExpirationPolicyName>LFU</globalExpirationPolicyName>
  98. <globalQuota>
  99. <value>100</value>
  100. <units>GiB</units>
  101. </globalQuota>
  102. <layerQuotas/>
  103. </gwcQuotaConfiguration>
  104. The following JSON example changes the globalQuote and expirationPolicyName parameters:
  105. .. code-block:: console
  106. curl -v -u admin:geoserver "http://localhost:8090/geoserver/gwc/rest/diskquota.json" -X PUT -d "{"gwcQuotaConfiguration":{"globalQuota":{"value":"100","units":"MiB"},"globalExpirationPolicyName":"LRU"}}"
  107. ::
  108. < HTTP/1.1 200 OK
  109. < Date: Fri, 18 Mar 2011 21:02:20 GMT
  110. < Server: Noelios-Restlet-Engine/1.0..8
  111. < Content-Type: application/json; charset=ISO-8859-1
  112. < Content-Length: 241
  113. <
  114. * Connection #0 to host localhost left intact
  115. * Closing connection #0
  116. {"gwcQuotaConfiguration":{"diskBlockSize":2048,"enabled":true,"maxConcurrentCleanUps":5,"cacheCleanUpFrequency":5,"globalExpirationPolicyName":"LRU","globalQuota":{"value":"100","units":"MiB"},"cacheCleanUpUnits":"SECONDS","layerQuotas":[]}}
  117. The following *invalid* XML example has an invalid parameter (maxConcurrentCleanUps must be > 0). It returns a 400 response code and contains an error message as plain text:
  118. .. code-block:: console
  119. curl -v -u admin:geoserver "http://localhost:8090/geoserver/gwc/rest/diskquota.xml" -X PUT -d "<gwcQuotaConfiguration><maxConcurrentCleanUps>-1</maxConcurrentCleanUps></gwcQuotaConfiguration>"
  120. ::
  121. < HTTP/1.1 400 Bad Request
  122. < Date: Fri, 18 Mar 2011 20:53:26 GMT
  123. < Server: Noelios-Restlet-Engine/1.0..8
  124. < Content-Type: text/plain; charset=ISO-8859-1
  125. < Content-Length: 53
  126. <
  127. * Connection #0 to host localhost left intact
  128. * Closing connection #0
  129. maxConcurrentCleanUps shall be a positive integer: -1
  130. The following *invalid* JSON example uses an unknown unit of measure (ZZiB). It returns a 400 response code and contains an error message as plain text:
  131. .. code-block:: console
  132. curl -v -u admin:geoserver "http://localhost:8090/geoserver/gwc/rest/diskquota.json" -X PUT -d "{"gwcQuotaConfiguration":{"globalQuota":{"value":"100","units":"ZZiB"}}}"
  133. ::
  134. < HTTP/1.1 400 Bad Request
  135. < Date: Fri, 18 Mar 2011 20:56:23 GMT
  136. < Server: Noelios-Restlet-Engine/1.0..8
  137. < Content-Type: text/plain; charset=ISO-8859-1
  138. < Content-Length: 601
  139. <
  140. No enum const class org.geowebcache.diskquota.storage.StorageUnit.ZZiB : No enum const class org.geowebcache.diskquota.storage.StorageUnit.ZZiB
  141. ---- Debugging information ----
  142. message : No enum const class org.geowebcache.diskquota.storage.StorageUnit.ZZiB
  143. cause-exception : java.lang.IllegalArgumentException
  144. cause-message : No enum const class org.geowebcache.diskquota.storage.StorageUnit.ZZiB
  145. class : org.geowebcache.diskquota.DiskQuotaConfig
  146. required-type : org.geowebcache.diskquota.storage.Quota
  147. line number : -1
  148. * Connection #0 to host localhost left intact
  149. * Closing connection #0