use of com.qlangtech.tis.fullbuild.indexbuild.IRemoteJobTrigger in project plugins by qlangtech.
the class TestLocalTableDumpAndIndex method startIndexBuild.
public void startIndexBuild(String solrCoreName, IJoinTaskContext execContext, ITISCoordinator zkCoordinator, String timePoint) throws Exception {
LocalIndexBuilderTriggerFactory builderTriggerFactory = new LocalIndexBuilderTriggerFactory();
File localOfflineDir = LocalTableDumpFactory.getLocalOfflineRootDir();
String indexName = ITestDumpCommon.INDEX_COLLECTION;
String groupNum = "0";
Integer taskId = 123;
ITISFileSystem fileSystem = builderTriggerFactory.getFileSystem();
ImportDataProcessInfo buildParam = new ImportDataProcessInfo(taskId, fileSystem, zkCoordinator);
buildParam.setIndexName(indexName);
MockDataSourceFactory employeesDataSource = MockDataSourceFactory.getMockEmployeesDataSource();
List<ColumnMetaData> eployeeTableMeta = employeesDataSource.getTableMetadata(TABLE_EMPLOYEES);
String colsLiteria = eployeeTableMeta.stream().map((c) -> c.getKey()).collect(Collectors.joining(","));
buildParam.setBuildTableTitleItems(colsLiteria);
SnapshotDomain snapshot = com.qlangtech.tis.manage.common.SnapshotDomainUtils.mockEmployeeSnapshotDomain();
snapshot.writeResource2fs(fileSystem, buildParam.getCoreName(Integer.parseInt(groupNum)), ConfigFileReader.FILE_SCHEMA);
snapshot.writeResource2fs(fileSystem, buildParam.getCoreName(Integer.parseInt(groupNum)), ConfigFileReader.FILE_SOLR);
IRemoteJobTrigger buildJob = builderTriggerFactory.createBuildJob(execContext, timePoint, indexName, groupNum, buildParam);
buildJob.submitJob();
/**
* -----------------------------------------------------------
* 开始执行索引build
* -----------------------------------------------------------
*/
TestLocalTableDumpAndIndex.waitJobTerminatorAndAssert(buildJob);
// long hdfsTimeStamp, String hdfsUser, SolrCore core, File indexDir, SolrQueryResponse rsp, String taskId
indexFlowback2SolrEngineNode(solrCoreName, timePoint, localOfflineDir, taskId);
}
use of com.qlangtech.tis.fullbuild.indexbuild.IRemoteJobTrigger in project plugins by qlangtech.
the class LocalTableDumpFactory method triggerTask.
public static IRemoteJobTrigger triggerTask(TaskContext context, ILocalTask task) {
TisZkClient zk = context.getCoordinator().unwrap();
Objects.requireNonNull(zk, "zk(TisZkClient) can not be null");
AtomicReference<Throwable> errRef = new AtomicReference<>();
CountDownLatch countDown = new CountDownLatch(1);
final ExecutorService executor = Executors.newSingleThreadExecutor((r) -> {
Thread t = new Thread(r);
t.setUncaughtExceptionHandler((thread, e) -> {
errRef.set(e);
logger.error(e.getMessage(), e);
countDown.countDown();
});
return t;
});
return new IRemoteJobTrigger() {
@Override
public void submitJob() {
executor.execute(() -> {
RpcServiceReference statusRpc = null;
try {
statusRpc = StatusRpcClient.getService(zk);
task.process(statusRpc);
countDown.countDown();
} catch (Exception e) {
throw new RuntimeException(e);
} finally {
try {
statusRpc.get().close();
} catch (Throwable e) {
}
}
});
}
@Override
public RunningStatus getRunningStatus() {
RunningStatus runningStatus = null;
// 反馈执行状态
if (countDown.getCount() > 0) {
runningStatus = new RunningStatus(0, false, false);
} else {
executor.shutdown();
runningStatus = new RunningStatus(1, true, errRef.get() == null);
}
return runningStatus;
}
};
}
use of com.qlangtech.tis.fullbuild.indexbuild.IRemoteJobTrigger in project plugins by qlangtech.
the class TestLocalTableDumpAndIndex method startDump.
/**
* 单轮 dump测试
*
* @param tableDumpFactory
* @param taskContext
* @throws Exception
*/
private void startDump(LocalTableDumpFactory tableDumpFactory, TaskContext taskContext) throws Exception {
IRemoteJobTrigger singleTableDumpJob = tableDumpFactory.createSingleTableDumpJob(this.getEmployeeTab(), taskContext);
singleTableDumpJob.submitJob();
waitJobTerminatorAndAssert(singleTableDumpJob);
}
Aggregations