use of com.hazelcast.jet.impl.util.ProgressState in project hazelcast-jet by hazelcast.
the class ProcessorTaskletTest method callUntil.
private static void callUntil(Tasklet tasklet, ProgressState expectedState) {
int iterCount = 0;
for (ProgressState r; (r = tasklet.call()) != expectedState; ) {
assertEquals("Failed to make progress", MADE_PROGRESS, r);
assertTrue(String.format("tasklet.call() invoked %d times without reaching %s. Last state was %s", CALL_COUNT_LIMIT, expectedState, r), ++iterCount < CALL_COUNT_LIMIT);
}
}
use of com.hazelcast.jet.impl.util.ProgressState in project hazelcast-jet by hazelcast.
the class ProcessorTaskletTest_Blocking method callUntil.
private static void callUntil(Tasklet tasklet, ProgressState expectedState) {
System.out.println("================= call tasklet");
int iterCount = 0;
for (ProgressState r; (r = tasklet.call()) != expectedState; ) {
assertEquals("Failed to make progress", MADE_PROGRESS, r);
assertTrue(String.format("tasklet.call() invoked %d times without reaching %s. Last state was %s", CALL_COUNT_LIMIT, expectedState, r), ++iterCount < CALL_COUNT_LIMIT);
System.out.println("================= call tasklet");
}
}
use of com.hazelcast.jet.impl.util.ProgressState in project hazelcast-jet by hazelcast.
the class ProcessorTaskletTest_Snapshots method callUntil.
private static void callUntil(Tasklet tasklet, ProgressState expectedState) {
int iterCount = 0;
for (ProgressState r; (r = tasklet.call()) != expectedState; ) {
assertEquals("Failed to make progress", MADE_PROGRESS, r);
assertTrue(String.format("tasklet.call() invoked %d times without reaching %s. Last state was %s", CALL_COUNT_LIMIT, expectedState, r), ++iterCount < CALL_COUNT_LIMIT);
}
}
use of com.hazelcast.jet.impl.util.ProgressState in project hazelcast-jet by hazelcast.
the class ProcessorTaskletTest_Watermarks method callUntil.
private static void callUntil(long now, ProcessorTasklet tasklet, ProgressState expectedState) {
int iterCount = 0;
for (ProgressState r; (r = tasklet.call(MILLISECONDS.toNanos(now))) != expectedState; ) {
assertEquals("Failed to make progress", MADE_PROGRESS, r);
assertTrue(String.format("tasklet.call() invoked %d times without reaching %s. Last state was %s", CALL_COUNT_LIMIT, expectedState, r), ++iterCount < CALL_COUNT_LIMIT);
}
}
use of com.hazelcast.jet.impl.util.ProgressState in project hazelcast-jet by hazelcast.
the class ProcessorTasklet method fillInbox.
private void fillInbox(long now) {
assert inbox.isEmpty() : "inbox is not empty";
assert pendingWatermark == null : "null wm expected, but was " + pendingWatermark;
if (instreamCursor == null) {
return;
}
final InboundEdgeStream first = instreamCursor.value();
ProgressState result;
do {
currInstream = instreamCursor.value();
result = NO_PROGRESS;
// skip ordinals where a snapshot barrier has already been received
if (ssContext != null && ssContext.processingGuarantee() == ProcessingGuarantee.EXACTLY_ONCE && receivedBarriers.get(currInstream.ordinal())) {
instreamCursor.advance();
continue;
}
result = currInstream.drainTo(inbox.queue()::add);
progTracker.madeProgress(result.isMadeProgress());
// check if the last drained item is special
Object lastItem = inbox.queue().peekLast();
if (lastItem instanceof Watermark) {
long newWmValue = ((Watermark) inbox.queue().removeLast()).timestamp();
long wm = watermarkCoalescer.observeWm(now, currInstream.ordinal(), newWmValue);
if (wm != NO_NEW_WM) {
pendingWatermark = new Watermark(wm);
}
} else if (lastItem instanceof SnapshotBarrier) {
SnapshotBarrier barrier = (SnapshotBarrier) inbox.queue().removeLast();
observeSnapshot(currInstream.ordinal(), barrier.snapshotId());
} else if (lastItem != null && !(lastItem instanceof BroadcastItem)) {
watermarkCoalescer.observeEvent(currInstream.ordinal());
}
if (result.isDone()) {
receivedBarriers.clear(currInstream.ordinal());
long wm = watermarkCoalescer.queueDone(currInstream.ordinal());
// In this case we might overwrite the WM here, but that's fine since the second WM should be newer.
if (wm != NO_NEW_WM) {
assert pendingWatermark == null || pendingWatermark.timestamp() < wm : "trying to assign lower WM. Old=" + pendingWatermark.timestamp() + ", new=" + wm;
pendingWatermark = new Watermark(wm);
}
instreamCursor.remove();
numActiveOrdinals--;
}
// pop current priority group
if (!instreamCursor.advance()) {
instreamCursor = popInstreamGroup();
return;
}
} while (!result.isMadeProgress() && instreamCursor.value() != first);
}
Aggregations