Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
46 changes: 46 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,46 @@
<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>

<groupId>org.examples.jet.snapshot</groupId>
<artifactId>jet-pipelines</artifactId>
<version>1.0-SNAPSHOT</version>

<name>jet-pipelines</name>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<hazelcast-version>5.4.0</hazelcast-version>
<junit-jupiter-api-version>5.8.2</junit-jupiter-api-version>
<maven-surefire-plugin-version>3.0.0-M7</maven-surefire-plugin-version>
</properties>

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

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire-plugin-version}</version>
</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
Loading