Skip to content

Commit c6e38ac

Browse files
aiceflowerv-kkhuangcasionone
authored
#AI commit# 优化: AI规约文档提交,Linkis日志打印优化 (#5374)
Co-authored-by: v-kkhuang <420895376@qq.com> Co-authored-by: Casion <casionone@gmail.com>
1 parent 2937222 commit c6e38ac

27 files changed

Lines changed: 12522 additions & 391 deletions

File tree

.ai/README.md

Lines changed: 188 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,188 @@
1+
# Linkis AI 开发文档导航
2+
3+
> **版本信息**
4+
> - 文档版本: 1.0.0
5+
> - 最后更新: 2025-01-28
6+
> - 适用版本: Apache Linkis 1.17.0+
7+
8+
---
9+
10+
## 🚀 快速开始
11+
12+
### 新手必读(按顺序阅读)
13+
1. **[项目核心规约](./project-context.md)** - 包含技术栈、架构设计、开发规范和模板
14+
2. **[强制性开发规则](./rules.md)** - 必须无条件遵守的开发规则
15+
3. **[模块文档](#模块文档索引)** - 根据你要开发的功能选择对应模块
16+
17+
### 常见开发场景快速跳转
18+
- 🆕 新增 REST 接口 → [REST接口开发模板](#rest接口开发)
19+
- ⚙️ 添加配置项 → [配置管理规范](#配置管理)
20+
- 🗄️ 修改数据库 → [数据库变更规范](#数据库变更)
21+
- 🐛 异常处理 → [异常处理规范](#异常处理)
22+
- 📝 日志记录 → [日志规范](#日志规范)
23+
24+
---
25+
26+
## 📚 核心文档索引
27+
28+
### 🎯 开发规范文档
29+
| 文档 | 用途 | 何时查看 |
30+
|------|------|----------|
31+
| [project-context.md](./project-context.md) | 项目角色定位、技术栈、架构设计、开发模板 | 开始任何开发工作前必读 |
32+
| [rules.md](./rules.md) | 强制性开发规则、需求实现步骤 | 每次开发新需求时参考 |
33+
34+
### 🏗️ 模块文档索引
35+
36+
#### 微服务治理服务(基础设施层)
37+
| 服务 | 文档 | 主要功能 |
38+
|------|------|----------|
39+
| Gateway | [gateway.md](./modules/microservice-governance/gateway.md) | API网关、路由转发、安全认证 |
40+
| Eureka | [eureka.md](./modules/microservice-governance/eureka.md) | 服务注册与发现 |
41+
| 概览 | [README.md](./modules/microservice-governance/README.md) | 微服务治理服务概述 |
42+
43+
#### 计算治理服务(核心业务层)
44+
| 服务 | 文档 | 主要功能 |
45+
|------|------|----------|
46+
| Entrance | [entrance.md](./modules/computation-governance/entrance.md) | 任务提交入口、调度管理 |
47+
| JobHistory | [jobhistory.md](./modules/computation-governance/jobhistory.md) | 任务历史记录查询 |
48+
| Manager | [manager.md](./modules/computation-governance/manager.md) | 资源管理、应用管理 |
49+
| ECM | [ecm.md](./modules/computation-governance/ecm.md) | 引擎连接管理 |
50+
| 概览 | [README.md](./modules/computation-governance/README.md) | 计算治理服务概述 |
51+
52+
#### 公共增强服务(支撑服务层)
53+
| 服务 | 文档 | 主要功能 |
54+
|------|------|----------|
55+
| PublicService | [publicservice.md](./modules/public-enhancements/publicservice.md) | 公共服务、文件管理 |
56+
| Configuration | [configuration.md](./modules/public-enhancements/configuration.md) | 配置管理 |
57+
| BML | [bml.md](./modules/public-enhancements/bml.md) | 大数据物料库 |
58+
| DataSource | [datasource.md](./modules/public-enhancements/datasource.md) | 数据源管理 |
59+
| Context | [context.md](./modules/public-enhancements/context.md) | 上下文服务 |
60+
| Monitor | [monitor.md](./modules/public-enhancements/monitor.md) | 监控服务 |
61+
| 概览 | [README.md](./modules/public-enhancements/README.md) | 公共增强服务概述 |
62+
63+
---
64+
65+
## 🔍 按功能快速查找
66+
67+
### <a name="rest接口开发"></a>REST接口开发
68+
- **开发模板**: [project-context.md - REST接口层](./project-context.md#1-rest接口层)
69+
- **API规范**: [project-context.md - API设计规范](./project-context.md#api设计规范)
70+
- **参考示例**:
71+
- Entrance接口: [entrance.md - API Interfaces](./modules/computation-governance/entrance.md#api-interfaces)
72+
- Configuration接口: [configuration.md - API Interfaces](./modules/public-enhancements/configuration.md#api-interfaces)
73+
74+
### <a name="配置管理"></a>配置管理
75+
- **配置规范**: [project-context.md - 配置管理规范](./project-context.md#配置管理规范)
76+
- **配置示例库**: [project-context.md - 常用配置示例库](./project-context.md#常用配置示例库)
77+
- **配置模板**: [project-context.md - 配置类](./project-context.md#4-配置类)
78+
- **参考实现**: linkis-jobhistory/conf/JobhistoryConfiguration
79+
80+
### <a name="数据库变更"></a>数据库变更
81+
- **变更规则**: [rules.md - 数据库修改原则](./rules.md#数据库修改原则)
82+
- **DDL脚本位置**: `linkis-dist/package/db/linkis_ddl.sql`
83+
- **DML脚本位置**: `linkis-dist/package/db/linkis_dml.sql`
84+
- **表结构参考**: 各模块文档的 "Database Table Structures" 章节
85+
86+
### <a name="异常处理"></a>异常处理
87+
- **异常规范**: [project-context.md - 异常处理规范](./project-context.md#异常处理规范)
88+
- **统一异常**: `org.apache.linkis.common.exception.LinkisException`
89+
- **常见错误**: [project-context.md - 常见错误及避免方法](./project-context.md#常见错误及避免方法)
90+
91+
### <a name="日志规范"></a>日志规范
92+
- **日志规范**: [project-context.md - 日志规范](./project-context.md#日志规范)
93+
- **Logger定义**: 必须使用 `LoggerFactory.getLogger(ClassName.class)`
94+
- **日志级别**: ERROR/WARN/INFO/DEBUG 使用场景
95+
96+
---
97+
98+
## 🎨 开发模板快速复制
99+
100+
### 新增功能完整流程
101+
```
102+
1. 查看 rules.md - 需求实现步骤
103+
2. 创建需求文档和设计文档
104+
3. 使用 project-context.md 中的代码模板:
105+
- REST接口层模板
106+
- 服务层模板
107+
- 数据访问层模板
108+
- 配置类模板
109+
4. 添加功能开关(默认false)
110+
5. 记录数据库变更
111+
6. 编写测试和文档
112+
```
113+
114+
### REST接口模板快速链接
115+
👉 [project-context.md - 新功能开发模板](./project-context.md#新功能开发模板)
116+
117+
### 配置类模板快速链接
118+
👉 [project-context.md - 配置类](./project-context.md#4-配置类)
119+
120+
---
121+
122+
## ⚠️ 重要提醒
123+
124+
### 🚫 禁止操作(来自 rules.md)
125+
- **数据库结构**: 除非明确指定,严禁修改现有表结构
126+
- **第三方依赖**: 不允许引入新的第三方依赖库
127+
- **核心接口**: 不得修改现有公共接口的签名
128+
129+
### ✅ 必须遵守
130+
- **最小改动原则**: 所有功能实现必须遵循最小改动原则
131+
- **功能可配置**: 所有功能必须增加功能开关,默认关闭
132+
- **向后兼容**: 新增功能必须考虑向后兼容性
133+
134+
---
135+
136+
## 💡 开发技巧
137+
138+
### 编程语言选择
139+
- **Java**: REST API、Service层、Entity类、配置类
140+
- **Scala**: 计算逻辑、RPC通信、复杂业务处理、配置对象
141+
142+
### 字符编码
143+
统一使用 `StandardCharsets.UTF_8`,禁止使用字符串 `"UTF-8"`
144+
145+
### 统一返回体
146+
所有REST接口返回 `org.apache.linkis.server.Message`
147+
148+
---
149+
150+
## 📖 如何使用这些文档
151+
152+
### 场景1: 我要在 Entrance 服务中新增一个接口
153+
1. 阅读 [entrance.md](./modules/computation-governance/entrance.md) 了解服务结构
154+
2. 查看 [project-context.md - REST接口层模板](./project-context.md#1-rest接口层)
155+
3. 参考 entrance.md 中现有接口实现
156+
4. 遵循 [rules.md](./rules.md) 中的开发规则
157+
5. 添加功能开关配置
158+
159+
### 场景2: 我需要添加一个新的配置项
160+
1. 查看 [project-context.md - 配置管理规范](./project-context.md#配置管理规范)
161+
2. 参考 [project-context.md - 配置类模板](./project-context.md#4-配置类)
162+
3. 查看 `JobhistoryConfiguration` 实现示例
163+
4. 在当前模块的 conf 目录下的 Configuration 类中添加
164+
165+
### 场景3: 我需要修改数据库表
166+
1. 查看 [rules.md - 数据库修改原则](./rules.md#数据库修改原则)
167+
2. 确认是否能通过新增字段实现(优先选择)
168+
3. 将变更记录到 `linkis-dist/package/db/linkis_ddl.sql`
169+
4. 如有初始化数据,记录到 `linkis-dist/package/db/linkis_dml.sql`
170+
171+
---
172+
173+
## 🔄 文档更新记录
174+
175+
| 版本 | 日期 | 更新内容 | 更新人 |
176+
|------|------|----------|--------|
177+
| 1.0.0 | 2025-01-28 | 创建导航文档,优化文档结构 | AI |
178+
179+
---
180+
181+
## 📞 帮助与反馈
182+
183+
如果文档中有不清楚的地方,请:
184+
1. 先查看对应模块的详细文档
185+
2. 查看 project-context.md 中的开发模板和示例
186+
3. 参考现有代码实现
187+
188+
**记住**: 遵循规范比快速开发更重要!
Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
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

Comments
 (0)