Search in sources :

Example 51 with Channel

use of com.alibaba.otter.shared.common.model.config.channel.Channel in project otter by alibaba.

the class ChannelAction method doAdd.

/**
     * 添加Channel
     * 
     * @param channelInfo
     * @param channelParameterInfo
     * @throws Exception
     */
public void doAdd(@FormGroup("channelInfo") Group channelInfo, @FormGroup("channelParameterInfo") Group channelParameterInfo, @FormField(name = "formChannelError", group = "channelInfo") CustomErrors err, Navigator nav) throws Exception {
    Channel channel = new Channel();
    ChannelParameter parameter = new ChannelParameter();
    channelInfo.setProperties(channel);
    channelParameterInfo.setProperties(parameter);
    // 新建Channel默认关闭该状态
    channel.setStatus(ChannelStatus.STOP);
    channel.setParameters(parameter);
    try {
        channelService.create(channel);
    } catch (RepeatConfigureException rce) {
        err.setMessage("invalidChannelName");
        return;
    }
    nav.redirectTo(WebConstant.CHANNEL_LIST_LINK);
}
Also used : RepeatConfigureException(com.alibaba.otter.manager.biz.common.exceptions.RepeatConfigureException) ChannelParameter(com.alibaba.otter.shared.common.model.config.channel.ChannelParameter) Channel(com.alibaba.otter.shared.common.model.config.channel.Channel)

Example 52 with Channel

use of com.alibaba.otter.shared.common.model.config.channel.Channel in project otter by alibaba.

the class DataMediaPairAction method doDelete.

/**
     * 删除映射关系
     */
public void doDelete(@Param("dataMediaPairId") Long dataMediaPairId, @Param("pipelineId") Long pipelineId, Navigator nav) throws WebxException {
    Channel channel = channelService.findByPipelineId(pipelineId);
    if (channel.getStatus().isStart()) {
        nav.redirectTo(WebConstant.ERROR_FORBIDDEN_Link);
        return;
    }
    dataMediaPairService.remove(dataMediaPairId);
    nav.redirectToLocation("dataMediaPairList.htm?pipelineId=" + pipelineId);
}
Also used : Channel(com.alibaba.otter.shared.common.model.config.channel.Channel)

Example 53 with Channel

use of com.alibaba.otter.shared.common.model.config.channel.Channel in project otter by alibaba.

the class AddBatchDataMediaPair method execute.

public void execute(@Param("pipelineId") Long pipelineId, Context context, Navigator nav) throws Exception {
    Channel channel = channelService.findByPipelineId(pipelineId);
    if (channel.getStatus().isStart()) {
        nav.redirectTo(WebConstant.ERROR_FORBIDDEN_Link);
        return;
    }
    context.put("pipelineId", pipelineId);
    context.put("channelId", channel.getId());
}
Also used : Channel(com.alibaba.otter.shared.common.model.config.channel.Channel)

Example 54 with Channel

use of com.alibaba.otter.shared.common.model.config.channel.Channel in project otter by alibaba.

the class PipelineList method execute.

public void execute(@Param("channelId") Long channelId, @Param("pipelineId") Long pipelineId, HttpSession session, Context context) throws Exception {
    Channel channel = channelService.findByIdWithoutColumn(channelId);
    List<Pipeline> pipelines = channel.getPipelines();
    List<Pipeline> tempPipe = new ArrayList<Pipeline>();
    if ((pipelineId != null) && (pipelineId != 0l)) {
        for (Pipeline pipeline : pipelines) {
            if (!pipeline.getId().equals(pipelineId)) {
                tempPipe.add(pipeline);
            }
        }
        pipelines.removeAll(tempPipe);
    }
    Map<Long, DelayStat> delayStats = new HashMap<Long, DelayStat>(pipelines.size(), 1f);
    Map<Long, MainStemEventData> mainstemDatas = new HashMap<Long, MainStemEventData>(pipelines.size(), 1f);
    Map<Long, ThroughputStat> throughputStats = new HashMap<Long, ThroughputStat>(pipelines.size(), 1f);
    Map<Long, List<AlarmRule>> alarmRuleStats = new HashMap<Long, List<AlarmRule>>(pipelines.size(), 1f);
    Map<Long, PositionEventData> positionDatas = new HashMap<Long, PositionEventData>(pipelines.size(), 1f);
    for (Pipeline pipeline : pipelines) {
        DelayStat delayStat = delayStatService.findRealtimeDelayStat(pipeline.getId());
        if (delayStat.getDelayNumber() == null) {
            delayStat.setDelayNumber(0L);
            delayStat.setDelayTime(0L);
            delayStat.setGmtModified(pipeline.getGmtModified());
        }
        delayStats.put(pipeline.getId(), delayStat);
        mainstemDatas.put(pipeline.getId(), arbitrateViewService.mainstemData(channel.getId(), pipeline.getId()));
        ThroughputCondition condition = new ThroughputCondition();
        condition.setPipelineId(pipeline.getId());
        condition.setType(ThroughputType.ROW);
        ThroughputStat throughputStat = throughputStatService.findThroughputStatByPipelineId(condition);
        throughputStats.put(pipeline.getId(), throughputStat);
        List<AlarmRule> alarmRules = alarmRuleService.getAlarmRules(pipeline.getId());
        alarmRuleStats.put(pipeline.getId(), alarmRules);
        PositionEventData positionData = arbitrateViewService.getCanalCursor(pipeline.getParameters().getDestinationName(), pipeline.getParameters().getMainstemClientId());
        positionDatas.put(pipeline.getId(), positionData);
    }
    context.put("channel", channel);
    context.put("pipelines", pipelines);
    context.put("delayStats", delayStats);
    context.put("throughputStats", throughputStats);
    context.put("alarmRuleStats", alarmRuleStats);
    context.put("mainstemDatas", mainstemDatas);
    context.put("positionDatas", positionDatas);
}
Also used : PositionEventData(com.alibaba.otter.shared.arbitrate.model.PositionEventData) HashMap(java.util.HashMap) AlarmRule(com.alibaba.otter.shared.common.model.config.alarm.AlarmRule) Channel(com.alibaba.otter.shared.common.model.config.channel.Channel) ArrayList(java.util.ArrayList) MainStemEventData(com.alibaba.otter.shared.arbitrate.model.MainStemEventData) DelayStat(com.alibaba.otter.shared.common.model.statistics.delay.DelayStat) Pipeline(com.alibaba.otter.shared.common.model.config.pipeline.Pipeline) ThroughputStat(com.alibaba.otter.shared.common.model.statistics.throughput.ThroughputStat) ArrayList(java.util.ArrayList) List(java.util.List) ThroughputCondition(com.alibaba.otter.manager.biz.statistics.throughput.param.ThroughputCondition)

