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();
}
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();
}
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();
}
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);
}
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;
}
Aggregations