Search in sources :

Example 1 with SystemParameter

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

the class AlarmRuleAction method doOnekeyAddMonitor.

/**
     * 一键添加监控
     */
public void doOnekeyAddMonitor(@Param("pipelineId") Long pipelineId, Navigator nav) throws Exception {
    List<AlarmRule> existRules = alarmRuleService.getAlarmRules(pipelineId);
    if (!existRules.isEmpty()) {
        nav.redirectToLocation("alarmRuleList.htm?pipelineId=" + pipelineId);
        return;
    }
    SystemParameter systemParameter = systemParameterService.find();
    AlarmRule alarmRule = new AlarmRule();
    alarmRule.setPipelineId(pipelineId);
    alarmRule.setDescription("one key added!");
    alarmRule.setAutoRecovery(Boolean.FALSE);
    alarmRule.setReceiverKey(systemParameter.getDefaultAlarmReceiveKey());
    alarmRule.setStatus(AlarmRuleStatus.DISABLE);
    alarmRule.setRecoveryThresold(3);
    alarmRule.setIntervalTime(1800L);
    try {
        alarmRule.setMonitorName(MonitorName.EXCEPTION);
        alarmRule.setMatchValue("ERROR,EXCEPTION");
        alarmRule.setIntervalTime(1800L);
        alarmRule.setAutoRecovery(false);
        alarmRule.setRecoveryThresold(2);
        alarmRuleService.create(alarmRule);
        alarmRule.setMonitorName(MonitorName.POSITIONTIMEOUT);
        alarmRule.setMatchValue("600");
        alarmRule.setIntervalTime(1800L);
        alarmRule.setAutoRecovery(true);
        alarmRule.setRecoveryThresold(0);
        alarmRuleService.create(alarmRule);
        alarmRule.setMonitorName(MonitorName.DELAYTIME);
        alarmRule.setMatchValue("600");
        alarmRule.setIntervalTime(1800L);
        alarmRule.setAutoRecovery(false);
        alarmRule.setRecoveryThresold(2);
        alarmRuleService.create(alarmRule);
        alarmRule.setMonitorName(MonitorName.PROCESSTIMEOUT);
        alarmRule.setMatchValue("60");
        alarmRule.setIntervalTime(1800L);
        alarmRule.setAutoRecovery(true);
        alarmRule.setRecoveryThresold(2);
        alarmRuleService.create(alarmRule);
    // alarmRule.setMonitorName(MonitorName.PIPELINETIMEOUT);
    // alarmRule.setMatchValue("43200");
    // alarmRuleService.create(alarmRule);
    } catch (Exception e) {
        return;
    }
    nav.redirectToLocation("alarmRuleList.htm?pipelineId=" + pipelineId);
}
Also used : AlarmRule(com.alibaba.otter.shared.common.model.config.alarm.AlarmRule) SystemParameter(com.alibaba.otter.shared.common.model.config.parameter.SystemParameter) WebxException(com.alibaba.citrus.webx.WebxException) RepeatConfigureException(com.alibaba.otter.manager.biz.common.exceptions.RepeatConfigureException)

Example 2 with SystemParameter

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

the class ChannelServiceImpl method doToModel.

/**
     * <pre>
     * 用于DO对象转化为Model对象
     * 现阶段优化:
     *      需要五次SQL交互:pipeline\node\dataMediaPair\dataMedia\dataMediaSource(五个层面)
     *      目前优化方案为单层只执行一次SQL,避免重复循环造成IO及数据库查询开销
     * 长期优化:
     *      对SQL进行改造,尽量减小SQL调用次数
     * </pre>
     * 
     * @param channelDO
     * @return Channel
     */
private Channel doToModel(ChannelDO channelDo) {
    Channel channel = new Channel();
    try {
        channel.setId(channelDo.getId());
        channel.setName(channelDo.getName());
        channel.setDescription(channelDo.getDescription());
        channel.setStatus(arbitrateManageService.channelEvent().status(channelDo.getId()));
        channel.setParameters(channelDo.getParameters());
        channel.setGmtCreate(channelDo.getGmtCreate());
        channel.setGmtModified(channelDo.getGmtModified());
        List<Pipeline> pipelines = pipelineService.listByChannelIds(channelDo.getId());
        // 合并PipelineParameter和ChannelParameter
        SystemParameter systemParameter = systemParameterService.find();
        for (Pipeline pipeline : pipelines) {
            PipelineParameter parameter = new PipelineParameter();
            parameter.merge(systemParameter);
            parameter.merge(channel.getParameters());
            // 最后复制pipelineId参数
            parameter.merge(pipeline.getParameters());
            pipeline.setParameters(parameter);
        // pipeline.getParameters().merge(channel.getParameters());
        }
        channel.setPipelines(pipelines);
    } catch (Exception e) {
        logger.error("ERROR ## change the channel DO to Model has an exception");
        throw new ManagerException(e);
    }
    return channel;
}
Also used : Channel(com.alibaba.otter.shared.common.model.config.channel.Channel) SystemParameter(com.alibaba.otter.shared.common.model.config.parameter.SystemParameter) PipelineParameter(com.alibaba.otter.shared.common.model.config.pipeline.PipelineParameter) ManagerException(com.alibaba.otter.manager.biz.common.exceptions.ManagerException) 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)