Example 55 with Channel

use of com.alibaba.otter.shared.common.model.config.channel.Channel in project otter by alibaba.

the class SystemReduction method execute.

public void execute(@Param("command") String command, Context context) throws Exception {
    @SuppressWarnings("unchecked") String resultStr = "";
    if ("true".equals(command)) {
        List<Channel> channels = channelService.listAll();
        try {
            // 初始化根节点
            arbitrateManageService.systemEvent().init();
            // 遍历所有的Channel节点
            for (Channel channel : channels) {
                // 在ZK中初始化每个channel节点
                arbitrateManageService.channelEvent().init(channel.getId());
                // 在ZK中初始化该channel下的pipeline节点
                List<Pipeline> pipelines = channel.getPipelines();
                //
                for (Pipeline pipeline : pipelines) {
                    arbitrateManageService.pipelineEvent().init(pipeline.getChannelId(), pipeline.getId());
                }
            }
            resultStr = "恭喜!Zookeeper节点数据已经补全";
        } catch (ArbitrateException ae) {
            logger.error("ERROR ## init zookeeper has a problem ", ae);
            resultStr = "出错了!回复zookeeper的时候遇到问题!";
        } catch (Exception e) {
            logger.error("ERROR ## init zookeeper has a problem ", e);
            resultStr = "出错了!回复zookeeper的时候遇到问题!";
        }
    }
    context.put("resultStr", resultStr);
}
Also used : Channel(com.alibaba.otter.shared.common.model.config.channel.Channel) ArbitrateException(com.alibaba.otter.shared.arbitrate.exception.ArbitrateException) ArbitrateException(com.alibaba.otter.shared.arbitrate.exception.ArbitrateException) Pipeline(com.alibaba.otter.shared.common.model.config.pipeline.Pipeline)

Aggregations

Channel (com.alibaba.otter.shared.common.model.config.channel.Channel)77 Pipeline (com.alibaba.otter.shared.common.model.config.pipeline.Pipeline)38 Mock (mockit.Mock)16 ArrayList (java.util.ArrayList)13 ManagerException (com.alibaba.otter.manager.biz.common.exceptions.ManagerException)10 RepeatConfigureException (com.alibaba.otter.manager.biz.common.exceptions.RepeatConfigureException)10 ChannelArbitrateEvent (com.alibaba.otter.shared.arbitrate.impl.manage.ChannelArbitrateEvent)10 BeforeClass (org.testng.annotations.BeforeClass)10 PipelineArbitrateEvent (com.alibaba.otter.shared.arbitrate.impl.manage.PipelineArbitrateEvent)9 InvalidConfigureException (com.alibaba.otter.manager.biz.common.exceptions.InvalidConfigureException)8 NodeArbitrateEvent (com.alibaba.otter.shared.arbitrate.impl.manage.NodeArbitrateEvent)8 Node (com.alibaba.otter.shared.common.model.config.node.Node)7 Event (com.alibaba.otter.shared.communication.core.model.Event)7 Test (org.testng.annotations.Test)7 ChannelStatus (com.alibaba.otter.shared.common.model.config.channel.ChannelStatus)6 DataMediaPair (com.alibaba.otter.shared.common.model.config.data.DataMediaPair)6 HashMap (java.util.HashMap)6 ChannelDO (com.alibaba.otter.manager.biz.config.channel.dal.dataobject.ChannelDO)5 SystemParameter (com.alibaba.otter.shared.common.model.config.parameter.SystemParameter)5 Identity (com.alibaba.otter.shared.etl.model.Identity)5