|
19 | 19 |
|
20 | 20 | package org.apache.iotdb.db.pipe.agent.task.connection; |
21 | 21 |
|
| 22 | +import org.apache.iotdb.commons.exception.pipe.PipeRuntimeOutOfMemoryCriticalException; |
22 | 23 | import org.apache.iotdb.commons.pipe.agent.task.connection.UnboundedBlockingPendingQueue; |
23 | 24 | import org.apache.iotdb.commons.pipe.agent.task.progress.PipeEventCommitManager; |
24 | 25 | import org.apache.iotdb.commons.pipe.datastructure.pattern.IoTDBTreePattern; |
|
41 | 42 | import org.slf4j.Logger; |
42 | 43 | import org.slf4j.LoggerFactory; |
43 | 44 |
|
| 45 | +import java.util.Iterator; |
44 | 46 | import java.util.concurrent.atomic.AtomicInteger; |
45 | 47 |
|
46 | 48 | public class PipeEventCollector implements EventCollector { |
@@ -142,8 +144,31 @@ private void parseAndCollectEvent(final PipeTsFileInsertionEvent sourceEvent) th |
142 | 144 | } |
143 | 145 |
|
144 | 146 | try { |
145 | | - for (final TabletInsertionEvent parsedEvent : sourceEvent.toTabletInsertionEvents()) { |
146 | | - collectParsedRawTableEvent((PipeRawTabletInsertionEvent) parsedEvent); |
| 147 | + final Iterable<TabletInsertionEvent> iterable = sourceEvent.toTabletInsertionEvents(); |
| 148 | + final Iterator<TabletInsertionEvent> iterator = iterable.iterator(); |
| 149 | + while (iterator.hasNext()) { |
| 150 | + final TabletInsertionEvent parsedEvent = iterator.next(); |
| 151 | + int retryCount = 0; |
| 152 | + while (true) { |
| 153 | + try { |
| 154 | + collectParsedRawTableEvent((PipeRawTabletInsertionEvent) parsedEvent); |
| 155 | + break; |
| 156 | + } catch (final PipeRuntimeOutOfMemoryCriticalException e) { |
| 157 | + if (retryCount++ % 100 == 0) { |
| 158 | + LOGGER.warn( |
| 159 | + "parseAndCollectEvent: failed to allocate memory for parsing TsFile {}, retry count is {}, will keep retrying.", |
| 160 | + sourceEvent.getTsFile(), |
| 161 | + retryCount, |
| 162 | + e); |
| 163 | + } else if (LOGGER.isDebugEnabled()) { |
| 164 | + LOGGER.debug( |
| 165 | + "parseAndCollectEvent: failed to allocate memory for parsing TsFile {}, retry count is {}, will keep retrying.", |
| 166 | + sourceEvent.getTsFile(), |
| 167 | + retryCount, |
| 168 | + e); |
| 169 | + } |
| 170 | + } |
| 171 | + } |
147 | 172 | } |
148 | 173 | } finally { |
149 | 174 | sourceEvent.close(); |
|
0 commit comments