Search in sources :

Example 1 with IndexBuilderTriggerFactory

use of com.qlangtech.tis.offline.IndexBuilderTriggerFactory in project plugins by qlangtech.

the class LocalIndexBuilderTriggerFactory method createBuildJob.

/**
 * 执行索引触发任务
 *
 * @param timePoint
 * @param indexName
 * @param groupNum
 * @param buildParam
 * @return
 * @throws Exception
 */
@Override
public IRemoteJobTrigger createBuildJob(IJoinTaskContext execContext, String timePoint, String indexName, String groupNum, IIndexBuildParam buildParam) throws Exception {
    String coreName = buildParam.getCoreName(Integer.parseInt(groupNum));
    Map<String, String> params = Maps.newHashMap();
    params.put(IndexBuildParam.INDEXING_BUILD_TABLE_TITLE_ITEMS, buildParam.getBuildTableTitleItems());
    params.put(IndexBuildParam.JOB_TYPE, IndexBuildParam.JOB_TYPE_INDEX_BUILD);
    params.put(IndexBuildParam.INDEXING_MAX_DOC_FAILD_LIMIT, "100");
    ITISFileSystem fs = this.getFileSystem();
    params.put(IndexBuildParam.INDEXING_SOLRCONFIG_PATH, ConfigFileReader.FILE_SOLR.getFsPath(fs, coreName));
    params.put(IndexBuildParam.INDEXING_SCHEMA_PATH, ConfigFileReader.FILE_SCHEMA.getFsPath(fs, coreName));
    params.put(IndexBuildParam.INDEXING_MAX_NUM_SEGMENTS, "1");
    params.put(IndexBuildParam.INDEXING_GROUP_NUM, "0");
    params.put(IndexBuildParam.INDEXING_SERVICE_NAME, indexName);
    // params.put(IndexBuildParam.INDEXING_BUILDER_TRIGGER_FACTORY, "yarn-index-build");
    params.put(IndexBuildParam.INDEXING_INCR_TIME, timePoint);
    // IndexBuildSourcePathCreator pathCreator = buildParam.getHdfsSourcePath();
    // Objects.requireNonNull(pathCreator, "pathCreator can not be null");
    // File dumpRoot = LocalTableDumpFactory.getLocalOfflineRootDir();
    // File tableRoot = new File(dumpRoot, DB_EMPLOYEES + "/" + TABLE_EMPLOYEES + "/all");
    // IJoinTaskContext execContext, String group, ITabPartition ps
    IndexBuildSourcePathCreator indexBuildSourcePathCreator = this.createIndexBuildSourcePathCreator(execContext, () -> timePoint);
    String sourcePath = URLEncoder.encode(indexBuildSourcePathCreator.build(groupNum), TisUTF8.getName());
    params.put(IndexBuildParam.INDEXING_SOURCE_PATH, sourcePath);
    // "/user/admin/search4totalpay/all/0/output/20200525134425"
    params.put(IndexBuildParam.INDEXING_OUTPUT_PATH, ImportDataProcessInfo.createIndexDir(this.getFileSystem(), timePoint, groupNum, indexName, false));
    params.put(IndexBuildParam.INDEXING_CORE_NAME, coreName);
    params.put(IParamContext.KEY_TASK_ID, String.valueOf(buildParam.getTaskId()));
    params.put(IndexBuildParam.INDEXING_ROW_COUNT, "999");
    TaskContext context = TaskContext.create(params);
    context.setCoordinator(buildParam.getCoordinator());
    return LocalTableDumpFactory.triggerTask(context, (rpc) -> {
        IndexBuilderTriggerFactory buildTrigger = LocalIndexBuilderTriggerFactory.this;
        IndexBuildNodeMaster.executeIndexBuild(context, buildTrigger, rpc, false);
    });
}
Also used : IJoinTaskContext(com.qlangtech.tis.order.center.IJoinTaskContext) ITISFileSystem(com.qlangtech.tis.fs.ITISFileSystem) IndexBuilderTriggerFactory(com.qlangtech.tis.offline.IndexBuilderTriggerFactory)

Aggregations

ITISFileSystem (com.qlangtech.tis.fs.ITISFileSystem)1 IndexBuilderTriggerFactory (com.qlangtech.tis.offline.IndexBuilderTriggerFactory)1 IJoinTaskContext (com.qlangtech.tis.order.center.IJoinTaskContext)1