Search in sources :

Example 1 with ParamAction

use of com.dtstack.taier.pluginapi.pojo.ParamAction in project Taier by DTStack.

the class ConsoleService method searchJob.

public ConsoleJobVO searchJob(String jobName) {
    String jobId = null;
    ScheduleJob scheduleJob = scheduleJobMapper.getByName(jobName);
    if (scheduleJob != null) {
        jobId = scheduleJob.getJobId();
    }
    if (jobId == null) {
        return null;
    }
    ScheduleEngineJobCache engineJobCache = scheduleEngineJobCacheMapper.getOne(jobId);
    if (engineJobCache == null) {
        return null;
    }
    try {
        ParamAction paramAction = PublicUtil.jsonStrToObject(engineJobCache.getJobInfo(), ParamAction.class);
        Tenant tenant = tenantMapper.selectById(scheduleJob.getTenantId());
        ConsoleJobInfoVO consoleJobInfoVO = this.fillJobInfo(paramAction, scheduleJob, engineJobCache, tenant);
        ConsoleJobVO vo = new ConsoleJobVO();
        vo.setTheJob(consoleJobInfoVO);
        vo.setNodeAddress(engineJobCache.getNodeAddress());
        vo.setTheJobIdx(1);
        return vo;
    } catch (Exception e) {
        LOGGER.error("searchJob error:", e);
    }
    return null;
}
Also used : ParamAction(com.dtstack.taier.pluginapi.pojo.ParamAction) ConsoleJobVO(com.dtstack.taier.develop.vo.console.ConsoleJobVO) ConsoleJobInfoVO(com.dtstack.taier.develop.vo.console.ConsoleJobInfoVO) RdosDefineException(com.dtstack.taier.common.exception.RdosDefineException)

Example 2 with ParamAction

use of com.dtstack.taier.pluginapi.pojo.ParamAction in project Taier by DTStack.

the class JobDealer method getAndUpdateEngineLog.

public String getAndUpdateEngineLog(String jobId, String engineJobId, String appId, Long tenantId) {
    if (StringUtils.isBlank(engineJobId)) {
        return "";
    }
    String engineLog = null;
    try {
        ScheduleEngineJobCache engineJobCache = scheduleJobCacheService.getJobCacheByJobId(jobId);
        if (null == engineJobCache) {
            return "";
        }
        ParamAction paramAction = PublicUtil.jsonStrToObject(engineJobCache.getJobInfo(), ParamAction.class);
        Map<String, Object> pluginInfo = paramAction.getPluginInfo();
        JobIdentifier jobIdentifier = new JobIdentifier(engineJobId, appId, jobId, tenantId, paramAction.getTaskType(), TaskParamsUtils.parseDeployTypeByTaskParams(paramAction.getTaskParams(), engineJobCache.getComputeType()).getType(), null, MapUtils.isEmpty(pluginInfo) ? null : JSONObject.toJSONString(pluginInfo), paramAction.getComponentVersion());
        // 从engine获取log
        engineLog = workerOperator.getEngineLog(jobIdentifier);
        if (engineLog != null) {
            scheduleJobService.updateExpandByJobId(jobId, engineLog, null);
        }
    } catch (Throwable e) {
        LOGGER.error("getAndUpdateEngineLog error jobId:{} error:.", jobId, e);
    }
    return engineLog;
}
Also used : ParamAction(com.dtstack.taier.pluginapi.pojo.ParamAction) JSONObject(com.alibaba.fastjson.JSONObject) JobIdentifier(com.dtstack.taier.pluginapi.JobIdentifier) ScheduleEngineJobCache(com.dtstack.taier.dao.domain.ScheduleEngineJobCache)

Example 3 with ParamAction

use of com.dtstack.taier.pluginapi.pojo.ParamAction in project Taier by DTStack.

the class JobRestartDealer method checkJobInfo.

private Pair<Boolean, JobClient> checkJobInfo(String jobId, ScheduleEngineJobCache jobCache, Integer status) {
    Pair<Boolean, JobClient> check = new Pair<>(false, null);
    if (!TaskStatus.FAILED.getStatus().equals(status) && !TaskStatus.SUBMITFAILD.getStatus().equals(status)) {
        return check;
    }
    try {
        String jobInfo = jobCache.getJobInfo();
        ParamAction paramAction = PublicUtil.jsonStrToObject(jobInfo, ParamAction.class);
        JobClient jobClient = new JobClient(paramAction);
        if (!jobClient.getIsFailRetry()) {
            LOGGER.info("[retry=false] jobId:{} isFailRetry:{} isFailRetry is false.", jobClient.getJobId(), jobClient.getIsFailRetry());
            return check;
        }
        return new Pair<>(true, jobClient);
    } catch (Exception e) {
        // 解析任务的jobInfo反序列到ParamAction失败,任务不进行重试.
        LOGGER.error("[retry=false] jobId:{} default not retry, because getIsFailRetry happens error:.", jobId, e);
        return check;
    }
}
Also used : ParamAction(com.dtstack.taier.pluginapi.pojo.ParamAction) JobClient(com.dtstack.taier.pluginapi.JobClient) IOException(java.io.IOException) Pair(org.apache.commons.math3.util.Pair)

Example 4 with ParamAction

use of com.dtstack.taier.pluginapi.pojo.ParamAction in project Taier by DTStack.

the class HiveClient method main.

