|
18 | 18 |
|
19 | 19 | package com.dtstack.chunjun.source;
|
20 | 20 |
|
| 21 | +import com.dtstack.chunjun.constants.Metrics; |
| 22 | +import com.dtstack.chunjun.dirty.manager.DirtyManager; |
| 23 | +import com.dtstack.chunjun.metrics.AccumulatorCollector; |
21 | 24 | import com.dtstack.chunjun.restore.FormatState;
|
22 | 25 | import com.dtstack.chunjun.source.format.BaseRichInputFormat;
|
23 | 26 | import com.dtstack.chunjun.util.ExceptionUtil;
|
@@ -112,19 +115,28 @@ public void run(SourceContext<OUT> ctx) throws Exception {
|
112 | 115 | if (isRunning && format instanceof RichInputFormat) {
|
113 | 116 | ((RichInputFormat) format).openInputFormat();
|
114 | 117 | }
|
115 |
| - |
116 | 118 | OUT nextElement = serializer.createInstance();
|
117 | 119 | while (isRunning) {
|
118 | 120 | format.open(splitIterator.next());
|
119 |
| - |
| 121 | + AccumulatorCollector accumulatorCollector = |
| 122 | + ((BaseRichInputFormat) format).getAccumulatorCollector(); |
| 123 | + DirtyManager dirtyManager = ((BaseRichInputFormat) format).getDirtyManager(); |
120 | 124 | // for each element we also check if cancel
|
121 | 125 | // was called by checking the isRunning flag
|
122 | 126 |
|
123 | 127 | while (isRunning && !format.reachedEnd()) {
|
124 | 128 | synchronized (ctx.getCheckpointLock()) {
|
125 |
| - nextElement = format.nextRecord(nextElement); |
126 |
| - if (nextElement != null) { |
127 |
| - ctx.collect(nextElement); |
| 129 | + try { |
| 130 | + nextElement = format.nextRecord(nextElement); |
| 131 | + if (nextElement != null) { |
| 132 | + ctx.collect(nextElement); |
| 133 | + } |
| 134 | + } catch (Exception e) { |
| 135 | + // 脏数据总数应是所有slot的脏数据总数,而不是单个的 |
| 136 | + long globalErrors = |
| 137 | + accumulatorCollector.getAccumulatorValue( |
| 138 | + Metrics.NUM_ERRORS, false); |
| 139 | + dirtyManager.collect(nextElement, e, null, globalErrors); |
128 | 140 | }
|
129 | 141 | }
|
130 | 142 | }
|
|
0 commit comments