use of com.alibaba.otter.shared.arbitrate.model.TerminEventData.TerminType in project otter by alibaba.
the class TerminMemoryArbitrateEvent method single.
public void single(TerminEventData data) {
// 正向处理
final TerminType type = data.getType();
MemoryStageController stageController = ArbitrateFactory.getInstance(data.getPipelineId(), MemoryStageController.class);
if (type.isNormal()) {
Assert.notNull(data.getProcessId());
stageController.offerTermin(data);
} else if (type.isWarning()) {
// warn单独处理,不需要关闭相关的pipeline
warningTerminProcess.process(data);
} 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);
}
}
// 内存中构造异常termin信号返回
stageController.termin(data.getType());
}
}
use of com.alibaba.otter.shared.arbitrate.model.TerminEventData.TerminType in project otter by alibaba.
the class TerminZooKeeperArbitrateEvent method single.
/**
* <pre>
* 算法:
* 1. 创建对应的termin节点,标志process为终结状态
* </pre>
*/
public void single(final TerminEventData data) {
// 正向处理
final TerminType type = data.getType();
if (type.isNormal()) {
Assert.notNull(data.getProcessId());
// 单独处理
normalTerminProcess.process(data);
} else if (type.isWarning()) {
// warn单独处理,不需要关闭相关的pipeline
warningTerminProcess.process(data);
} else {
Channel channel = ArbitrateConfigUtils.getChannel(data.getPipelineId());
if (data.getType().isRollback()) {
boolean paused = channelEvent.pause(channel.getId());
if (paused) {
// 如果pause成功,则发送报警信息
warningTerminProcess.process(data);
}
} else if (data.getType().isShutdown()) {
boolean shutdowned = channelEvent.stop(channel.getId());
// 发送报警信息
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());
// 发送报警信息
if (restarted) {
warningTerminProcess.process(data);
}
}
}
}
Aggregations