Search in sources :

Example 1 with ProgressState

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);
    }
}
Also used : ProgressState(com.hazelcast.jet.impl.util.ProgressState)

Example 2 with ProgressState

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");
    }
}
Also used : ProgressState(com.hazelcast.jet.impl.util.ProgressState)

Example 3 with ProgressState

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);
    }
}
Also used : ProgressState(com.hazelcast.jet.impl.util.ProgressState)

Example 4 with ProgressState

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);
    }
}
Also used : ProgressState(com.hazelcast.jet.impl.util.ProgressState)

Example 5 with ProgressState

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);
}
Also used : ProgressState(com.hazelcast.jet.impl.util.ProgressState) Watermark(com.hazelcast.jet.core.Watermark)

Aggregations

ProgressState (com.hazelcast.jet.impl.util.ProgressState)19 Watermark (com.hazelcast.jet.core.Watermark)4 Nonnull (javax.annotation.Nonnull)3 JetException (com.hazelcast.jet.JetException)2 ObjectWithPartitionId (com.hazelcast.jet.impl.util.ObjectWithPartitionId)2 RestartableException (com.hazelcast.jet.RestartableException)1 LongLongAccumulator (com.hazelcast.jet.accumulator.LongLongAccumulator)1 SnapshotRepository (com.hazelcast.jet.impl.SnapshotRepository)1 DONE (com.hazelcast.jet.impl.execution.StoreSnapshotTasklet.State.DONE)1 DRAIN (com.hazelcast.jet.impl.execution.StoreSnapshotTasklet.State.DRAIN)1 FLUSH (com.hazelcast.jet.impl.execution.StoreSnapshotTasklet.State.FLUSH)1 REACHED_BARRIER (com.hazelcast.jet.impl.execution.StoreSnapshotTasklet.State.REACHED_BARRIER)1 AsyncMapWriter (com.hazelcast.jet.impl.util.AsyncMapWriter)1 ExceptionUtil.withTryCatch (com.hazelcast.jet.impl.util.ExceptionUtil.withTryCatch)1 ProgressTracker (com.hazelcast.jet.impl.util.ProgressTracker)1 ILogger (com.hazelcast.logging.ILogger)1 Data (com.hazelcast.nio.serialization.Data)1 NodeEngine (com.hazelcast.spi.NodeEngine)1 Entry (java.util.Map.Entry)1 CompletableFuture (java.util.concurrent.CompletableFuture)1