Skip to content

Commit

Permalink
fix #80
Browse files Browse the repository at this point in the history
  • Loading branch information
liangyongrui committed Mar 2, 2020
1 parent 6909330 commit 71e11f4
Show file tree
Hide file tree
Showing 31 changed files with 243 additions and 257 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
package com.xiaomi.thain.common.model.rp

import com.alibaba.fastjson.JSON
import com.xiaomi.thain.common.model.dr.FlowExecutionDr
import java.sql.Timestamp

/**
* flowExecution dr
*
* @author [email protected]
*/
data class FlowExecutionRp(
/**
* 自增id
*/
val id: Long,
/**
* 所属的流程id
*/
val flowId: Long,
/**
* 流程执行状态, 0 等待运行 1 执行中、2 执行结束、3 执行异常
*/
val status: Int,
/**
* 执行机器
*/
val hostInfo: String?,
/**
* 触发类型,1手动,2自动调度
*/
val triggerType: Int,
/**
* 执行变量
*/
val variables: Map<String, Any>,
/**
* 流程执行日志
*/
val logs: String?,
/**
* 创建时间
*/
val createTime: Timestamp?,
/**
* 更新时间
*/
val updateTime: Timestamp?,
/**
* 最近一次心跳时间
*/
val heartbeat: Timestamp?
) {
constructor(o: FlowExecutionDr) : this(
id = o.id,
flowId = o.flowId,
status = o.status,
hostInfo = o.hostInfo,
triggerType = o.triggerType,
variables = JSON.parseObject(o.variables),
logs = o.logs,
createTime = o.createTime,
updateTime = o.updateTime,
heartbeat = o.heartbeat
)

}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.xiaomi.thain.component.annotation

import java.lang.annotation.Inherited

/**
* Thain组件
*
* @author [email protected]
*/
@kotlin.annotation.Retention(AnnotationRetention.RUNTIME)
@Target(AnnotationTarget.ANNOTATION_CLASS, AnnotationTarget.CLASS)
@Inherited
annotation class ThainComponent(val value: String)
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ import java.text.ParseException
* @author [email protected]
* @date 19-5-16 下午8:38
*/

private const val NON_EXIST_FLOW = "flow does not exist:{0}"

