xmpp python包装器的部署和设置

远程WPS python包装框架

远程WPS python框架源代码可在geosolutions s.a.s的公共Github存储库中获得。

用户可以使用pypi分发版安装“wps remote”python包:

pip install wps-remote==2.11.0

源代码存储库位于以下地址:

源代码可以在主开发上找到( main )分支。

系统如何工作

此安装程序将配置远程WPS Python包装器以启动一个名为 test.py 执行 gdal_contour 在GeoTIFF DEM上。

这个 test.py 可执行文件只接受两个参数:

  • -i ;“--interval”,nargs='?”,默认值为“10”,帮助为“等高线之间的高程间隔”

  • -w ;“--workdir”,纳格斯='?”,default=”,help=“远程进程沙盒工作目录。”

要处理的命令行和geotiff的路径(随源代码一起作为示例数据提供)是硬编码到python代码中的,必须相应地更改为系统设置,如后面的文档中所述:

  • gdalContour = r'/usr/bin/gdal_contour'

  • src = r'/share/xmpp_data/resource_dir/srtm_39_04/srtm_39_04_c.tif'

假设在执行过程中,算法以类似于以下格式的形式向标准输出发送日志和进度信息:

2016-02-15 15:18:03,594 - main.create_logger - [INFO] ProgressInfo:100%

日志格式已通过 logger_test.properties 文件:

[loggers]
keys=root

[handlers]
keys=consoleHandler

[formatters]
keys=simpleFormatter

[logger_root]
level=DEBUG
handlers=consoleHandler

[handler_consoleHandler]
class=StreamHandler
level=DEBUG
formatter=simpleFormatter
args=(sys.stdout,)

[formatter_simpleFormatter]
format=%(asctime)s - %(name)s - [%(levelname)s] %(message)s
datefmt=

远程WPS Python包装器的作用是处理GeoServer WPS和 test.py 可执行的。

必须通过指定可执行文件的输入和输出参数(远程XMPP服务器的连接参数除外)的数量和类型来配置python包装器。由于某些属性文件包含一组正则表达式,Python包装器知道如何从命令行调用可执行文件,以及如何解析和解释日志信息,这些正则表达式将在本文档中进一步详细介绍。

每个可执行文件都必须有一个python包装器的运行实例,每个可执行文件都有自己的特定配置和xmpp用户。包装实例将自动连接到xmpp服务器,geoserver将发送一个 “邀请” 消息一旦识别出XMPP通信信道上出现的新的经过身份验证的用户。为了通过远程进程工厂将WPS进程注册到GeoServer中,Python包装器必须用 “注册” 包含有关可执行文件的I/O参数的所有详细信息的消息。所有这些段落都由远程WPS-Python框架自动、透明地管理给用户。

每当用户发出一个新的geoserver wps执行请求时,python包装器就会启动一个新的线程,用来自geoserver本身的输入参数调用可执行文件。这两个正在运行的实例通过由geoserver远程进程工厂生成的唯一“进程执行ID”进行连接。

从现在起,python包装器线程将跟踪整个执行过程,并负责将反馈和日志记录信息发送到geoserver远程进程工厂,然后将其翻译并转发给geoserver wps执行管理器。从外部来看,用户将体验到一个符合OGC WPS的流程的标准执行。

配置步骤摘要

通过python包装器将新的可执行实例连接到geoserver需要以下总结的几个配置步骤:

  1. Clone a structure of .properties files containing:
    • xmpp服务器的连接参数

    • 可执行命令行的描述符

    • 进程I/O参数的描述符

    • 日志信息

  2. Update the remote.config file with the correct XMPP Server information:
    • 提供远程主机和端口参数

    • 提供域和XMPP通信安全通道的详细信息

    • 提供指向共享文件夹的指针

  3. Update the logger.properties file with the full path to the service.log file.

  4. Update the service.config file with the executables parameters:
    • 服务名和命名空间

      备注

      xmpp服务器上必须存在名为的用户 namespace.serviceName 以及与服务命名空间标识相同的通信通道。

      例如。:

      • 服务=gdalcontour

      • 名称空间=默认值

      意味着在XMPP服务器上,我们正在寻找一个名为 default 我们将尝试连接到用户名 default.gdalContour .

      在运行python包装器守护程序之前,必须定义这两个守护程序。

    • 服务的描述和主可执行文件的完整路径

    • 其他辅助参数,如本地输出文件夹(存储执行的临时结果的位置)和最大运行时间

    • 输入和要采取的行动的描述

    • 输出和要采取的行动的描述

    • 日志信息的描述和要采取的操作

安装和配置步骤

基本环境准备

以下命令将准备MS Windows 7+、Windows 2008+Server ISO计算机用于部署:

  1. 远程WPS python包装

  2. 示例可执行文件的示例配置和测试 test.py 运行 gdal_contour 在GeoTIFF DEM上

系统准备:标准和基本操作系统包

Python

为了正确地工作,系统需要具有少量包的python 2.7.9+。在Windows系统上安装python非常快

# as administrator

#.1 Download the Python 2.7.9 installation package from the browser, choosing the best suitable distribution accordingly to the OS

  https://www.python.org/downloads/release/python-279/

