use of com.alibaba.otter.shared.common.model.config.channel.Channel in project otter by alibaba.
the class ChannelAction method doAdd.
/**
* 添加Channel
*
* @param channelInfo
* @param channelParameterInfo
* @throws Exception
*/
public void doAdd(@FormGroup("channelInfo") Group channelInfo, @FormGroup("channelParameterInfo") Group channelParameterInfo, @FormField(name = "formChannelError", group = "channelInfo") CustomErrors err, Navigator nav) throws Exception {
Channel channel = new Channel();
ChannelParameter parameter = new ChannelParameter();
channelInfo.setProperties(channel);
channelParameterInfo.setProperties(parameter);
// 新建Channel默认关闭该状态
channel.setStatus(ChannelStatus.STOP);
channel.setParameters(parameter);
try {
channelService.create(channel);
} catch (RepeatConfigureException rce) {
err.setMessage("invalidChannelName");
return;
}
nav.redirectTo(WebConstant.CHANNEL_LIST_LINK);
}
use of com.alibaba.otter.shared.common.model.config.channel.Channel in project otter by alibaba.
the class DataMediaPairAction method doDelete.
/**
* 删除映射关系
*/
public void doDelete(@Param("dataMediaPairId") Long dataMediaPairId, @Param("pipelineId") Long pipelineId, Navigator nav) throws WebxException {
Channel channel = channelService.findByPipelineId(pipelineId);
if (channel.getStatus().isStart()) {
nav.redirectTo(WebConstant.ERROR_FORBIDDEN_Link);
return;
}
dataMediaPairService.remove(dataMediaPairId);
nav.redirectToLocation("dataMediaPairList.htm?pipelineId=" + pipelineId);
}
use of com.alibaba.otter.shared.common.model.config.channel.Channel in project otter by alibaba.
the class AddBatchDataMediaPair method execute.
public void execute(@Param("pipelineId") Long pipelineId, Context context, Navigator nav) throws Exception {
Channel channel = channelService.findByPipelineId(pipelineId);
if (channel.getStatus().isStart()) {
nav.redirectTo(WebConstant.ERROR_FORBIDDEN_Link);
return;
}
context.put("pipelineId", pipelineId);
context.put("channelId", channel.getId());
}
use of com.alibaba.otter.shared.common.model.config.channel.Channel in project otter by alibaba.
the class PipelineList method execute.
public void execute(@Param("channelId") Long channelId, @Param("pipelineId") Long pipelineId, HttpSession session, Context context) throws Exception {
Channel channel = channelService.findByIdWithoutColumn(channelId);
List<Pipeline> pipelines = channel.getPipelines();
List<Pipeline> tempPipe = new ArrayList<Pipeline>();
if ((pipelineId != null) && (pipelineId != 0l)) {
for (Pipeline pipeline : pipelines) {
if (!pipeline.getId().equals(pipelineId)) {
tempPipe.add(pipeline);
}
}
pipelines.removeAll(tempPipe);
}
Map<Long, DelayStat> delayStats = new HashMap<Long, DelayStat>(pipelines.size(), 1f);
Map<Long, MainStemEventData> mainstemDatas = new HashMap<Long, MainStemEventData>(pipelines.size(), 1f);
Map<Long, ThroughputStat> throughputStats = new HashMap<Long, ThroughputStat>(pipelines.size(), 1f);
Map<Long, List<AlarmRule>> alarmRuleStats = new HashMap<Long, List<AlarmRule>>(pipelines.size(), 1f);
Map<Long, PositionEventData> positionDatas = new HashMap<Long, PositionEventData>(pipelines.size(), 1f);
for (Pipeline pipeline : pipelines) {
DelayStat delayStat = delayStatService.findRealtimeDelayStat(pipeline.getId());
if (delayStat.getDelayNumber() == null) {
delayStat.setDelayNumber(0L);
delayStat.setDelayTime(0L);
delayStat.setGmtModified(pipeline.getGmtModified());
}
delayStats.put(pipeline.getId(), delayStat);
mainstemDatas.put(pipeline.getId(), arbitrateViewService.mainstemData(channel.getId(), pipeline.getId()));
ThroughputCondition condition = new ThroughputCondition();
condition.setPipelineId(pipeline.getId());
condition.setType(ThroughputType.ROW);
ThroughputStat throughputStat = throughputStatService.findThroughputStatByPipelineId(condition);
throughputStats.put(pipeline.getId(), throughputStat);
List<AlarmRule> alarmRules = alarmRuleService.getAlarmRules(pipeline.getId());
alarmRuleStats.put(pipeline.getId(), alarmRules);
PositionEventData positionData = arbitrateViewService.getCanalCursor(pipeline.getParameters().getDestinationName(), pipeline.getParameters().getMainstemClientId());
positionDatas.put(pipeline.getId(), positionData);
}
context.put("channel", channel);
context.put("pipelines", pipelines);
context.put("delayStats", delayStats);
context.put("throughputStats", throughputStats);
context.put("alarmRuleStats", alarmRuleStats);
context.put("mainstemDatas", mainstemDatas);
context.put("positionDatas", positionDatas);
}
use of com.alibaba.otter.shared.common.model.config.channel.Channel in project otter by alibaba.
the class SystemReduction method execute.
public void execute(@Param("command") String command, Context context) throws Exception {
@SuppressWarnings("unchecked") String resultStr = "";
if ("true".equals(command)) {
List<Channel> channels = channelService.listAll();
try {
// 初始化根节点
arbitrateManageService.systemEvent().init();
// 遍历所有的Channel节点
for (Channel channel : channels) {
// 在ZK中初始化每个channel节点
arbitrateManageService.channelEvent().init(channel.getId());
// 在ZK中初始化该channel下的pipeline节点
List<Pipeline> pipelines = channel.getPipelines();
//
for (Pipeline pipeline : pipelines) {
arbitrateManageService.pipelineEvent().init(pipeline.getChannelId(), pipeline.getId());
}
}
resultStr = "恭喜!Zookeeper节点数据已经补全";
} catch (ArbitrateException ae) {
logger.error("ERROR ## init zookeeper has a problem ", ae);
resultStr = "出错了!回复zookeeper的时候遇到问题!";
} catch (Exception e) {
logger.error("ERROR ## init zookeeper has a problem ", e);
resultStr = "出错了!回复zookeeper的时候遇到问题!";
}
}
context.put("resultStr", resultStr);
}
Aggregations