Search in sources :

Example 21 with Channel

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

the class ConfigClientServiceImpl method findPipeline.

public Pipeline findPipeline(Long pipelineId) {
    Long channelId = channelMapping.get(pipelineId);
    Channel channel = channelCache.get(channelId);
    List<Pipeline> pipelines = channel.getPipelines();
    for (Pipeline pipeline : pipelines) {
        if (pipeline.getId().equals(pipelineId)) {
            return pipeline;
        }
    }
    throw new ConfigException("no pipeline for pipelineId[" + pipelineId + "]");
}
Also used : Channel(com.alibaba.otter.shared.common.model.config.channel.Channel) ConfigException(com.alibaba.otter.shared.common.model.config.ConfigException) Pipeline(com.alibaba.otter.shared.common.model.config.pipeline.Pipeline)

Example 22 with Channel

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

the class AddPipeline method execute.

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

Example 23 with Channel

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

the class AnalysisDelayStat method execute.

public void execute(@Param("d5221") String startTime, @Param("d5222") String endTime, @Param("pipelineId") Long pipelineId, HttpSession session, Context context) throws Exception {
    Date end = null;
    Date start = null;
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
    if (StringUtils.isEmpty(startTime) || StringUtils.isEmpty(endTime)) {
        start = new Date(System.currentTimeMillis() / 60000 * 60000 - 24 * 60 * 60 * 1000);
        end = new Date(System.currentTimeMillis() / 60000 * 60000);
    } else {
        // 当前24小时,时间取整分钟
        sdf.setLenient(false);
        if (null != startTime && null != endTime) {
            start = sdf.parse(startTime);
            end = sdf.parse(endTime);
        }
    }
    Channel channel = channelService.findByPipelineId(pipelineId);
    Map<Long, DelayStatInfo> delayStatInfos = new HashMap<Long, DelayStatInfo>();
    if (null != start && null != end) {
        delayStatInfos = delayStatService.listTimelineDelayStat(pipelineId, start, end);
    }
    Double delayAvg = 0.0;
    for (DelayStatInfo info : delayStatInfos.values()) {
        delayAvg += info.getAvgDelayTime();
    }
    if (delayStatInfos.size() != 0) {
        delayAvg = delayAvg / (1.0 * delayStatInfos.size());
    }
    context.put("delayStatInfos", delayStatInfos);
    context.put("delayAvg", delayAvg);
    context.put("channel", channel);
    context.put("pipelineId", pipelineId);
    context.put("start", sdf.format(start));
    context.put("end", sdf.format(end));
}
Also used : HashMap(java.util.HashMap) Channel(com.alibaba.otter.shared.common.model.config.channel.Channel) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date) DelayStatInfo(com.alibaba.otter.manager.biz.statistics.delay.param.DelayStatInfo)

Example 24 with Channel

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

the class BehaviorHistoryCurve method execute.

public void execute(@Param("d5221") String startTime, @Param("d5222") String endTime, @Param("dataMediaPairId") Long dataMediaPairId, HttpSession session, Context context) throws Exception {
    Date end = null;
    Date start = null;
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
    if (StringUtils.isEmpty(startTime) || StringUtils.isEmpty(endTime)) {
        start = new Date(System.currentTimeMillis() / 60000 * 60000 - 24 * 60 * 60 * 1000);
        end = new Date(System.currentTimeMillis() / 60000 * 60000);
    } else {
        // 当前24小时,时间取整分钟
        sdf.setLenient(false);
        if (null != startTime && null != endTime) {
            start = sdf.parse(startTime);
            end = sdf.parse(endTime);
        }
    }
    DataMediaPair dataMediaPair = dataMediaPairService.findById(dataMediaPairId);
    Channel channel = channelService.findByPipelineId(dataMediaPair.getPipelineId());
    Map<Long, BehaviorHistoryInfo> behaviourHistoryInfos = new LinkedHashMap<Long, BehaviorHistoryInfo>();
    TimelineBehaviorHistoryCondition condition = new TimelineBehaviorHistoryCondition();
    if (null != start && null != end) {
        condition.setStart(start);
        condition.setEnd(end);
        condition.setPairId(dataMediaPairId);
        behaviourHistoryInfos = tableStatService.listTimelineBehaviorHistory(condition);
    }
    Long totalInsert = 0L;
    Long totalUpdate = 0L;
    Long totalDelete = 0L;
    Long totalFileCount = 0L;
    Long totalFileSize = 0L;
    for (BehaviorHistoryInfo info : behaviourHistoryInfos.values()) {
        totalInsert += info.getInsertNumber();
        totalUpdate += info.getUpdateNumber();
        totalDelete += info.getDeleteNumber();
        totalFileCount += info.getFileNumber();
        totalFileSize += info.getFileSize();
    }
    context.put("totalInsert", totalInsert);
    context.put("totalUpdate", totalUpdate);
    context.put("totalDelete", totalDelete);
    context.put("totalFileCount", totalFileCount);
    context.put("totalFileSize", totalFileSize);
    context.put("behaviourHistoryInfos", behaviourHistoryInfos);
    context.put("start", sdf.format(start));
    context.put("end", sdf.format(end));
    context.put("dataMediaPair", dataMediaPair);
    context.put("channel", channel);
}
Also used : DataMediaPair(com.alibaba.otter.shared.common.model.config.data.DataMediaPair) Channel(com.alibaba.otter.shared.common.model.config.channel.Channel) BehaviorHistoryInfo(com.alibaba.otter.manager.biz.statistics.table.param.BehaviorHistoryInfo) TimelineBehaviorHistoryCondition(com.alibaba.otter.manager.biz.statistics.table.param.TimelineBehaviorHistoryCondition) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date) LinkedHashMap(java.util.LinkedHashMap)

Example 25 with Channel

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

the class CanalInfo method execute.

public void execute(@Param("canalId") Long canalId, Context context) throws Exception {
    Canal canal = canalService.findById(canalId);
    AutoKeeperCluster zkCluster = autoKeeperClusterService.findAutoKeeperClusterById(canal.getCanalParameter().getZkClusterId());
    List<Pipeline> pipelines = pipelineService.listByDestinationWithoutOther(canal.getName());
    List<Long> channelIds = new ArrayList<Long>();
    for (Pipeline pipeline : pipelines) {
        channelIds.add(pipeline.getChannelId());
    }
    List<Channel> channels = channelService.listOnlyChannels(channelIds.toArray(new Long[channelIds.size()]));
    Map<Long, Channel> channelMap = new HashMap<Long, Channel>();
    for (Channel channel : channels) {
        channelMap.put(channel.getId(), channel);
    }
    context.put("canal", canal);
    context.put("pipelines", pipelines);
    context.put("channelMap", channelMap);
    context.put("zkCluster", zkCluster);
}
Also used : HashMap(java.util.HashMap) Canal(com.alibaba.otter.canal.instance.manager.model.Canal) Channel(com.alibaba.otter.shared.common.model.config.channel.Channel) ArrayList(java.util.ArrayList) AutoKeeperCluster(com.alibaba.otter.shared.common.model.autokeeper.AutoKeeperCluster) 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