Search in sources :

Example 21 with Func

use of com.qlangtech.tis.manage.spring.aop.Func in project tis by qlangtech.

the class DataxAction method doCreateDatax.

/**
 * 创建DataX实例
 *
 * @param context
 */
@Func(value = PermissionConstant.DATAX_MANAGE)
public void doCreateDatax(Context context) throws Exception {
    String dataxName = this.getString(PARAM_KEY_DATAX_NAME);
    DataxProcessor dataxProcessor = IAppSource.load(null, dataxName);
    Application app = dataxProcessor.buildApp();
    SchemaAction.CreateAppResult createAppResult = this.createNewApp(context, app, false, (newAppId) -> {
        SchemaAction.CreateAppResult appResult = new SchemaAction.CreateAppResult();
        appResult.setSuccess(true);
        appResult.setNewAppId(newAppId);
        return appResult;
    });
}
Also used : SchemaAction(com.qlangtech.tis.runtime.module.action.SchemaAction) Application(com.qlangtech.tis.manage.biz.dal.pojo.Application) Func(com.qlangtech.tis.manage.spring.aop.Func)

Example 22 with Func

use of com.qlangtech.tis.manage.spring.aop.Func in project tis by qlangtech.

the class DataxAction method doGetTableMapper.

/**
 * 取得表映射
 *
 * @param context
 */
@Func(value = PermissionConstant.DATAX_MANAGE, sideEffect = false)
public void doGetTableMapper(Context context) {
    String dataxName = this.getString(PARAM_KEY_DATAX_NAME);
    KeyedPluginStore<DataxReader> readerStore = DataxReader.getPluginStore(this, dataxName);
    DataxReader dataxReader = readerStore.getPlugin();
    Objects.requireNonNull(dataxReader, "dataReader:" + dataxName + " relevant instance can not be null");
    IDataxProcessor.TableAlias tableAlias;
    Optional<DataxProcessor> dataXAppSource = IAppSource.loadNullable(this, dataxName);
    Map<String, IDataxProcessor.TableAlias> tabMaps = Collections.emptyMap();
    if (dataXAppSource.isPresent()) {
        DataxProcessor dataxSource = dataXAppSource.get();
        tabMaps = dataxSource.getTabAlias();
    }
    if (!dataxReader.hasMulitTable()) {
        throw new IllegalStateException("reader has not set table at least");
    }
    List<IDataxProcessor.TableAlias> tmapList = Lists.newArrayList();
    for (ISelectedTab selectedTab : dataxReader.getSelectedTabs()) {
        tableAlias = tabMaps.get(selectedTab.getName());
        if (tableAlias == null) {
            tmapList.add(new IDataxProcessor.TableAlias(selectedTab.getName()));
        } else {
            tmapList.add(tableAlias);
        }
    }
    this.setBizResult(context, tmapList);
}
Also used : ISelectedTab(com.qlangtech.tis.plugin.ds.ISelectedTab) Func(com.qlangtech.tis.manage.spring.aop.Func)

Example 23 with Func

use of com.qlangtech.tis.manage.spring.aop.Func in project tis by qlangtech.

the class FullbuildWorkflowAction method doFeedbackAsynTaskStatus.

/**
 * 接收异步执行任务执行状态
 *
 * @param context
 */
@Func(value = PermissionConstant.DATAFLOW_MANAGE, sideEffect = false)
public void doFeedbackAsynTaskStatus(Context context) {
    Integer taskid = this.getInt(IParamContext.KEY_TASK_ID);
    String jobName = this.getString(IParamContext.KEY_ASYN_JOB_NAME);
    boolean execSuccess = this.getBoolean(IParamContext.KEY_ASYN_JOB_SUCCESS);
    this.updateAsynTaskState(taskid, jobName, execSuccess, 0);
    this.setBizResult(context, new CreateNewTaskResult(taskid, null));
}
Also used : CreateNewTaskResult(com.qlangtech.tis.manage.common.CreateNewTaskResult) Func(com.qlangtech.tis.manage.spring.aop.Func)

Example 24 with Func

use of com.qlangtech.tis.manage.spring.aop.Func in project tis by qlangtech.

the class StreamScriptRepo method execute.

