use of com.alibaba.otter.shared.arbitrate.model.TerminEventData in project otter by alibaba.
the class GlobalTask method sendRollbackTermin.
protected void sendRollbackTermin(long pipelineId, String message) {
TerminEventData errorEventData = new TerminEventData();
errorEventData.setPipelineId(pipelineId);
errorEventData.setType(TerminType.ROLLBACK);
errorEventData.setCode("setl");
errorEventData.setDesc(message);
arbitrateEventService.terminEvent().single(errorEventData);
// 每次发送完报警后,sleep一段时间,继续做后面的事
try {
Thread.sleep(3000 + RandomUtils.nextInt(3000));
} catch (InterruptedException e) {
}
}
use of com.alibaba.otter.shared.arbitrate.model.TerminEventData in project otter by alibaba.
the class GlobalTask method processMissData.
/**
* 自动处理数据为null的情况,重新发一遍数据
*/
protected void processMissData(long pipelineId, String message) {
TerminEventData errorEventData = new TerminEventData();
errorEventData.setPipelineId(pipelineId);
errorEventData.setType(TerminType.RESTART);
errorEventData.setCode("setl");
errorEventData.setDesc(message);
arbitrateEventService.terminEvent().single(errorEventData);
}
use of com.alibaba.otter.shared.arbitrate.model.TerminEventData in project otter by alibaba.
the class OtterAlarmHandler method sendAlarm.
public void sendAlarm(String destination, String msg) {
TerminEventData errorEventData = new TerminEventData();
errorEventData.setPipelineId(pipelineId);
errorEventData.setType(TerminType.WARNING);
errorEventData.setCode("canal");
errorEventData.setDesc(destination + ":" + msg);
arbitrateEventService.terminEvent().single(errorEventData);
}
use of com.alibaba.otter.shared.arbitrate.model.TerminEventData in project otter by alibaba.
the class LoadZooKeeperArbitrateEvent method single.
/**
* <pre>
* 算法:
* 1. 创建对应的loaded节点,标志load已完成
* </pre>
*
* @param pipelineId 同步流id
*/
public void single(EtlEventData data) {
Assert.notNull(data);
try {
// String path = StagePathUtils.getLoadStage(data.getPipelineId(), data.getProcessId());
// // 序列化
// data.setEndTime(new Date().getTime());// 返回当前时间
// byte[] bytes = JsonUtils.marshalToByte(data, SerializerFeature.WriteClassName);
// try {
// zookeeper.create(path, bytes, CreateMode.PERSISTENT);
// } catch (NodeExistsException e) {
// throw new ArbitrateException("Load_single", e.getMessage(), e);
// } catch (KeeperException e) {
// throw new ArbitrateException("Load_single", e.getMessage(), e);
// } catch (InterruptedException e) {
// // ignore
// }
// 返回当前时间
data.setEndTime(new Date().getTime());
// 调用Termin信号
TerminEventData termin = new TerminEventData();
termin.setPipelineId(data.getPipelineId());
termin.setProcessId(data.getProcessId());
termin.setStartTime(data.getStartTime());
termin.setEndTime(data.getEndTime());
termin.setFirstTime(data.getFirstTime());
termin.setNumber(data.getNumber());
termin.setBatchId(data.getBatchId());
termin.setSize(data.getSize());
termin.setExts(data.getExts());
termin.setType(TerminType.NORMAL);
termin.setCode("setl");
termin.setDesc("");
termin.setCurrNid(ArbitrateConfigUtils.getCurrentNid());
terminEvent.single(termin);
} finally {
// // 最后一步释放锁
// DistributedLock lock = getLock(data.getPipelineId());
// try {
// lock.unlock();// 解除lock
// } catch (KeeperException e) {
// throw new ArbitrateException("Load_single", e.getMessage(), e);
// }
}
}
use of com.alibaba.otter.shared.arbitrate.model.TerminEventData in project otter by alibaba.
the class ArbitrateAllTest method testDemo.
@Test
public void testDemo() {
// 设置启动标志
channelEvent.start(channelId);
// 停顿一下
sleep();
PermitMonitor permit = ArbitrateFactory.getInstance(pipelineId, PermitMonitor.class);
// 优先启动主导线程
mainStem.submit(pipelineId);
try {
// 阻塞等待授权
permit.waitForPermit();
} catch (InterruptedException e1) {
want.fail();
}
if (arbitrateMode.isZookeeper()) {
ArbitrateFactory.getInstance(pipelineId, SelectStageListener.class);
ArbitrateFactory.getInstance(pipelineId, ExtractStageListener.class);
ArbitrateFactory.getInstance(pipelineId, TransformStageListener.class);
ArbitrateFactory.getInstance(pipelineId, LoadStageListener.class);
}
if (arbitrateMode.isMemory()) {
ArbitrateFactory.getInstance(pipelineId, MemoryStageController.class);
}
if (arbitrateMode.isRpc()) {
ArbitrateFactory.getInstance(pipelineId, RpcStageController.class);
ArbitrateFactory.getInstance(pipelineId, SelectProcessListener.class);
}
if (arbitrateMode.isZookeeper() || arbitrateMode.isRpc()) {
ArbitrateFactory.getInstance(pipelineId, ExtractRandomLoadBanlance.class);
ArbitrateFactory.getInstance(pipelineId, ExtractRoundRobinLoadBalance.class);
ArbitrateFactory.getInstance(pipelineId, TransformRandomLoadBanlance.class);
ArbitrateFactory.getInstance(pipelineId, TransformRoundRobinLoadBalance.class);
}
// 启动
select.submit(pipelineId);
extract.submit(pipelineId);
transform.submit(pipelineId);
load.submit(pipelineId);
view.submit(pipelineId);
this.termin.submit(pipelineId);
try {
// 运行30s
Thread.sleep(20 * 1000);
} catch (InterruptedException e) {
want.fail();
}
// 发送结束事件
TerminEventData termin = new TerminEventData();
termin.setPipelineId(pipelineId);
termin.setType(TerminType.SHUTDOWN);
arbitrateEventService.terminEvent().single(termin);
// 等待处理完所有的termin事件
sleep(5 * 1000L);
// 关闭
select.destory(pipelineId);
extract.destory(pipelineId);
transform.destory(pipelineId);
load.destory(pipelineId);
view.destory(pipelineId);
this.termin.destory(pipelineId);
ArbitrateFactory.destory(pipelineId);
}
Aggregations