use of com.qlangtech.tis.workflow.pojo.WorkFlowBuildHistory in project tis by qlangtech.
the class DefaultChainContext method loadPhaseStatusFromLatest.
@Override
public PhaseStatusCollection loadPhaseStatusFromLatest(String appName) {
Optional<WorkFlowBuildHistory> latestWFSuccessTask = DagTaskUtils.getLatestWFSuccessTaskId(appName);
if (!latestWFSuccessTask.isPresent()) {
return null;
}
WorkFlowBuildHistory h = latestWFSuccessTask.get();
PhaseStatusCollection phaseStatusCollection = IndexSwapTaskflowLauncher.loadPhaseStatusFromLocal(h.getId());
if (phaseStatusCollection == null) {
return null;
}
return phaseStatusCollection;
}
use of com.qlangtech.tis.workflow.pojo.WorkFlowBuildHistory in project tis by qlangtech.
the class TestFullbuildWorkflowAction method testAsynJobExecute.
/**
* 执行异步任务 创建->任务提提交->等待反馈-> 完成
*
* @throws Exception
*/
public void testAsynJobExecute() throws Exception {
FullbuildWorkflowAction.MAX_CAS_RETRY_COUNT = 100;
/**
*=====================================================
* 创建任务
* =======================================================
*/
int taskId = -1;
final int subTaskSize = 20;
try {
String dataxName = "ttt";
request.setParameter("emethod", "createNewTask");
request.setParameter("action", "fullbuild_workflow_action");
request.setParameter(IFullBuildContext.KEY_TRIGGER_TYPE, String.valueOf(TriggerType.MANUAL.getValue()));
request.setParameter(IFullBuildContext.KEY_APP_NAME, dataxName);
ActionProxy proxy = getActionProxy();
this.replay();
String result = proxy.execute();
assertEquals("FullbuildWorkflowAction_ajax", result);
AjaxValve.ActionExecResult aResult = showBizResult();
assertNotNull(aResult);
assertTrue(aResult.isSuccess());
CreateNewTaskResult bizResult = (CreateNewTaskResult) aResult.getBizResult();
assertNotNull(bizResult);
taskId = bizResult.getTaskid();
assertTrue(taskId > 0);
this.verifyAll();
this.setUp();
/**
*======================================================
* 提交异步任务
* ========================================================
*/
request.setParameter("emethod", "taskComplete");
request.setParameter("action", "fullbuild_workflow_action");
request.setParameter(IParamContext.KEY_TASK_ID, String.valueOf(taskId));
request.setParameter(IParamContext.KEY_EXEC_RESULT, String.valueOf(ExecResult.SUCCESS.getValue()));
Set<String> jobs = Sets.newHashSet();
String[] jobsName = new String[subTaskSize];
for (int i = 0; i < subTaskSize; i++) {
jobsName[i] = "customer_order_relation_" + i + ".json";
jobs.add(jobsName[i]);
}
request.setParameter(IParamContext.KEY_ASYN_JOB_NAME, jobsName);
proxy = getActionProxy();
result = proxy.execute();
assertEquals("FullbuildWorkflowAction_ajax", result);
aResult = showBizResult();
assertNotNull(aResult);
assertTrue(aResult.isSuccess());
WorkFlowBuildHistory history = this.runContext.getWorkflowDAOFacade().getWorkFlowBuildHistoryDAO().selectByPrimaryKey(taskId);
assertNotNull("taskid:" + taskId + " relevant history", history);
assertTrue(ExecResult.parse(history.getState()) == ExecResult.ASYN_DOING);
JSONObject subTaskStatus = JSON.parseObject(history.getAsynSubTaskStatus());
assertEquals(subTaskSize, subTaskStatus.keySet().size());
subTaskStatus.forEach((key, val) -> {
assertTrue(jobs.contains(key));
JSONObject s = (JSONObject) val;
assertFalse(key, s.getBoolean(IParamContext.KEY_ASYN_JOB_SUCCESS));
assertFalse(key, s.getBoolean(IParamContext.KEY_ASYN_JOB_COMPLETE));
});
/**
*======================================================
* 等待接收反馈信息
* ========================================================
*/
ExecutorService executorService = Executors.newFixedThreadPool(20);
Throwable[] excep = new Throwable[1];
CountDownLatch countDown = new CountDownLatch(subTaskSize);
final int tskid = taskId;
for (String jobName : jobsName) {
executorService.submit(() -> {
try {
TestFullbuildWorkflowAction subTest = new TestFullbuildWorkflowAction();
subTest.setUp();
subTest.feedbackAsynTaskStatus(tskid, jobName);
subTest.tearDown();
} catch (Throwable e) {
excep[0] = e;
} finally {
countDown.countDown();
}
});
// this.setUp();
// feedbackAsynTaskStatus(tskid, jobName);
}
countDown.await();
if (excep[0] != null) {
throw new RuntimeException(excep[0]);
}
history = this.runContext.getWorkflowDAOFacade().getWorkFlowBuildHistoryDAO().selectByPrimaryKey(taskId);
subTaskStatus = JSON.parseObject(history.getAsynSubTaskStatus());
assertEquals(subTaskSize, subTaskStatus.keySet().size());
subTaskStatus.forEach((key, val) -> {
assertTrue(jobs.contains(key));
JSONObject s = (JSONObject) val;
assertTrue(key, s.getBoolean(IParamContext.KEY_ASYN_JOB_SUCCESS));
assertTrue(key, s.getBoolean(IParamContext.KEY_ASYN_JOB_COMPLETE));
});
assertEquals(ExecResult.SUCCESS, ExecResult.parse(history.getState()));
assertEquals((int) subTaskSize + 1, (int) history.getLastVer());
} finally {
if (taskId > 0) {
this.runContext.getWorkflowDAOFacade().getWorkFlowBuildHistoryDAO().deleteByPrimaryKey(taskId);
}
}
}
use of com.qlangtech.tis.workflow.pojo.WorkFlowBuildHistory in project tis by qlangtech.
the class TestFullbuildWorkflowAction method feedbackAsynTaskStatus.
// public void testFeedbackAsynTaskStatus() throws Exception {
// feedbackAsynTaskStatus(887, "customer_order_relation_7.json");
// while (true) {
// WorkFlowBuildHistory buildHistory = this.runContext.getWorkflowDAOFacade().getWorkFlowBuildHistoryDAO().selectByPrimaryKey(887);
// System.out.println("last_ver:" + buildHistory.getLastVer());
// Thread.sleep(1000);
// }
// }
private void feedbackAsynTaskStatus(int taskId, String jobName) throws Exception {
WorkFlowBuildHistory buildHistory = this.runContext.getWorkflowDAOFacade().getWorkFlowBuildHistoryDAO().selectByPrimaryKey(taskId);
assertNotNull("buildHistory can not be null", buildHistory);
request.setParameter(IParamContext.KEY_REQUEST_DISABLE_TRANSACTION, String.valueOf(true));
request.setParameter("emethod", "feedbackAsynTaskStatus");
request.setParameter("action", "fullbuild_workflow_action");
request.setParameter(IParamContext.KEY_TASK_ID, String.valueOf(taskId));
request.setParameter(IParamContext.KEY_ASYN_JOB_NAME, jobName);
request.setParameter(IParamContext.KEY_ASYN_JOB_SUCCESS, String.valueOf(true));
ActionProxy proxy = getActionProxy();
String result = proxy.execute();
assertEquals("FullbuildWorkflowAction_ajax", result);
AjaxValve.ActionExecResult aResult = showBizResult();
assertNotNull(aResult);
assertTrue(aResult.isSuccess());
}
use of com.qlangtech.tis.workflow.pojo.WorkFlowBuildHistory in project tis by qlangtech.
the class DataxAction method doGetExecStatistics.
@Func(value = PermissionConstant.DATAX_MANAGE, sideEffect = false)
public void doGetExecStatistics(Context context) throws Exception {
WorkFlowBuildHistoryCriteria historyCriteria = new WorkFlowBuildHistoryCriteria();
Date from = ManageUtils.getOffsetDate(-7);
SimpleDateFormat dateFormat = new SimpleDateFormat("MM-dd");
Map<String, DataXExecStatus> execStatis = Maps.newTreeMap();
ExecResult execResult = null;
DataXExecStatus execStatus = null;
String timeLab = null;
for (int i = 0; i < 8; i++) {
timeLab = dateFormat.format(ManageUtils.getOffsetDate(-i));
execStatis.put(timeLab, new DataXExecStatus(timeLab));
}
int successCount = 0;
int errCount = 0;
historyCriteria.createCriteria().andAppIdEqualTo(this.getAppDomain().getAppid()).andCreateTimeGreaterThan(from);
for (WorkFlowBuildHistory h : this.wfDAOFacade.getWorkFlowBuildHistoryDAO().selectByExample(historyCriteria)) {
execResult = ExecResult.parse(h.getState());
execStatus = execStatis.get(dateFormat.format(h.getCreateTime()));
if (execStatus == null) {
continue;
}
if (execResult == ExecResult.SUCCESS) {
execStatus.successCount++;
successCount++;
} else if (execResult == ExecResult.FAILD) {
execStatus.errCount++;
errCount++;
}
}
Map<String, Object> bizResult = Maps.newHashMap();
bizResult.put("data", execStatis.values());
Map<String, Integer> allStatis = Maps.newHashMap();
allStatis.put("errCount", errCount);
allStatis.put("successCount", successCount);
bizResult.put("statis", allStatis);
this.setBizResult(context, bizResult);
}
use of com.qlangtech.tis.workflow.pojo.WorkFlowBuildHistory in project tis by qlangtech.
the class WorkFlowBuildHistoryDAOImpl method deleteByPrimaryKey.
public int deleteByPrimaryKey(Integer id) {
WorkFlowBuildHistory key = new WorkFlowBuildHistory();
key.setId(id);
return this.deleteRecords("work_flow_build_history.ibatorgenerated_deleteByPrimaryKey", key);
}
Aggregations