public final class Jet extends Object
Modifier and Type | Method and Description |
---|---|
static JetInstance |
bootstrappedInstance()
Returns either a local Jet instance or a "bootstrapped" Jet client for
a remote Jet cluster, depending on the context.
|
@Nonnull public static JetInstance bootstrappedInstance()
When you submit a job to a Jet instance that runs locally in your JVM,
it will have all the dependency classes available. However, when you
take the same job to a remote Jet cluster, you'll often find that it
fails with a ClassNotFoundException
because the remote cluster
doesn't have all the classes you use in the job.
Normally you would have to explicitly add all the dependency classes to
the JobConfig
, either one by one or
packaged into a JAR. If you're submitting a job using the command-line
tool jet submit
, the JAR to attach is the same JAR that
contains the code that submits the job.
This factory takes all of the above into account in order to provide a smoother experience:
jet submit
, it returns a local JetInstance
, either by creating a new one or looking up a cached one.
The instance won't join any cluster.
jet submit
, it returns a "bootstrapped"
instance of Jet client that automatically attaches the JAR to all jobs
you submit using it.
To use this feature, follow these steps:
main()
method and your Jet code the usual way, making
sure you use this method (instead of HazelcastInstance.getJetInstance()
)
to acquire a Jet client instance.
jetjob.jar
) with your entry point
declared as the Main-Class
in MANIFEST.MF
. The JAR should
include all dependencies required to run it (except the Jet classes
— these are already available on the cluster classpath).
jet submit jetjob.jar
on the command
line. This assumes you have downloaded the Jet distribution package and
its bin
directory is on your system path. The Jet client will use
the configuration file <distro_root>/config/hazelcast-client.yaml
.
Adjust that file as needed.
public class CustomJetJob { public static void main(String[] args) { JetInstance jet = Jet.bootstrappedInstance(); jet.newJob(buildPipeline()).join(); } public static Pipeline createPipeline() { // ... } }
Copyright © 2021 Hazelcast, Inc.. All rights reserved.