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();
}
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);
}
}
Aggregations