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

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


                        String exceptionCause = "query channelId:" + channelId + " return null.";
                        logger.error("ERROR ## " + exceptionCause);
                        throw new ManagerException(exceptionCause);
                    }

                    ChannelStatus oldStatus = arbitrateManageService.channelEvent().status(channelDo.getId());
                    Channel channel = doToModel(channelDo);
                    // 检查下ddl/home配置
                    List<Pipeline> pipelines = channel.getPipelines();
                    if (pipelines.size() > 1) {
                        boolean ddlSync = true;
                        boolean homeSync = true;
                        for (Pipeline pipeline : pipelines) {
                            homeSync &= pipeline.getParameters().isHome();
                            ddlSync &= pipeline.getParameters().getDdlSync();
                        }

                        if (ddlSync) {
                            throw new InvalidConfigureException(INVALID_TYPE.DDL);
                        }

                        if (homeSync) {
                            throw new InvalidConfigureException(INVALID_TYPE.HOME);
                        }
                    }

                    channel.setStatus(oldStatus);
                    ChannelStatus newStatus = channelStatus;
                    if (newStatus != null) {
                        if (newStatus.equals(oldStatus)) {
                            // String exceptionCause = "switch the channel(" +
                            // channelId + ") status to " +
                            // channelStatus
                            // + " but it had the status:" + oldStatus;
                            // logger.error("ERROR ## " + exceptionCause);
                            // throw new ManagerException(exceptionCause);
                            // ignored
                            return;
                        } else {
                            channel.setStatus(newStatus);// 强制修改为当前变更状态
                        }
                    } else {
                        newStatus = oldStatus;
                    }

                    // 针对关闭操作,要优先更改对应的status,避免node工作线程继续往下跑
                    if (newStatus.isStop()) {
                        arbitrateManageService.channelEvent().stop(channelId);
                    } else if (newStatus.isPause()) {
                        arbitrateManageService.channelEvent().pause(channelId);
                    }

                    // 通知变更内容
                    boolean result = configRemoteService.notifyChannel(channel);// 客户端响应成功,才更改对应的状态

                    if (result) {
                        // 针对启动的话,需要先通知到客户端,客户端启动线程后,再更改channel状态
                        if (newStatus.isStart()) {
                            arbitrateManageService.channelEvent().start(channelId);
                        }
                    }

                } catch (Exception e) {
View Full Code Here


            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提取出来。
View Full Code Here

            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提取出来。
View Full Code Here

            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提取出来。
View Full Code Here

        permitMonitor.waitForPermit();// 阻塞等待授权

        ExtractStageListener extractStageListener = ArbitrateFactory.getInstance(pipelineId, ExtractStageListener.class);
        Long processId = extractStageListener.waitForProcess(); // 符合条件的processId

        ChannelStatus status = permitMonitor.getChannelPermit();
        if (status.isStart()) {// 即时查询一下当前的状态,状态随时可能会变
            // 根据pipelineId+processId构造对应的path
            String path = StagePathUtils.getSelectStage(pipelineId, processId);

            try {
                byte[] data = zookeeper.readData(path);
View Full Code Here

    @Test
    public void testInit() {
        channelEvent.init(channelId);
        String path = StagePathUtils.getChannelByChannelId(channelId);
        byte[] data = zookeeper.readData(path);
        ChannelStatus status = JsonUtils.unmarshalFromByte(data, ChannelStatus.class);
        want.bool(status == ChannelStatus.STOP).is(true);
        channelEvent.destory(channelId);
    }
View Full Code Here

        channelEvent.init(channelId);
        // 启动
        channelEvent.start(channelId);
        String path = StagePathUtils.getChannelByChannelId(channelId);
        byte[] data = zookeeper.readData(path);
        ChannelStatus status = JsonUtils.unmarshalFromByte(data, ChannelStatus.class);
        want.bool(status == ChannelStatus.START).is(true);
        channelEvent.destory(channelId);
    }
View Full Code Here

    public void test_aPause() {
        // 启动
        channelEvent.pause(channelId);
        String path = StagePathUtils.getChannelByChannelId(channelId);
        byte[] data = zookeeper.readData(path);
        ChannelStatus status = JsonUtils.unmarshalFromByte(data, ChannelStatus.class);
        want.bool(status == ChannelStatus.PAUSE).is(true);
    }
View Full Code Here

    public void test_bStart() {
        // 启动
        channelEvent.start(channelId);
        String path = StagePathUtils.getChannelByChannelId(channelId);
        byte[] data = zookeeper.readData(path);
        ChannelStatus status = JsonUtils.unmarshalFromByte(data, ChannelStatus.class);
        want.bool(status == ChannelStatus.START).is(true);
    }
View Full Code Here

        List<Long> theStatusPks = new ArrayList<Long>();
        if (null != status) {
            List<Long> allChannelPks = channelService.listAllChannelId();

            for (Long channelPk : allChannelPks) {
                ChannelStatus channelStatus = arbitrateManageService.channelEvent().status(channelPk);
                if (channelStatus.equals(ChannelStatus.valueOf(status))) {
                    theStatusPks.add(channelPk);
                }
            }
        }
View Full Code Here

TOP

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

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.