class ThainFacade(processEngineConfiguration: ProcessEngineConfiguration,
schedulerEngineConfiguration: SchedulerEngineConfiguration) {

Expand Down Expand Up @@ -124,7 +127,7 @@ class ThainFacade(processEngineConfiguration: ProcessEngineConfiguration,
*
* 返回 flow execution id
*/
fun startFlow(flowId: Long, variables: Map<String, String>, appId: String, username: String): Long {
fun startFlow(flowId: Long, variables: Map<String, Any>, appId: String, username: String): Long {
val id = processEngine.startProcess(flowId, variables)
FlowOperationLogHandler(
flowId = flowId,
Expand Down Expand Up @@ -229,8 +232,4 @@ class ThainFacade(processEngineConfiguration: ProcessEngineConfiguration,
}
}

companion object {
private const val NON_EXIST_FLOW = "flow does not exist:{0}"
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class ProcessEngine(processEngineConfiguration: ProcessEngineConfiguration, val
/**
* 手动触发一次
*/
fun startProcess(flowId: Long, variables: Map<String, String>): Long {
fun startProcess(flowId: Long, variables: Map<String, Any>): Long {
return flowExecutionLoader.startAsync(flowId, variables)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class FlowExecutionLoader(private val processEngineStorage: ProcessEngineStorage
}
}

fun startAsync(flowId: Long, variables: Map<String, String>): Long {
fun startAsync(flowId: Long, variables: Map<String, Any>): Long {
val addFlowExecutionDp = AddFlowExecutionDp(
flowId = flowId,
hostInfo = HostUtils.hostInfo,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,22 +97,22 @@ class FlowExecutor(flowExecutionDr: FlowExecutionDr,
// do down
}
}
executableJobs.forEach { job ->
executableJobs.forEach {
val future = CompletableFuture.runAsync(Runnable {
flowExecutionService.addInfo("Start executing the job [${job.name}]")
flowExecutionService.addInfo("Start executing the job [${it.name}]")
try {
JobExecutor.start(flowExecutionId, job, jobExecutionModelMap[job.id]
JobExecutor.start(flowExecutionId, it, jobExecutionModelMap[it.id]
?: error(""), processEngineStorage)
} catch (e: Exception) {
flowExecutionService.addError("Job[${job.name}] exception: ${ExceptionUtils.getRootCauseMessage(e)}")
flowExecutionService.addError("Job[${it.name}] exception: ${ExceptionUtils.getRootCauseMessage(e)}")
return@Runnable
} catch (e: Throwable) {
processEngineStorage.mailService.sendSeriousError(ThrowableUtils.extractStackTrace(e))
flowExecutionService.addError("Job[${job.name}] exception: ${e.message}")
flowExecutionService.addError("Job[${it.name}] exception: ${e.message}")
return@Runnable
}
flowExecutionService.addInfo("Execute job[${job.name}] complete")
flowExecutionStorage.addFinishJob(job.name)
flowExecutionService.addInfo("Execute job[${it.name}] complete")
flowExecutionStorage.addFinishJob(it.name)
runExecutableJobs()
}, flowExecutionJobThreadPool)
jobFutureQueue.add(future)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,10 @@ import java.util.*
* @author [email protected]
*/

private const val SYSTEM_GROUP = "system"

class SchedulerEngine(schedulerEngineConfiguration: SchedulerEngineConfiguration,
processEngine: ProcessEngine) {
companion object {
private const val SYSTEM_GROUP = "system"
}

private val log = LoggerFactory.getLogger(this.javaClass)!!
private val scheduler: Scheduler
Expand Down
7 changes: 5 additions & 2 deletions thain-fe/src/commonModels/FlowExecutionAllInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@
* can be found in the LICENSE file in the root directory of this source tree.
*/
import { JobModel } from './JobModel';
import { FlowExecutionModel } from './FlowExecutionModel';
import FlowExecutionModel from './FlowExecutionModel';
import { JobExecutionModel } from './JobExecutionModel';

export class FlowExecutionAllInfo {
class FlowExecutionAllInfo {
flowExecutionModel: FlowExecutionModel = new FlowExecutionModel();

jobModelList: JobModel[] = [];

jobExecutionModelList: JobExecutionModel[] = [];
}
export default FlowExecutionAllInfo;
12 changes: 11 additions & 1 deletion thain-fe/src/commonModels/FlowExecutionModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,23 @@
/**
* 数据库中的 thain_flow_execution
*/
export class FlowExecutionModel {
class FlowExecutionModel {
id = 0;

flowId = 0;

status = 0;

hostInfo = '';

triggerType = 0;

variables: { [key: string]: string } | undefined;

logs = '';

createTime = 0;

updateTime = 0;
}
export default FlowExecutionModel;
1 change: 1 addition & 0 deletions thain-fe/src/locales/en-US/flowExecution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export default {
'flow.execution.execution.machine': 'Execution machine',
'flow.execution.create.time': 'Create time',
'flow.execution.update.time': 'Update time',
'flow.execution.variables': 'Variables',
'flow.execution.operation': 'Operation',
'flow.execution.log.detail': 'Log details',
'job.execution.running': 'Running',
Expand Down
1 change: 1 addition & 0 deletions thain-fe/src/locales/zh-CN/flowExecution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export default {
'flow.execution.execution.machine': '执行机器',
'flow.execution.create.time': '创建时间',
'flow.execution.update.time': '更新时间',
'flow.execution.variables': '执行变量',
'flow.execution.status': '作业状态',
'flow.execution.operation': '操作',
'flow.execution.log.detail': '日志详情',
Expand Down
Loading

0 comments on commit 71e11f4

Please sign in to comment.