use of com.hazelcast.jet.JetInstance in project hazelcast-jet by hazelcast.
the class CancellationTest method when_jobCancelled_then_jobStatusIsSetEventually.
@Test
public void when_jobCancelled_then_jobStatusIsSetEventually() {
// Given
JetInstance instance = newInstance();
DAG dag = new DAG();
dag.newVertex("slow", StuckSource::new);
Job job = instance.newJob(dag);
assertExecutionStarted();
// When
job.cancel();
// Then
assertTrueEventually(() -> assertEquals(JobStatus.COMPLETED, job.getStatus()), 3);
}
use of com.hazelcast.jet.JetInstance in project hazelcast-jet by hazelcast.
the class Processors_slidingWindowingIntegrationTest method runTest.
private void runTest(List<MyEvent> sourceEvents, List<TimestampedEntry<String, Long>> expectedOutput) throws Exception {
JetInstance instance = createJetMember();
SlidingWindowPolicy wDef = slidingWinPolicy(2000, 1000);
DAG dag = new DAG();
// to prevent serialization of whole class
boolean isBatchLocal = isBatch;
DistributedFunction<? super MyEvent, ?> keyFn = MyEvent::getKey;
DistributedToLongFunction<? super MyEvent> timestampFn = MyEvent::getTimestamp;
Vertex source = dag.newVertex("source", () -> new EmitListP(sourceEvents, isBatchLocal)).localParallelism(1);
Vertex insertPP = dag.newVertex("insertWmP", insertWatermarksP(wmGenParams(timestampFn, limitingLagAndLull(500, 1000), emitByFrame(wDef), -1))).localParallelism(1);
Vertex sink = dag.newVertex("sink", SinkProcessors.writeListP("sink"));
dag.edge(between(source, insertPP).isolated());
AggregateOperation<LongAccumulator, Long> counting = counting();
if (singleStageProcessor) {
Vertex slidingWin = dag.newVertex("slidingWin", Processors.aggregateToSlidingWindowP(singletonList(keyFn), singletonList(timestampFn), TimestampKind.EVENT, wDef, counting, TimestampedEntry::new));
dag.edge(between(insertPP, slidingWin).partitioned(MyEvent::getKey).distributed()).edge(between(slidingWin, sink));
} else {
Vertex accumulateByFrame = dag.newVertex("accumulateByFrame", Processors.accumulateByFrameP(singletonList(keyFn), singletonList(timestampFn), TimestampKind.EVENT, wDef, counting.withFinishFn(identity())));
Vertex slidingWin = dag.newVertex("slidingWin", combineToSlidingWindowP(wDef, counting, TimestampedEntry::new));
dag.edge(between(insertPP, accumulateByFrame).partitioned(keyFn)).edge(between(accumulateByFrame, slidingWin).partitioned(entryKey()).distributed()).edge(between(slidingWin, sink));
}
Job job = instance.newJob(dag);
if (isBatch) {
job.join();
}
IList<MyEvent> sinkList = instance.getList("sink");
assertTrueEventually(() -> assertEquals(streamToString(expectedOutput.stream()), streamToString(new ArrayList<>(sinkList).stream())), 5);
// wait a little more and make sure, that there are no more frames
Thread.sleep(1000);
assertTrue(sinkList.size() == expectedOutput.size());
}
use of com.hazelcast.jet.JetInstance in project hazelcast-jet by hazelcast.
the class SnapshotFailureTest method setup.
@Before
public void setup() {
JetConfig config = new JetConfig();
config.getInstanceConfig().setCooperativeThreadCount(LOCAL_PARALLELISM);
// force snapshots to fail by adding a failing map store configuration for snapshot data maps
MapConfig mapConfig = new MapConfig(SnapshotRepository.SNAPSHOT_DATA_NAME_PREFIX + '*');
MapStoreConfig mapStoreConfig = mapConfig.getMapStoreConfig();
mapStoreConfig.setEnabled(true);
mapStoreConfig.setImplementation(new FailingMapStore());
config.getHazelcastConfig().addMapConfig(mapConfig);
config.getHazelcastConfig().addEventJournalConfig(new EventJournalConfig().setMapName(SnapshotRepository.SNAPSHOT_NAME_PREFIX + '*'));
JetInstance[] instances = createJetMembers(config, 2);
instance1 = instances[0];
}
use of com.hazelcast.jet.JetInstance in project hazelcast-jet-reference-manual by hazelcast.
the class Considerations method s9.
static void s9() {
// tag::s9[]
SerializerConfig serializerConfig = new SerializerConfig().setImplementation(new MyItemSerializer()).setTypeClass(MyItem.class);
JetConfig config = new JetConfig();
config.getHazelcastConfig().getSerializationConfig().addSerializerConfig(serializerConfig);
JetInstance jet = Jet.newJetInstance(config);
// end::s9[]
}
use of com.hazelcast.jet.JetInstance in project hazelcast-jet-reference-manual by hazelcast.
the class ImdgConnectors method s9.
static void s9() {
// tag::s9[]
JetConfig cfg = new JetConfig();
cfg.getHazelcastConfig().getMapEventJournalConfig("inputMap").setEnabled(true).setCapacity(// how many events to keep before evicting
1000).setTimeToLiveSeconds(// evict events older than this
10);
JetInstance jet = Jet.newJetInstance(cfg);
// end::s9[]
// tag::s10[]
cfg.getHazelcastConfig().getCacheEventJournalConfig("inputCache").setEnabled(true).setCapacity(1000).setTimeToLiveSeconds(10);
// end::s10[]
}
Aggregations