Search in sources :

Example 26 with ZkNoNodeException

use of org.I0Itec.zkclient.exception.ZkNoNodeException in project otter by alibaba.

the class SystemArbitrateEvent method switchWarmup.

/**
     * 手工触发一次主备切换
     */
public void switchWarmup(Long channelId, Long pipelineId) {
    String path = ManagePathUtils.getMainStem(channelId, pipelineId);
    try {
        while (true) {
            Stat stat = new Stat();
            byte[] bytes = zookeeper.readData(path, stat);
            MainStemEventData mainStemData = JsonUtils.unmarshalFromByte(bytes, MainStemEventData.class);
            mainStemData.setActive(false);
            try {
                zookeeper.writeData(path, JsonUtils.marshalToByte(mainStemData), stat.getVersion());
                logger.warn("relase channelId[{}],pipelineId[{}] mainstem successed! ", channelId, pipelineId);
                break;
            } catch (ZkBadVersionException e) {
            // ignore , retrying
            }
        }
    } catch (ZkNoNodeException e) {
    // ignore
    } catch (ZkException e) {
        throw new ArbitrateException("releaseMainStem", pipelineId.toString(), e);
    }
}
Also used : Stat(org.apache.zookeeper.data.Stat) ZkNoNodeException(org.I0Itec.zkclient.exception.ZkNoNodeException) ZkException(org.I0Itec.zkclient.exception.ZkException) MainStemEventData(com.alibaba.otter.shared.arbitrate.model.MainStemEventData) ZkBadVersionException(org.I0Itec.zkclient.exception.ZkBadVersionException) ArbitrateException(com.alibaba.otter.shared.arbitrate.exception.ArbitrateException)

Example 27 with ZkNoNodeException

use of org.I0Itec.zkclient.exception.ZkNoNodeException in project otter by alibaba.

the class MainStemMonitorTest method switchWarmup.

/**
     * 手工触发一次主备切换
     */
private void switchWarmup(Long channelId, Long pipelineId) {
    String path = ManagePathUtils.getMainStem(channelId, pipelineId);
    try {
        while (true) {
            Stat stat = new Stat();
            byte[] bytes = zookeeper.readData(path, stat);
            MainStemEventData mainStemData = JsonUtils.unmarshalFromByte(bytes, MainStemEventData.class);
            mainStemData.setActive(false);
            try {
                zookeeper.writeData(path, JsonUtils.marshalToByte(mainStemData), stat.getVersion());
                break;
            } catch (ZkBadVersionException e) {
            // ignore , retrying
            }
        }
    } catch (ZkNoNodeException e) {
    // ignore
    } catch (ZkException e) {
        throw new ArbitrateException("releaseMainStem", pipelineId.toString(), e);
    }
}
Also used : Stat(org.apache.zookeeper.data.Stat) ZkNoNodeException(org.I0Itec.zkclient.exception.ZkNoNodeException) ZkException(org.I0Itec.zkclient.exception.ZkException) MainStemEventData(com.alibaba.otter.shared.arbitrate.model.MainStemEventData) ZkBadVersionException(org.I0Itec.zkclient.exception.ZkBadVersionException) ArbitrateException(com.alibaba.otter.shared.arbitrate.exception.ArbitrateException)

Aggregations

ZkNoNodeException (org.I0Itec.zkclient.exception.ZkNoNodeException)27 ZkException (org.I0Itec.zkclient.exception.ZkException)22 ArbitrateException (com.alibaba.otter.shared.arbitrate.exception.ArbitrateException)17 EtlEventData (com.alibaba.otter.shared.arbitrate.model.EtlEventData)7 PermitMonitor (com.alibaba.otter.shared.arbitrate.impl.setl.monitor.PermitMonitor)5 ChannelStatus (com.alibaba.otter.shared.common.model.config.channel.ChannelStatus)5 ZkNodeExistsException (org.I0Itec.zkclient.exception.ZkNodeExistsException)5 ArrayList (java.util.ArrayList)4 PositionRange (com.alibaba.otter.canal.protocol.position.PositionRange)3 MainStemEventData (com.alibaba.otter.shared.arbitrate.model.MainStemEventData)3 Node (com.alibaba.otter.shared.common.model.config.node.Node)3 ZkInterruptedException (org.I0Itec.zkclient.exception.ZkInterruptedException)3 TerminMonitor (com.alibaba.otter.shared.arbitrate.impl.setl.monitor.TerminMonitor)2 Date (java.util.Date)2 ZkBadVersionException (org.I0Itec.zkclient.exception.ZkBadVersionException)2 Stat (org.apache.zookeeper.data.Stat)2 CanalMetaManagerException (com.alibaba.otter.canal.meta.exception.CanalMetaManagerException)1 ClientIdentity (com.alibaba.otter.canal.protocol.ClientIdentity)1 CanalClientException (com.alibaba.otter.canal.protocol.exception.CanalClientException)1 StageComparator (com.alibaba.otter.shared.arbitrate.impl.setl.helper.StageComparator)1