@Override protected boolean isComplete(Chunk<I> inputs) { /* * Need to remember the write skips across transactions, otherwise they * keep coming back. Since we register skips with the inputs they will * not be processed again but the output skips need to be saved for * registration later with the listeners. The inputs are going to be the * same for all transactions processing the same chunk, but the outputs * are not, so we stash them in user data on the inputs. */ @SuppressWarnings("unchecked") UserData<O> data = (UserData<O>) inputs.getUserData(); Chunk<O> previous = data.getOutputs(); return inputs.isEmpty() && previous.getSkips().isEmpty(); }
private void callSkipListeners(final Chunk<I> inputs, final Chunk<O> outputs) { for (SkipWrapper<I> wrapper : inputs.getSkips()) { I item = wrapper.getItem(); if (item == null) { continue; } Throwable e = wrapper.getException(); callProcessSkipListener(item, e); } for (SkipWrapper<O> wrapper : outputs.getSkips()) { Throwable e = wrapper.getException(); try { getListener().onSkipInWrite(wrapper.getItem(), e); } catch (RuntimeException ex) { throw new SkipListenerFailedException("Fatal exception in SkipListener.", ex, e); } } // Clear skips if we are possibly going to process this chunk again outputs.clearSkips(); inputs.clearSkips(); }
@Override protected Chunk<O> getAdjustedOutputs(Chunk<I> inputs, Chunk<O> outputs) { @SuppressWarnings("unchecked") UserData<O> data = (UserData<O>) inputs.getUserData(); Chunk<O> previous = data.getOutputs(); Chunk<O> next = new Chunk<>(outputs.getItems(), previous.getSkips()); next.setBusy(previous.isBusy()); // Remember for next time if there are skips accumulating data.setOutputs(next); return next; }
@Test public void testRetry() throws Exception { logger.debug("Starting simple scenario"); List<String> items = new ArrayList<>(chunk.getItems()); int before = items.size(); items.removeAll(Collections.singleton("fail")); boolean error = true; while (error && count++ < BACKSTOP_LIMIT) { try { statefulRetry(chunk); error = false; } catch (Exception e) { error = true; } } logger.debug("Chunk: " + chunk); assertTrue("Backstop reached. Probably an infinite loop...", count < BACKSTOP_LIMIT); assertFalse(chunk.getItems().contains("fail")); assertEquals(items, chunk.getItems()); assertEquals(before-chunk.getItems().size(), chunk.getSkips().size()); }
if (!inputs.getSkips().isEmpty()) { if (outputIterator.hasNext()) { outputIterator.remove();
@Override protected boolean isComplete(Chunk<I> inputs) { /* * Need to remember the write skips across transactions, otherwise they * keep coming back. Since we register skips with the inputs they will * not be processed again but the output skips need to be saved for * registration later with the listeners. The inputs are going to be the * same for all transactions processing the same chunk, but the outputs * are not, so we stash them in user data on the inputs. */ @SuppressWarnings("unchecked") UserData<O> data = (UserData<O>) inputs.getUserData(); Chunk<O> previous = data.getOutputs(); return inputs.isEmpty() && previous.getSkips().isEmpty(); }
@Override protected boolean isComplete(Chunk<I> inputs) { /* * Need to remember the write skips across transactions, otherwise they * keep coming back. Since we register skips with the inputs they will * not be processed again but the output skips need to be saved for * registration later with the listeners. The inputs are going to be the * same for all transactions processing the same chunk, but the outputs * are not, so we stash them in user data on the inputs. */ @SuppressWarnings("unchecked") UserData<O> data = (UserData<O>) inputs.getUserData(); Chunk<O> previous = data.getOutputs(); return inputs.isEmpty() && previous.getSkips().isEmpty(); }
@Override protected boolean isComplete(Chunk<I> inputs) { /* * Need to remember the write skips across transactions, otherwise they * keep coming back. Since we register skips with the inputs they will * not be processed again but the output skips need to be saved for * registration later with the listeners. The inputs are going to be the * same for all transactions processing the same chunk, but the outputs * are not, so we stash them in user data on the inputs. */ @SuppressWarnings("unchecked") UserData<O> data = (UserData<O>) inputs.getUserData(); Chunk<O> previous = data.getOutputs(); return inputs.isEmpty() && previous.getSkips().isEmpty(); }
@Override protected boolean isComplete(Chunk<I> inputs) { /* * Need to remember the write skips across transactions, otherwise they * keep coming back. Since we register skips with the inputs they will * not be processed again but the output skips need to be saved for * registration later with the listeners. The inputs are going to be the * same for all transactions processing the same chunk, but the outputs * are not, so we stash them in user data on the inputs. */ @SuppressWarnings("unchecked") UserData<O> data = (UserData<O>) inputs.getUserData(); Chunk<O> previous = data.getOutputs(); return inputs.isEmpty() && previous.getSkips().isEmpty(); }
private void callSkipListeners(final Chunk<I> inputs, final Chunk<O> outputs) { for (SkipWrapper<I> wrapper : inputs.getSkips()) { I item = wrapper.getItem(); if (item == null) { continue; } Throwable e = wrapper.getException(); callProcessSkipListener(item, e); } for (SkipWrapper<O> wrapper : outputs.getSkips()) { Throwable e = wrapper.getException(); try { getListener().onSkipInWrite(wrapper.getItem(), e); } catch (RuntimeException ex) { throw new SkipListenerFailedException("Fatal exception in SkipListener.", ex, e); } } // Clear skips if we are possibly going to process this chunk again outputs.clearSkips(); inputs.clearSkips(); }
private void callSkipListeners(final Chunk<I> inputs, final Chunk<O> outputs) { for (SkipWrapper<I> wrapper : inputs.getSkips()) { I item = wrapper.getItem(); if (item == null) { continue; } Throwable e = wrapper.getException(); callProcessSkipListener(item, e); } for (SkipWrapper<O> wrapper : outputs.getSkips()) { Throwable e = wrapper.getException(); try { getListener().onSkipInWrite(wrapper.getItem(), e); } catch (RuntimeException ex) { throw new SkipListenerFailedException("Fatal exception in SkipListener.", ex, e); } } // Clear skips if we are possibly going to process this chunk again outputs.clearSkips(); inputs.clearSkips(); }
@Override protected Chunk<O> getAdjustedOutputs(Chunk<I> inputs, Chunk<O> outputs) { @SuppressWarnings("unchecked") UserData<O> data = (UserData<O>) inputs.getUserData(); Chunk<O> previous = data.getOutputs(); Chunk<O> next = new Chunk<O>(outputs.getItems(), previous.getSkips()); next.setBusy(previous.isBusy()); // Remember for next time if there are skips accumulating data.setOutputs(next); return next; }
private void callSkipListeners(final Chunk<I> inputs, final Chunk<O> outputs) { for (SkipWrapper<I> wrapper : inputs.getSkips()) { I item = wrapper.getItem(); if (item == null) { continue; } Throwable e = wrapper.getException(); callProcessSkipListener(item, e); } for (SkipWrapper<O> wrapper : outputs.getSkips()) { Throwable e = wrapper.getException(); try { getListener().onSkipInWrite(wrapper.getItem(), e); } catch (RuntimeException ex) { throw new SkipListenerFailedException("Fatal exception in SkipListener.", ex, e); } } // Clear skips if we are possibly going to process this chunk again outputs.clearSkips(); inputs.clearSkips(); }
@Override protected Chunk<O> getAdjustedOutputs(Chunk<I> inputs, Chunk<O> outputs) { @SuppressWarnings("unchecked") UserData<O> data = (UserData<O>) inputs.getUserData(); Chunk<O> previous = data.getOutputs(); Chunk<O> next = new Chunk<O>(outputs.getItems(), previous.getSkips()); next.setBusy(previous.isBusy()); // Remember for next time if there are skips accumulating data.setOutputs(next); return next; }
private void callSkipListeners(final Chunk<I> inputs, final Chunk<O> outputs) { for (SkipWrapper<I> wrapper : inputs.getSkips()) { I item = wrapper.getItem(); if (item == null) { continue; } Throwable e = wrapper.getException(); callProcessSkipListener(item, e); } for (SkipWrapper<O> wrapper : outputs.getSkips()) { Throwable e = wrapper.getException(); try { getListener().onSkipInWrite(wrapper.getItem(), e); } catch (RuntimeException ex) { throw new SkipListenerFailedException("Fatal exception in SkipListener.", ex, e); } } // Clear skips if we are possibly going to process this chunk again outputs.clearSkips(); inputs.clearSkips(); }
@Override protected Chunk<O> getAdjustedOutputs(Chunk<I> inputs, Chunk<O> outputs) { @SuppressWarnings("unchecked") UserData<O> data = (UserData<O>) inputs.getUserData(); Chunk<O> previous = data.getOutputs(); Chunk<O> next = new Chunk<O>(outputs.getItems(), previous.getSkips()); next.setBusy(previous.isBusy()); // Remember for next time if there are skips accumulating data.setOutputs(next); return next; }
@Override protected Chunk<O> getAdjustedOutputs(Chunk<I> inputs, Chunk<O> outputs) { @SuppressWarnings("unchecked") UserData<O> data = (UserData<O>) inputs.getUserData(); Chunk<O> previous = data.getOutputs(); Chunk<O> next = new Chunk<O>(outputs.getItems(), previous.getSkips()); next.setBusy(previous.isBusy()); // Remember for next time if there are skips accumulating data.setOutputs(next); return next; }
if (!inputs.getSkips().isEmpty()) { if (outputIterator.hasNext()) { outputIterator.remove();
if (!inputs.getSkips().isEmpty()) { if (outputIterator.hasNext()) { outputIterator.remove();