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;
}
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();
}
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();
}
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);
}
}
Aggregations