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;
}
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;
}
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);
}
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();
}
});
}
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);
}
Aggregations