public interface JetInstance
Modifier and Type | Method and Description |
---|---|
JetCacheManager |
getCacheManager()
Obtain the
JetCacheManager that provides access to JSR-107 (JCache) caches
configured on a Hazelcast Jet cluster. |
Cluster |
getCluster()
Returns information about the cluster this Jet instance is part of.
|
JetConfig |
getConfig()
Returns the configuration for this Jet member.
|
HazelcastInstance |
getHazelcastInstance()
Returns the underlying Hazelcast IMDG instance used by Jet.
|
Job |
getJob(long jobId)
Returns the job with the given id or
null if no such job could
be found. |
default Job |
getJob(String name)
Returns the active or last submitted job with the given name or
null if no such job could be found. |
List<Job> |
getJobs()
Returns all submitted jobs including running and completed ones.
|
List<Job> |
getJobs(String name)
Returns all jobs submitted with the given name, ordered in descending
order by submission time.
|
default JobStateSnapshot |
getJobStateSnapshot(String name)
Returns the
JobStateSnapshot object representing an exported
snapshot with the given name. |
default Collection<JobStateSnapshot> |
getJobStateSnapshots()
Returns the collection of exported job state snapshots stored in the
cluster.
|
<E> IList<E> |
getList(String name)
Returns the distributed list instance with the specified name.
|
<K,V> IMap<K,V> |
getMap(String name)
Returns the distributed map instance with the specified name.
|
String |
getName()
Returns the name of the Jet instance.
|
<T> Observable<T> |
getObservable(String name)
Returns an
Observable instance with the specified name. |
Collection<Observable<?>> |
getObservables()
Returns a list of all the
Observables that are active. |
<E> ITopic<E> |
getReliableTopic(String name)
Returns a distributed reliable topic instance with the specified name.
|
<K,V> ReplicatedMap<K,V> |
getReplicatedMap(String name)
Returns the replicated map instance with the specified name.
|
SqlService |
getSql()
Returns the Hazelcast SQL service.
|
default Job |
newJob(DAG dag)
Creates and returns a Jet job based on the supplied DAG.
|
Job |
newJob(DAG dag,
JobConfig config)
Creates and returns a Jet job based on the supplied DAG and job
configuration.
|
default Job |
newJob(Pipeline pipeline)
Creates and returns an executable job based on the supplied pipeline.
|
Job |
newJob(Pipeline pipeline,
JobConfig config)
Creates and returns a Jet job based on the supplied pipeline and job
configuration.
|
Job |
newJobIfAbsent(DAG dag,
JobConfig config)
Creates and returns a Jet job based on the supplied DAG and job
configuration.
|
Job |
newJobIfAbsent(Pipeline pipeline,
JobConfig config)
Creates and returns a Jet job based on the supplied pipeline and job
configuration.
|
LightJob |
newLightJob(DAG dag)
Submits a job defined in the Core API.
|
LightJob |
newLightJob(Pipeline p)
Submits a light job for execution.
|
default <T> Observable<T> |
newObservable()
Returns a new observable with a randomly generated name
|
void |
shutdown()
Shuts down the current instance.
|
@Nonnull HazelcastInstance getHazelcastInstance()
JetInstance
.@Nonnull Cluster getCluster()
@Nonnull JetConfig getConfig()
@Nonnull default Job newJob(@Nonnull DAG dag)
@Nonnull default Job newJob(@Nonnull Pipeline pipeline)
@Nonnull Job newJob(@Nonnull DAG dag, @Nonnull JobConfig config)
If the name in the JobConfig is non-null, Jet checks if there is an
active job with equal name, in which case it throws JobAlreadyExistsException
. Job is active if it is running,
suspended or waiting to be run; that is it has not completed or failed.
Thus there can be at most one active job with a given name at a time and
you can re-use the job name after the previous job completed.
See also newJobIfAbsent(com.hazelcast.jet.core.DAG, com.hazelcast.jet.config.JobConfig)
.
JobAlreadyExistsException
- if there is an active job with
an equal name@Nonnull Job newJob(@Nonnull Pipeline pipeline, @Nonnull JobConfig config)
If the name in the JobConfig is non-null, Jet checks if there is an
active job with equal name, in which case it throws JobAlreadyExistsException
. Job is active if it is running,
suspended or waiting to be run; that is it has not completed or failed.
Thus there can be at most one active job with a given name at a time and
you can re-use the job name after the previous job completed.
See also newJobIfAbsent(com.hazelcast.jet.core.DAG, com.hazelcast.jet.config.JobConfig)
.
JobAlreadyExistsException
- if there is an active job with
an equal name@Nonnull Job newJobIfAbsent(@Nonnull DAG dag, @Nonnull JobConfig config)
If the name in the JobConfig is non-null, Jet checks if there is an active job with equal name. If there is, it will join that job instead of submitting a new one. Job is active if it is running, suspended or waiting to be run; that is it has not completed or failed. In other words, this method ensures that the job with this name is running and is not running multiple times in parallel.
This method is useful for microservices deployment when each package contains a jet member and the job and you want the job to run only once. But if the job is a batch job and runs very quickly, it can happen that it executes multiple times, because the job name can be reused after a previous execution completed.
If the job name is null, a new job is always submitted.
See also newJob(com.hazelcast.jet.core.DAG)
.
@Nonnull Job newJobIfAbsent(@Nonnull Pipeline pipeline, @Nonnull JobConfig config)
If the name in the JobConfig is non-null, Jet checks if there is an active job with equal name. If there is, it will join that job instead of submitting a new one. Job is active if it is running, suspended or waiting to be run; that is it has not completed or failed. In other words, this method ensures that the job with this name is running and is not running multiple times in parallel.
This method is useful for microservices deployment when each package contains a jet member and the job and you want the job to run only once. But if the job is a batch job and runs very quickly, it can happen that it executes multiple times, because the job name can be reused after a previous execution completed.
If the job name is null, a new job is always submitted.
See also newJob(com.hazelcast.jet.core.DAG)
.
@Nonnull LightJob newLightJob(Pipeline p)
getJobs()
or in Management Center (this
will be added later)
RestartableException
doesn't restart the job, but it will
fail
It substantially reduces the overhead for jobs that take milliseconds to complete.
A light job will not be cancelled if the client disconnects. It's potential failure will be only logged in member logs.
@Nonnull List<Job> getJobs()
@Nullable Job getJob(long jobId)
null
if no such job could
be found. Currently it returns null
also for light jobs.@Nonnull List<Job> getJobs(@Nonnull String name)
@Nullable default Job getJob(@Nonnull String name)
null
if no such job could be found. The returned job can be already
completed.@Nullable default JobStateSnapshot getJobStateSnapshot(@Nonnull String name)
JobStateSnapshot
object representing an exported
snapshot with the given name. Returns null
if no such snapshot
exists.@Nonnull default Collection<JobStateSnapshot> getJobStateSnapshots()
@Beta @Nonnull SqlService getSql()
The service is in beta state. Behavior and API might change in future releases. Binary compatibility is not guaranteed between minor or patch releases.
Hazelcast can execute SQL statements using either the default SQL backend contained in the Hazelcast IMDG code, or using the Jet SQL backend in this package. The algorithm is this: we first try the default backend, if it can't execute a particular statement, we try the Jet backend.
For proper functionality the hazelcast-jet-sql.jar
has to be on
the class path.
The text below summarizes Hazelcast Jet SQL features. For a summary of the default SQL engine features, see the superclass documentation.
In the first release we support a very limited set of features, essentially only reading and writing from/to the above connectors and projection + filtering. Currently these are unsupported: joins, grouping, aggregation. We plan to support these in the future.
SqlService
@Nonnull <K,V> IMap<K,V> getMap(@Nonnull String name)
It's possible to use the map as a data source or sink in a Jet Pipeline
, using Sources.map(String)
or Sinks.map(String)
and the change stream of the map can be read using
Sources.mapJournal(String, JournalInitialPosition)
.
name
- name of the distributed map@Nonnull <K,V> ReplicatedMap<K,V> getReplicatedMap(@Nonnull String name)
A replicated map can be used for enriching a stream, see GeneralStage.mapUsingReplicatedMap(String, FunctionEx, BiFunctionEx)
.
name
- name of the distributed map@Nonnull <E> IList<E> getList(@Nonnull String name)
It's possible to use the link as a data source or sink in a Jet Pipeline
, using Sources.list(String)
or Sinks.list(String)
.
name
- name of the distributed list@Nonnull <E> ITopic<E> getReliableTopic(@Nonnull String name)
name
- name of the distributed topic@Nonnull JetCacheManager getCacheManager()
JetCacheManager
that provides access to JSR-107 (JCache) caches
configured on a Hazelcast Jet cluster.
Note that this method does not return a JCache CacheManager
JetCacheManager
JetCacheManager
@Nonnull <T> Observable<T> getObservable(@Nonnull String name)
Observable
instance with the specified name.
Represents a flowing sequence of events produced by jobs containing
observable sinks.
Multiple calls of this method with the same name return the same instance (unless it was destroyed in the meantime).
In order to observe the events register an Observer
on the
Observable
.
name
- name of the observable@Nonnull default <T> Observable<T> newObservable()
@Nonnull Collection<Observable<?>> getObservables()
Observables
that are active.
By "active" we mean that their backing Ringbuffer
has been
created, which happens when either their first Observer
is
registered or when the job publishing their data (via
observable sinks) starts
executing.void shutdown()
The call blocks until the instance is actually down.
Note: If you call this.getHazelcastInstance().shutdown()
,
it will cause all the jobs that run on this member to be forcefully
terminated, without creating a terminal snapshot. After the cluster
stabilizes again, Jet will restart them from the last snapshot that was
created some time ago.
Copyright © 2021 Hazelcast, Inc.. All rights reserved.