use of com.hazelcast.jet.JetException in project hazelcast by hazelcast.
the class PythonService method destroy.
@SuppressFBWarnings("RV_RETURN_VALUE_IGNORED")
void destroy() {
// Stopping the Python subprocess is essential, lower the interrupted flag
boolean interrupted = Thread.interrupted();
try {
sink.onCompleted();
if (!completionLatch.await(1, SECONDS)) {
logger.info("gRPC call has not completed on time");
}
GrpcUtil.shutdownChannel(chan, logger, 1);
server.stop();
} catch (Exception e) {
throw new JetException("PythonService.destroy() failed: " + e, e);
} finally {
if (interrupted) {
currentThread().interrupt();
}
}
}
use of com.hazelcast.jet.JetException in project hazelcast by hazelcast.
the class KinesisIntegrationTest method customProjection.
@Test
@Category(SerialTest.class)
public void customProjection() {
HELPER.createStream(1);
sendMessages();
Long expectedPerSequenceNo = 1L;
try {
Pipeline pipeline = Pipeline.create();
StreamSource<String> source = kinesisSource().withProjectionFn((r, s) -> {
byte[] payload = new byte[r.getData().remaining()];
r.getData().get(payload);
return r.getSequenceNumber();
}).build();
pipeline.readFrom(source).withoutTimestamps().groupingKey(r -> r).rollingAggregate(counting()).apply(assertCollectedEventually(ASSERT_TRUE_EVENTUALLY_TIMEOUT, results -> {
assertEquals(MESSAGES, results.size());
results.forEach(v -> assertEquals(expectedPerSequenceNo, v.getValue()));
}));
hz().getJet().newJob(pipeline).join();
fail("Expected exception not thrown");
} catch (CompletionException ce) {
Throwable cause = peel(ce);
assertTrue(cause instanceof JetException);
assertTrue(cause.getCause() instanceof AssertionCompletedException);
}
}
use of com.hazelcast.jet.JetException in project hazelcast by hazelcast.
the class KinesisIntegrationTest method timestampsAndWatermarks.
@Test
@Category(SerialTest.class)
public void timestampsAndWatermarks() {
HELPER.createStream(1);
sendMessages();
try {
Pipeline pipeline = Pipeline.create();
pipeline.readFrom(kinesisSource().build()).withNativeTimestamps(0).window(WindowDefinition.sliding(500, 100)).aggregate(counting()).apply(assertCollectedEventually(ASSERT_TRUE_EVENTUALLY_TIMEOUT, windowResults -> {
// multiple windows, so watermark works
assertTrue(windowResults.size() > 1);
}));
hz().getJet().newJob(pipeline).join();
fail("Expected exception not thrown");
} catch (CompletionException ce) {
Throwable cause = peel(ce);
assertTrue(cause instanceof JetException);
assertTrue(cause.getCause() instanceof AssertionCompletedException);
}
}
use of com.hazelcast.jet.JetException in project hazelcast by hazelcast.
the class KinesisTestHelper method wait.
private void wait(int attempt, String action) {
if (attempt > RETRY_STRATEGY.getMaxAttempts()) {
throw new JetException(String.format("Abort waiting for %s, too many attempts", action));
}
logger.info(String.format("Waiting for %s ...", action));
long duration = RETRY_STRATEGY.getIntervalFunction().waitAfterAttempt(attempt);
try {
TimeUnit.MILLISECONDS.sleep(duration);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new JetException(String.format("Waiting for %s interrupted", action));
}
}
use of com.hazelcast.jet.JetException in project hazelcast by hazelcast.
the class JobCoordinationService method submitLightJob.
public CompletableFuture<Void> submitLightJob(long jobId, Data serializedJobDefinition, JobConfig jobConfig, Subject subject) {
Object jobDefinition = nodeEngine().getSerializationService().toObject(serializedJobDefinition);
DAG dag;
if (jobDefinition instanceof DAG) {
dag = (DAG) jobDefinition;
} else {
int coopThreadCount = config.getCooperativeThreadCount();
dag = ((PipelineImpl) jobDefinition).toDag(new Context() {
@Override
public int defaultLocalParallelism() {
return coopThreadCount;
}
});
}
// First insert just a marker into the map. This is to prevent initializing the light job if the jobId
// was submitted twice. This can happen e.g. if the client retries.
Object oldContext = lightMasterContexts.putIfAbsent(jobId, UNINITIALIZED_LIGHT_JOB_MARKER);
if (oldContext != null) {
throw new JetException("duplicate jobId " + idToString(jobId));
}
checkPermissions(subject, dag);
// Initialize and start the job (happens in the constructor). We do this before adding the actual
// LightMasterContext to the map to avoid possible races of the job initialization and cancellation.
LightMasterContext mc = new LightMasterContext(nodeEngine, this, dag, jobId, jobConfig, subject);
oldContext = lightMasterContexts.put(jobId, mc);
assert oldContext == UNINITIALIZED_LIGHT_JOB_MARKER;
scheduleJobTimeout(jobId, jobConfig.getTimeoutMillis());
return mc.getCompletionFuture().whenComplete((r, t) -> {
Object removed = lightMasterContexts.remove(jobId);
assert removed instanceof LightMasterContext : "LMC not found: " + removed;
unscheduleJobTimeout(jobId);
});
}
Aggregations