@Override
@Func(value = PermissionConstant.PERMISSION_PLUGIN_GET_CONFIG, sideEffect = false)
public void execute(Context context) throws Exception {
    File rootDir = Config.getDataDir();
    String path = this.getString("path");
    if (StringUtils.isEmpty(path)) {
        throw new IllegalArgumentException("illegal argument 'path'");
    }
    HttpServletResponse response = (HttpServletResponse) DefaultFilter.getRespone();
    File targetFile = new File(rootDir, path);
    if (!targetFile.exists()) {
        // throw new IllegalStateException("target file not exist:" + targetFile.getAbsolutePath());
        response.addHeader(ConfigFileContext.KEY_HEAD_FILE_NOT_EXIST, String.valueOf(Boolean.TRUE.booleanValue()));
        return;
    }
    boolean getMeta = Boolean.parseBoolean(this.getRequest().getHeader(ConfigFileContext.StreamProcess.HEADER_KEY_GET_FILE_META));
    logger.info("path:{},getChildren:{},local file exist:{},getMeta:{}", path, !targetFile.isFile(), targetFile.exists(), getMeta);
    if (targetFile.isFile()) {
        // 是否取文件meta信息
        response = HdfsAction.getDownloadResponse(targetFile, !getMeta);
        if (!getMeta) {
            try (InputStream input = FileUtils.openInputStream(targetFile)) {
                IOUtils.copyLarge(input, response.getOutputStream());
            }
        }
    } else {
        response.addHeader(ConfigFileContext.KEY_HEAD_FILE_DOWNLOAD, String.valueOf(false));
        List<String> subs = new ArrayList<>();
        File sub = null;
        for (String d : targetFile.list((d, fn) -> !StringUtils.endsWith(fn, CenterResource.KEY_LAST_MODIFIED_EXTENDION))) {
            sub = new File(targetFile, d);
            subs.add(d + ":" + (sub.isDirectory() ? "d" : "f"));
        }
        response.addHeader(ConfigFileContext.KEY_HEAD_FILES, subs.stream().collect(Collectors.joining(",")));
    // this.setBizResult(context, targetFile.list());
    }
}
Also used : InputStream(java.io.InputStream) ArrayList(java.util.ArrayList) HttpServletResponse(javax.servlet.http.HttpServletResponse) File(java.io.File) Func(com.qlangtech.tis.manage.spring.aop.Func)

Example 25 with Func

use of com.qlangtech.tis.manage.spring.aop.Func in project tis by qlangtech.

the class CoreAction method doIncrDelete.

/**
 * 删除增量通道
 *
 * @param context
 * @throws Exception
 */
@Func(value = PermissionConstant.PERMISSION_INCR_PROCESS_MANAGE)
public void doIncrDelete(Context context) throws Exception {
    IndexStreamCodeGenerator indexStreamCodeGenerator = getIndexStreamCodeGenerator(this);
    indexStreamCodeGenerator.deleteScript();
    TISK8sDelegate k8sDelegate = TISK8sDelegate.getK8SDelegate(this.getCollectionName());
    // 删除增量实例
    k8sDelegate.removeIncrProcess();
}
Also used : IndexStreamCodeGenerator(com.qlangtech.tis.compiler.streamcode.IndexStreamCodeGenerator) Func(com.qlangtech.tis.manage.spring.aop.Func)

Aggregations

Func (com.qlangtech.tis.manage.spring.aop.Func)64 JSONObject (com.alibaba.fastjson.JSONObject)12 DataXJobWorker (com.qlangtech.tis.datax.job.DataXJobWorker)6 File (java.io.File)6 Date (java.util.Date)6 Context (com.alibaba.citrus.turbine.Context)5 Application (com.qlangtech.tis.manage.biz.dal.pojo.Application)5 JSONObject (org.json.JSONObject)5 Validator (com.qlangtech.tis.plugin.annotation.Validator)4 IControlMsgHandler (com.qlangtech.tis.runtime.module.misc.IControlMsgHandler)4 IFieldErrorHandler (com.qlangtech.tis.runtime.module.misc.IFieldErrorHandler)4 DelegateControl4JsonPostMsgHandler (com.qlangtech.tis.runtime.module.misc.impl.DelegateControl4JsonPostMsgHandler)4 WorkFlow (com.qlangtech.tis.workflow.pojo.WorkFlow)4 JSONArray (org.json.JSONArray)4 ExecResult (com.qlangtech.tis.assemble.ExecResult)3 FullbuildPhase (com.qlangtech.tis.assemble.FullbuildPhase)3 IndexStreamCodeGenerator (com.qlangtech.tis.compiler.streamcode.IndexStreamCodeGenerator)3 DescriptorExtensionList (com.qlangtech.tis.extension.DescriptorExtensionList)3 IOException (java.io.IOException)3 Matcher (java.util.regex.Matcher)3