Linkis Task submission and execution Rest API document

  • The return of the Linkis Restful interface follows the following standard return format:
  1. {
  2. "method": "",
  3. "status": 0,
  4. "message": "",
  5. "data": {}
  6. }

Convention:

  • method: Returns the requested Restful API URI, which is mainly used in WebSocket mode.
  • status: return status information, where: -1 means no login, 0 means success, 1 means error, 2 means verification failed, 3 means no access to the interface.
  • data: return specific data.
  • message: return the requested prompt message. If the status is not 0, the message returned is an error message, and the data may have a stack field, which returns specific stack information.

For more information about the Linkis Restful interface specification, please refer to: Linkis Restful Interface Specification

1. Submit for Execution

  • Interface /api/rest_j/v1/entrance/execute

  • Submission method POST

  1. {
  2. "executeApplicationName": "hive", //Engine type
  3. "requestApplicationName": "dss", //Client service type
  4. "executionCode": "show tables",
  5. "params": {"variable": {}, "configuration": {}},
  6. "runType": "hql", //The type of script to run
  7. "source": {"scriptPath":"file:///tmp/hadoop/1.hql"}
  8. }
  • Interface /api/rest_j/v1/entrance/submit

  • Submission method POST

  1. {
  2. "executionContent": {"code": "show tables", "runType": "sql"},
  3. "params": {"variable": {}, "configuration": {}},
  4. "source": {"scriptPath": "file:///mnt/bdp/hadoop/1.hql"},
  5. "labels": {
  6. "engineType": "spark-2.4.3",
  7. "userCreator": "hadoop-IDE"
  8. }
  9. }

-Return to example

  1. {
  2. "method": "/api/rest_j/v1/entrance/execute",
  3. "status": 0,
  4. "message": "Request executed successfully",
  5. "data": {
  6. "execID": "030418IDEhivebdpdwc010004:10087IDE_hadoop_21",
  7. "taskID": "123"
  8. }
  9. }
  • execID is the unique identification execution ID generated for the task after the user task is submitted to Linkis. It is of type String. This ID is only useful when the task is running, similar to the concept of PID. The design of ExecID is (requestApplicationName length)(executeAppName length)(Instance length)${requestApplicationName}${executeApplicationName}${entranceInstance information ip+port}${requestApplicationName}_${umUser}_${index}

  • taskID is the unique ID that represents the task submitted by the user. This ID is generated by the database self-increment and is of Long type

2. Get Status

  • Interface /api/rest_j/v1/entrance/${execID}/status

  • Submission method GET

  • Return to example

  1. {
  2. "method": "/api/rest_j/v1/entrance/{execID}/status",
  3. "status": 0,
  4. "message": "Get status successful",
  5. "data": {
  6. "execID": "${execID}",
  7. "status": "Running"
  8. }
  9. }

3. Get Logs

  • Interface /api/rest_j/v1/entrance/${execID}/log?fromLine=${fromLine}&size=${size}

  • Submission method GET

  • The request parameter fromLine refers to the number of lines from which to get, and size refers to the number of lines of logs that this request gets

  • Return example, where the returned fromLine needs to be used as a parameter for the next request of this interface

  1. {
  2. "method": "/api/rest_j/v1/entrance/${execID}/log",
  3. "status": 0,
  4. "message": "Return log information",
  5. "data": {
  6. "execID": "${execID}",
  7. "log": ["error log","warn log","info log", "all log"],
  8. "fromLine": 56
  9. }
  10. }

4. Get Progress

  • Interface /api/rest_j/v1/entrance/${execID}/progress

  • Submission method GET

  • Return to example

  1. {
  2. "method": "/api/rest_j/v1/entrance/{execID}/progress",
  3. "status": 0,
  4. "message": "Return progress information",
  5. "data": {
  6. "execID": "${execID}",
  7. "progress": 0.2,
  8. "progressInfo": [
  9. {
  10. "id": "job-1",
  11. "succeedTasks": 2,
  12. "failedTasks": 0,
  13. "runningTasks": 5,
  14. "totalTasks": 10
  15. },
  16. {
  17. "id": "job-2",
  18. "succeedTasks": 5,
  19. "failedTasks": 0,
  20. "runningTasks": 5,
  21. "totalTasks": 10
  22. }
  23. ]
  24. }
  25. }

5. Kill Task

  • Interface /api/rest_j/v1/entrance/${execID}/kill

  • Submission method POST

  1. {
  2. "method": "/api/rest_j/v1/entrance/{execID}/kill",
  3. "status": 0,
  4. "message": "OK",
  5. "data": {
  6. "execID":"${execID}"
  7. }
  8. }