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);
}
}
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);
}
}
Aggregations