

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# Neptune openCypher 状态 servlet 和状态端点
<a name="access-graph-opencypher-status"></a>

openCypher 状态端点提供对服务器上当前正在运行或等待运行的查询的相关信息的访问。它还允许您取消这些查询。端点为：

```
https://(the server):(the port number)/openCypher/status
```

您可以使用 HTTP `GET` 和 `POST` 方法从服务器获取当前状态或取消查询。您也可以使用 `DELETE` 方法取消正在运行或等待的查询。

## 状态请求的参数
<a name="access-graph-opencypher-status-parameters"></a>

**状态查询参数**
+ **`includeWaiting`**（`true` 或 `false`）- 当设置为 `true` 且其它参数不存在时，会导致返回等待的查询和正在运行的查询的状态信息。
+ **`cancelQuery`** – 仅与 `GET` 和 `POST` 方法结合使用，以表示这是取消请求。`DELETE` 方法不需要此参数。

  不使用 `cancelQuery` 参数的值，但如果 `cancelQuery` 存在，则需要使用 `queryId` 参数来确定要取消哪个查询。
+ **`queryId`** – 包含特定查询的 ID。

  与 `GET` 或 `POST` 方法结合使用且 `cancelQuery` 参数不存在时，`queryId` 会导致返回其标识的特定查询的状态信息。如果 `cancelQuery` 参数存在，则会取消 `queryId` 标识的特定查询。

  与 `DELETE` 方法结合使用时，`queryId` 始终表示要取消的特定查询。
+ **`silent`** – 仅在取消查询时使用。如果设置为 `true`，则导致取消以静默方式进行。

## 状态请求响应字段
<a name="access-graph-opencypher-status-response-fields"></a>

**如果未提供特定查询的 ID，则为状态响应字段**
+ **acceptedQueryCount**— 已接受但尚未完成的查询数量，包括队列中的查询。
+ **runningQueryCount**— 当前正在运行的 OpenCypher 查询的数量。
+ **queries** – 当前 openCypher 查询的列表。

**特定查询的状态响应字段**
+ **queryId** – 查询的 GUID id。Neptune 为每个查询自动分配该 ID 值，或者您也可以分配自己的 ID（请参阅[将自定义 ID 注入到 Neptune Gremlin 或 SPARQL 查询中](features-query-id.md)）。
+ **queryString** – 提交的查询。在超过 1024 个字符时，将截断为此长度。
+ **queryEvalStats**— 此查询的统计信息：
  + **waited** – 表示查询等待了多长时间，以毫秒为单位。
  + **elapsed** – 到目前为止，查询已运行的毫秒数。
  + **cancelled** – `True` 表示查询已取消，或 `False` 表示尚未取消。

## 状态请求和响应示例
<a name="access-graph-opencypher-status-samples"></a>
+ **请求所有查询的状态，包括正在等待的查询：**

  ```
  curl https://server:port/openCypher/status \
    --data-urlencode "includeWaiting=true"
  ```

  *响应：*

  ```
  {
    "acceptedQueryCount" : 0,
    "runningQueryCount" : 0,
    "queries" : [ ]
  }
  ```
+ **请求正在运行的查询的状态，**不** 包括正在等待的查询：**

  ```
  curl https://server:port/openCypher/status
  ```

  *响应：*

  ```
  {
    "acceptedQueryCount" : 0,
    "runningQueryCount" : 0,
    "queries" : [ ]
  }
  ```
+ **请求单个查询的状态：**

  ```
  curl https://server:port/openCypher/status \
   --data-urlencode "queryId=eadc6eea-698b-4a2f-8554-5270ab17ebee"
  ```

  *响应：*

  ```
  {
    "queryId" : "eadc6eea-698b-4a2f-8554-5270ab17ebee",
    "queryString" : "MATCH (n1)-[:knows]->(n2), (n2)-[:knows]->(n3), (n3)-[:knows]->(n4), (n4)-[:knows]->(n5), (n5)-[:knows]->(n6), (n6)-[:knows]->(n7), (n7)-[:knows]->(n8), (n8)-[:knows]->(n9), (n9)-[:knows]->(n10) RETURN COUNT(n1);",
    "queryEvalStats" : {
      "waited" : 0,
      "elapsed" : 23463,
      "cancelled" : false
    }
  }
  ```
+ **请求取消查询**

  1. 使用 `POST`：

  ```
  curl -X POST https://server:port/openCypher/status \
    --data-urlencode "cancelQuery" \
    --data-urlencode "queryId=f43ce17b-db01-4d37-a074-c76d1c26d7a9"
  ```

  *响应：*

  ```
  {
    "status" : "200 OK",
    "payload" : true
  }
  ```

  2. 使用 `GET`：

  ```
  curl -X GET https://server:port/openCypher/status \
    --data-urlencode "cancelQuery" \
    --data-urlencode "queryId=588af350-cfde-4222-bee6-b9cedc87180d"
  ```

  *响应：*

  ```
  {
    "status" : "200 OK",
    "payload" : true
  }
  ```

  3. 使用 `DELETE`：

  ```
  curl -X DELETE \
    -s "https://server:port/openCypher/status?queryId=b9a516d1-d25c-4301-bb80-10b2743ecf0e"
  ```

  *响应：*

  ```
  {
    "status" : "200 OK",
    "payload" : true
  }
  ```