Search in sources :

Example 6 with WorkflowException

use of org.apache.inlong.manager.common.exceptions.WorkflowException in project incubator-inlong by apache.

the class WorkflowContext method clone.

@Override
public WorkflowContext clone() {
    try {
        WorkflowContext workflowContext = (WorkflowContext) super.clone();
        workflowContext.setProcess(process.clone());
        workflowContext.setCurrentElement(currentElement.clone());
        if (actionContext != null) {
            workflowContext.setActionContext(actionContext.clone());
        }
        return workflowContext;
    } catch (Exception e) {
        log.error("workflow context clone failed", e);
        throw new WorkflowException("workflow context clone failed " + this.getProcessEntity().getId());
    }
}
Also used : WorkflowException(org.apache.inlong.manager.common.exceptions.WorkflowException) WorkflowException(org.apache.inlong.manager.common.exceptions.WorkflowException)

Example 7 with WorkflowException

use of org.apache.inlong.manager.common.exceptions.WorkflowException in project incubator-inlong by apache.

the class DefaultHiveTableOperator method createTable.

private void createTable(String groupId, SinkForSortDTO config) {
    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("begin create hive table for inlong group={}, config={}", groupId, config);
    }
    // Get all info from config
    HiveSinkDTO hiveInfo = HiveSinkDTO.getFromJson(config.getExtParams());
    HiveTableQueryBean tableBean = getTableQueryBean(config, hiveInfo);
    try {
        // create database if not exists
        dataSourceService.createDb(tableBean);
        // check if the table exists
        List<ColumnInfoBean> columns = dataSourceService.queryColumns(tableBean);
        if (columns.size() == 0) {
            // no such table, create one
            dataSourceService.createTable(tableBean);
        } else {
            // set columns, skip the first columns already exist in hive
            List<HiveColumnQueryBean> columnsSkipHistory = tableBean.getColumns().stream().skip(columns.size()).collect(toList());
            if (columnsSkipHistory.size() != 0) {
                tableBean.setColumns(columnsSkipHistory);
                dataSourceService.createColumn(tableBean);
            }
        }
        sinkService.updateStatus(config.getId(), EntityStatus.SINK_CONFIG_SUCCESSFUL.getCode(), "create hive table success");
    } catch (Throwable e) {
        LOGGER.error("create hive table error, ", e);
        sinkService.updateStatus(config.getId(), EntityStatus.SINK_CONFIG_FAILED.getCode(), e.getMessage());
        throw new WorkflowException("create hive table failed, reason: " + e.getMessage());
    }
    LOGGER.info("success create hive table for data group [" + groupId + "]");
}
Also used : HiveTableQueryBean(org.apache.inlong.manager.common.pojo.query.hive.HiveTableQueryBean) WorkflowException(org.apache.inlong.manager.common.exceptions.WorkflowException) HiveSinkDTO(org.apache.inlong.manager.common.pojo.sink.hive.HiveSinkDTO) ColumnInfoBean(org.apache.inlong.manager.common.pojo.query.ColumnInfoBean) HiveColumnQueryBean(org.apache.inlong.manager.common.pojo.query.hive.HiveColumnQueryBean)

Aggregations

WorkflowException (org.apache.inlong.manager.common.exceptions.WorkflowException)7 WorkflowTaskEntity (org.apache.inlong.manager.dao.entity.WorkflowTaskEntity)2 Element (org.apache.inlong.manager.workflow.definition.Element)2 NextableElement (org.apache.inlong.manager.workflow.definition.NextableElement)2 Collections (java.util.Collections)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 ColumnInfoBean (org.apache.inlong.manager.common.pojo.query.ColumnInfoBean)1 HiveColumnQueryBean (org.apache.inlong.manager.common.pojo.query.hive.HiveColumnQueryBean)1 HiveTableQueryBean (org.apache.inlong.manager.common.pojo.query.hive.HiveTableQueryBean)1 HiveSinkDTO (org.apache.inlong.manager.common.pojo.sink.hive.HiveSinkDTO)1 ProcessDetailResponse (org.apache.inlong.manager.common.pojo.workflow.ProcessDetailResponse)1 TaskResponse (org.apache.inlong.manager.common.pojo.workflow.TaskResponse)1 WorkflowApproverQuery (org.apache.inlong.manager.common.pojo.workflow.WorkflowApproverQuery)1 Preconditions (org.apache.inlong.manager.common.util.Preconditions)1 WorkflowApproverEntity (org.apache.inlong.manager.dao.entity.WorkflowApproverEntity)1 WorkflowEventLogEntity (org.apache.inlong.manager.dao.entity.WorkflowEventLogEntity)1 WorkflowProcessEntity (org.apache.inlong.manager.dao.entity.WorkflowProcessEntity)1 WorkflowContext (org.apache.inlong.manager.workflow.WorkflowContext)1 EndEvent (org.apache.inlong.manager.workflow.definition.EndEvent)1