zoukankan      html  css  js  c++  java
  • easy-batch job listeners

    easy-batch 的listeners给与我们提供了一个系统状态的一个日志监控点,同时
    基于不同的类型提供了不通的监控

    Job listener

    job 关联的

    • 需要实现的方法签名
     
    public interface JobListener {
        void beforeJobStart(JobParameters parameters);
        void afterJobEnd(JobReport report);
    }
    • 参考图

    • 注册方法
    Job job = new JobBuilder()
        .jobListener(new MyJobListener())
        .build();
    • 一些场景
    设置以及请求梨园(before/after job)
    锁(解锁)工作目录(start/stop job)
    Archive log files at the end of Job 日志文件归档(job 结束)
    execution 执行完备发送邮件
    。。。。

    Record reader/writer listeners

    • 方法签名
    public interface RecordReaderListener {
        void beforeRecordReading();
        void afterRecordReading(Record record);
        void onRecordReadingException(final Throwable throwable);
    }
    public interface RecordWriterListener {
        void beforeRecordWriting(Batch batch);
        void afterRecordWriting(Batch batch);
        void onRecordWritingException(Batch batch, final Throwable throwable);
    }
    • 参考图

    • 注册
    Job job = new JobBuilder()
        .readerListener(new MyReaderListener())
        .writerListener(new MyWriterListener())
        .build();

    Processing pipeline listener

    • 方法签名
    public interface PipelineListener {
        Record beforeRecordProcessing(final Record record);
        void afterRecordProcessing(final Record inputRecord, final Record outputRecord);
        void onRecordProcessingException(final Record record, final Throwable throwable);
    }
    • 参考图

    • 注册
    Job job = new JobBuilder()
        .pipelineListener(new MyPipelineListener())
        .build();
    • 一些场景
    计算每条record 的processing 时间
    自定义每条record在pre/post的 processing 
    。。。。

    Batch listener

    • 方法签名
    public interface BatchListener {
        void beforeBatchReading();
        void afterBatchProcessing(final Batch batch);
        void afterBatchWriting(final Batch batch);
        void onBatchWritingException(final Batch batch, Throwable throwable);
    }
    • 参考图

    • 注册
    Job job = new JobBuilder()
        .batchListener(new MyBatchListener())
        .build();
    • 一些场景
    Define transaction boundaries 定义事务的边界
    自定义每个batch pre/post process 阶段
    。。。。

    参考资料

    https://github.com/j-easy/easy-batch/wiki/listeners

  • 相关阅读:
    POJ 1741 Tree(树分治)
    HDU 2196 Computer(树形dp)
    2015沈阳区域赛Meeting(最短路 + 建图)
    make the fence great again(dp 二维)
    2017沈阳区域赛Infinite Fraction Path(BFS + 剪枝)
    bitset详解
    2016青岛区域赛.Coding Contest(费用流 + 概率计算转换为加法计算)
    2019上海网络赛B题(差分 + 离散化 or 差分 + 思维)
    poj-1664.放苹果.(递推)
    hdu-4738.Caocao's Bridges(图中权值最小的桥)
  • 原文地址:https://www.cnblogs.com/rongfengliang/p/12732804.html
Copyright © 2011-2022 走看看