Search in sources :

Example 1 with ClientAccessException

use of com.dtstack.taier.common.exception.ClientAccessException in project Taier by DTStack.

the class ClientCache method getClient.

/**
 * @param pluginInfo 集群配置信息
 * @return
 */
public IClient getClient(String pluginInfo) throws ClientAccessException {
    String typeName = "";
    try {
        if (StringUtils.isBlank(pluginInfo)) {
            throw new RdosDefineException("plugin info is empty");
        }
        Properties properties = PublicUtil.jsonStrToObjectWithOutNull(pluginInfo, Properties.class);
        typeName = properties.getProperty(ConfigConstant.TYPE_NAME_KEY);
        if (StringUtils.isBlank(typeName)) {
            throw new RdosDefineException("typeName  is empty");
        }
        String md5plugin = MD5Util.getMd5String(pluginInfo);
        String md5sum = null;
        if (!properties.containsKey(MD5_SUM_KEY) || (md5sum = MathUtil.getString(properties.get(MD5_SUM_KEY))) == null) {
            String md5zip = MathUtil.getString(properties.get(MD5_ZIP_KEY));
            if (md5zip == null) {
                md5zip = "";
            }
            md5sum = md5zip + md5plugin;
            properties.setProperty(MD5_SUM_KEY, md5sum);
        }
        Map<String, IClient> clientMap = cache.computeIfAbsent(typeName, k -> Maps.newConcurrentMap());
        IClient client = clientMap.get(md5sum);
        if (client == null) {
            synchronized (clientMap) {
                client = clientMap.get(md5sum);
                if (client == null) {
                    client = ClientFactory.buildPluginClient(pluginInfo, pluginPath);
                    client.init(properties);
                    clientMap.putIfAbsent(md5sum, client);
                }
            }
        }
        return client;
    } catch (Throwable e) {
        LOGGER.error("------- typeName {}  plugin info {} get client error ", typeName, pluginInfo, e);
        throw new ClientAccessException(e);
    }
}
Also used : RdosDefineException(com.dtstack.taier.common.exception.RdosDefineException) IClient(com.dtstack.taier.pluginapi.client.IClient) Properties(java.util.Properties) ClientAccessException(com.dtstack.taier.common.exception.ClientAccessException)

Example 2 with ClientAccessException

use of com.dtstack.taier.common.exception.ClientAccessException in project Taier by DTStack.

the class JobSubmitDealer method submitJob.

private void submitJob(JobClient jobClient) {
    JobResult jobResult = null;
    try {
        // 判断资源
        JudgeResult judgeResult = workerOperator.judgeSlots(jobClient);
        if (JudgeResult.JudgeType.OK == judgeResult.getResult()) {
            LOGGER.info("jobId:{} taskType:{} submit to engine start.", jobClient.getJobId(), jobClient.getTaskType());
            jobClient.doStatusCallBack(TaskStatus.COMPUTING.getStatus());
            // 提交任务
            jobResult = workerOperator.submitJob(jobClient);
            if (LOGGER.isDebugEnabled()) {
                LOGGER.debug("jobId:{} taskType:{} submit jobResult:{}.", jobClient.getJobId(), jobClient.getTaskType(), jobResult);
            }
            jobClient.setEngineTaskId(jobResult.getData(JobResult.EXT_ID_KEY));
            jobClient.setApplicationId(jobResult.getData(JobResult.JOB_ID_KEY));
            addToTaskListener(jobClient, jobResult);
            LOGGER.info("jobId:{} taskType:{} submit to engine end.", jobClient.getJobId(), jobClient.getTaskType());
        } else if (JudgeResult.JudgeType.LIMIT_ERROR == judgeResult.getResult()) {
            LOGGER.info("jobId:{} taskType:{} submitJob happens system limitError:{}", jobClient.getJobId(), jobClient.getTaskType(), judgeResult.getReason());
            jobClient.setEngineTaskId(null);
            jobResult = JobResult.createErrorResult(false, judgeResult.getReason());
            addToTaskListener(jobClient, jobResult);
        } else if (JudgeResult.JudgeType.EXCEPTION == judgeResult.getResult()) {
            LOGGER.info("jobId:{} taskType:{} judgeSlots result is exception {}", jobClient.getJobId(), jobClient.getTaskType(), judgeResult.getReason());
            handlerFailedWithRetry(jobClient, true, new Exception(judgeResult.getReason()));
        } else {
            LOGGER.info("jobId:{} taskType:{} judgeSlots result is false.", jobClient.getJobId(), jobClient.getTaskType());
            handlerNoResource(jobClient, judgeResult);
        }
    } catch (WorkerAccessException e) {
        LOGGER.info(" jobId:{} taskType:{} worker not find.", jobClient.getJobId(), jobClient.getTaskType());
        handlerNoResource(jobClient, workerNotFindResult);
    } catch (ClientAccessException | ClientArgumentException e) {
        handlerFailedWithRetry(jobClient, false, e);
    } catch (Throwable e) {
        handlerFailedWithRetry(jobClient, true, e);
    }
}
Also used : ClientArgumentException(com.dtstack.taier.pluginapi.exception.ClientArgumentException) JobResult(com.dtstack.taier.pluginapi.pojo.JobResult) JudgeResult(com.dtstack.taier.pluginapi.pojo.JudgeResult) ClientAccessException(com.dtstack.taier.common.exception.ClientAccessException) WorkerAccessException(com.dtstack.taier.common.exception.WorkerAccessException) ClientArgumentException(com.dtstack.taier.pluginapi.exception.ClientArgumentException) ClientAccessException(com.dtstack.taier.common.exception.ClientAccessException) RdosDefineException(com.dtstack.taier.common.exception.RdosDefineException) WorkerAccessException(com.dtstack.taier.common.exception.WorkerAccessException)

Aggregations

ClientAccessException (com.dtstack.taier.common.exception.ClientAccessException)2 RdosDefineException (com.dtstack.taier.common.exception.RdosDefineException)2 WorkerAccessException (com.dtstack.taier.common.exception.WorkerAccessException)1 IClient (com.dtstack.taier.pluginapi.client.IClient)1 ClientArgumentException (com.dtstack.taier.pluginapi.exception.ClientArgumentException)1 JobResult (com.dtstack.taier.pluginapi.pojo.JobResult)1 JudgeResult (com.dtstack.taier.pluginapi.pojo.JudgeResult)1 Properties (java.util.Properties)1