Search in sources :

Example 1 with PhaseStatusCollection

use of com.qlangtech.tis.fullbuild.phasestatus.PhaseStatusCollection 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;
}
Also used : PhaseStatusCollection(com.qlangtech.tis.fullbuild.phasestatus.PhaseStatusCollection) WorkFlowBuildHistory(com.qlangtech.tis.workflow.pojo.WorkFlowBuildHistory)

Example 2 with PhaseStatusCollection

use of com.qlangtech.tis.fullbuild.phasestatus.PhaseStatusCollection in project tis by qlangtech.

the class TrackableExecuteInterceptor method getTaskPhaseReference.

public static PhaseStatusCollection getTaskPhaseReference(Integer taskId) {
    PhaseStatusCollection status = taskPhaseReference.get(taskId);
    Objects.requireNonNull(status, "taskId:" + taskId + " relevant status can not be null");
    return status;
}
Also used : PhaseStatusCollection(com.qlangtech.tis.fullbuild.phasestatus.PhaseStatusCollection)

Example 3 with PhaseStatusCollection

use of com.qlangtech.tis.fullbuild.phasestatus.PhaseStatusCollection 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 PhaseStatusCollection

use of com.qlangtech.tis.fullbuild.phasestatus.PhaseStatusCollection in project tis by qlangtech.

the class FullBuildStatCollectorServer method buildPhraseStatus.

@Override
public void buildPhraseStatus(PBuildPhaseStatusParam request, StreamObserver<PPhaseStatusCollection> responseObserver) {
    final int taskid = (int) request.getTaskid();
    logger.info("receive taskid:" + taskid + " ge relevant phaseStatusSet apply");
    final ServerCallStreamObserver<PPhaseStatusCollection> serverCallStreamObserver = (ServerCallStreamObserver<PPhaseStatusCollection>) responseObserver;
    // 先查一下数据库判断该任务是否已经结束
    final AtomicBoolean wasReady = new AtomicBoolean();
    serverCallStreamObserver.setOnReadyHandler(() -> {
        if (serverCallStreamObserver.isReady() && !wasReady.get()) {
            wasReady.set(true);
            // Signal the request sender to send one message. This happens when isReady() turns true, signaling that
            // the receive buffer has enough free space to receive more messages. Calling request() serves to prime
            // the message pump.
            serverCallStreamObserver.request(1);
            PhaseStatusCollection phaseStatusSet = null;
            do {
                phaseStatusSet = TrackableExecuteInterceptor.getTaskPhaseReference(taskid);
                if (phaseStatusSet == null) {
                    phaseStatusSet = IndexSwapTaskflowLauncher.loadPhaseStatusFromLocal(taskid);
                }
            } while (serverCallStreamObserver.isReady() && isStatusNotPresent(phaseStatusSet));
            logger.info("ready to send taskid:" + taskid + "relevant stat info");
            while (serverCallStreamObserver.isReady()) {
                serverCallStreamObserver.onNext(convertPP(phaseStatusSet));
                if (phaseStatusSet.isComplete()) {
                    // 如果已经完成了就立即停止发送消息
                    break;
                }
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                }
            }
            logger.info("stopto monitor taskid:" + taskid + "relevant stat info");
            serverCallStreamObserver.onCompleted();
        }
    });
}
Also used : PhaseStatusCollection(com.qlangtech.tis.fullbuild.phasestatus.PhaseStatusCollection) ServerCallStreamObserver(io.grpc.stub.ServerCallStreamObserver) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean)

Example 5 with PhaseStatusCollection

use of com.qlangtech.tis.fullbuild.phasestatus.PhaseStatusCollection in project tis by qlangtech.

the class IncrStatusUmbilicalProtocolImpl method reportBuildIndexStatus.

@Override
public void reportBuildIndexStatus(com.qlangtech.tis.rpc.grpc.log.common.BuildSharedPhaseStatus buildStatus, StreamObserver<Empty> responseObserver) {
    Integer taskid = buildStatus.getTaskid();
    if (taskid == null) {
        throw new IllegalArgumentException("taskid can not be null");
    }
    PhaseStatusCollection phaseStatusSet = TrackableExecuteInterceptor.getTaskPhaseReference(taskid);
    if (phaseStatusSet == null) {
        log.warn("taskid:" + taskid + " relevent phaseStatusSet is null");
        returnEmpty(responseObserver);
        return;
    }
    BuildPhaseStatus status = phaseStatusSet.getBuildPhase();
    BuildSharedPhaseStatus sharedBuildStatus = status.getBuildSharedPhaseStatus(buildStatus.getSharedName());
    if (!sharedBuildStatus.isFaild()) {
        sharedBuildStatus.setFaild(buildStatus.getFaild());
    }
    if (!sharedBuildStatus.isComplete()) {
        sharedBuildStatus.setComplete(buildStatus.getComplete());
    }
    if (sharedBuildStatus.isWaiting()) {
        sharedBuildStatus.setWaiting(buildStatus.getWaiting());
    }
    sharedBuildStatus.setAllBuildSize(buildStatus.getAllBuildSize());
    sharedBuildStatus.setBuildReaded(buildStatus.getBuildReaded());
    status.isComplete();
    returnEmpty(responseObserver);
}
Also used : PhaseStatusCollection(com.qlangtech.tis.fullbuild.phasestatus.PhaseStatusCollection) BuildSharedPhaseStatus(com.qlangtech.tis.fullbuild.phasestatus.impl.BuildSharedPhaseStatus) BuildPhaseStatus(com.qlangtech.tis.fullbuild.phasestatus.impl.BuildPhaseStatus)

Aggregations

PhaseStatusCollection (com.qlangtech.tis.fullbuild.phasestatus.PhaseStatusCollection)14 DumpPhaseStatus (com.qlangtech.tis.fullbuild.phasestatus.impl.DumpPhaseStatus)5 BuildPhaseStatus (com.qlangtech.tis.fullbuild.phasestatus.impl.BuildPhaseStatus)2 File (java.io.File)2 JSONObject (com.alibaba.fastjson.JSONObject)1 TisZkClient (com.qlangtech.tis.TisZkClient)1 FullbuildPhase (com.qlangtech.tis.assemble.FullbuildPhase)1 DataXJobSubmit (com.qlangtech.tis.datax.DataXJobSubmit)1 IDataxProcessor (com.qlangtech.tis.datax.IDataxProcessor)1 ExecutePhaseRange (com.qlangtech.tis.exec.ExecutePhaseRange)1 IExecChainContext (com.qlangtech.tis.exec.IExecChainContext)1 DefaultChainContext (com.qlangtech.tis.exec.impl.DefaultChainContext)1 Describable (com.qlangtech.tis.extension.Describable)1 XmlFile (com.qlangtech.tis.extension.impl.XmlFile)1 IRemoteTaskTrigger (com.qlangtech.tis.fullbuild.indexbuild.IRemoteTaskTrigger)1 RunningStatus (com.qlangtech.tis.fullbuild.indexbuild.RunningStatus)1 JobLog (com.qlangtech.tis.fullbuild.phasestatus.JobLog)1 BuildSharedPhaseStatus (com.qlangtech.tis.fullbuild.phasestatus.impl.BuildSharedPhaseStatus)1 TableDumpStatus (com.qlangtech.tis.fullbuild.phasestatus.impl.DumpPhaseStatus.TableDumpStatus)1 IndexBackFlowPhaseStatus (com.qlangtech.tis.fullbuild.phasestatus.impl.IndexBackFlowPhaseStatus)1