Example 3 with SystemParameter

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

the class ChannelServiceImpl method doToModel.

/**
     * <pre>
     * 用于DO对象数组转化为Model对象数组
     * 现阶段优化:
     *      需要五次SQL交互:pipeline\node\dataMediaPair\dataMedia\dataMediaSource(五个层面)
     *      目前优化方案为单层只执行一次SQL,避免重复循环造成IO及数据库查询开销
     * 长期优化:
     *      对SQL进行改造,尽量减小SQL调用次数
     * </pre>
     * 
     * @param channelDO
     * @return Channel
     */
private List<Channel> doToModel(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.listByChannelIds(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 4 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_mysql.

@Test
public void test_db_load_mysql() {
    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 = generatorDataMediaPairForMysql(20);
    pipeline.setPairs(pairs);
    pipeline.getParameters().merge(new SystemParameter());
    pipeline.getParameters().merge(new ChannelParameter());
    // pipeline.getParameters().setChannelInfo("LJH_DEMO");
    // 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 = generatorEventDataForMysql(0, 20, EventType.INSERT);
    for (EventData eventData : eventDatas) {
        rowBatch.merge(eventData);
    }
    eventDatas = generatorEventDataForMysql(10, 10, EventType.INSERT);
    for (EventData eventData : eventDatas) {
        rowBatch.merge(eventData);
    }
    eventDatas = generatorEventDataForMysql(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)

Example 5 with SystemParameter

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

the class SystemParameterAction method doEdit.

/**
     * 修改系统参数
     */
public void doEdit(@FormGroup("systemParameterDetailInfo") Group systemParameterDetailInfo, Navigator nav) throws Exception {
    SystemParameter systemParameter = new SystemParameter();
    systemParameterDetailInfo.setProperties(systemParameter);
    String defaultAlarmReceiver = systemParameterDetailInfo.getField("defaultAlarmReceiver").getStringValue();
    String[] defaultAlarmReceiverStrs = StringUtils.split(defaultAlarmReceiver, "=");
    if (defaultAlarmReceiverStrs.length != 2) {
        throw new ManagerException("defaultAlarmReceiver[" + defaultAlarmReceiver + "] is not valid!");
    }
    systemParameter.setDefaultAlarmReceiveKey(defaultAlarmReceiverStrs[0]);
    systemParameter.setDefaultAlarmReceiver(defaultAlarmReceiverStrs[1]);
    String alarmReceiver = systemParameterDetailInfo.getField("alarmReceiver").getStringValue();
    List<String> alarmReceivers = new ArrayList<String>();
    String[] alarmReceiver1 = StringUtils.split(alarmReceiver, "\n");
    for (String alarmReceiverStr : alarmReceiver1) {
        String[] alarmReceiver2 = StringUtils.split(alarmReceiverStr, ";");
        for (String alarmReceiverStr2 : alarmReceiver2) {
            alarmReceivers.add(alarmReceiverStr2);
        }
    }
    Map<String, String> alarmReceiverMap = new LinkedHashMap<String, String>();
    for (String alarmReceiverStr : alarmReceivers) {
        String[] alarmReceiverStrs = StringUtils.split(alarmReceiverStr, "=");
        if (alarmReceiverStrs.length != 2) {
            throw new ManagerException("alarmReceiver[" + alarmReceiver + "] is not valid!");
        }
        alarmReceiverMap.put(alarmReceiverStrs[0], alarmReceiverStrs[1]);
    }
    systemParameter.setAlarmReceiver(alarmReceiverMap);
    systemParameterService.createOrUpdate(systemParameter);
    nav.redirectToLocation("systemParameter.htm?edit=true");
}
Also used : ArrayList(java.util.ArrayList) SystemParameter(com.alibaba.otter.shared.common.model.config.parameter.SystemParameter) ManagerException(com.alibaba.otter.manager.biz.common.exceptions.ManagerException) LinkedHashMap(java.util.LinkedHashMap)

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