use of org.I0Itec.zkclient.exception.ZkException in project otter by alibaba.
the class LoadStageListener method stageChannged.
public void stageChannged(Long processId, List<String> stageNodes) {
try {
// 1. 根据pipelineId+processId构造对应的path
String path = StagePathUtils.getProcess(getPipelineId(), processId);
if (replyProcessIds.contains(processId)) {
// 避免重复处理
return;
}
// 2.2 判断是否存在了prev节点
if (stageNodes.contains(prevNode)) {
// 2.2.1 获取上一个节点的next node节点信息
byte[] data = zookeeper.readData(path + "/" + prevNode);
EtlEventData eventData = JsonUtils.unmarshalFromByte(data, EtlEventData.class);
if (eventData.getNextNid().equals(ArbitrateConfigUtils.getCurrentNid())) {
List<Long> currentProcessIds = stageMonitor.getCurrentProcessIds(false);
if (currentProcessIds.contains(processId) && currentProcessIds.get(0).equals(processId)) {
// 判断是否是当前最小的processId节点,轮到自己处理了
// 添加到返回队列,唤醒wait阻塞
addReply(processId);
}
}
}
} catch (ZkNoNodeException e) {
// 出现节点不存在,说明出现了error情况
} catch (ZkException e) {
logger.error("LoadStageListener", e);
}
}
use of org.I0Itec.zkclient.exception.ZkException in project otter by alibaba.
the class TransformStageListener method stageChannged.
public void stageChannged(Long processId, List<String> stageNodes) {
try {
// 1. 根据pipelineId+processId构造对应的path
String path = StagePathUtils.getProcess(getPipelineId(), processId);
// 2.1 判断是否存在了error节点,end节点或者current节点
if (stageNodes.contains(currentNode)) {
if (replyProcessIds.remove(processId)) {
if (logger.isDebugEnabled()) {
logger.debug("## remove reply id [{}]", processId);
}
}
// 不需要监听了
return;
}
if (replyProcessIds.contains(processId)) {
// 避免重复处理
return;
}
// 2.2 判断是否存在了prev节点
if (stageNodes.contains(prevNode)) {
// 2.2.1 获取上一个节点的next node节点信息
byte[] data = zookeeper.readData(path + "/" + prevNode);
EtlEventData eventData = JsonUtils.unmarshalFromByte(data, EtlEventData.class);
if (eventData.getNextNid().equals(ArbitrateConfigUtils.getCurrentNid())) {
// 添加到返回队列,唤醒wait阻塞
addReply(processId);
}
}
} catch (ZkNoNodeException e) {
// 出现节点不存在,说明出现了error情况
} catch (ZkException e) {
logger.error("TransformStageListener", e);
}
}
use of org.I0Itec.zkclient.exception.ZkException in project otter by alibaba.
the class ExtractStageListener method stageChannged.
public void stageChannged(Long processId, List<String> stageNodes) {
try {
// 1. 根据pipelineId+processId构造对应的path
String path = StagePathUtils.getProcess(getPipelineId(), processId);
// 2.1 判断是否存在了current节点
if (stageNodes.contains(currentNode)) {
if (replyProcessIds.remove(processId)) {
if (logger.isDebugEnabled()) {
logger.debug("## remove reply id [{}]", processId);
}
}
// 不需要监听了
return;
}
if (replyProcessIds.contains(processId)) {
// 避免重复处理
return;
}
// 2.2 判断是否存在了prev节点
if (stageNodes.contains(prevNode)) {
// 2.2.1 获取上一个节点的next node节点信息
byte[] data = zookeeper.readData(path + "/" + prevNode);
EtlEventData eventData = JsonUtils.unmarshalFromByte(data, EtlEventData.class);
if (eventData.getNextNid().equals(ArbitrateConfigUtils.getCurrentNid())) {
// 添加到返回队列,唤醒wait阻塞
addReply(processId);
}
}
} catch (ZkNoNodeException e) {
// 出现节点不存在,说明出现了error情况
} catch (ZkException e) {
logger.error("ExtractStageListener", e);
}
}
use of org.I0Itec.zkclient.exception.ZkException in project otter by alibaba.
the class SelectStageListener method recovery.
/**
* 尝试载入一下上一次未使用的processId,可能发生mainstem切换,新的S模块需要感知前S模块已创建但未使用的process,不然就是一个死锁。而针对已经使用的processId会由e/t/l节点进行处理
*/
private void recovery(Long pipelineId) {
List<Long> currentProcessIds = stageMonitor.getCurrentProcessIds(false);
for (Long processId : currentProcessIds) {
String path = StagePathUtils.getProcess(pipelineId, processId);
try {
byte[] bytes = zookeeper.readData(path);
ProcessNodeEventData nodeData = JsonUtils.unmarshalFromByte(bytes, ProcessNodeEventData.class);
if (nodeData.getStatus().isUnUsed()) {
// 加入未使用的processId
addReply(processId);
}
} catch (ZkException e) {
logger.error("SelectStageListener", e);
}
}
}
use of org.I0Itec.zkclient.exception.ZkException in project otter by alibaba.
the class ChannelArbitrateEvent method init.
/**
* 初始化对应的channel节点,同步调用
*/
public void init(Long channelId) {
String path = ManagePathUtils.getChannelByChannelId(channelId);
// 初始化的数据对象
byte[] data = JsonUtils.marshalToByte(ChannelStatus.STOP);
try {
zookeeper.create(path, data, CreateMode.PERSISTENT);
} catch (ZkNodeExistsException e) {
// 如果节点已经存在,则不抛异常
// ignore
} catch (ZkNoNodeException e) {
// 创建父节点
zookeeper.createPersistent(path, data, true);
} catch (ZkException e) {
throw new ArbitrateException("Channel_init", channelId.toString(), e);
}
}
Aggregations