Search in sources :

Example 31 with Pipeline

use of com.alibaba.otter.shared.common.model.config.pipeline.Pipeline in project otter by alibaba.

the class PermitMonitorTest method init.

@BeforeClass
public void init() {
    // 初始化节点
    Mockit.setUpMock(ArbitrateConfigUtils.class, new Object() {

        @Mock
        public Channel getChannel(Long pipelineId) {
            Channel channel = new Channel();
            channel.setId(channelId);
            return channel;
        }

        @Mock
        public Pipeline getOppositePipeline(Long pipelineId) {
            Pipeline pipeline = new Pipeline();
            pipeline.setId(oppositePipelineId);
            return pipeline;
        }
    });
    zookeeper = getZookeeper();
    channelEvent = new ChannelArbitrateEvent();
    pipelineEvent = new PipelineArbitrateEvent();
}
Also used : Channel(com.alibaba.otter.shared.common.model.config.channel.Channel) ChannelArbitrateEvent(com.alibaba.otter.shared.arbitrate.impl.manage.ChannelArbitrateEvent) PipelineArbitrateEvent(com.alibaba.otter.shared.arbitrate.impl.manage.PipelineArbitrateEvent) Mock(mockit.Mock) Pipeline(com.alibaba.otter.shared.common.model.config.pipeline.Pipeline) BeforeClass(org.testng.annotations.BeforeClass)

Example 32 with Pipeline

use of com.alibaba.otter.shared.common.model.config.pipeline.Pipeline in project otter by alibaba.

the class ChannelArbitrateEventTest method init.

@BeforeClass
public void init() {
    // 初始化节点
    // mock 配置信息数据
    Mockit.setUpMock(ArbitrateConfigUtils.class, new Object() {

        @Mock
        public Channel getChannel(Long pipelineId) {
            Channel channel = new Channel();
            channel.setId(channelId);
            return channel;
        }

        @Mock
        public Pipeline getOppositePipeline(Long pipelineId) {
            Pipeline pipeline = new Pipeline();
            pipeline.setId(pipelineId);
            return pipeline;
        }
    });
    zookeeper = getZookeeper();
    channelEvent = new ChannelArbitrateEvent();
}
Also used : Channel(com.alibaba.otter.shared.common.model.config.channel.Channel) ChannelArbitrateEvent(com.alibaba.otter.shared.arbitrate.impl.manage.ChannelArbitrateEvent) Mock(mockit.Mock) Pipeline(com.alibaba.otter.shared.common.model.config.pipeline.Pipeline) BeforeClass(org.testng.annotations.BeforeClass)

Example 33 with Pipeline

use of com.alibaba.otter.shared.common.model.config.pipeline.Pipeline in project otter by alibaba.

the class PipelineArbitrateEventTest method init.

@BeforeClass
public void init() {
    // 初始化节点
    // mock 配置信息数据
    Mockit.setUpMock(ArbitrateConfigUtils.class, new Object() {

        @Mock
        public Channel getChannel(Long pipelineId) {
            Channel channel = new Channel();
            channel.setId(channelId);
            return channel;
        }

        @Mock
        public Pipeline getOppositePipeline(Long pipelineId) {
            Pipeline pipeline = new Pipeline();
            pipeline.setId(pipelineId);
            return pipeline;
        }
    });
    zookeeper = getZookeeper();
    channelEvent = new ChannelArbitrateEvent();
    pipelineEvent = new PipelineArbitrateEvent();
}
Also used : Channel(com.alibaba.otter.shared.common.model.config.channel.Channel) ChannelArbitrateEvent(com.alibaba.otter.shared.arbitrate.impl.manage.ChannelArbitrateEvent) PipelineArbitrateEvent(com.alibaba.otter.shared.arbitrate.impl.manage.PipelineArbitrateEvent) Mock(mockit.Mock) Pipeline(com.alibaba.otter.shared.common.model.config.pipeline.Pipeline) BeforeClass(org.testng.annotations.BeforeClass)

Example 34 with Pipeline

use of com.alibaba.otter.shared.common.model.config.pipeline.Pipeline in project otter by alibaba.

the class LogRecordServiceImpl method create.

