Search in sources :

Example 1 with JobIdentifier

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);
}
Also used : IClient(com.dtstack.taier.pluginapi.client.IClient) JobIdentifier(com.dtstack.taier.pluginapi.JobIdentifier)

Example 2 with 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;
}
Also used : ParamAction(com.dtstack.taier.pluginapi.pojo.ParamAction) JSONObject(com.alibaba.fastjson.JSONObject) JobIdentifier(com.dtstack.taier.pluginapi.JobIdentifier) ScheduleEngineJobCache(com.dtstack.taier.dao.domain.ScheduleEngineJobCache)

Example 3 with JobIdentifier

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);
}
Also used : ClusterClient(org.apache.flink.client.program.ClusterClient) JobResult(com.dtstack.taier.pluginapi.pojo.JobResult) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) JobIdentifier(com.dtstack.taier.pluginapi.JobIdentifier) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 4 with JobIdentifier

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);
}
Also used : ClusterClient(org.apache.flink.client.program.ClusterClient) ApplicationReportPBImpl(org.apache.hadoop.yarn.api.records.impl.pb.ApplicationReportPBImpl) JobIdentifier(com.dtstack.taier.pluginapi.JobIdentifier) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 5 with JobIdentifier

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);
}
Also used : JobResult(com.dtstack.taier.pluginapi.pojo.JobResult) RdbsExeQueue(com.dtstack.taier.rdbs.common.executor.RdbsExeQueue) JobIdentifier(com.dtstack.taier.pluginapi.JobIdentifier) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Aggregations

JobIdentifier (com.dtstack.taier.pluginapi.JobIdentifier)10 Test (org.junit.Test)6 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)6 JobResult (com.dtstack.taier.pluginapi.pojo.JobResult)3 ParamAction (com.dtstack.taier.pluginapi.pojo.ParamAction)3 RdbsExeQueue (com.dtstack.taier.rdbs.common.executor.RdbsExeQueue)3 ClusterClient (org.apache.flink.client.program.ClusterClient)3 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)3 JSONObject (com.alibaba.fastjson.JSONObject)2 ScheduleEngineJobCache (com.dtstack.taier.dao.domain.ScheduleEngineJobCache)2 IClient (com.dtstack.taier.pluginapi.client.IClient)2 TaskStatus (com.dtstack.taier.pluginapi.enums.TaskStatus)2 ApplicationReportPBImpl (org.apache.hadoop.yarn.api.records.impl.pb.ApplicationReportPBImpl)2 ScheduleJob (com.dtstack.taier.dao.domain.ScheduleJob)1 JobClient (com.dtstack.taier.pluginapi.JobClient)1 Map (java.util.Map)1 Properties (java.util.Properties)1 Configuration (org.apache.flink.configuration.Configuration)1