use of com.dtstack.taier.pluginapi.JobIdentifier 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.JobIdentifier 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.JobIdentifier in project Taier by DTStack.
the class FlinkClientTest method testCancelJob.
/*@Test
public void testBeforeSubmitFunc() throws Exception {
String absolutePath = temporaryFolder.newFile("21_window_WindowJoin.jar").getAbsolutePath();
JobClient jobClient = YarnMockUtil.mockJobClient("session", absolutePath);
FlinkConfig flinkConfig = new FlinkConfig();
Map<String, String> map = new HashMap<>();
map.put("test", "test");
// flinkConfig.setSftpConf();
MemberModifier.field(FlinkClient.class, "flinkConfig")
.set(flinkClient, flinkConfig);
MemberModifier.field(FlinkClient.class, "cacheFile")
.set(flinkClient, Maps.newConcurrentMap());
MemberModifier.field(FlinkClient.class, "hadoopConf")
.set(flinkClient, new HadoopConf());
flinkClient.beforeSubmitFunc(jobClient);
}*/
@Test
public void testCancelJob() throws Exception {
String jobId = "40c01cd0c53928fff6a55e8d8b8b022c";
String appId = "application_1594003499276_1278";
String taskId = "taskId";
JobIdentifier jobIdentifier = JobIdentifier.createInstance(jobId, appId, taskId);
ClusterClient clusterClient = YarnMockUtil.mockClusterClient();
when(flinkClusterClientManager.getClusterClient(null)).thenReturn(clusterClient);
JobResult jobResult = flinkClient.cancelJob(jobIdentifier);
Assert.assertNotNull(jobResult);
}
use of com.dtstack.taier.pluginapi.JobIdentifier in project Taier by DTStack.
the class FlinkClientTest method testGetCheckpoints.
@Test
public void testGetCheckpoints() throws Exception {
JobIdentifier jobIdentifier = new JobIdentifier("engineId", "application_1593762151957_0080", "taskId");
ApplicationReportPBImpl report = YarnMockUtil.mockApplicationReport(null);
when(yarnClient.getApplicationReport(any())).thenReturn(report);
when(flinkClientBuilder.getYarnClient()).thenReturn(yarnClient);
ClusterClient currClient = YarnMockUtil.mockClusterClient();
when(flinkClusterClientManager.getClusterClient(any())).thenReturn(currClient);
PowerMockito.mockStatic(PoolHttpClient.class);
when(PoolHttpClient.get(any())).thenReturn("{\"app\":{\"amContainerLogs\":\"http://dtstack01:8088/ws/v1/cluster/apps/application_9527\"}}");
String checkpoints = flinkClient.getCheckpoints(jobIdentifier);
Assert.assertNotNull(checkpoints);
}
use of com.dtstack.taier.pluginapi.JobIdentifier in project Taier by DTStack.
the class AbstractRdbsClientTest method testCancelJob.
@Test
public void testCancelJob() throws Exception {
RdbsExeQueue rdbsExeQueue = PowerMockito.mock(RdbsExeQueue.class);
when(rdbsExeQueue.cancelJob(any(String.class))).thenReturn(true);
MemberModifier.field(TestRdbsClient.class, "exeQueue").set(testRdbsClient, rdbsExeQueue);
JobIdentifier jobIdentifier = JobIdentifier.createInstance("test", "test", "test");
JobResult jobResult = testRdbsClient.cancelJob(jobIdentifier);
Assert.assertNotNull(jobResult);
}
Aggregations