Search in sources :

Example 1 with RestartableException

use of com.hazelcast.jet.RestartableException in project hazelcast by hazelcast.

the class StreamJmsP method snapshotCommitFinish.

@Override
public boolean snapshotCommitFinish(boolean success) {
    if (guarantee == NONE) {
        return true;
    }
    if (success) {
        try {
            session.commit();
            getLogger().fine("Session committed");
        } catch (JMSException e) {
            throw sneakyThrow(e);
        }
        seenIds.clear();
    } else if (guarantee == EXACTLY_ONCE) {
        // The `seenIds` and also unacknowledged messages in the session will grow without a limit.
        throw new RestartableException("the snapshot failed");
    }
    snapshotInProgress = false;
    return true;
}
Also used : RestartableException(com.hazelcast.jet.RestartableException) JMSException(javax.jms.JMSException)

Example 2 with RestartableException

use of com.hazelcast.jet.RestartableException in project hazelcast by hazelcast.

the class ReceiverTasklet method call.

@Override
@Nonnull
public ProgressState call() {
    if (receptionDone) {
        return collector.offerBroadcast(DONE_ITEM);
    }
    if (connectionChanged) {
        throw new RestartableException("The member was reconnected: " + sourceAddressString);
    }
    tracker.reset();
    tracker.notDone();
    tryFillInbox();
    int ackItemLocal = 0;
    for (ObjWithPtionIdAndSize o; (o = inbox.peek()) != null; ) {
        final Object item = o.getItem();
        if (item == DONE_ITEM) {
            receptionDone = true;
            inbox.remove();
            assert inbox.peek() == null : "Found something in the queue beyond the DONE_ITEM: " + inbox.remove();
            break;
        }
        ProgressState outcome = item instanceof BroadcastItem ? collector.offerBroadcast((BroadcastItem) item) : collector.offer(item, o.getPartitionId());
        if (!outcome.isDone()) {
            tracker.madeProgress(outcome.isMadeProgress());
            break;
        }
        tracker.madeProgress();
        inbox.remove();
        ackItemLocal += o.estimatedMemoryFootprint;
    }
    ackItem(ackItemLocal);
    numWaitingInInbox = inbox.size();
    return tracker.toProgressState();
}
Also used : RestartableException(com.hazelcast.jet.RestartableException) ProgressState(com.hazelcast.jet.impl.util.ProgressState) Nonnull(javax.annotation.Nonnull)

Example 3 with RestartableException

use of com.hazelcast.jet.RestartableException in project hazelcast by hazelcast.

the class SenderTasklet method call.

@Nonnull
@Override
public ProgressState call() {
    progTracker.reset();
    tryFillInbox();
    if (progTracker.isDone()) {
        return progTracker.toProgressState();
    }
    if (tryFillOutputBuffer()) {
        progTracker.madeProgress();
        if (!connection.write(new Packet(outputBuffer.toByteArray()).setPacketType(Packet.Type.JET))) {
            throw new RestartableException("Connection write failed in " + toString());
        }
    }
    return progTracker.toProgressState();
}
Also used : Packet(com.hazelcast.internal.nio.Packet) RestartableException(com.hazelcast.jet.RestartableException) Nonnull(javax.annotation.Nonnull)

Example 4 with RestartableException

use of com.hazelcast.jet.RestartableException in project hazelcast by hazelcast.

the class WriteFileP method process.

@Override
public void process(int ordinal, @Nonnull Inbox inbox) {
    // roll file on date change
    if (dateFormatter != null && !currentTimeFormatted().equals(lastFileDate)) {
        fileSequence = 0;
        utility.finishActiveTransaction();
    }
    FileResource transaction = utility.activeTransaction();
    Writer writer = transaction.writer();
    try {
        for (Object item; (item = inbox.poll()) != null; ) {
            @SuppressWarnings("unchecked") T castedItem = (T) item;
            writer.write(toStringFn.apply(castedItem));
            writer.write(System.lineSeparator());
            if (maxFileSize != DISABLE_ROLLING && sizeTrackingStream.size >= maxFileSize) {
                utility.finishActiveTransaction();
                writer = utility.activeTransaction().writer();
            }
        }
        writer.flush();
        if (maxFileSize != DISABLE_ROLLING && sizeTrackingStream.size >= maxFileSize) {
            utility.finishActiveTransaction();
        }
    } catch (IOException e) {
        throw new RestartableException(e);
    }
}
Also used : RestartableException(com.hazelcast.jet.RestartableException) IOException(java.io.IOException) OutputStreamWriter(java.io.OutputStreamWriter) Writer(java.io.Writer)

Aggregations

RestartableException (com.hazelcast.jet.RestartableException)4 Nonnull (javax.annotation.Nonnull)2 Packet (com.hazelcast.internal.nio.Packet)1 ProgressState (com.hazelcast.jet.impl.util.ProgressState)1 IOException (java.io.IOException)1 OutputStreamWriter (java.io.OutputStreamWriter)1 Writer (java.io.Writer)1 JMSException (javax.jms.JMSException)1