Search in sources :

Example 1 with SyncStatusEventData

use of com.alibaba.otter.shared.arbitrate.model.SyncStatusEventData in project otter by alibaba.

the class ToolArbitrateEventTest method test_simple.

@Test
public void test_simple() {
    toolEvent = new ToolArbitrateEvent();
    SyncStatusEventData eventData = toolEvent.fetch(pipelineId);
    eventData.setPipelineId(pipelineId);
    eventData.addStatus(new SyncStatus(false, 1000));
    eventData.addStatus(new SyncStatus(true, 1001));
    toolEvent.single(eventData);
    eventData = toolEvent.fetch(pipelineId);
    want.object(eventData).notNull();
}
Also used : SyncStatus(com.alibaba.otter.shared.arbitrate.model.SyncStatusEventData.SyncStatus) ToolArbitrateEvent(com.alibaba.otter.shared.arbitrate.impl.setl.ToolArbitrateEvent) SyncStatusEventData(com.alibaba.otter.shared.arbitrate.model.SyncStatusEventData) Test(org.testng.annotations.Test)

Example 2 with SyncStatusEventData

use of com.alibaba.otter.shared.arbitrate.model.SyncStatusEventData 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)

Aggregations

SyncStatusEventData (com.alibaba.otter.shared.arbitrate.model.SyncStatusEventData)2 ArbitrateException (com.alibaba.otter.shared.arbitrate.exception.ArbitrateException)1 ToolArbitrateEvent (com.alibaba.otter.shared.arbitrate.impl.setl.ToolArbitrateEvent)1 SyncStatus (com.alibaba.otter.shared.arbitrate.model.SyncStatusEventData.SyncStatus)1 ZkException (org.I0Itec.zkclient.exception.ZkException)1 Test (org.testng.annotations.Test)1