本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
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-status。
- 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 開發套件。
- 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-status。
- 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 開發套件。
- 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-status。
- 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 開發套件。
- 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 開發套件。
- 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
}