* 1. 开始阻塞获取符合条件的processId,获取对应的data数据直接返回
* </pre>
*/
public TerminEventData await(Long pipelineId) throws InterruptedException {
Assert.notNull(pipelineId);
TerminMonitor terminMonitor = ArbitrateFactory.getInstance(pipelineId, TerminMonitor.class);
Long processId = terminMonitor.waitForProcess(); // 符合条件的processId
if (logger.isDebugEnabled()) {
logger.debug("## await pipeline[{}] processId[{}] is termin", pipelineId, processId);
}
// 根据pipelineId+processId构造对应的path
String path = StagePathUtils.getTermin(pipelineId, processId);
try {
byte[] data = zookeeper.readData(path);
return JsonUtils.unmarshalFromByte(data, TerminEventData.class);
} catch (ZkNoNodeException e) {
logger.error("pipeline[{}] processId[{}] is process", pipelineId, processId);
terminMonitor.ack(processId); // modify for 2012-09-08, 发生主备切换时,await会进入死循环,针对NoNode后直接从内存队列中移除
return await(pipelineId); // 再取下一个节点
} catch (ZkException e) {
throw new ArbitrateException("Termin_await", e);
}
}