Search in sources :

Example 11 with JobClient

use of com.dtstack.taier.pluginapi.JobClient in project Taier by DTStack.

the class RdbsExeQueueTest method testInit.

@Test
public void testInit() throws Exception {
    BlockingQueue<JobClient> waitQueue = Queues.newLinkedBlockingQueue();
    JobClient jobClient = new JobClient();
    jobClient.setJobName("test");
    jobClient.setJobId("test");
    jobClient.setSql("select * from tableTest;");
    jobClient.setTaskParams("{\"task\":\"test\"}");
    waitQueue.add(jobClient);
    MemberModifier.field(RdbsExeQueue.class, "waitQueue").set(rdbsExeQueue, waitQueue);
    MemberModifier.field(RdbsExeQueue.class, "minSize").set(rdbsExeQueue, 1);
    MemberModifier.field(RdbsExeQueue.class, "maxSize").set(rdbsExeQueue, 1);
    rdbsExeQueue.init();
}
Also used : JobClient(com.dtstack.taier.pluginapi.JobClient) Test(org.junit.Test)

Example 12 with JobClient

use of com.dtstack.taier.pluginapi.JobClient in project Taier by DTStack.

the class ScheduleActionService method start.

/**
 * 接受来自客户端的请求, 并判断节点队列长度。
 * 如在当前节点,则直接处理任务
 */
public Boolean start(ParamActionExt paramActionExt) {
    if (LOGGER.isInfoEnabled()) {
        LOGGER.info("start  actionParam: {}", JSONObject.toJSONString(paramActionExt, propertyFilter));
    }
    try {
        boolean canAccepted = receiveStartJob(paramActionExt);
        // 会对重复数据做校验
        if (canAccepted) {
            JobClient jobClient = new JobClient(paramActionExt);
            jobClient.setType(getOrDefault(paramActionExt.getType(), EScheduleType.TEMP_JOB.getType()));
            jobDealer.addSubmitJob(jobClient);
            engineJobRetryMapper.delete(Wrappers.lambdaQuery(ScheduleEngineJobRetry.class).eq(ScheduleEngineJobRetry::getJobId, jobClient.getJobId()));
            return true;
        }
        LOGGER.warn("jobId:" + paramActionExt.getJobId() + " duplicate submissions are not allowed");
    } catch (Exception e) {
        runJobFail(paramActionExt, e, paramActionExt.getJobId());
    }
    return false;
}
Also used : JobClient(com.dtstack.taier.pluginapi.JobClient) ParseException(java.text.ParseException) RdosDefineException(com.dtstack.taier.common.exception.RdosDefineException) IOException(java.io.IOException)

Example 13 with JobClient

use of com.dtstack.taier.pluginapi.JobClient in project Taier by DTStack.

the class GroupPriorityQueue method emitJob2PriorityQueue.

/**
 * @return false: blocked | true: unblocked
 */
private boolean emitJob2PriorityQueue() {
    boolean empty = false;
    String localAddress = "";
    try {
        if (priorityQueueSize() >= getQueueSizeLimited()) {
            return false;
        }
        localAddress = environmentContext.getLocalAddress();
        long startId = 0L;
        outLoop: while (true) {
            List<ScheduleEngineJobCache> jobCaches = engineJobCacheService.listByStage(startId, localAddress, EJobCacheStage.DB.getStage(), jobResource);
            if (CollectionUtils.isEmpty(jobCaches)) {
                empty = true;
                break;
            }
            for (ScheduleEngineJobCache jobCache : jobCaches) {
                try {
                    ParamAction paramAction = PublicUtil.jsonStrToObject(jobCache.getJobInfo(), ParamAction.class);
                    JobClient jobClient = new JobClient(paramAction);
                    jobClient.setCallBack((jobStatus) -> {
                        jobDealer.updateJobStatus(jobClient.getJobId(), jobStatus);
                    });
                    boolean addInner = this.addInner(jobClient, false);
                    LOGGER.info("jobId:{} load from db, {} emit job to queue.", jobClient.getJobId(), addInner ? "success" : "failed");
                    if (!addInner) {
                        empty = false;
                        break outLoop;
                    }
                    startId = jobCache.getId();
                } catch (Exception e) {
                    LOGGER.error("", e);
                    // 数据转换异常--打日志
                    jobDealer.dealSubmitFailJob(jobCache.getJobId(), "This task stores information exception and cannot be converted." + e.toString());
                }
            }
        }
    } catch (Exception e) {
        LOGGER.error("emitJob2PriorityQueue localAddress:{} error:", localAddress, e);
    }
    if (empty) {
        blocked.set(false);
    }
    return empty;
}
Also used : Logger(org.slf4j.Logger) java.util.concurrent(java.util.concurrent) LoggerFactory(org.slf4j.LoggerFactory) EnvironmentContext(com.dtstack.taier.common.env.EnvironmentContext) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) StringUtils(org.apache.commons.lang3.StringUtils) ApplicationContext(org.springframework.context.ApplicationContext) EngineJobCacheService(com.dtstack.taier.scheduler.service.EngineJobCacheService) EJobCacheStage(com.dtstack.taier.common.enums.EJobCacheStage) CustomThreadFactory(com.dtstack.taier.pluginapi.CustomThreadFactory) ParamAction(com.dtstack.taier.pluginapi.pojo.ParamAction) JobClient(com.dtstack.taier.pluginapi.JobClient) PublicUtil(com.dtstack.taier.pluginapi.util.PublicUtil) List(java.util.List) JobClientComparator(com.dtstack.taier.common.queue.comparator.JobClientComparator) JobDealer(com.dtstack.taier.scheduler.jobdealer.JobDealer) CollectionUtils(org.apache.commons.collections.CollectionUtils) ScheduleEngineJobCache(com.dtstack.taier.dao.domain.ScheduleEngineJobCache) WorkerOperator(com.dtstack.taier.scheduler.WorkerOperator) JobSubmitDealer(com.dtstack.taier.scheduler.jobdealer.JobSubmitDealer) JobPartitioner(com.dtstack.taier.scheduler.server.JobPartitioner) ParamAction(com.dtstack.taier.pluginapi.pojo.ParamAction) List(java.util.List) JobClient(com.dtstack.taier.pluginapi.JobClient) ScheduleEngineJobCache(com.dtstack.taier.dao.domain.ScheduleEngineJobCache)

