use of com.hazelcast.jet.JetException in project hazelcast by hazelcast.
the class CdcSourceP method handleConnectException.
private void handleConnectException(RuntimeException ce) {
reconnectTracker.attemptFailed();
if (reconnectTracker.shouldTryAgain()) {
long waitTimeMs = reconnectTracker.getNextWaitTimeMs();
logger.warning("Failed to initialize the connector task, retrying in " + waitTimeMs + "ms" + getCause(ce));
} else {
throw shutDownAndThrow(new JetException("Failed to connect to database" + getCause(ce)));
}
}
use of com.hazelcast.jet.JetException in project hazelcast by hazelcast.
the class ReadHadoopNewApiP method getSplits.
private static <K, V> List<InputSplit> getSplits(Configuration configuration) throws Exception {
InputFormat<K, V> inputFormat = extractInputFormat(configuration);
Job job = Job.getInstance(configuration);
try {
return inputFormat.getSplits(job);
} catch (InvalidInputException e) {
String directory = configuration.get(INPUT_DIR, "");
boolean ignoreFileNotFound = configuration.getBoolean(HadoopSources.IGNORE_FILE_NOT_FOUND, true);
if (ignoreFileNotFound) {
ILogger logger = Logger.getLogger(ReadHadoopNewApiP.class);
logger.fine("The directory '" + directory + "' does not exist. This source will emit 0 items.");
return emptyList();
} else {
throw new JetException("The input " + directory + " matches no files");
}
}
}
use of com.hazelcast.jet.JetException in project hazelcast by hazelcast.
the class JobSummaryTest method when_job_failed.
@Test
public void when_job_failed() {
Pipeline p = Pipeline.create();
p.readFrom(Sources.mapJournal("invalid", JournalInitialPosition.START_FROM_OLDEST)).withoutTimestamps().writeTo(Sinks.noop());
Job job = instance.getJet().newJob(p, new JobConfig().setName("jobA"));
String msg = "";
try {
job.join();
} catch (Exception e) {
msg = e.getMessage();
}
List<JobSummary> list = getJetClientInstanceImpl(client).getJobSummaryList();
assertEquals(1, list.size());
JobSummary jobSummary = list.get(0);
assertContains(new JetException(jobSummary.getFailureText()).toString(), msg);
assertNotEquals(0, jobSummary.getCompletionTime());
}
use of com.hazelcast.jet.JetException in project hazelcast-jet by hazelcast.
the class ProcessorTasklet method stateMachineStep.
@SuppressWarnings("checkstyle:returncount")
private void stateMachineStep(long now) {
switch(state) {
case PROCESS_WATERMARK:
progTracker.notDone();
if (pendingWatermark == null) {
long wm = watermarkCoalescer.checkWmHistory(now);
if (wm == NO_NEW_WM) {
state = PROCESS_INBOX;
// recursion
stateMachineStep(now);
break;
}
pendingWatermark = new Watermark(wm);
}
if (pendingWatermark.equals(IDLE_MESSAGE) || processor.tryProcessWatermark(pendingWatermark)) {
state = EMIT_WATERMARK;
// recursion
stateMachineStep(now);
}
break;
case EMIT_WATERMARK:
progTracker.notDone();
if (outbox.offer(pendingWatermark)) {
state = PROCESS_INBOX;
pendingWatermark = null;
// recursion
stateMachineStep(now);
}
break;
case PROCESS_INBOX:
progTracker.notDone();
if (inbox.isEmpty() && (isSnapshotInbox() || processor.tryProcess())) {
fillInbox(now);
}
if (!inbox.isEmpty()) {
if (isSnapshotInbox()) {
processor.restoreFromSnapshot(inbox);
} else {
processor.process(currInstream.ordinal(), inbox);
}
}
if (inbox.isEmpty()) {
// there is either snapshot or instream is done, not both
if (currInstream != null && currInstream.isDone()) {
state = COMPLETE_EDGE;
progTracker.madeProgress();
return;
} else if (context.snapshottingEnabled() && numActiveOrdinals > 0 && receivedBarriers.cardinality() == numActiveOrdinals) {
// we have an empty inbox and received the current snapshot barrier from all active ordinals
state = SAVE_SNAPSHOT;
return;
} else if (numActiveOrdinals == 0) {
progTracker.madeProgress();
state = COMPLETE;
} else {
state = PROCESS_WATERMARK;
}
}
return;
case COMPLETE_EDGE:
progTracker.notDone();
if (isSnapshotInbox() ? processor.finishSnapshotRestore() : processor.completeEdge(currInstream.ordinal())) {
progTracker.madeProgress();
state = initialProcessingState();
}
return;
case SAVE_SNAPSHOT:
assert context.snapshottingEnabled() : "Snapshotting is not enabled";
progTracker.notDone();
if (processor.saveToSnapshot()) {
progTracker.madeProgress();
state = EMIT_BARRIER;
}
return;
case EMIT_BARRIER:
assert context.snapshottingEnabled() : "Snapshotting is not enabled";
progTracker.notDone();
if (outbox.offerToEdgesAndSnapshot(new SnapshotBarrier(pendingSnapshotId))) {
receivedBarriers.clear();
pendingSnapshotId++;
state = initialProcessingState();
}
return;
case COMPLETE:
progTracker.notDone();
// check ssContext to see if a barrier should be emitted
if (context.snapshottingEnabled()) {
long currSnapshotId = ssContext.lastSnapshotId();
assert currSnapshotId <= pendingSnapshotId : "Unexpected new snapshot id " + currSnapshotId + ", current was" + pendingSnapshotId;
if (currSnapshotId == pendingSnapshotId) {
state = SAVE_SNAPSHOT;
progTracker.madeProgress();
return;
}
}
if (processor.complete()) {
progTracker.madeProgress();
state = EMIT_DONE_ITEM;
}
return;
case EMIT_DONE_ITEM:
if (!outbox.offerToEdgesAndSnapshot(DONE_ITEM)) {
progTracker.notDone();
return;
}
state = END;
return;
default:
// note ProcessorState.END goes here
throw new JetException("Unexpected state: " + state);
}
}
use of com.hazelcast.jet.JetException in project hazelcast-jet by hazelcast.
the class StoreSnapshotTasklet method stateMachineStep.
private void stateMachineStep() {
switch(state) {
case DRAIN:
progTracker.notDone();
ProgressState result = inboundEdgeStream.drainTo(o -> {
if (o instanceof SnapshotBarrier) {
SnapshotBarrier barrier = (SnapshotBarrier) o;
assert pendingSnapshotId == barrier.snapshotId() : "Unexpected barrier, expected was " + pendingSnapshotId + ", but barrier was " + barrier.snapshotId() + ", this=" + this;
hasReachedBarrier = true;
} else {
mapWriter.put((Entry<Data, Data>) o);
}
});
if (result.isDone()) {
inputIsDone = true;
}
if (result.isMadeProgress()) {
progTracker.madeProgress();
state = FLUSH;
stateMachineStep();
}
return;
case FLUSH:
progTracker.notDone();
CompletableFuture<Void> future = new CompletableFuture<>();
future.whenComplete(withTryCatch(logger, (r, t) -> {
// this callback may be called from a non-tasklet thread
if (t != null) {
logger.severe("Error writing to snapshot map '" + currMapName() + "'", t);
snapshotContext.reportError(t);
}
// numActiveFlushes must be decremented last otherwise we may miss the error
numActiveFlushes.decrementAndGet();
}));
if (mapWriter.tryFlushAsync(future)) {
progTracker.madeProgress();
numActiveFlushes.incrementAndGet();
state = inputIsDone ? DONE : hasReachedBarrier ? REACHED_BARRIER : DRAIN;
}
return;
case REACHED_BARRIER:
progTracker.notDone();
if (numActiveFlushes.get() == 0) {
snapshotContext.snapshotDoneForTasklet();
pendingSnapshotId++;
mapWriter.setMapName(currMapName());
state = inputIsDone ? DONE : DRAIN;
hasReachedBarrier = false;
}
return;
case DONE:
if (numActiveFlushes.get() != 0) {
progTracker.notDone();
}
snapshotContext.taskletDone(pendingSnapshotId - 1, isHigherPrioritySource);
return;
default:
throw new JetException("Unexpected state: " + state);
}
}
Aggregations