#.2 Define the following System Environment Variables

PATH=%PATH%;C:\Python27;C:\Python27\Scripts
PYTHONPATH=.\;C:\Python27;C:\work\RemoteWPS

其他必需的Python包

# as administrator

# From a Command Line prompt

$> pip install wps-remote==2.11.0

配置RemoteWPS环境

NFS共享文件夹

将共享文件夹链接到 C:/share 通过NFS协议。只需打开MS Windows功能的NFS服务并创建到NFS服务器的客户端NFS连接,就可以实现这一点。

警告

已在Windows 10上删除“NFS服务”。它们仅在Windows 10企业版上可用。对于较旧的Windows版本,可以使用以下过程启用NFS客户端

安装客户端

  1. 转到控制面板→程序→程序和功能

  2. 从左侧导航栏中选择:打开或关闭Windows功能。

  3. 向下滚动到“NFS服务”,然后单击左侧的“加号”

  4. 选中“NFS客户端”

  5. 选择“确定”

  6. Windows应该安装客户端。一旦安装了客户机包,就可以使用“mount”命令。

安装出口

这假设如下:

  • 您知道并且可以使用NFS导出ping机器的主机名

  • 导出的文件系统的名称(例如/export、/home/users、/some/cool/file/path)

  • 文件系统已正确导出并可访问

    • 打开命令提示。( Win + R ,输入“cmd”并按OK)

    • 类型:

      mount \\{machinename}\{filesystem} {driveletter}

实例:

mount \\filehost\home\users H:
mount \\server1234\long\term\file\storage S:
mount \\nas324\exports E:

备注

必须在Windows计算机上完全复制共享文件夹结构,并且该文件夹可由Windows进程写入。

| /share
|
|-- xmpp_data
|
|-- -- output
|
|-- -- resource_dir

第一次部署RemoteWPS python框架

WPS远程WHL存档包含一个具有示例配置的文件夹:

xmpp_data

提取此文件夹并继续执行下一步。

这些文件也可以从GitHub源存储库下载。

要将RemoteWPS python框架克隆到工作文件夹中,例如:

$> cd C:\work

$> git clone https://github.com/geoserver/wps-remote RemoteWPS

设置 remote.config

# Edit the file xmpp_data/configs/remote.config

      [DEFAULT]

      bus_class_name = xmppBus.XMPPBus

      port = 5223
      address =  127.0.0.1
      domain = geoserver.org

      # . Those are the connection parameters to the XMPP Server.
      # . The user must exists on the Server and its name must be
      # . equal to the service name.
      user = default.GdalContour
      password = R3m0T3wP5

      mucService = conference.%(domain)s
      mucServicePassword = admin

      resource_file_dir = /share/xmpp_data/resource_dir

      # . Configure this option (along with 'backup_on_wps_execution_shared_dir'
      # . on single outputs of 'service.config') in order to make a copy
      # . of the results into a shared folder before sending messages to XMPP
      # . WARNING: this option takes precedence on "UPLOADER" option
      # wps_execution_shared_dir = /share/xmpp_data/share

      # . This section is used to configure the uploader class and connection
      # . parameters.
      # . This is necessary in order to let the 'upload_data' option work on
      # . single outputs of 'service.config'
      [UPLOADER]
      # There are different implementations of the FTP Uploader available right now:
      # . Plain standard FTP Protocol (based on ftplib)
      #       ftpUpload.FtpUpload
      # . FTP over TLS (FTPS) Protocol (based on ftplib)
      #       ftpsUpload.FtpsUpload
      # . S-FTP Protocol (based on paramiko Python lib)
      #       sftpUpload.SFtpUpload
      uploader_class_name = ftpUpload.FtpUpload
      uploader_host = ftp.<your_host_here>:<your_port_here_default_21>
      uploader_username = <ftp_username>
      uploader_password = <ftp_password_encrypted>

      # . "encryptor" you can use encrypted passwords with a private/public key couple
      #
      # . To generate a new private key use the following command:
      #     openssl genrsa -out myTestKey.pem -passout pass:"f00bar" -des3 2048
      #
      # . To generate a new public key use the following command:
      #     openssl rsa -pubout -in myTestKey.pem -passin pass:"f00bar" -out myTestKey.pub
      #
      # . To encrypt your password use the following utility
      #     python encrypt.py password path/to/rsakey.pub passphrase
      #
      # . To double check the password is correct use the following utility
      #     python decrypt.py password path/to/rsakey.pem passphrase
      uploader_private_rsa_key = /share/xmpp_data/ssl/myTestKey.pem
      uploader_passphrase = f00bar

此配置正常工作的必要条件是:

  1. 确定 <XMPP_server_ip_address> 可到达并且端口 5223 被防火墙允许

  2. 确定 default.GdalContour 用户存在于XMPP服务器中,并且密码正确

../../_images/python001.jpg
  1. MUC服务和MUC服务密码正确

  2. 资源目录和共享文件夹存在且可写

设置 logger.properties

# Edit the file xmpp_data/configs/logger.properties

[loggers]
keys=root

[handlers]
keys=consoleHandler,file

[formatters]
keys=simpleFormatter,consoleFormatter

