本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
Neptune openCypher 状态 servlet 和状态端点
openCypher 状态端点提供对服务器上当前正在运行或等待运行的查询的相关信息的访问。它还允许您取消这些查询。端点为:
https://(the server):(the port number)/openCypher/status
您可以使用 HTTP GET 和 POST 方法从服务器获取当前状态或取消查询。您也可以使用 DELETE 方法取消正在运行或等待的查询。
状态请求的参数
状态查询参数
-
includeWaiting(true 或 false)- 当设置为 true 且其它参数不存在时,会导致返回等待的查询和正在运行的查询的状态信息。
-
cancelQuery – 仅与 GET 和 POST 方法结合使用,以表示这是取消请求。DELETE 方法不需要此参数。
不使用 cancelQuery 参数的值,但如果 cancelQuery 存在,则需要使用 queryId 参数来确定要取消哪个查询。
-
queryId – 包含特定查询的 ID。
与 GET 或 POST 方法结合使用且 cancelQuery 参数不存在时,queryId 会导致返回其标识的特定查询的状态信息。如果 cancelQuery 参数存在,则会取消 queryId 标识的特定查询。
与 DELETE 方法结合使用时,queryId 始终表示要取消的特定查询。
-
silent – 仅在取消查询时使用。如果设置为 true,则导致取消以静默方式进行。
状态请求响应字段
如果未提供特定查询的 ID,则为状态响应字段
acceptedQueryCount— 已接受但尚未完成的查询数量,包括队列中的查询。
runningQueryCount— 当前正在运行的 OpenCypher 查询的数量。
queries – 当前 openCypher 查询的列表。
特定查询的状态响应字段
queryId – 查询的 GUID id。Neptune 为每个查询自动分配该 ID 值,或者您也可以分配自己的 ID(请参阅将自定义 ID 注入到 Neptune Gremlin 或 SPARQL 查询中)。
queryString – 提交的查询。在超过 1024 个字符时,将截断为此长度。
-
queryEvalStats— 此查询的统计信息:
waited – 表示查询等待了多长时间,以毫秒为单位。
elapsed – 到目前为止,查询已运行的毫秒数。
cancelled – True 表示查询已取消,或 False 表示尚未取消。
状态请求和响应示例
-
请求所有查询的状态,包括正在等待的查询:
- AWS CLI
-
aws neptunedata get-open-cypher-query-status \
--endpoint-url https://your-neptune-endpoint:port \
--include-waiting
有关更多信息,请参阅《 AWS CLI 命令参考》中的 get-open-cypher-query-stat us。
- SDK
-
import boto3
from botocore.config import Config
client = boto3.client(
'neptunedata',
endpoint_url='https://your-neptune-endpoint:port',
config=Config(read_timeout=None, retries={'total_max_attempts': 1})
)
response = client.get_open_cypher_query_status(
includeWaiting=True
)
print(response)
有关其他语言 AWS 的 SDK 示例,请参阅AWS SDK。
- awscurl
-
awscurl https://your-neptune-endpoint:port/openCypher/status \
--region us-east-1 \
--service neptune-db \
-X POST \
-d "includeWaiting=true"
此示例假设您的 AWS 证书是在您的环境中配置的。us-east-1替换为 Neptune 集群的区域。
- curl
-
curl https://your-neptune-endpoint:port/openCypher/status \
--data-urlencode "includeWaiting=true"
响应:
{
"acceptedQueryCount" : 0,
"runningQueryCount" : 0,
"queries" : [ ]
}
-
请求正在运行的查询的状态,不 包括正在等待的查询:
- AWS CLI
-
aws neptunedata get-open-cypher-query-status \
--endpoint-url https://your-neptune-endpoint:port
有关更多信息,请参阅《 AWS CLI 命令参考》中的 get-open-cypher-query-stat us。
- SDK
-
import boto3
from botocore.config import Config
client = boto3.client(
'neptunedata',
endpoint_url='https://your-neptune-endpoint:port',
config=Config(read_timeout=None, retries={'total_max_attempts': 1})
)
response = client.get_open_cypher_query_status()
print(response)
有关其他语言 AWS 的 SDK 示例,请参阅AWS SDK。
- awscurl
-
awscurl https://your-neptune-endpoint:port/openCypher/status \
--region us-east-1 \
--service neptune-db
此示例假设您的 AWS 证书是在您的环境中配置的。us-east-1替换为 Neptune 集群的区域。
- curl
-
curl https://your-neptune-endpoint:port/openCypher/status
响应:
{
"acceptedQueryCount" : 0,
"runningQueryCount" : 0,
"queries" : [ ]
}
-
请求单个查询的状态:
- AWS CLI
-
aws neptunedata get-open-cypher-query-status \
--endpoint-url https://your-neptune-endpoint:port \
--query-id eadc6eea-698b-4a2f-8554-5270ab17ebee
有关更多信息,请参阅《 AWS CLI 命令参考》中的 get-open-cypher-query-stat us。
- SDK
-
import boto3
from botocore.config import Config
client = boto3.client(
'neptunedata',
endpoint_url='https://your-neptune-endpoint:port',
config=Config(read_timeout=None, retries={'total_max_attempts': 1})
)
response = client.get_open_cypher_query_status(
queryId='eadc6eea-698b-4a2f-8554-5270ab17ebee'
)
print(response)
有关其他语言 AWS 的 SDK 示例,请参阅AWS SDK。
- awscurl
-
awscurl https://your-neptune-endpoint:port/openCypher/status \
--region us-east-1 \
--service neptune-db \
-X POST \
-d "queryId=eadc6eea-698b-4a2f-8554-5270ab17ebee"
此示例假设您的 AWS 证书是在您的环境中配置的。us-east-1替换为 Neptune 集群的区域。
- curl
-
curl https://your-neptune-endpoint: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
}
}
-
请求取消查询
- AWS CLI
-
aws neptunedata cancel-open-cypher-query \
--endpoint-url https://your-neptune-endpoint:port \
--query-id f43ce17b-db01-4d37-a074-c76d1c26d7a9
有关更多信息,请参阅《 AWS CLI 命令参考》cancel-open-cypher-query中的。
- SDK
-
import boto3
from botocore.config import Config
client = boto3.client(
'neptunedata',
endpoint_url='https://your-neptune-endpoint:port',
config=Config(read_timeout=None, retries={'total_max_attempts': 1})
)
response = client.cancel_open_cypher_query(
queryId='f43ce17b-db01-4d37-a074-c76d1c26d7a9'
)
print(response)
有关其他语言 AWS 的 SDK 示例,请参阅AWS SDK。
- awscurl
-
awscurl https://your-neptune-endpoint:port/openCypher/status \
--region us-east-1 \
--service neptune-db \
-X POST \
-d "cancelQuery" \
-d "queryId=f43ce17b-db01-4d37-a074-c76d1c26d7a9"
此示例假设您的 AWS 证书是在您的环境中配置的。us-east-1替换为 Neptune 集群的区域。
- curl
-
1. 使用 POST:
curl -X POST https://your-neptune-endpoint:port/openCypher/status \
--data-urlencode "cancelQuery" \
--data-urlencode "queryId=f43ce17b-db01-4d37-a074-c76d1c26d7a9"
2. 使用 GET:
curl -X GET https://your-neptune-endpoint:port/openCypher/status \
--data-urlencode "cancelQuery" \
--data-urlencode "queryId=588af350-cfde-4222-bee6-b9cedc87180d"
3. 使用 DELETE:
curl -X DELETE \
"https://your-neptune-endpoint:port/openCypher/status?queryId=b9a516d1-d25c-4301-bb80-10b2743ecf0e"
响应:
{
"status" : "200 OK",
"payload" : true
}