mirror of
https://github.com/datahub-project/datahub.git
synced 2025-11-02 03:39:03 +00:00
fix(restli): Add docs for get task status, and fix hostname regex (#8341)
Co-authored-by: Indy Prentice <indy@Indys-MacBook-Pro.local>
This commit is contained in:
parent
72a41ef9f6
commit
52c9eb9370
@ -298,6 +298,11 @@ module.exports = {
|
||||
label: "Truncate Timeseries Aspect",
|
||||
id: "docs/api/restli/truncate-time-series-aspect",
|
||||
},
|
||||
{
|
||||
type: "doc",
|
||||
label: "Get ElasticSearch Task Status Endpoint",
|
||||
id: "docs/api/restli/get-elastic-task-status",
|
||||
},
|
||||
{
|
||||
type: "doc",
|
||||
label: "Evaluate Tests",
|
||||
|
||||
50
docs/api/restli/get-elastic-task-status.md
Normal file
50
docs/api/restli/get-elastic-task-status.md
Normal file
@ -0,0 +1,50 @@
|
||||
# Get ElasticSearch Task Status Endpoint
|
||||
|
||||
You can do a HTTP POST request to `/gms/operations?action=getEsTaskStatus` endpoint to see the status of the input task running in ElasticSearch. For example, the task ID given by the [`truncateTimeseriesAspect` endpoint](./truncate-time-series-aspect.md). The task ID can be passed in as a string with node name and task ID separated by a colon (as is output by the previous API), or the node name and task ID parameters separately.
|
||||
|
||||
```
|
||||
curl --location --request POST 'https://demo.datahubproject.io/api/gms/operations?action=getEsTaskStatus' \
|
||||
--header 'Authorization: Bearer TOKEN'
|
||||
--header 'Content-Type: application/json' \
|
||||
--data-raw '{
|
||||
"task": "aB1cdEf2GHIJKLMnoPQr3S:123456"
|
||||
}'
|
||||
|
||||
curl --location --request POST http://localhost:8080/operations\?action\=getEsTaskStatus \
|
||||
--header 'Authorization: Bearer TOKEN'
|
||||
--header 'Content-Type: application/json' \
|
||||
--data-raw '{
|
||||
"nodeId": "aB1cdEf2GHIJKLMnoPQr3S",
|
||||
taskId: 12345
|
||||
}'
|
||||
```
|
||||
|
||||
The output will be a string representing a JSON object with the task status.
|
||||
```
|
||||
{
|
||||
"value": "{\"error\":\"Could not get task status for XIAMx5WySACgg9XxBgaKmw:12587\"}"
|
||||
}
|
||||
```
|
||||
```
|
||||
"{
|
||||
"completed": true,
|
||||
"taskId": "qhxGdzytQS-pQek8CwBCZg:54654",
|
||||
"runTimeNanos": 1179458,
|
||||
"status": "{
|
||||
"total": 0,
|
||||
"updated": 0,
|
||||
"created": 0,
|
||||
"deleted": 0,
|
||||
"batches": 0,
|
||||
"version_conflicts": 0,
|
||||
"noops": 0,
|
||||
"retries": {
|
||||
"bulk": 0,
|
||||
"search": 0
|
||||
},
|
||||
"throttled_millis": 0,
|
||||
"requests_per_second": -1.0,
|
||||
"throttled_until_millis": 0
|
||||
}
|
||||
}
|
||||
```
|
||||
@ -99,7 +99,7 @@ public class OperationsResource extends CollectionResourceTaskTemplate<String, V
|
||||
|
||||
@VisibleForTesting
|
||||
static boolean isTaskIdValid(String task) {
|
||||
if (task.matches("^[a-zA-Z0-9]+:[0-9]+$")) {
|
||||
if (task.matches("^[a-zA-Z0-9-_]+:[0-9]+$")) {
|
||||
try {
|
||||
return Long.parseLong(task.split(":")[1]) != 0;
|
||||
} catch (NumberFormatException e) {
|
||||
|
||||
@ -31,5 +31,8 @@ public class OperationsResourceTest extends TestCase {
|
||||
assertTrue(OperationsResource.isTaskIdValid("aB1cdEf2GHIJKLMnoPQr3S:123456"));
|
||||
assertFalse(OperationsResource.isTaskIdValid("123456:aB1cdEf2GHIJKLMnoPQr3S"));
|
||||
assertFalse(OperationsResource.isTaskIdValid(":123"));
|
||||
// node can have a - in it
|
||||
assertTrue(OperationsResource.isTaskIdValid("qhxGdzytQS-pQek8CwBCZg:54654"));
|
||||
assertTrue(OperationsResource.isTaskIdValid("qhxGdzytQSpQek8CwBCZg_:54654"));
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user