|
| 1 | +# Computation Governance Services |
| 2 | + |
| 3 | +The computation governance services handle the core computation task lifecycle management in Linkis. |
| 4 | + |
| 5 | +## Service Modules |
| 6 | + |
| 7 | +- [Entrance Service](./entrance.md) - Task submission and entrance point |
| 8 | +- [Manager Service](./manager.md) - Resource and application management |
| 9 | +- [ECM Service](./ecm.md) - Engine Connection Manager |
| 10 | +- [JobHistory Service](./jobhistory.md) - Task execution history tracking |
| 11 | + |
| 12 | +## Overview |
| 13 | + |
| 14 | +These services form the core of Linkis' computation governance capabilities, managing the complete lifecycle of computation tasks from submission to execution and monitoring. |
| 15 | + |
| 16 | +## Common Features |
| 17 | + |
| 18 | +### Task Lifecycle Management |
| 19 | +- Task submission and validation |
| 20 | +- Task scheduling and resource allocation |
| 21 | +- Task execution monitoring |
| 22 | +- Task result management |
| 23 | +- Task error handling and recovery |
| 24 | + |
| 25 | +### Engine Management |
| 26 | +- Dynamic engine connection creation |
| 27 | +- Engine lifecycle management |
| 28 | +- Engine resource monitoring |
| 29 | +- Engine scaling capabilities |
| 30 | + |
| 31 | +### Resource Governance |
| 32 | +- Multi-tenant resource isolation |
| 33 | +- Load balancing across engines |
| 34 | +- Resource usage tracking |
| 35 | +- Quota management |
| 36 | + |
| 37 | +## API Interface Summary |
| 38 | + |
| 39 | +### Entrance Service APIs |
| 40 | +- Task submission: `POST /api/entrance/submit` |
| 41 | +- Task status query: `GET /api/entrance/{id}/status` |
| 42 | +- Task progress: `GET /api/entrance/{id}/progress` |
| 43 | +- Task log retrieval: `GET /api/entrance/{id}/log` |
| 44 | +- Task cancellation: `GET /api/entrance/{id}/kill` |
| 45 | + |
| 46 | +### Manager Service APIs |
| 47 | +- Engine instance management |
| 48 | +- Resource allocation and monitoring |
| 49 | +- Node status querying |
| 50 | +- Engine creation requests |
| 51 | + |
| 52 | +### ECM Service APIs |
| 53 | +- Engine connection management |
| 54 | +- Engine lifecycle operations |
| 55 | +- Resource reporting |
| 56 | +- Engine metrics collection |
| 57 | + |
| 58 | +### JobHistory Service APIs |
| 59 | +- Job history querying |
| 60 | +- Job detail retrieval |
| 61 | +- Job statistics reporting |
| 62 | + |
| 63 | +## Database Schema Summary |
| 64 | + |
| 65 | +### Job History Group Table |
| 66 | +```sql |
| 67 | +CREATE TABLE `linkis_ps_job_history_group_history` ( |
| 68 | + `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'Primary Key, auto increment', |
| 69 | + `job_req_id` varchar(64) DEFAULT NULL COMMENT 'job execId', |
| 70 | + `submit_user` varchar(50) DEFAULT NULL COMMENT 'who submitted this Job', |
| 71 | + `execute_user` varchar(50) DEFAULT NULL COMMENT 'who actually executed this Job', |
| 72 | + `source` text DEFAULT NULL COMMENT 'job source', |
| 73 | + `labels` text DEFAULT NULL COMMENT 'job labels', |
| 74 | + `params` text DEFAULT NULL COMMENT 'job params', |
| 75 | + `progress` varchar(32) DEFAULT NULL COMMENT 'Job execution progress', |
| 76 | + `status` varchar(50) DEFAULT NULL COMMENT 'Script execution status, must be one of the following: Inited, WaitForRetry, Scheduled, Running, Succeed, Failed, Cancelled, Timeout', |
| 77 | + `log_path` varchar(200) DEFAULT NULL COMMENT 'File path of the job log', |
| 78 | + `error_code` int DEFAULT NULL COMMENT 'Error code. Generated when the execution of the script fails', |
| 79 | + `error_desc` varchar(1000) DEFAULT NULL COMMENT 'Execution description. Generated when the execution of script fails', |
| 80 | + `created_time` datetime(3) DEFAULT CURRENT_TIMESTAMP(3) COMMENT 'Creation time', |
| 81 | + `updated_time` datetime(3) DEFAULT CURRENT_TIMESTAMP(3) COMMENT 'Update time', |
| 82 | + `instances` varchar(250) DEFAULT NULL COMMENT 'Entrance instances', |
| 83 | + `metrics` text DEFAULT NULL COMMENT 'Job Metrics', |
| 84 | + `engine_type` varchar(32) DEFAULT NULL COMMENT 'Engine type', |
| 85 | + `execution_code` text DEFAULT NULL COMMENT 'Job origin code or code path', |
| 86 | + `result_location` varchar(500) DEFAULT NULL COMMENT 'File path of the resultsets', |
| 87 | + `observe_info` varchar(500) DEFAULT NULL COMMENT 'The notification information configuration of this job', |
| 88 | + PRIMARY KEY (`id`), |
| 89 | + KEY `idx_created_time` (`created_time`), |
| 90 | + KEY `idx_submit_user` (`submit_user`) |
| 91 | +); |
| 92 | +``` |
| 93 | + |
| 94 | +### Job History Detail Table |
| 95 | +```sql |
| 96 | +CREATE TABLE `linkis_ps_job_history_detail` ( |
| 97 | + `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'Primary Key, auto increment', |
| 98 | + `job_history_id` bigint(20) NOT NULL COMMENT 'ID of JobHistory', |
| 99 | + `result_location` varchar(500) DEFAULT NULL COMMENT 'File path of the resultsets', |
| 100 | + `execution_content` text DEFAULT NULL COMMENT 'The script code or other execution content executed by this Job', |
| 101 | + `result_array_size` int(4) DEFAULT 0 COMMENT 'size of result array', |
| 102 | + `job_group_info` text DEFAULT NULL COMMENT 'Job group info/path', |
| 103 | + `created_time` datetime(3) DEFAULT CURRENT_TIMESTAMP(3) COMMENT 'Creation time', |
| 104 | + `updated_time` datetime(3) DEFAULT CURRENT_TIMESTAMP(3) COMMENT 'Update time', |
| 105 | + `status` varchar(32) DEFAULT NULL COMMENT 'status', |
| 106 | + `priority` int(4) DEFAULT 0 COMMENT 'order of subjob', |
| 107 | + PRIMARY KEY (`id`) |
| 108 | +); |
| 109 | +``` |
| 110 | + |
| 111 | +### Common Lock Table |
| 112 | +```sql |
| 113 | +CREATE TABLE `linkis_ps_common_lock` ( |
| 114 | + `id` int(11) NOT NULL AUTO_INCREMENT, |
| 115 | + `lock_object` varchar(255) COLLATE utf8_bin DEFAULT NULL, |
| 116 | + `locker` VARCHAR(255) CHARSET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT 'locker', |
| 117 | + `time_out` longtext COLLATE utf8_bin, |
| 118 | + `update_time` datetime DEFAULT CURRENT_TIMESTAMP, |
| 119 | + `create_time` datetime DEFAULT CURRENT_TIMESTAMP, |
| 120 | + PRIMARY KEY (`id`), |
| 121 | + UNIQUE KEY `uniq_lock_object` (`lock_object`) |
| 122 | +); |
| 123 | +``` |
| 124 | + |
| 125 | +## RPC Methods Summary |
| 126 | + |
| 127 | +### Entrance Service RPCs |
| 128 | +- `submitTask(TaskRequest request)` |
| 129 | +- `getTaskStatus(String taskId)` |
| 130 | +- `cancelTask(String taskId)` |
| 131 | +- `getTaskResult(String taskId)` |
| 132 | + |
| 133 | +### Manager Service RPCs |
| 134 | +- `requestEngine(EngineRequest request)` |
| 135 | +- `releaseEngine(String engineId)` |
| 136 | +- `getEngineStatus(String engineId)` |
| 137 | +- `getNodeMetrics(String nodeId)` |
| 138 | + |
| 139 | +### ECM Service RPCs |
| 140 | +- `createEngineConnection(EngineCreateRequest request)` |
| 141 | +- `terminateEngineConnection(String engineId)` |
| 142 | +- `reportEngineResourceUsage(String engineId, ResourceUsage usage)` |
| 143 | +- `getEngineMetrics(String engineId)` |
| 144 | + |
| 145 | +### JobHistory Service RPCs |
| 146 | +- `saveJobHistory(JobHistory history)` |
| 147 | +- `queryJobHistory(JobHistoryQuery query)` |
| 148 | +- `getJobDetails(Long jobId)` |
| 149 | +- `updateJobStatus(Long jobId, String status)` |
| 150 | + |
| 151 | +## Dependencies |
| 152 | + |
| 153 | +- linkis-commons - Shared utilities |
| 154 | +- linkis-protocol - Communication protocols |
| 155 | +- linkis-rpc - Remote procedure calls |
| 156 | +- Various engine connection plugins |
| 157 | +- Spring Cloud ecosystem |
0 commit comments