Search in sources :

Example 16 with MainStemEventData

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

the class PermitMonitorTest method initMainStem.

private void initMainStem(Long pipelineId) {
    String pipelinePath = StagePathUtils.getPipeline(channelId, pipelineId);
    String path = pipelinePath + "/" + ArbitrateConstants.NODE_MAINSTEM;
    MainStemEventData eventData = new MainStemEventData();
    eventData.setStatus(MainStemEventData.Status.TAKEING);
    // 初始化的数据对象
    byte[] bytes = JsonUtils.marshalToByte(eventData);
    zookeeper.create(path, bytes, CreateMode.EPHEMERAL);
}
Also used : MainStemEventData(com.alibaba.otter.shared.arbitrate.model.MainStemEventData)

Example 17 with MainStemEventData

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

the class PermitMonitorTest method updateMainStem.

private void updateMainStem(Long pipelineId, MainStemEventData.Status status) {
    String pipelinePath = StagePathUtils.getPipeline(channelId, pipelineId);
    String path = pipelinePath + "/" + ArbitrateConstants.NODE_MAINSTEM;
    MainStemEventData eventData = new MainStemEventData();
    eventData.setStatus(status);
    // 初始化的数据对象
    byte[] bytes = JsonUtils.marshalToByte(eventData);
    zookeeper.writeData(path, bytes);
}
Also used : MainStemEventData(com.alibaba.otter.shared.arbitrate.model.MainStemEventData)

Example 18 with MainStemEventData

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

the class MainStemArbitrateEventTest method test_mainStem.

@Test
public void test_mainStem() {
    // 启动
    channelEvent.start(channelId);
    mainStemEvent = new MainStemArbitrateEvent();
    try {
        mainStemEvent.await(pipelineId);
        MainStemEventData eventData = new MainStemEventData();
        eventData.setPipelineId(pipelineId);
        eventData.setStatus(MainStemEventData.Status.OVERTAKE);
        mainStemEvent.single(eventData);
        PermitMonitor permit = ArbitrateFactory.getInstance(pipelineId, PermitMonitor.class);
        // 阻塞等待授权
        permit.waitForPermit();
    } catch (InterruptedException e) {
        want.fail();
    }
    boolean check = mainStemEvent.check(pipelineId);
    want.bool(check).is(true);
    // 删除mainStem节点
    mainStemEvent.release(pipelineId);
}
Also used : PermitMonitor(com.alibaba.otter.shared.arbitrate.impl.setl.monitor.PermitMonitor) MainStemEventData(com.alibaba.otter.shared.arbitrate.model.MainStemEventData) MainStemArbitrateEvent(com.alibaba.otter.shared.arbitrate.impl.setl.MainStemArbitrateEvent) Test(org.testng.annotations.Test) BaseEventTest(com.alibaba.otter.shared.arbitrate.BaseEventTest)

Aggregations

MainStemEventData (com.alibaba.otter.shared.arbitrate.model.MainStemEventData)18 ZkException (org.I0Itec.zkclient.exception.ZkException)5 PermitMonitor (com.alibaba.otter.shared.arbitrate.impl.setl.monitor.PermitMonitor)4 ChannelStatus (com.alibaba.otter.shared.common.model.config.channel.ChannelStatus)4 Pipeline (com.alibaba.otter.shared.common.model.config.pipeline.Pipeline)3 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 ZkNoNodeException (org.I0Itec.zkclient.exception.ZkNoNodeException)3 ArbitrateException (com.alibaba.otter.shared.arbitrate.exception.ArbitrateException)2 PositionEventData (com.alibaba.otter.shared.arbitrate.model.PositionEventData)2 ProcessNodeEventData (com.alibaba.otter.shared.arbitrate.model.ProcessNodeEventData)2 Channel (com.alibaba.otter.shared.common.model.config.channel.Channel)2 ThroughputStat (com.alibaba.otter.shared.common.model.statistics.throughput.ThroughputStat)2 ZkBadVersionException (org.I0Itec.zkclient.exception.ZkBadVersionException)2 Stat (org.apache.zookeeper.data.Stat)2 TopDelayStat (com.alibaba.otter.manager.biz.statistics.delay.param.TopDelayStat)1 DataStat (com.alibaba.otter.manager.biz.statistics.delay.param.TopDelayStat.DataStat)1 ThroughputCondition (com.alibaba.otter.manager.biz.statistics.throughput.param.ThroughputCondition)1 BaseEventTest (com.alibaba.otter.shared.arbitrate.BaseEventTest)1 ChannelArbitrateEvent (com.alibaba.otter.shared.arbitrate.impl.manage.ChannelArbitrateEvent)1