Search in sources :

Example 1 with ExecutePhaseRange

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;
}
Also used : ExecutePhaseRange(com.qlangtech.tis.exec.ExecutePhaseRange) NewTaskParam(com.qlangtech.tis.manage.common.DagTaskUtils.NewTaskParam)

Example 2 with ExecutePhaseRange

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);
}
Also used : ExecutePhaseRange(com.qlangtech.tis.exec.ExecutePhaseRange) NewTaskParam(com.qlangtech.tis.manage.common.DagTaskUtils.NewTaskParam)

Example 3 with ExecutePhaseRange

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);
}
Also used : DataXJobSubmit(com.qlangtech.tis.datax.DataXJobSubmit) IRemoteTaskTrigger(com.qlangtech.tis.fullbuild.indexbuild.IRemoteTaskTrigger) IDataxProcessor(com.qlangtech.tis.datax.IDataxProcessor) AtomicReference(java.util.concurrent.atomic.AtomicReference) RpcServiceReference(com.tis.hadoop.rpc.RpcServiceReference) DumpPhaseStatus(com.qlangtech.tis.fullbuild.phasestatus.impl.DumpPhaseStatus) IExecChainContext(com.qlangtech.tis.exec.IExecChainContext) PhaseStatusCollection(com.qlangtech.tis.fullbuild.phasestatus.PhaseStatusCollection) RunningStatus(com.qlangtech.tis.fullbuild.indexbuild.RunningStatus) ExecutePhaseRange(com.qlangtech.tis.exec.ExecutePhaseRange) ITISRpcService(com.tis.hadoop.rpc.ITISRpcService) File(java.io.File) TisZkClient(com.qlangtech.tis.TisZkClient)

Example 4 with ExecutePhaseRange

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;
}
Also used : ExecutePhaseRange(com.qlangtech.tis.exec.ExecutePhaseRange) AbstractActionInvocation(com.qlangtech.tis.exec.AbstractActionInvocation) ActionInvocation(com.qlangtech.tis.exec.ActionInvocation) ExecuteResult(com.qlangtech.tis.exec.ExecuteResult)

Example 5 with ExecutePhaseRange

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;
}
Also used : ExecutePhaseRange(com.qlangtech.tis.exec.ExecutePhaseRange)

Aggregations

ExecutePhaseRange (com.qlangtech.tis.exec.ExecutePhaseRange)7 DefaultChainContext (com.qlangtech.tis.exec.impl.DefaultChainContext)2 TestParamContext (com.qlangtech.tis.fullbuild.taskflow.TestParamContext)2 NewTaskParam (com.qlangtech.tis.manage.common.DagTaskUtils.NewTaskParam)2 TisZkClient (com.qlangtech.tis.TisZkClient)1 DataXJobSubmit (com.qlangtech.tis.datax.DataXJobSubmit)1 IDataxProcessor (com.qlangtech.tis.datax.IDataxProcessor)1 AbstractActionInvocation (com.qlangtech.tis.exec.AbstractActionInvocation)1 ActionInvocation (com.qlangtech.tis.exec.ActionInvocation)1 ExecuteResult (com.qlangtech.tis.exec.ExecuteResult)1 IExecChainContext (com.qlangtech.tis.exec.IExecChainContext)1 IDumpTable (com.qlangtech.tis.fullbuild.indexbuild.IDumpTable)1 IRemoteTaskTrigger (com.qlangtech.tis.fullbuild.indexbuild.IRemoteTaskTrigger)1 ITabPartition (com.qlangtech.tis.fullbuild.indexbuild.ITabPartition)1 RunningStatus (com.qlangtech.tis.fullbuild.indexbuild.RunningStatus)1 PhaseStatusCollection (com.qlangtech.tis.fullbuild.phasestatus.PhaseStatusCollection)1 DumpPhaseStatus (com.qlangtech.tis.fullbuild.phasestatus.impl.DumpPhaseStatus)1 TabPartitions (com.qlangtech.tis.sql.parser.TabPartitions)1 ITISRpcService (com.tis.hadoop.rpc.ITISRpcService)1 RpcServiceReference (com.tis.hadoop.rpc.RpcServiceReference)1