Search in sources :

Example 36 with ArbitrateException

use of com.alibaba.otter.shared.arbitrate.exception.ArbitrateException in project otter by alibaba.

the class ArbitrateFactory method newInstance.

// ==================== helper method =======================
private static Object newInstance(Class type, Long pipelineId) {
    Constructor _constructor = null;
    Object[] _constructorArgs = new Object[1];
    _constructorArgs[0] = pipelineId;
    try {
        _constructor = type.getConstructor(new Class[] { Long.class });
    } catch (NoSuchMethodException e) {
        throw new ArbitrateException("Constructor_notFound");
    }
    try {
        return _constructor.newInstance(_constructorArgs);
    } catch (Exception e) {
        throw new ArbitrateException("Constructor_newInstance_error", e);
    }
}
Also used : Constructor(java.lang.reflect.Constructor) ArbitrateException(com.alibaba.otter.shared.arbitrate.exception.ArbitrateException) ArbitrateException(com.alibaba.otter.shared.arbitrate.exception.ArbitrateException) BeansException(org.springframework.beans.BeansException)

Example 37 with ArbitrateException

use of com.alibaba.otter.shared.arbitrate.exception.ArbitrateException in project otter by alibaba.

the class ToolArbitrateEvent method fetch.

/**
     * 提供数据接口获取对应pipeline上的状态
     */
public SyncStatusEventData fetch(Long pipelineId) {
    String path = StagePathUtils.getPipeline(pipelineId);
    try {
        byte[] bytes = zookeeper.readData(path);
        if (bytes == null || bytes.length == 0) {
            SyncStatusEventData evnetData = new SyncStatusEventData();
            evnetData.setPipelineId(pipelineId);
            return evnetData;
        } else {
            return JsonUtils.unmarshalFromByte(bytes, SyncStatusEventData.class);
        }
    } catch (ZkException e) {
        // 没有节点返回空
        throw new ArbitrateException("fetch_SyncStatus", pipelineId.toString(), e);
    }
}
Also used : ZkException(org.I0Itec.zkclient.exception.ZkException) ArbitrateException(com.alibaba.otter.shared.arbitrate.exception.ArbitrateException) SyncStatusEventData(com.alibaba.otter.shared.arbitrate.model.SyncStatusEventData)

Example 38 with ArbitrateException

use of com.alibaba.otter.shared.arbitrate.exception.ArbitrateException in project otter by alibaba.

the class ToolArbitrateEvent method single.

/**
     * 提供数据接口更新对应的pipeline上的状态
     */
public void single(SyncStatusEventData syncStatus) {
    String path = StagePathUtils.getPipeline(syncStatus.getPipelineId());
    try {
        byte[] bytes = JsonUtils.marshalToByte(syncStatus);
        zookeeper.writeData(path, bytes);
        logger.info("## single status : " + syncStatus);
    } catch (ZkException e) {
        throw new ArbitrateException("single_SyncStatus", syncStatus.getPipelineId().toString(), e);
    }
}
Also used : ZkException(org.I0Itec.zkclient.exception.ZkException) ArbitrateException(com.alibaba.otter.shared.arbitrate.exception.ArbitrateException)

Example 39 with ArbitrateException

use of com.alibaba.otter.shared.arbitrate.exception.ArbitrateException 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

ArbitrateException (com.alibaba.otter.shared.arbitrate.exception.ArbitrateException)39 ZkException (org.I0Itec.zkclient.exception.ZkException)27 ZkNoNodeException (org.I0Itec.zkclient.exception.ZkNoNodeException)17 ChannelStatus (com.alibaba.otter.shared.common.model.config.channel.ChannelStatus)8 ZkNodeExistsException (org.I0Itec.zkclient.exception.ZkNodeExistsException)7 PermitMonitor (com.alibaba.otter.shared.arbitrate.impl.setl.monitor.PermitMonitor)6 EtlEventData (com.alibaba.otter.shared.arbitrate.model.EtlEventData)6 Node (com.alibaba.otter.shared.common.model.config.node.Node)4 ArrayList (java.util.ArrayList)4 TerminMonitor (com.alibaba.otter.shared.arbitrate.impl.setl.monitor.TerminMonitor)3 KeeperException (org.apache.zookeeper.KeeperException)3 Stat (org.apache.zookeeper.data.Stat)3 StageComparator (com.alibaba.otter.shared.arbitrate.impl.setl.helper.StageComparator)2 MainStemEventData (com.alibaba.otter.shared.arbitrate.model.MainStemEventData)2 TerminEventData (com.alibaba.otter.shared.arbitrate.model.TerminEventData)2 Channel (com.alibaba.otter.shared.common.model.config.channel.Channel)2 Date (java.util.Date)2 ZkBadVersionException (org.I0Itec.zkclient.exception.ZkBadVersionException)2 ErrorHandlerHelper (com.alibaba.citrus.webx.util.ErrorHandlerHelper)1 RemedyIndexComparator (com.alibaba.otter.shared.arbitrate.impl.setl.helper.RemedyIndexComparator)1