Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/modules/ROOT/examples/jet
10 changes: 10 additions & 0 deletions jet/operator-jet-job-snapshot/hz.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: hazelcast.com/v1alpha1
kind: Hazelcast
metadata:
name: hazelcast
spec:
clusterSize: 3
licenseKeySecretName: hazelcast-license-key
jet:
enabled: true
resourceUploadEnabled: true
39 changes: 39 additions & 0 deletions jet/operator-jet-job-snapshot/jet-pipelines/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<artifactId>jet-pipelines</artifactId>

<parent>
<artifactId>jet</artifactId>
<groupId>com.hazelcast.samples.jet</groupId>
<version>0.1-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>

<name>jet-pipelines</name>

<dependencies>
<dependency>
<groupId>com.hazelcast</groupId>
<artifactId>hazelcast</artifactId>
<version>${hazelcast.version}</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package org.examples.jet.snapshot;

import com.hazelcast.core.Hazelcast;
import com.hazelcast.core.HazelcastInstance;
import com.hazelcast.jet.pipeline.JournalInitialPosition;
import com.hazelcast.jet.pipeline.Pipeline;
import com.hazelcast.jet.pipeline.Sinks;
import com.hazelcast.jet.pipeline.Sources;

public class JobV1 {

public static void main(String[] args) {
var p = Pipeline.create();
var transactionSource = Sources.mapJournal("transaction", JournalInitialPosition.START_FROM_OLDEST);
var loggerSink = Sinks.logger();
p.readFrom(transactionSource)
.withIngestionTimestamps()
.setName("Emit Transactions")
.map(e -> {
System.out.printf("The transaction '%s' is being executed in 'job-v1'\n", e.getKey());
// execute the transaction
return String.format("[Job V1] transaction:'%s' payload:'%s'", e.getKey(), e.getValue());
})
.setName("Apply Transactions")
.writeTo(loggerSink)
.setName("Log Transactions");

HazelcastInstance hz = Hazelcast.bootstrappedInstance();
hz.getJet().newJob(p);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package org.examples.jet.snapshot;

import com.hazelcast.core.Hazelcast;
import com.hazelcast.core.HazelcastInstance;
import com.hazelcast.jet.pipeline.JournalInitialPosition;
import com.hazelcast.jet.pipeline.Pipeline;
import com.hazelcast.jet.pipeline.Sinks;
import com.hazelcast.jet.pipeline.Sources;

public class JobV2 {

public static void main(String[] args) {
var p = Pipeline.create();
var transactionSource = Sources.mapJournal("transaction", JournalInitialPosition.START_FROM_OLDEST);
var loggerSink = Sinks.logger();
p.readFrom(transactionSource)
.withIngestionTimestamps()
.setName("Emit Transactions")
.map(e -> {
System.out.printf("The transaction '%s' is being executed in 'job-v2'\n", e.getKey());
// execute the transaction
return String.format("[Job V2] transaction:'%s' payload:'%s'", e.getKey(), e.getValue());
})
.setName("Apply Transactions")
.writeTo(loggerSink)
.setName("Log Transactions");

HazelcastInstance hz = Hazelcast.bootstrappedInstance();
hz.getJet().newJob(p);
}

}
12 changes: 12 additions & 0 deletions jet/operator-jet-job-snapshot/job-v1.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: hazelcast.com/v1alpha1
kind: JetJob
metadata:
name: transaction-v1
spec:
hazelcastResourceName: hazelcast
state: Running
jarName: jet-pipelines-1.0-SNAPSHOT.jar
mainClass: org.examples.jet.snapshot.JobV1
bucketConfig:
bucketURI: '<BUCKET-URI>'
secretName: '<SECRET-NAME>'
13 changes: 13 additions & 0 deletions jet/operator-jet-job-snapshot/job-v2.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: hazelcast.com/v1alpha1
kind: JetJob
metadata:
name: transaction-v2
spec:
hazelcastResourceName: hazelcast
state: Running
jarName: jet-pipelines-1.0-SNAPSHOT.jar
mainClass: org.examples.jet.snapshot.JobV2
initialSnapshotResourceName: snapshot-transaction
bucketConfig:
bucketURI: '<BUCKET-URI>'
secretName: '<SECRET-NAME>'
8 changes: 8 additions & 0 deletions jet/operator-jet-job-snapshot/map.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: hazelcast.com/v1alpha1
kind: Map
metadata:
name: transaction
spec:
hazelcastResourceName: hazelcast
eventJournal:
capacity: 9000
7 changes: 7 additions & 0 deletions jet/operator-jet-job-snapshot/snapshot.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: hazelcast.com/v1alpha1
kind: JetJobSnapshot
metadata:
name: snapshot-transaction
spec:
jetJobResourceName: transaction-v1
cancelJob: true
1 change: 1 addition & 0 deletions jet/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
<module>wordcount-compute-isolation</module>
<module>cdc</module>
<module>mongodb</module>
<module>operator-jet-job-snapshot/jet-pipelines</module>
</modules>

<properties>
Expand Down
Loading