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