Search in sources :

Example 1 with RemedyIndexEventData

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

the class ToolArbitrateEvent method listRemedyIndexs.

/**
     * 查询当前的remedy index记录
     */
public List<RemedyIndexEventData> listRemedyIndexs(Long pipelineId) {
    String path = StagePathUtils.getRemedyRoot(pipelineId);
    List<RemedyIndexEventData> datas = new ArrayList<RemedyIndexEventData>();
    try {
        List<String> nodes = zookeeper.getChildren(path);
        for (String node : nodes) {
            RemedyIndexEventData data = RemedyIndexEventData.parseNodeName(node);
            data.setPipelineId(pipelineId);
            datas.add(data);
        }
    } catch (ZkException e) {
        throw new ArbitrateException("listRemedyIndexs", pipelineId.toString(), e);
    }
    // 做一下排序
    Collections.sort(datas, new RemedyIndexComparator());
    return datas;
}
Also used : RemedyIndexEventData(com.alibaba.otter.shared.arbitrate.model.RemedyIndexEventData) ZkException(org.I0Itec.zkclient.exception.ZkException) RemedyIndexComparator(com.alibaba.otter.shared.arbitrate.impl.setl.helper.RemedyIndexComparator) ArrayList(java.util.ArrayList) ArbitrateException(com.alibaba.otter.shared.arbitrate.exception.ArbitrateException)

Example 2 with RemedyIndexEventData

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

the class ToolArbitrateEventTest method test_remedy.

@Test
public void test_remedy() {
    toolEvent = new ToolArbitrateEvent();
    RemedyIndexEventData data = new RemedyIndexEventData();
    Date now = new Date();
    Long start = now.getTime() - 24 * 3600 * 60;
    Long startProcessId = 100L;
    for (int i = 10; i >= 1; i--) {
        data.setPipelineId(pipelineId);
        data.setProcessId(startProcessId + i);
        data.setStartTime(start + startProcessId + i);
        data.setEndTime(start + startProcessId + 2 * i);
        toolEvent.addRemedyIndex(data);
    }
    List<RemedyIndexEventData> indexs = toolEvent.listRemedyIndexs(pipelineId);
    want.collection(indexs).sizeEq(10);
    for (RemedyIndexEventData index : indexs) {
        toolEvent.removeRemedyIndex(index);
    }
    indexs = toolEvent.listRemedyIndexs(pipelineId);
    want.collection(indexs).sizeEq(0);
}
Also used : RemedyIndexEventData(com.alibaba.otter.shared.arbitrate.model.RemedyIndexEventData) ToolArbitrateEvent(com.alibaba.otter.shared.arbitrate.impl.setl.ToolArbitrateEvent) Date(java.util.Date) Test(org.testng.annotations.Test)

Aggregations

RemedyIndexEventData (com.alibaba.otter.shared.arbitrate.model.RemedyIndexEventData)2 ArbitrateException (com.alibaba.otter.shared.arbitrate.exception.ArbitrateException)1 ToolArbitrateEvent (com.alibaba.otter.shared.arbitrate.impl.setl.ToolArbitrateEvent)1 RemedyIndexComparator (com.alibaba.otter.shared.arbitrate.impl.setl.helper.RemedyIndexComparator)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 ZkException (org.I0Itec.zkclient.exception.ZkException)1 Test (org.testng.annotations.Test)1