Example 14 with JobClient

use of com.dtstack.taier.pluginapi.JobClient in project Taier by DTStack.

the class NodeRecoverService method recoverJobCaches.

public void recoverJobCaches() {
    String localAddress = environmentContext.getLocalAddress();
    try {
        long startId = 0L;
        while (true) {
            List<ScheduleEngineJobCache> jobCaches = engineJobCacheService.listByStage(startId, localAddress, EJobCacheStage.SUBMITTED.getStage(), null);
            if (CollectionUtils.isEmpty(jobCaches)) {
                break;
            }
            List<JobClient> afterJobClients = new ArrayList<>(jobCaches.size());
            for (ScheduleEngineJobCache jobCache : jobCaches) {
                try {
                    ParamAction paramAction = PublicUtil.jsonStrToObject(jobCache.getJobInfo(), ParamAction.class);
                    JobClient jobClient = new JobClient(paramAction);
                    afterJobClients.add(jobClient);
                    startId = jobCache.getId();
                } catch (Exception e) {
                    LOGGER.error("", e);
                    // 数据转换异常--打日志
                    jobDealer.dealSubmitFailJob(jobCache.getJobId(), "This task stores information exception and cannot be converted." + ExceptionUtil.getErrorMessage(e));
                }
            }
            if (CollectionUtils.isNotEmpty(afterJobClients)) {
                jobDealer.afterSubmitJobVast(afterJobClients);
            }
        }
    } catch (Exception e) {
        LOGGER.error("----broker:{} RecoverDealer error:", localAddress, e);
    }
}
Also used : ParamAction(com.dtstack.taier.pluginapi.pojo.ParamAction) ArrayList(java.util.ArrayList) JobClient(com.dtstack.taier.pluginapi.JobClient) ScheduleEngineJobCache(com.dtstack.taier.dao.domain.ScheduleEngineJobCache)

Example 15 with JobClient

use of com.dtstack.taier.pluginapi.JobClient in project Taier by DTStack.

the class HadoopClient method main.

public static void main(String[] args) throws Exception {
    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);
        HadoopClient client = new HadoopClient();
        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();
        }
    }
}
Also used : ParamAction(com.dtstack.taier.pluginapi.pojo.ParamAction) JobClient(com.dtstack.taier.pluginapi.JobClient) YarnException(org.apache.hadoop.yarn.exceptions.YarnException) PluginDefineException(com.dtstack.taier.pluginapi.exception.PluginDefineException) ClusterResource(com.dtstack.taier.pluginapi.pojo.ClusterResource)

Aggregations

JobClient (com.dtstack.taier.pluginapi.JobClient)28 ParamAction (com.dtstack.taier.pluginapi.pojo.ParamAction)14 Test (org.junit.Test)6 PluginDefineException (com.dtstack.taier.pluginapi.exception.PluginDefineException)5 JobResult (com.dtstack.taier.pluginapi.pojo.JobResult)5 IOException (java.io.IOException)5 JarFileInfo (com.dtstack.taier.pluginapi.JarFileInfo)4 JobIdentifier (com.dtstack.taier.pluginapi.JobIdentifier)4 ClusterResource (com.dtstack.taier.pluginapi.pojo.ClusterResource)4 Properties (java.util.Properties)4 Logger (org.slf4j.Logger)4 LoggerFactory (org.slf4j.LoggerFactory)4 JSONObject (com.alibaba.fastjson.JSONObject)3 KerberosUtils (com.dtstack.taier.base.util.KerberosUtils)3 RdosDefineException (com.dtstack.taier.common.exception.RdosDefineException)3 ScheduleEngineJobCache (com.dtstack.taier.dao.domain.ScheduleEngineJobCache)3 FlinkConfig (com.dtstack.taier.flink.FlinkConfig)3 EJobType (com.dtstack.taier.pluginapi.enums.EJobType)3 JudgeResult (com.dtstack.taier.pluginapi.pojo.JudgeResult)3 File (java.io.File)3