填瓦和删节

geoWebcache rest api提供了一个RESTful接口,通过该接口,用户可以在每层的基础上添加或删除缓存中的图块。

操作

网址: /gwc/rest/seed/<layer>.<format>

方法

行动

返回代码

格式

GET

返回填瓦设定线程的状态

200

JSON

POST

发出填瓦和删节任务请求

200

XML、JSON

PUT

405

DELETE

405

陈述

下面的示例使用 cURL 工具,尽管示例适用于任何支持HTTP的工具或库。

填瓦

以下XML请求启动填瓦设定任务:

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"
* About to connect() to localhost port 8080 (#0)
*   Trying 127.0.0.1... connected
* Connected to localhost (127.0.0.1) port 8080 (#0)
* Server auth using Basic with user 'admin'
> POST /geoserver/gwc/rest/seed/nurc:Arc_Sample.xml HTTP/1.1
> Authorization: Basic YWRtaW46Z2Vvc2VydmVy
> 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
> Host: localhost:8080
> Accept: */*
> Content-type: text/xml
> Content-Length: 209
>
< HTTP/1.1 200 OK

以下是填瓦请求的一个更完整的XML片段,包括参数过滤器:

<?xml version="1.0" encoding="UTF-8"?>
<seedRequest>
  <name>topp:states</name>
  <bounds>
    <coords>
      <double>-2495667.977678598</double>
      <double>-2223677.196231552</double>
      <double>3291070.6104286816</double>
      <double>959189.3312465074</double>
    </coords>
  </bounds>

  <!-- These are listed on http://localhost:8080/geoserver/gwc/demo -->
  <gridSetId>EPSG:2163</gridSetId>
  <zoomStart>0</zoomStart>
  <zoomStop>2</zoomStop>
  <format>image/png</format>

  <!-- type can be seed, reseed, or truncate -->
  <type>truncate</type>

  <!-- Number of seeding threads to run in parallel.
       If type == truncate only one thread will be used
       regardless of this parameter -->
  <threadCount>1</threadCount>
  <!-- Parameter filters -->
  <parameters>
    <entry>
      <string>STYLES</string>
      <string>pophatch</string>
    </entry>
    <entry>
      <string>CQL_FILTER</string>
      <string>TOTPOP > 10000</string>
    </entry>
  </parameters>
</seedRequest>

截断

以下XML请求启动截断任务:

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"
* About to connect() to localhost port 8080 (#0)
*   Trying 127.0.0.1... connected
* Connected to localhost (127.0.0.1) port 8080 (#0)
* Server auth using Basic with user 'admin'
> POST /geoserver/gwc/rest/seed/nurc:Arc_Sample.json HTTP/1.1
> Authorization: Basic YWRtaW46Z2Vvc2VydmVy
> 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
> Host: localhost:8080
> Accept: */*
> Content-type: application/json
> Content-Length: 205
>
< HTTP/1.1 200 OK
< Date: Fri, 14 Oct 2011 22:09:21 GMT
< Server: Noelios-Restlet-Engine/1.0..8
< Transfer-Encoding: chunked
<
* Connection #0 to host localhost left intact
* Closing connection #0

查询正在运行的任务

网址: /gwc/rest/seed[/<layer>].json

方法

行动

返回代码

格式

GET

获取正在运行和挂起任务的全局或每层状态

200

JSON

POST

405

PUT

405

DELETE

405

获取填瓦设定线程的当前状态

向发送GET请求 /gwc/rest/seed.json 资源返回所有层的挂起(已调度)和正在运行任务的列表。

向发送GET请求 /gwc/rest/seed/<layer name>.json 资源返回该特定层的挂起(已调度)和正在运行任务的列表。

返回的内容是形式为的JSON数组:

{"long-array-array":[[<long>,<long>,<long>,<long>,<long>],...]}

如果没有挂起或正在运行的任务,则返回的数组为空::

{"long-array-array":[]}

返回的数组数组包含每个填瓦设定/截断任务一个数组。每个线程数组中每个长值的含义是:

[tiles processed, total number of tiles to process, estimated remaining time (in seconds), Task ID, Task status]

归还的人 Task Status 值将是以下值之一:

-1 = ABORTED
 0 = PENDING
 1 = RUNNING
 2 = DONE

下面的示例返回 topp:states 层:

curl -u <user>:<password> -v -XGET http://localhost:8080/geoserver/gwc/rest/seed/topp:states.json
{"long-array-array":[[17888,44739250,18319,1,1],[17744,44739250,18468,2,1],[16608,44739250,19733,3,0],[0,1000,1000,4,0]]}

在上面的回答中,任务 12 对于 topp:states 层正在运行,任务 34 处于等待可用线程的挂起状态。

下面的示例返回所有层的任务列表。

curl -u <user>:<password> -XGET http://localhost:8080/geoserver/gwc/rest/seed.json
{"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]]}

正在终止正在运行的任务

网址: /gwc/rest/seed[/<layer>]

方法

行动

返回代码

格式

GET

405

POST

发出终止运行和/或挂起任务请求

200

PUT

405

DELETE

405

/gwc/rest/seed 资源终止挂起和/或正在运行的任务 所有层 .向 /gwc/rest/seed/<layername> 资源终止特定层的挂起和/或运行任务。

可以终止单个或所有挂起和/或正在运行的任务。使用参数 kill_all 具有以下值之一: runningpendingall .

备注

为了向后兼容, kill_all 参数值 1 也被接受,相当于 running .

以下请求终止所有正在运行的填瓦和截断任务。

curl -v -u admin:geoserver -d "kill_all=all"  "http://localhost:8080/geoserver/gwc/rest/seed"
* About to connect() to localhost port 8080 (#0)
*   Trying 127.0.0.1... connected
< HTTP/1.1 200 OK
< Date: Fri, 14 Oct 2011 22:23:04 GMT
< Server: Noelios-Restlet-Engine/1.0..8
< Content-Type: text/html; charset=ISO-8859-1
< Content-Length: 426
<
<html>
...
* Connection #0 to host localhost left intact
* Closing connection #0
Previous: 管理层