[logger_root]
level=DEBUG
handlers=file, consoleHandler

[handler_consoleHandler]
class=StreamHandler
level=DEBUG
formatter=consoleFormatter
args=(sys.stdout,)
filter=

[handler_file]
class=handlers.TimedRotatingFileHandler
interval=midnight
backupCount=5
formatter=simpleFormatter
level=DEBUG
args=('/share/xmpp_data/service.log',)

[formatter_simpleFormatter]
format=%(asctime)s - %(name)s - %(levelname)s - %(message)s
datefmt=

[formatter_consoleFormatter]
format=%(asctime)s [%(levelname)s] %(message)s
datefmt=

此配置正常工作的必要条件是:

  1. 确保“c:/share/xmpp_data/”存在并可写

设置 service.config

# Edit the file xmpp_data/configs/myservice/service.config

      # This is a INI file to be read with python ConfigParser (https://docs.python.org/2/library/configparser.html)
      # Is possible to reference another variable in the ini file using the format %(<variable name>)s (note the 's' at the end)

      # ########################################### #
      # Default Service Params                      #
      # ########################################### #

      [DEFAULT]
      service = GdalContour
      namespace = default
      description = GDAL Contour Remote Service
      executable_path = /share/xmpp_data/configs/myservice/code
      executable_cmd = python %(executable_path)s/test.py
      output_dir = /share/xmpp_data/output/
      unique_execution_id = %(unique_exe_id)s
      workdir = %(output_dir)s/%(unique_execution_id)s
      active = True
      max_running_time_seconds = 300

      # . This option allows you to set the CPU and Memory average load scan time.
      # . It is espressed in 'minutes' and if disabled here it will be set by default
      # . to 15 minutes.
      load_average_scan_minutes = 1

      # . Use this option to completely avoid using this host (and prevent starting a new
      # . 'processbot') whenever one of the following process names are running.
      # . In other words, if one of the following processes are currently running on this machine,
      # . GeoServer won't send any WPS execute request until they are finished.
      process_blacklist = [resource consuming process name1, resource consuming process name2]

      # ########################################### #
      # Inputs and Actions Declaration              #
      # ########################################### #

      [Input1]
      class = param
      name = interval
      title = Elevation Interval
      type = int
      description = Elevation interval between contours.
      min = 1
      max = 1
      default = 200

      [Action1]
      class = cmdline
      input_ref = interval
      alias = i
      template = -name value

      [Const1]
      class = const
      name = workdir
      type = string
      description = Remote process sandbox working directory
      value = %(workdir)s


      [Action2]
      class = cmdline
      input_ref = workdir
      alias = w
      template = -name value

      # ########################################### #
      # Output Parameters Declaration               #
      # ########################################### #

      [Output1]
      name = result1
      type = application/zip
      description = WPS Resource Binary File
      title = SRTM
      filepath = %(workdir)s/contour.zip
      publish_as_layer = true
      publish_default_style = polygon
      publish_target_workspace = it.geosolutions
      publish_layer_name = contour

      # . Enable this option in order to perform a backup of this output
      # . before sending it to GeoServer.
      # . WARNING: This option works only along with 'wps_execution_shared_dir'
      # .          option on 'remote.config', and takes precedence on 'upload_data'
      # backup_on_wps_execution_shared_dir = true

      # . Enable this option if you want the output to be uploaded on remote host.
      # . Notice that you must also configure uploader parameters on 'remote.config'
      # upload_data = true

      # . Optionally it is possible to specify a root folder if the uploader class supports it.
      # upload_data_root = /remote-wps/default

      [Output2]
      name = result2
      type = application/x-netcdf
      description = NetCDF Binary File
      title = flexpart
      filepath = %(output_dir)s/flexpart.nc
      publish_as_layer = true
      publish_default_style = raster
      publish_target_workspace = it.geosolutions
      publish_layer_name = flexpart

      # . Enable this option in order to perform a backup of this output
      # . before sending it to GeoServer.
      # . WARNING: This option works only along with 'wps_execution_shared_dir'
      # .          option on 'remote.config', and takes precedence on 'upload_data'
      # backup_on_wps_execution_shared_dir = true

      # . Enable this option if you want the output to be uploaded on remote host.
      # . Notice that you must also configure uploader parameters on 'remote.config'
      # upload_data = true

      # . Optionally it is possible to specify a root folder if the uploader class supports it.
      # upload_data_root = /remote-wps/default

      [Output3]
      name = result3
      type = application/owc
      description = WPS OWC Json MapContext
      layers_to_publish = result2
      publish_as_layer = true
      publish_layer_name = owc_json_ctx
      publish_metadata = /share/xmpp_data/resource_dir/owc_json_ctx.json

      # ########################################### #
      # Logging Options Declaration                 #
      # ########################################### #

      [Logging]
      stdout_parser = [.*\[DEBUG\](.*), .*\[INFO\] ProgressInfo\:([-+]?[0-9]*\.?[0-9]*)\%, .*\[(INFO)\](.*), .*\[(WARN)\](.*), .*\[(ERROR)\](.*), .*\[(CRITICAL)\](.*)]
      stdout_action = [ignore,          progress,                                          log,              log,              abort,               abort]

