Search in sources :

Example 6 with SystemParameter

use of com.alibaba.otter.shared.common.model.config.parameter.SystemParameter in project otter by alibaba.

the class DefaultAlarmService method doSend.

public void doSend(AlarmMessage data) throws Exception {
    // 只发送纯文本
    SimpleMailMessage mail = new SimpleMailMessage();
    mail.setFrom(username);
    // 主题
    mail.setSubject(TITLE);
    // 邮件内容
    mail.setText(data.getMessage());
    String[] receiveKeys = StringUtils.split(StringUtils.replace(data.getReceiveKey(), ";", ","), ",");
    SystemParameter systemParameter = systemParameterService.find();
    List<String> mailAddress = new ArrayList<String>();
    for (String receiveKey : receiveKeys) {
        String receiver = convertToReceiver(systemParameter, receiveKey);
        String[] strs = StringUtils.split(StringUtils.replace(receiver, ";", ","), ",");
        for (String str : strs) {
            if (isMail(str)) {
                if (str != null) {
                    mailAddress.add(str);
                }
            } else if (isSms(str)) {
            // do nothing
            }
        }
    }
    if (!mailAddress.isEmpty()) {
        mail.setTo(mailAddress.toArray(new String[mailAddress.size()]));
        doSendMail(mail);
    }
}
Also used : SimpleMailMessage(org.springframework.mail.SimpleMailMessage) ArrayList(java.util.ArrayList) SystemParameter(com.alibaba.otter.shared.common.model.config.parameter.SystemParameter)

Example 7 with SystemParameter

use of com.alibaba.otter.shared.common.model.config.parameter.SystemParameter in project otter by alibaba.

the class ChannelServiceImpl method doToModelWithColumn.

private List<Channel> doToModelWithColumn(List<ChannelDO> channelDos) {
    List<Channel> channels = new ArrayList<Channel>();
    try {
        // 1.将ChannelID单独拿出来
        List<Long> channelIds = new ArrayList<Long>();
        for (ChannelDO channelDo : channelDos) {
            channelIds.add(channelDo.getId());
        }
        Long[] idArray = new Long[channelIds.size()];
        // 拿到所有的Pipeline进行ChannelID过滤,避免重复查询。
        List<Pipeline> pipelines = pipelineService.listByChannelIdsWithoutColumn(channelIds.toArray(idArray));
        SystemParameter systemParameter = systemParameterService.find();
        for (ChannelDO channelDo : channelDos) {
            Channel channel = new Channel();
            channel.setId(channelDo.getId());
            channel.setName(channelDo.getName());
            channel.setDescription(channelDo.getDescription());
            ChannelStatus channelStatus = arbitrateManageService.channelEvent().status(channelDo.getId());
            channel.setStatus(null == channelStatus ? ChannelStatus.STOP : channelStatus);
            channel.setParameters(channelDo.getParameters());
            channel.setGmtCreate(channelDo.getGmtCreate());
            channel.setGmtModified(channelDo.getGmtModified());
            // 遍历,将该Channel节点下的Pipeline提取出来。
            List<Pipeline> subPipelines = new ArrayList<Pipeline>();
            for (Pipeline pipeline : pipelines) {
                if (pipeline.getChannelId().equals(channelDo.getId())) {
                    // 合并PipelineParameter和ChannelParameter
                    PipelineParameter parameter = new PipelineParameter();
                    parameter.merge(systemParameter);
                    parameter.merge(channel.getParameters());
                    // 最后复制pipelineId参数
                    parameter.merge(pipeline.getParameters());
                    pipeline.setParameters(parameter);
                    subPipelines.add(pipeline);
                }
            }
            channel.setPipelines(subPipelines);
            channels.add(channel);
        }
    } catch (Exception e) {
        logger.error("ERROR ## change the channels DO to Model has an exception");
        throw new ManagerException(e);
    }
    return channels;
}
Also used : Channel(com.alibaba.otter.shared.common.model.config.channel.Channel) ArrayList(java.util.ArrayList) ChannelStatus(com.alibaba.otter.shared.common.model.config.channel.ChannelStatus) InvalidConfigureException(com.alibaba.otter.manager.biz.common.exceptions.InvalidConfigureException) RepeatConfigureException(com.alibaba.otter.manager.biz.common.exceptions.RepeatConfigureException) ManagerException(com.alibaba.otter.manager.biz.common.exceptions.ManagerException) Pipeline(com.alibaba.otter.shared.common.model.config.pipeline.Pipeline) SystemParameter(com.alibaba.otter.shared.common.model.config.parameter.SystemParameter) ChannelDO(com.alibaba.otter.manager.biz.config.channel.dal.dataobject.ChannelDO) PipelineParameter(com.alibaba.otter.shared.common.model.config.pipeline.PipelineParameter) ManagerException(com.alibaba.otter.manager.biz.common.exceptions.ManagerException)