public void create(Event event) {
    LogRecord logRecord = new LogRecord();
    if (event instanceof NodeAlarmEvent) {
        NodeAlarmEvent nodeAlarmEvent = (NodeAlarmEvent) event;
        Pipeline tempPipeline = new Pipeline();
        tempPipeline.setId(nodeAlarmEvent.getPipelineId());
        logRecord.setPipeline(tempPipeline);
        logRecord.setNid(nodeAlarmEvent.getNid());
        logRecord.setTitle(nodeAlarmEvent.getTitle());
        logRecord.setMessage(nodeAlarmEvent.getMessage());
    }
    create(logRecord);
}
Also used : LogRecord(com.alibaba.otter.shared.common.model.config.record.LogRecord) NodeAlarmEvent(com.alibaba.otter.shared.communication.model.arbitrate.NodeAlarmEvent) Pipeline(com.alibaba.otter.shared.common.model.config.pipeline.Pipeline)

Example 35 with Pipeline

use of com.alibaba.otter.shared.common.model.config.pipeline.Pipeline in project otter by alibaba.

the class LogRecordServiceImpl method doToModel.

/**
 * <pre>
 * 用于DO对象转化为Model对象
 * </pre>
 *
 * @param channelDO
 * @return Channel
 */
private LogRecord doToModel(LogRecordDO logRecordDo) {
    LogRecord logRecord = new LogRecord();
    try {
        logRecord.setId(logRecordDo.getId());
        if (logRecordDo.getPipelineId() > 0 && logRecordDo.getChannelId() > 0) {
            try {
                Channel channel = channelService.findByPipelineId(logRecordDo.getPipelineId());
                logRecord.setChannel(channel);
                for (Pipeline pipeline : channel.getPipelines()) {
                    if (pipeline.getId().equals(logRecordDo.getPipelineId())) {
                        logRecord.setPipeline(pipeline);
                    }
                }
            } catch (Exception e) {
                // 可能历史的log记录对应的channel/pipeline已经被删除了,直接忽略吧
                Channel channel = new Channel();
                channel.setId(0l);
                logRecord.setChannel(channel);
                Pipeline pipeline = new Pipeline();
                pipeline.setId(0l);
                logRecord.setPipeline(pipeline);
            }
        } else {
            Channel channel = new Channel();
            channel.setId(-1l);
            logRecord.setChannel(channel);
            Pipeline pipeline = new Pipeline();
            pipeline.setId(-1l);
            logRecord.setPipeline(pipeline);
        }
        logRecord.setTitle(logRecordDo.getTitle());
        logRecord.setNid(logRecordDo.getNid());
        logRecord.setMessage(logRecordDo.getMessage());
        logRecord.setGmtCreate(logRecordDo.getGmtCreate());
        logRecord.setGmtModified(logRecordDo.getGmtModified());
    } catch (Exception e) {
        logger.error("ERROR ## ");
        throw new ManagerException(e);
    }
    return logRecord;
}
Also used : LogRecord(com.alibaba.otter.shared.common.model.config.record.LogRecord) Channel(com.alibaba.otter.shared.common.model.config.channel.Channel) ManagerException(com.alibaba.otter.manager.biz.common.exceptions.ManagerException) ManagerException(com.alibaba.otter.manager.biz.common.exceptions.ManagerException) Pipeline(com.alibaba.otter.shared.common.model.config.pipeline.Pipeline)

Aggregations

Pipeline (com.alibaba.otter.shared.common.model.config.pipeline.Pipeline)105 Channel (com.alibaba.otter.shared.common.model.config.channel.Channel)38 ArrayList (java.util.ArrayList)37 Node (com.alibaba.otter.shared.common.model.config.node.Node)22 Test (org.testng.annotations.Test)20 DataMediaPair (com.alibaba.otter.shared.common.model.config.data.DataMediaPair)19 EventData (com.alibaba.otter.shared.etl.model.EventData)19 Mock (mockit.Mock)19 ManagerException (com.alibaba.otter.manager.biz.common.exceptions.ManagerException)17 RepeatConfigureException (com.alibaba.otter.manager.biz.common.exceptions.RepeatConfigureException)17 Identity (com.alibaba.otter.shared.etl.model.Identity)12 RowBatch (com.alibaba.otter.shared.etl.model.RowBatch)12 BaseDbTest (com.alibaba.otter.node.etl.BaseDbTest)10 ChannelArbitrateEvent (com.alibaba.otter.shared.arbitrate.impl.manage.ChannelArbitrateEvent)10 PipelineArbitrateEvent (com.alibaba.otter.shared.arbitrate.impl.manage.PipelineArbitrateEvent)9 PipelineParameter (com.alibaba.otter.shared.common.model.config.pipeline.PipelineParameter)9 FileBatch (com.alibaba.otter.shared.etl.model.FileBatch)9 FileData (com.alibaba.otter.shared.etl.model.FileData)9 HashMap (java.util.HashMap)9 BeforeClass (org.testng.annotations.BeforeClass)9