use of com.dtstack.taier.pluginapi.client.IClient 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.pluginapi.client.IClient in project Taier by DTStack.
the class ClientOperator method stopJob.
public JobResult stopJob(JobClient jobClient) throws Exception {
if (jobClient.getEngineTaskId() == null) {
return JobResult.createSuccessResult(jobClient.getJobId());
}
JobIdentifier jobIdentifier = new JobIdentifier(jobClient.getEngineTaskId(), jobClient.getApplicationId(), jobClient.getJobId(), jobClient.getTenantId(), jobClient.getTaskType(), jobClient.getDeployMode(), jobClient.getUserId(), jobClient.getPluginInfo(), jobClient.getComponentVersion());
jobIdentifier.setForceCancel(jobClient.getForceCancel());
checkoutOperator(jobClient.getPluginInfo(), jobIdentifier);
jobIdentifier.setTimeout(getCheckoutTimeout(jobClient));
IClient client = clientCache.getClient(jobClient.getPluginInfo());
return client.cancelJob(jobIdentifier);
}
use of com.dtstack.taier.pluginapi.client.IClient in project Taier by DTStack.
the class ClientOperator method getJobStatus.
public TaskStatus getJobStatus(String pluginInfo, JobIdentifier jobIdentifier) {
checkoutOperator(pluginInfo, jobIdentifier);
String jobId = jobIdentifier.getEngineJobId();
if (Strings.isNullOrEmpty(jobId) && Strings.isNullOrEmpty(jobIdentifier.getApplicationId())) {
throw new RdosDefineException("can't get job of jobId is empty or null!");
}
try {
IClient client = clientCache.getClient(pluginInfo);
Object result = client.getJobStatus(jobIdentifier);
if (result == null) {
return null;
}
return (TaskStatus) result;
} catch (Exception e) {
LOGGER.error("getStatus happens error:{}", jobId, e);
return TaskStatus.NOTFOUND;
}
}
use of com.dtstack.taier.pluginapi.client.IClient in project Taier by DTStack.
the class ClientOperator method testConnect.
public ComponentTestResult testConnect(String pluginInfo) {
JSONObject pluginConfig = JSONObject.parseObject(pluginInfo);
String typeName = pluginConfig.getString(ConfigConstant.TYPE_NAME_KEY);
IClient clusterClient = clientCache.getDefaultPlugin(typeName);
return clusterClient.testConnect(pluginInfo);
}
use of com.dtstack.taier.pluginapi.client.IClient in project Taier by DTStack.
the class ClientOperator method getEngineLog.
public String getEngineLog(String pluginInfo, JobIdentifier jobIdentifier) {
checkoutOperator(pluginInfo, jobIdentifier);
String logInfo;
try {
IClient client = clientCache.getClient(pluginInfo);
logInfo = client.getJobLog(jobIdentifier);
} catch (Exception e) {
logInfo = ExceptionUtil.getErrorMessage(e);
}
return logInfo;
}
Aggregations