Example 8 with SystemParameter

use of com.alibaba.otter.shared.common.model.config.parameter.SystemParameter in project otter by alibaba.

the class DbLoadActionTest method test_db_load_oracle.

@Test
public void test_db_load_oracle() {
    ArbitrateConfigRegistry.regist(configClientService);
    dbLoadAction = (DbLoadAction) TestedObject.getSpringBeanFactory().getBean("dbLoadAction");
    final Channel channel = new Channel();
    channel.setId(1L);
    final Pipeline pipeline = new Pipeline();
    pipeline.setId(100L);
    List<DataMediaPair> pairs = generatorDataMediaPairForOracle(20);
    pipeline.setPairs(pairs);
    pipeline.getParameters().merge(new SystemParameter());
    pipeline.getParameters().merge(new ChannelParameter());
    // final Pipeline oppositePipeline = new Pipeline();
    // oppositePipeline.setId(101L);
    channel.setPipelines(Arrays.asList(pipeline));
    final Node currentNode = new Node();
    currentNode.setId(1L);
    new NonStrictExpectations() {

        {
            configClientService.findChannel(anyLong);
            returns(channel);
            configClientService.findPipeline(anyLong);
            returns(pipeline);
            configClientService.currentNode();
            returns(currentNode);
        }
    };
    Identity identity = new Identity();
    identity.setChannelId(100L);
    identity.setPipelineId(100L);
    identity.setProcessId(100L);
    RowBatch rowBatch = new RowBatch();
    rowBatch.setIdentity(identity);
    List<EventData> eventDatas = generatorEventDataForOracle(0, 20, EventType.INSERT);
    for (EventData eventData : eventDatas) {
        rowBatch.merge(eventData);
    }
    eventDatas = generatorEventDataForOracle(10, 10, EventType.INSERT);
    for (EventData eventData : eventDatas) {
        rowBatch.merge(eventData);
    }
    eventDatas = generatorEventDataForOracle(19, 1, EventType.DELETE);
    for (EventData eventData : eventDatas) {
        rowBatch.merge(eventData);
    }
    WeightController controller = new WeightController(1);
    dbLoadAction.load(rowBatch, controller);
}
Also used : DataMediaPair(com.alibaba.otter.shared.common.model.config.data.DataMediaPair) ChannelParameter(com.alibaba.otter.shared.common.model.config.channel.ChannelParameter) Channel(com.alibaba.otter.shared.common.model.config.channel.Channel) Node(com.alibaba.otter.shared.common.model.config.node.Node) EventData(com.alibaba.otter.shared.etl.model.EventData) Pipeline(com.alibaba.otter.shared.common.model.config.pipeline.Pipeline) RowBatch(com.alibaba.otter.shared.etl.model.RowBatch) SystemParameter(com.alibaba.otter.shared.common.model.config.parameter.SystemParameter) WeightController(com.alibaba.otter.node.etl.load.loader.weight.WeightController) Identity(com.alibaba.otter.shared.etl.model.Identity) Test(org.testng.annotations.Test) BaseDbTest(com.alibaba.otter.node.etl.BaseDbTest)

Aggregations

SystemParameter (com.alibaba.otter.shared.common.model.config.parameter.SystemParameter)8 Channel (com.alibaba.otter.shared.common.model.config.channel.Channel)5 Pipeline (com.alibaba.otter.shared.common.model.config.pipeline.Pipeline)5 ManagerException (com.alibaba.otter.manager.biz.common.exceptions.ManagerException)4 RepeatConfigureException (com.alibaba.otter.manager.biz.common.exceptions.RepeatConfigureException)4 ArrayList (java.util.ArrayList)4 InvalidConfigureException (com.alibaba.otter.manager.biz.common.exceptions.InvalidConfigureException)3 PipelineParameter (com.alibaba.otter.shared.common.model.config.pipeline.PipelineParameter)3 ChannelDO (com.alibaba.otter.manager.biz.config.channel.dal.dataobject.ChannelDO)2 BaseDbTest (com.alibaba.otter.node.etl.BaseDbTest)2 WeightController (com.alibaba.otter.node.etl.load.loader.weight.WeightController)2 ChannelParameter (com.alibaba.otter.shared.common.model.config.channel.ChannelParameter)2 ChannelStatus (com.alibaba.otter.shared.common.model.config.channel.ChannelStatus)2 DataMediaPair (com.alibaba.otter.shared.common.model.config.data.DataMediaPair)2 Node (com.alibaba.otter.shared.common.model.config.node.Node)2 EventData (com.alibaba.otter.shared.etl.model.EventData)2 Identity (com.alibaba.otter.shared.etl.model.Identity)2 RowBatch (com.alibaba.otter.shared.etl.model.RowBatch)2 Test (org.testng.annotations.Test)2 WebxException (com.alibaba.citrus.webx.WebxException)1