use of com.qlangtech.tis.exec.ExecutePhaseRange in project tis by qlangtech.
the class TisServlet method createNewTask.
/**
* 创建新的task
*
* @param chainContext
* @return taskid
*/
Integer createNewTask(IExecChainContext chainContext) {
Integer workflowId = chainContext.getWorkflowId();
NewTaskParam newTaskParam = new NewTaskParam();
ExecutePhaseRange executeRanage = chainContext.getExecutePhaseRange();
if (chainContext.hasIndexName() || executeRanage.getEnd().bigThan(FullbuildPhase.JOIN)) {
String indexname = chainContext.getIndexName();
newTaskParam.setAppname(indexname);
}
String histroyTaskId = chainContext.getString(IFullBuildContext.KEY_BUILD_HISTORY_TASK_ID);
if (StringUtils.isNotBlank(histroyTaskId)) {
newTaskParam.setHistoryTaskId(Integer.parseInt(histroyTaskId));
}
newTaskParam.setWorkflowid(workflowId);
newTaskParam.setExecuteRanage(executeRanage);
newTaskParam.setTriggerType(TriggerType.MANUAL);
Integer taskid = DagTaskUtils.createNewTask(newTaskParam);
logger.info("create new taskid:" + taskid);
chainContext.setAttribute(IParamContext.KEY_TASK_ID, taskid);
return taskid;
}
use of com.qlangtech.tis.exec.ExecutePhaseRange in project tis by qlangtech.
the class TestTask method testCreateTask.
public void testCreateTask() {
NewTaskParam newTaskParam = new NewTaskParam();
// newTaskParam.setBuildHistoryId(taskId);
String indexname = "search4supplyUnionTabs";
if (StringUtils.isNotBlank(indexname)) {
newTaskParam.setAppname(indexname);
}
newTaskParam.setWorkflowid(15);
ExecutePhaseRange execRange = new ExecutePhaseRange(FullbuildPhase.FullDump, FullbuildPhase.IndexBackFlow);
// (FullbuildPhase.FullDump);
newTaskParam.setExecuteRanage(execRange);
// newTaskParam.setToPhase(FullbuildPhase.IndexBackFlow);
newTaskParam.setTriggerType(TriggerType.MANUAL);
Integer taskid = DagTaskUtils.createNewTask(newTaskParam);
System.out.println(taskid);
}
use of com.qlangtech.tis.exec.ExecutePhaseRange in project plugins by qlangtech.
the class TestLocalDataXJobSubmit method testCreateDataXJob.
public void testCreateDataXJob() throws Exception {
Optional<DataXJobSubmit> dataXJobSubmit = DataXJobSubmit.getDataXJobSubmit(DataXJobSubmit.InstanceType.LOCAL);
Assert.assertTrue("dataXJobSubmit shall present", dataXJobSubmit.isPresent());
LocalDataXJobSubmit jobSubmit = (LocalDataXJobSubmit) dataXJobSubmit.get();
jobSubmit.setMainClassName(LocalDataXJobMainEntrypoint.class.getName());
jobSubmit.setWorkingDirectory(new File("."));
jobSubmit.setClasspath("target/classes:target/test-classes");
AtomicReference<ITISRpcService> ref = new AtomicReference<>();
ref.set(StatusRpcClient.AssembleSvcCompsite.MOCK_PRC);
RpcServiceReference statusRpc = new RpcServiceReference(ref);
DataXJobSubmit.IDataXJobContext dataXJobContext = EasyMock.createMock("dataXJobContext", DataXJobSubmit.IDataXJobContext.class);
IExecChainContext taskContext = EasyMock.createMock("taskContext", IExecChainContext.class);
EasyMock.expect(dataXJobContext.getTaskContext()).andReturn(taskContext).anyTimes();
IDataxProcessor dataxProcessor = EasyMock.createMock("dataxProcessor", IDataxProcessor.class);
EasyMock.expect(taskContext.getIndexName()).andReturn(dataXName).anyTimes();
EasyMock.expect(taskContext.getTaskId()).andReturn(TaskId).anyTimes();
int preSuccessTaskId = 99;
PhaseStatusCollection preSuccessTask = new PhaseStatusCollection(preSuccessTaskId, new ExecutePhaseRange(FullbuildPhase.FullDump, FullbuildPhase.FullDump));
DumpPhaseStatus preDumpStatus = new DumpPhaseStatus(preSuccessTaskId);
DumpPhaseStatus.TableDumpStatus tableDumpStatus = preDumpStatus.getTable(dataXfileName);
tableDumpStatus.setAllRows(LocalDataXJobMainEntrypoint.testAllRows);
preSuccessTask.setDumpPhase(preDumpStatus);
EasyMock.expect(taskContext.loadPhaseStatusFromLatest(dataXName)).andReturn(preSuccessTask).times(3);
TisZkClient zkClient = EasyMock.createMock("TisZkClient", TisZkClient.class);
String zkSubPath = "nodes0000000020";
EasyMock.expect(zkClient.getChildren(ZkUtils.ZK_ASSEMBLE_LOG_COLLECT_PATH, null, true)).andReturn(Collections.singletonList(zkSubPath)).times(3);
EasyMock.expect(zkClient.getData(EasyMock.eq(ZkUtils.ZK_ASSEMBLE_LOG_COLLECT_PATH + "/" + zkSubPath), EasyMock.isNull(), EasyMock.anyObject(Stat.class), EasyMock.eq(true))).andReturn(statusCollectorHost.getBytes(TisUTF8.get())).times(3);
EasyMock.expect(taskContext.getZkClient()).andReturn(zkClient).anyTimes();
EasyMock.replay(taskContext, dataxProcessor, zkClient, dataXJobContext);
IRemoteTaskTrigger dataXJob = jobSubmit.createDataXJob(dataXJobContext, statusRpc, dataxProcessor, dataXfileName);
RunningStatus running = getRunningStatus(dataXJob);
assertTrue("running.isSuccess", running.isSuccess());
jobSubmit.setMainClassName(LocalDataXJobMainEntrypointThrowException.class.getName());
dataXJob = jobSubmit.createDataXJob(dataXJobContext, statusRpc, dataxProcessor, dataXfileName);
running = getRunningStatus(dataXJob);
assertFalse("shall faild", running.isSuccess());
assertTrue("shall complete", running.isComplete());
jobSubmit.setMainClassName(LocalDataXJobMainEntrypointCancellable.class.getName());
dataXJob = jobSubmit.createDataXJob(dataXJobContext, statusRpc, dataxProcessor, dataXfileName);
running = getRunningStatus(dataXJob, false);
Thread.sleep(2000);
dataXJob.cancel();
int i = 0;
while (i++ < 3 && !(running = dataXJob.getRunningStatus()).isComplete()) {
Thread.sleep(1000);
}
assertFalse("shall faild", running.isSuccess());
assertTrue("shall complete", running.isComplete());
EasyMock.verify(taskContext, dataxProcessor, zkClient);
}
use of com.qlangtech.tis.exec.ExecutePhaseRange in project tis by qlangtech.
the class IndexSwapTaskflowLauncher method startWork.
/**
* 由servlet接收到命令之后触发
*
* @param execContext
* @throws Exception
*/
@SuppressWarnings("all")
public ExecuteResult startWork(DefaultChainContext chainContext) throws Exception {
chainContext.rebindLoggingMDCParams();
ActionInvocation invoke = null;
ExecutePhaseRange range = chainContext.getExecutePhaseRange();
logger.info("start component:" + range.getStart() + ",end component:" + range.getEnd());
// chainContext.setZkClient(zkClient);
Objects.requireNonNull(this.zkClient, "zkClient can not be null");
chainContext.setZkClient(this.zkClient);
// chainContext.setZkStateReader(zkStateReader);
// Objects.requireNonNull(chainContext.getIndexBuildFileSystem(), "IndexBuildFileSystem of chainContext can not be null");
// Objects.requireNonNull(chainContext.getTableDumpFactory(), "tableDumpFactory of chainContext can not be null");
// chainContext.setIndexMetaData(createIndexMetaData(chainContext));
invoke = AbstractActionInvocation.createExecChain(chainContext);
ExecuteResult execResult = invoke.invoke();
if (!execResult.isSuccess()) {
logger.warn(execResult.getMessage());
SendSMSUtils.send("[ERR]fulbud:" + chainContext.getIndexName() + " falid," + execResult.getMessage(), SendSMSUtils.BAISUI_PHONE);
}
return execResult;
}
use of com.qlangtech.tis.exec.ExecutePhaseRange in project tis by qlangtech.
the class DefaultChainContext method getExecutePhaseRange.
// public void setTableDumpFactory(TableDumpFactory factory) {
// this.fs2Table = factory;
// }
// @Override
// public IIndexMetaData getIndexMetaData() {
// return this.indexMetaData;
// }
// public void setIndexMetaData(IIndexMetaData indexMetaData) {
// this.indexMetaData = indexMetaData;
// }
@Override
public ExecutePhaseRange getExecutePhaseRange() {
if (this.executePhaseRange == null) {
String start = StringUtils.defaultIfEmpty(this.getString(COMPONENT_START), FullbuildPhase.FullDump.getName());
String end = StringUtils.defaultIfEmpty(this.getString(COMPONENT_END), FullbuildPhase.IndexBackFlow.getName());
this.executePhaseRange = new ExecutePhaseRange(FullbuildPhase.parse(start), FullbuildPhase.parse(end));
}
return this.executePhaseRange;
}
Aggregations