此配置正常工作的必要条件是:

  1. 确定 default.GdalContour 用户存在于XMPP服务器中,并且密码正确

  2. 确定 default 通道存在于XMPP服务器上

  3. 确保可执行路径和命令正确

  4. 确定 output_dir 存在并可写

  5. 确定 max_running_time_seconds 已设置为足够高的值,以允许可执行文件完成作业。

    geoserver实例还必须遵守必须相应配置的WPS执行时间。以便访问GeoServer Web管理GUI。

    以管理员身份登录(默认凭据为admin/geoserver,应随时更改)。

    从“Web处理服务设置”页

    ../../_images/python002.png
    ../../_images/python003.png

    超时和并行执行的数量(异步和同步)必须根据执行需要进行相应的调整。

  6. 确保已为命令行执行正确配置了输入

    [Input1]
    class = param
    name = interval
    title = Elevation Interval
    type = int
    description = Elevation interval between contours.
    min = 1
    max = 1
    default = 200
    
    [Action1]
    class = cmdline
    input_ref = interval
    alias = i
    template = -name value
    

    上面的配置设置了 int (预期值将被解释为文本并声明为WPS的文本),这是必需的( min = 1 )可以有一个值( max = 1

    这个 [Action1] 通过 input_ref 等于 [Input1].name .

    在上面的示例中,该操作只获取用户指定的输入值,并将其转发到命令行。

    最后的结果是:

    $> /work/RemoteWPS/xmpp_data/configs/myservice/code/test.py <input_value_here>
    

    这个 [Action1].template 属性允许在可执行文件需要时指定选项的名称。

    作为实例 [Action1].template ::

    alias = i
    template = -name value
    

    会导致如下情况:

    $> /work/RemoteWPS/xmpp_data/configs/myservice/code/test.py -i <input_value>
    

    存在其他类型的输入和操作。

    作为一个实例,可以指定 constant 输入类型如下:

    [Const1]
    class = const
    name = workdir
    type = string
    description = Remote process sandbox working directory
    value = %(workdir)s
    
    [Action2]
    class = cmdline
    input_ref = workdir
    alias = w
    template = -name value
    

    这个 [Const1].value 可以是常量值或对配置文件属性的引用。

    在上面的示例中,我们将把进程工作目录的完整路径传递给命令行,该路径是运行时创建的唯一文件夹,远程WPS框架存储进程执行的临时和中间结果。

    启用上面的常量输入,生成的命令行类似于下面的命令行:

    $> /work/RemoteWPS/xmpp_data/configs/myservice/code/test.py -i <input_value> -w /share/xmpp_data/output/<exec_id>
    

    备注

    这个 <exec_id> 仅在运行时已知。

  7. 确保已为命令行执行正确配置输出

    [Output1]
    name = result1
    type = application/zip
    description = WPS Resource Binary File
    title = SRTM
    filepath = %(workdir)s/contour.zip
    publish_as_layer = true
    publish_default_style = polygon
    publish_target_workspace = it.geosolutions
    publish_layer_name = contour
    

    在上面的例子中,我们只向WPS声明 one 类型的输出 application/zip .

    在这种情况下,RemoteWPS框架希望找到 contour.zip 在执行结束时将文件放入工作目录(见上文)。

    这里可以定义许多可能的输出。作为实例,可以定义类型为 string 它可以从一个文件中读取结果并将其作为纯文本流输出。

    还可以根据可执行结果定义几种二进制输出。有关更多详细信息,请参阅本节末尾的远程WPS python框架特定文档。

  8. 确保“stdoutu parser”的正则表达式对于可执行文件的输出是正确和有效的。

    [Logging]
    stdout_parser = [.*\[DEBUG\](.*), .*\[INFO\] ProgressInfo\:([-+]?[0-9]*\.?[0-9]*)\%, .*\[(INFO)\](.*), .*\[(WARN)\](.*), .*\[(ERROR)\](.*), .*\[(CRITICAL)\](.*)]
    stdout_action = [ignore,          progress,                                          log,              log,              log,               abort]
    

    上述配置示例:

    • 全部忽略 STDOUT 从接收的调试日志 test.py

    • Translates as progress info message any number parsed by the regex from STDOUT and sends it to GeoServer WPS.

    • 全部记录 STDOUT 从接收的信息、警告和错误日志 test.py

    • Translates as abort message any keyword CRITICAL parsed by the regex from STDOUT and sends it to GeoServer WPS.

    至少 进步中止 消息是必需的,以便跟踪进程执行进度和故障状态。

一个运行示例

在本节中 远程“gdal轮廓”流程绑定示例 将演示如何在GeoServer中运行示例以及如何分析结果。

附件A:远程WPS python包装器参考

本节旨在总结RemoteWPS Python包装器当前可能的选项 service.config 配置。

默认节

# ########################################### #
# Default Service Params                      #
# ########################################### #

[DEFAULT]
service = GdalContour
namespace = default
description = GDAL Contour Remote Service
executable_path = /work/RemoteWPS/xmpp_data/configs/myservice/code
executable_cmd = python %(executable_path)s/test.py
output_dir = /share/xmpp_data/output/
unique_execution_id = %(unique_exe_id)s
workdir = %(output_dir)s/%(unique_execution_id)s
sharedir = /home/myproc/repository/default
active = True
max_running_time_seconds = 300
load_average_scan_minutes = 1
process_blacklist = [resource consuming process name1, resource consuming process name2]
  • 服务 ;WPS服务的名称。在GeoServer上,WPS进程将表示为 namespace.service

    备注

    XMPP服务器 must 有一个名为完全限定服务名的注册用户 namespace.service

  • 命名空间 ;服务的命名空间(或前缀)。以及 服务 参数,它表示服务的完全限定名。

  • 描述 ;它包含GeoServer WPS进程的文本描述。

  • executable_path ;要包装的可执行文件的完整路径。

  • executable_cmd ;可执行命令。

  • output_dir ;Python包装器存储日志和临时文件的基本输出文件夹。

  • unique_execution_id ;GeoServer生成并通过 REQUEST 命令信息。

  • 工作迪尔 ;存储结果和日志文件的临时文件夹。

  • sharedir ;要放置的共享文件夹 backup 结果: backup_on_wps_execution_shared_dir 财产相等 true

  • 积极的布尔 启用或禁用服务的。

  • max_running_time_seconds ;在此之后,python包装器尝试关闭进程并发送 FAILED 发送给GeoServer的消息。

  • load_average_scan_minutes ;此选项允许您设置CPU和内存的平均负载扫描时间。它将在“分钟”内播放,如果在此处禁用,则默认设置为15分钟。

  • process_blacklist ;使用此选项可完全避免在下列进程名之一运行时使用此主机(并防止启动新的“processbot”)。换句话说,如果此计算机上当前正在运行以下进程之一,GeoServer将不会发送任何WPS execute请求,直到它们完成为止。

输入部分

# ########################################### #
# Inputs and Actions Declaration              #
# ########################################### #

[Input1]
class = param
name = interval
title = Elevation Interval
type = int
description = Elevation interval between contours.
min = 1
max = 1
default = 200

[Action1]
class = cmdline
input_ref = interval
alias = i
template = -name value

[Const1]
class = const
name = workdir
type = string
description = Remote process sandbox working directory
value = %(workdir)s

[Action2]
class = cmdline
input_ref = workdir
alias = w
template = -name value

这个 输入部分 可以包含三种类型的对象:

  1. [Input#] ;对应GeoServer WPS输入参数的描述符。

  2. [Action#]1..n[Input] .参考是通过 input_ref 财产。

  3. [Const#] ;传递给可执行文件并对GeoServer WPS透明的常量值。

[[Input#]]

  • ;使用内省来实例化输入参数。目前唯一允许的值是 param

  • name ;输入参数的名称。这也是GeoServer输入参数的名称。

  • 标题 ;输入参数的标题。用作内部描述符。

  • 描述 ;输入参数的说明。这也是GeoServer输入参数的说明。

  • type ;输入参数的类型。允许的类型包括:

    1. string ;简单的文本输入。将自动删除无效字符。

    2. int ;整数数值输入值。

    3. float ;浮点数字输入值。

    4. url ;必须包含有效的URL。将自动删除无效字符。

    5. application/json ;威胁为JSON字符串。它将被Python包装器解析并转换为一个复杂的对象。

    6. datetime ;转化为 Python datetime 相应地反对 格式化程序 包含日期模式且还必须提供的属性。

  • min ;可选参数,用于设置GeoServer WPS允许的此类型的最小输入集。 0 默认情况下。

  • max ;可选参数,用于设置GeoServer WPS允许的此类型的最大输入集。 0 (别名无限)默认情况下。

  • 违约 ;如果未提供值,则用于设置此输入的默认值的可选参数。

  • 格式化程序 ;与一起使用的可选参数 datetime 输入。定义要应用于输入字符串的日期模式(例如:%Y-%m-%d%H:%m:%S)

[[Action#]]

  • ;使用内省来实例化操作类型。

    1. cmdline ;关联输入的值将作为对应于 template 指定(例如:--名称=值)。

      • template ;键值对格式的模板(例如:Template=-name-value)

      • alias ;键的别名(例如:Alias=i将转换为-i值)

    2. createJSONfile ;关联输入的值将转储到JSON文件,并将对该文件的引用传递到可执行文件。

      • target_filepath ;存储JSON文件的路径。

      • json_schema ;用于验证输入值的JSON架构的路径。

    3. updateJSONfile ;关联输入的值将被替换为目标模板JSON文件,然后作为引用传递给executbale。

      • source_filepath ;源JSON模板文件的路径。

      • target_filepath ;目标JSON文件的路径。

      • json_path_expr ;用于填充值的JSON路径表达式。

    4. copyfile ;关联输入的值将被解释为指向源文件的路径。文件的内容将被复制到一个临时文件中,然后作为引用传递给executbale。

      • source_filepath ;源JSON模板文件的路径。

      • target_filepath ;目标JSON文件的路径。

    5. updateINIfile ;关联输入的值将被替换为目标模板INI文件,然后作为引用传递给executbale。

      • source_filepath ;源JSON模板文件的路径。

      • target_filepath ;目标JSON文件的路径。

      • section ;存储键值对项的INI文件的节。

    6. updateINIfileList ;关联输入的值将被分析为 list 替换为目标模板INI文件,然后作为引用传递给executbale。

      • source_filepath ;源JSON模板文件的路径。

      • target_filepath ;目标JSON文件的路径。

      • section ;存储键值对项的INI文件的节。

  • input_refname 此操作引用的输入参数的。

[[Const#]]

  • class = const

  • name ;输入参数的名称,由操作用作引用。

  • type ;可能是 [[Input#].type] 那些。

  • 描述 ;参数的内部描述。

  • 价值 ;由引用操作分析的固定值。

输出部分

# ########################################### #
# Output Parameters Declaration               #
# ########################################### #

# WARNING: the name must start with the keyword "result"

[Output1]
name = result1
type = string
description = WPS Resource Plain Text
filepath = %(workdir)s/geoserverLayerOutput.xml

[Output2]
name = result2
type = image/geotiff
description = WPS Resource Binary File
title = SRTM
filepath = %(workdir)s/srtm_39_04_c.tif
backup_on_wps_execution_shared_dir = true
publish_as_layer = true
publish_default_style = raster
publish_target_workspace = it.geosolutions
publish_layer_name = srtm_39_04_c
# Such metadata is a JSON snippet itself (/tmp/resource_dir/result2.json) with a small particularity.
# Since you cannot know a-priori some of the final Layer properties,
# you can use inside the json (/tmp/resource_dir/result2.json) some keywords which will be updated
# automatically by the RemoteWPS which are the following ones:
#
# ${type}
# ${name}
# ${title}
# ${description}
# ${lastUpdated}
# ${getMapBaseUrl}
# ${srs}
# ${bbox}
# ${workspace}
# ${layers}
# ${styles}
publish_metadata = /<path_to>/resource_dir/result2.json

[Output3]
name = result3
type = image/geotiff;stream
description = WPS Resource Binary Stream
title = This Is A GeoTIFF Layer
filepath = %(workdir)s/srtm_39_04_c.tif
publish_as_layer = true
publish_default_style = raster
publish_target_workspace = it.geosolutions
publish_layer_name = srtm_39_04_c

[Output4]
name = result4
type = application/x-netcdf
description = NetCDF Binary File
title = Wind
filepath = %(workdir)s/RS1_STB_1FSCLS20111003_175545_00000018xS2x_16bxx_83066_29447_wind.nc
backup_on_wps_execution_shared_dir = true
publish_as_layer = true
publish_default_style = raster
publish_target_workspace = it.geosolutions
publish_layer_name = wind
# Such metadata is a JSON snippet itself (/tmp/resource_dir/result3.json) with a small particularity.
# Since you cannot know a-priori some of the final Layer properties,
# you can use inside the json (/tmp/resource_dir/result4.json) some keywords which will be updated
# automatically by the RemoteWPS which are the following ones:
#
# ${type}
# ${name}
# ${title}
# ${description}
# ${lastUpdated}
# ${getMapBaseUrl}
# ${srs}
# ${bbox}
# ${workspace}
# ${layers}
# ${styles}
publish_metadata = /<path_to>/resource_dir/result4.json

# ########################################### #
# GML Possible type values are                #
#  text/xml;subtype=gml/3.1.1                 #
#  text/xml;subtype=gml/2.1.2                 #
#  application/gml-3.1.1                      #
#  application/gml-2.1.2                      #
# ########################################### #
[Output5]
name = result5
type = text/xml;subtype=gml/3.1.1
description = WPS Resource GML
filepath = %(workdir)s/geoserverLoadLayerOutput.xml

[Output6]
name = result6
type = video/mp4
description = Video MP4 Binary File
title = Wind
filepath = %(workdir)s/RS1_STB_1FSCLS20111003_175545_00000018xS2x_16bxx_83066_29447_wind.mp4
backup_on_wps_execution_shared_dir = false

[Output7]
name = result7
type = application/owc
description = WPS OWC Json MapContext
layers_to_publish = result2;result4
publish_as_layer = true
publish_layer_name = owc_json_ctx
publish_metadata = /<path_to>/resource_dir/owc_json_ctx.json

上面的示例表示远程WPS包装器当前支持的所有可能的输出类型。

  • type = string

    filepath 被读取并发送到WPS。geoserver wps将此声明为 text/plain 输出类型。

  • type = image/geotiff

    filepath 被读取并发送到WPS。geoserver wps将此声明为 otput binary 原始文件输出类型。

  • type = image/geotiff;stream

    filepath 被读取并发送到WPS。geoserver wps将此声明为 otput binary 原始流输出类型。

  • type = application/x-netcdf

    由指定的二进制NetCDF的内容 filepath 被读取并发送到WPS。geoserver wps将此声明为 otput binary 原始文件输出类型。

  • type = text/xml;subtype=gml/3.1.1

    filepath 被读取并发送到WPS。geoserver wps将此声明为 text/xml 输出类型。

  • type = video/mp4

    filepath 被读取并发送到WPS。geoserver wps将此声明为 otput binary 原始文件输出类型。

  • type = application/owc

    这是一种特殊类型的输出。从GeoServer WPS的角度来看 text/plain 描述Web映射上下文的JSON输出类型。

    GeoServer端的远程WPS插件负责发布由 layers_to_publish = result2;result4 并呈现由 publish_metadata 每个输出的。

    结果将是一个复杂的JSONWMC,描述要发布的映射。

    要激活此功能,请更新GeoServer remoteProcess.propertiesGEOSERVER_DATA_DIR 有了新的选择:

    # full path to the template used to generate the OWS WMC Json output
    
    owc_wms_json_template = /tmp/resource_dir/wmc_template.json
    

    样品 wmc_template.json

    {
      "type": "FeatureCollection",
      "id": "GeoServer OWC Map Context: version of 2015-07-14",
      "geometry": {
                  "type":"Polygon",
                  "coordinates": ${renderingArea}
        },
        "features" : [
                <#list featureList?keys as key>
                {
                    "type": "Feature",
                    "id": "${featureList[key].name}",
                    "geometry":
                    {
                    "type" : "Polygon",
                    "coordinates" : ${featureList[key].geometryCoords}
                },
                "properties": {
                    <#if featureList[key].owcProperties != "">${featureList[key].owcProperties},</#if>
                    "offerings" : [
                        {
                          "code" : "http://www.opengis.net/spec/owc-atom/1.0/req/wms",
                          "operations" : [{
                              "code" : "GetCapabilities",
                              "method" : "GET",
                              "type" : "application/xml",
                              "href" : "${featureList[key].getMapBaseUrl}?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetCapabilities",
                              "request":{},
                              "result":{}
                            },{
                              "code" : "GetMap",
                              "method" : "GET",
                              "type" : "image/png",
                              "href" : "${featureList[key].getMapBaseUrl}?SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&SRS=${featureList[key].srs}&BBOX=${featureList[key].bbox}&WIDTH=500&HEIGHT=500&LAYERS=${featureList[key].layers}&STYLES=${featureList[key].styles}&FORMAT=image/png&BGCOLOR=0xffffff&TRANSPARENT=TRUE&EXCEPTIONS=application/vnd.ogc.se_xml",
                              "request":{},
                              "result":{}
                            }],
                          "contents" : []
                        }
                    <#if featureList[key].type == "VECTOR">
                        ,{
                          "code" : "http://www.opengis.net/spec/owc-atom/1.0/req/wfs",
                          "operations" : [{
                              "code" : "DescribeFeatureType",
                              "method" : "GET",
                              "type" : "application/xml",
                              "href" : "${featureList[key].getMapBaseUrl}?SERVICE=WFS&VERSION=1.1.0&REQUEST=DescribeFeatureType&TYPENAME=${featureList[key].layers}",
                              "request":{},
                              "result":{}
                            },{
                              "code" : "GetFeature",
                              "method" : "GET",
                              "type" : "application/xml",
                              "href" : "${featureList[key].getMapBaseUrl}?SERVICE=WFS&VERSION=1.1.0&REQUEST=GetFeature&TYPENAME=${featureList[key].layers}",
                              "request":{},
                              "result":{}
                            }],
                          "contents" : []
                        }
                <#elseif featureList[key].type == "RASTER">
                        ,{
                          "code" : "http://www.opengis.net/spec/owc-atom/1.0/req/wcs",
                          "operations" : [{
                              "code" : "DescribeCoverage",
                              "method" : "GET",
                              "type" : "application/xml",
                              "href" : "${featureList[key].getMapBaseUrl}?SERVICE=WCS&VERSION=1.1.0&REQUEST=GetCapabilities&IDENTIFIER=${featureList[key].layers}",
                              "request":{},
                              "result":{}
                            },{
                              "code" : "GetCoverage",
                              "method" : "GET",
                              "type" : "image/tiff",
                              "href" : "${featureList[key].getMapBaseUrl}?SERVICE=WCS&VERSION=1.1.0&REQUEST=GetCoverage&IDENTIFIER=${featureList[key].layers}&BOUNDINGBOX=${featureList[key].bbox}&FORMAT=GeoTIFF",
                              "request":{},
                              "result":{}
                            }],
                          "contents" : []
                        }
                </#if>
                ]
               }
             }<#if key_has_next>,</#if>
         </#list>
         ]
      ,
    
      "properties" : {
                ${owcProperties}
          }
    
    }
    

    样品 owc_json_ctx.json

    "lang" : "en",
    "title" : "Sample Title goes here",
    "subtitle" : "Sample sub-title goes here",
    "generator" : "Sample generator",
    "rights" : "Sample Legal Constraints and CopyRights (C)",
    "authors" : [{"name" : "Author1 Name"}, {"name" : "Author2 Name"}],
    "contributors" : [{"name" : "Contrib1 Name"}, {"name" : "Contrib2 Name"}],
    "categories" : [{
            "term" : "wms",
            "label" : "This file is compliant with version 1.0 of OGC Context"
        },{
            "term" : "maps",
            "label" : "This file contains maps"
    }],
    "links" : [{
            "rel" : "profile",
            "href" : "http://www.opengis.net/spec/owc-atom/1.0/req/core",
            "title" : "This file is compliant with version 1.0 of OGC Context"
        },{
            "rel" : "via",
            "type" : "application/xml",
            "href" : "http://www.opengis.uab.cat/wms/satcat/metadades/EPSG_23031/Cat_20110301.htm",
            "title" : "HMTL metadata in Catalan"
        }]
    

    样品 result#.json

    "title" : "Result 2",
    "updated" : "${lastUpdated}",
    "content" : "Sample Content Description for result 2 goes here",
    "authors" : [
        {
          "name" : "GeoServer Administrator",
          "email" : "info@sample.author.com"
        }
    ],
    "authors" : [{"name" : "Author2.1 Name"}, {"name" : "Author2.2 Name"}],
    "contributors" : [{"name" : "Contrib2.1 Name"}, {"name" : "Contrib2.2 Name"}],
    "categories" : [{"name" : "Category2.1 Name"}, {"name" : "Category2.2 Name"}],
    "links" : [
        {
         "rel" : "enclosure",
         "type" : "image/png",
         "title" : "WMS output for ${title}",
         "href" : "${getMapBaseUrl}?SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&SRS=${srs}&BBOX=${bbox}&WIDTH=500&HEIGHT=500&LAYERS=${layers}&FORMAT=image/png&BGCOLOR=0xffffff&TRANSPARENT=TRUE&EXCEPTIONS=application/vnd.ogc.se_xml"
        },
        {
         "rel" : "icon",
         "type" : "image/png",
         "title" : "Preview for ${title}",
         "href" : "${getMapBaseUrl}?SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&SRS=${srs}&BBOX=${bbox}&WIDTH=100&HEIGHT=100&LAYERS=${layers}&STYLES=${styles}&FORMAT=image/png&BGCOLOR=0xffffff&TRANSPARENT=TRUE&EXCEPTIONS=application/vnd.ogc.se_xml"
        },
        {
         "rel" : "via",
         "type" : "application/vnd.ogc.wms_xml",
         "title" : "Original GetCapabilities document",
         "href" : "${getMapBaseUrl}?SERVICE=WMS&VERSION=1.1.1&REQUEST=GetCapabilities"
        }
    ]
    

其他输出选项

  • backup_on_wps_execution_shared_dir ;这是一个布尔值,它告诉远程WPS首先将结果存储到 共享目录 定义为 [DEFAULT] 在流式输出到GeoServer之前。这允许远程WPS在清除资源时保留结果。

  • upload_data ;这是一个布尔值,它告诉远程WPS首先将结果上载到 host 定义为 [UPLOADER] 在流式输出到GeoServer之前。这允许远程WPS在清除资源时保留结果。

    警告

    如果对某个输出都启用了,则 backup_on_wps_execution_shared_dir 优先于 upload_data 一个。

  • publish_as_layer ;用于指示geoserver远程WPS try 通过GeoServer自动将结果发布为新图层的步骤 进口商 插件。

  • publish_default_style ;发布图层时使用的默认样式。

  • publish_target_workspace ;发布图层时使用的默认工作空间。

  • publish_layer_name ;发布图层时使用的默认名称。

日志记录部分

# ########################################### #
# Logging RegEx and Levels                    #
# ########################################### #

[Logging]
stdout_parser = [.*\[DEBUG\](.*), .*\[INFO\] ProgressInfo\:([-+]?[0-9]*\.?[0-9]*)\%, .*\[(INFO)\](.*), .*\[(WARN)\](.*), .*\[(ERROR)\](.*), .*\[(CRITICAL)\](.*)]
stdout_action = [ignore,          progress,                                          log,              log,              log,               abort]
  • stdout_parser

    此属性必须包含 list 与可能的可执行文件匹配的正则表达式的 STDOUT 记录用户要转发到GeoServer的消息。

    作为一个实例

    .*\[DEBUG\](.*)
    

    匹配包含关键字的所有消息 [DEBUG] 并转发给相应的 stdout_action见下文 )第一个匹配组的内容 (.*)

    在这种情况下 [DEBUG] 被转发到操作。

    另一个例子

    .*\[INFO\] ProgressInfo\:([-+]?[0-9]*\.?[0-9]*)\%
    

    匹配包含关键字的所有消息 [INFO] ProgressInfo:<any_number>% 并转发给相应的 stdout_action见下文 )第一个匹配组的内容 ([-+]?[0-9]*\.?[0-9]*)

    在这种情况下,表达式从文本中提取浮点数和符号 [-+]

  • stdout_action

    此属性必须包含 list特别行动 它将获取相应正则表达式的内容,并将其转发给GeoServer打包的特定XMPP消息。

    作为一个实例

    • 进步 ;获取匹配的内容并发送 PROGRESS 发送给GeoServer的XMPP消息。这个 PROGRESS messgae必须始终包含数字。

    • 中止 ;获取匹配的内容并发送 ABORT 发送给GeoServer的XMPP消息。这将导致GeoServer将WPS进程标记为 FAILED .

    • 忽视 ;只需抛出与相应正则表达式匹配的所有内容。

    • log ;发送 LOG 发送给GeoServer的消息,其中包含匹配的内容。这将显示在GeoServer日志文件中。