public static void main(String[] args) throws IOException {
    FileInputStream fileInputStream = null;
    InputStreamReader inputStreamReader = null;
    BufferedReader reader = null;
    try {
        System.setProperty("HADOOP_USER_NAME", "admin");
        // input params json file path
        String filePath = args[0];
        File paramsFile = new File(filePath);
        fileInputStream = new FileInputStream(paramsFile);
        inputStreamReader = new InputStreamReader(fileInputStream);
        reader = new BufferedReader(inputStreamReader);
        String request = reader.readLine();
        Map params = PublicUtil.jsonStrToObject(request, Map.class);
        ParamAction paramAction = PublicUtil.mapToObject(params, ParamAction.class);
        JobClient jobClient = new JobClient(paramAction);
        String pluginInfo = jobClient.getPluginInfo();
        Properties properties = PublicUtil.jsonStrToObject(pluginInfo, Properties.class);
        String md5plugin = MD5Util.getMd5String(pluginInfo);
        properties.setProperty("md5sum", md5plugin);
        HiveClient client = new HiveClient();
        client.init(properties);
        ClusterResource clusterResource = client.getClusterResource();
        LOG.info("submit success!");
        LOG.info(clusterResource.toString());
        System.exit(0);
    } catch (Exception e) {
        LOG.error("submit error!", e);
    } finally {
        if (reader != null) {
            reader.close();
            inputStreamReader.close();
            fileInputStream.close();
        }
    }
}
Also used : ParamAction(com.dtstack.taier.pluginapi.pojo.ParamAction) Properties(java.util.Properties) Map(java.util.Map) JobClient(com.dtstack.taier.pluginapi.JobClient) ClusterResource(com.dtstack.taier.pluginapi.pojo.ClusterResource)

Example 5 with ParamAction

use of com.dtstack.taier.pluginapi.pojo.ParamAction in project Taier by DTStack.

the class Launcher method main.

public static void main(String[] args) throws Exception {
    System.setProperty("HADOOP_USER_NAME", "admin");
    // job json path
    String jobJsonPath = USER_DIR + SP + "local-test/src/main/json/dtscript-agent.json";
    // create jobClient
    String content = getJobContent(jobJsonPath);
    Map params = PublicUtil.jsonStrToObject(content, Map.class);
    ParamAction paramAction = PublicUtil.mapToObject(params, ParamAction.class);
    JobClient jobClient = new JobClient(paramAction);
    // create jobIdentifier
    String jobId = "jobId";
    String appId = "appId";
    String taskId = "taskId";
    JobIdentifier jobIdentifier = JobIdentifier.createInstance(jobId, appId, taskId);
    // get pluginInfo
    String pluginInfo = jobClient.getPluginInfo();
    Properties properties = PublicUtil.jsonStrToObject(pluginInfo, Properties.class);
    String md5plugin = MD5Util.getMd5String(pluginInfo);
    properties.setProperty("md5sum", md5plugin);
    // create client
    String pluginParentPath = USER_DIR + SP + "pluginLibs";
    IClient client = ClientFactory.buildPluginClient(pluginInfo, pluginParentPath);
    // client init
    ClassLoaderCallBackMethod.callbackAndReset(new CallBack<String>() {

        @Override
        public String execute() throws Exception {
            client.init(properties);
            return null;
        }
    }, client.getClass().getClassLoader(), true);
    // test target method
    ClassLoaderCallBackMethod.callbackAndReset(new CallBack<Object>() {

        @Override
        public Object execute() throws Exception {
            JobResult jobResult = client.submitJob(jobClient);
            return jobResult;
        }
    }, client.getClass().getClassLoader(), true);
    LOG.info("Launcher Success!");
    System.exit(0);
}
Also used : JobResult(com.dtstack.taier.pluginapi.pojo.JobResult) IClient(com.dtstack.taier.pluginapi.client.IClient) JobIdentifier(com.dtstack.taier.pluginapi.JobIdentifier) Properties(java.util.Properties) JobClient(com.dtstack.taier.pluginapi.JobClient) ParamAction(com.dtstack.taier.pluginapi.pojo.ParamAction) Map(java.util.Map)

Aggregations

ParamAction (com.dtstack.taier.pluginapi.pojo.ParamAction)16 JobClient (com.dtstack.taier.pluginapi.JobClient)11 ScheduleEngineJobCache (com.dtstack.taier.dao.domain.ScheduleEngineJobCache)6 ScheduleJob (com.dtstack.taier.dao.domain.ScheduleJob)3 JobIdentifier (com.dtstack.taier.pluginapi.JobIdentifier)3 ClusterResource (com.dtstack.taier.pluginapi.pojo.ClusterResource)3 IOException (java.io.IOException)3 Map (java.util.Map)3 Properties (java.util.Properties)3 JSONObject (com.alibaba.fastjson.JSONObject)2 RdosDefineException (com.dtstack.taier.common.exception.RdosDefineException)2 PluginDefineException (com.dtstack.taier.pluginapi.exception.PluginDefineException)2 JobResult (com.dtstack.taier.pluginapi.pojo.JobResult)2 EJobCacheStage (com.dtstack.taier.common.enums.EJobCacheStage)1 EnvironmentContext (com.dtstack.taier.common.env.EnvironmentContext)1 JobClientComparator (com.dtstack.taier.common.queue.comparator.JobClientComparator)1 ConsoleJobInfoVO (com.dtstack.taier.develop.vo.console.ConsoleJobInfoVO)1 ConsoleJobVO (com.dtstack.taier.develop.vo.console.ConsoleJobVO)1 CustomThreadFactory (com.dtstack.taier.pluginapi.CustomThreadFactory)1 JarFileInfo (com.dtstack.taier.pluginapi.JarFileInfo)1