Package com.alibaba.otter.shared.common.model.config.channel

Examples of com.alibaba.otter.shared.common.model.config.channel.Channel


    /**
     * 执行结束同步任务操作
     */
    private Boolean termin(Long channelId, final TerminType type) throws Exception {
        Channel channel = ArbitrateConfigUtils.getChannelByChannelId(channelId);
        List<Pipeline> pipelines = channel.getPipelines();
        List<Future<Boolean>> futures = new ArrayList<Future<Boolean>>();
        for (final Pipeline pipeline : pipelines) {
            futures.add(arbitrateExecutor.submit(new Callable<Boolean>() {

                public Boolean call() {
View Full Code Here


            stageController.offerTermin(data);
        } else if (type.isWarning()) {
            warningTerminProcess.process(data); // warn单独处理,不需要关闭相关的pipeline
        } else {
            // 内存版可以简化处理rollback/restart/shutdown模型,不需要进行process的termin操作处理
            Channel channel = ArbitrateConfigUtils.getChannel(data.getPipelineId());
            if (data.getType().isRollback()) {
                boolean paused = channelEvent.pause(channel.getId(), false);
                if (paused) {// 如果pause成功,则发送报警信息
                    warningTerminProcess.process(data);
                }
            } else if (data.getType().isShutdown()) {
                boolean shutdowned = channelEvent.stop(channel.getId(), false);
                // 发送报警信息
                if (shutdowned) {
                    warningTerminProcess.process(data);
                }
                // 发送关闭命令给manager
                StopChannelEvent event = new StopChannelEvent();
                event.setChannelId(channel.getId());
                arbitrateCommmunicationClient.callManager(event);
            } else if (data.getType().isRestart()) {
                boolean restarted = channelEvent.restart(channel.getId(), false);
                // 发送报警信息
                if (restarted) {
                    warningTerminProcess.process(data);
                }
            }
View Full Code Here

        return channelCache.get(channelId);
    }

    public Pipeline findOppositePipeline(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) == false) {// 这里假定pipeline只有两个
                return pipeline;
            }
        }
View Full Code Here

        return null;
    }

    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;
            }
        }
View Full Code Here

        // 获取一下nid变量
        channelMapping = new MapMaker().makeComputingMap(new Function<Long, Long>() {

            public Long apply(Long pipelineId) {
                // 处理下pipline -> channel映射关系不存在的情况
                Channel channel = channelService.findByPipelineId(pipelineId);
                if (channel == null) {
                    throw new ConfigException("No Such Channel by pipelineId[" + pipelineId + "]");
                }

                updateMapping(channel, pipelineId);// 排除下自己
                channelCache.put(channel.getId(), channel);// 更新下channelCache
                return channel.getId();

            }
        });

        channelCache = new RefreshMemoryMirror<Long, Channel>(timeout, new ComputeFunction<Long, Channel>() {

            public Channel apply(Long key, Channel oldValue) {
                Channel channel = channelService.findById(key);
                if (channel == null) {
                    // 其他情况直接返回内存中的旧值
                    return oldValue;
                } else {
                    updateMapping(channel, null);// 排除下自己
View Full Code Here

    // }

    // ================ helper method ================

    private static String getChannelId(Long pipelineId) {
        Channel channel = ArbitrateConfigUtils.getChannel(pipelineId);
        return String.valueOf(channel.getId());
    }
View Full Code Here

TOP

Related Classes of com.alibaba.otter.shared.common.model.config.channel.Channel

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.