Class ProcessorMetaSupplier.RandomMemberPms
- All Implemented Interfaces:
ProcessorMetaSupplier
,DataSerializable
,IdentifiedDataSerializable
,Serializable
- Enclosing interface:
- ProcessorMetaSupplier
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.hazelcast.jet.core.ProcessorMetaSupplier
ProcessorMetaSupplier.Context, ProcessorMetaSupplier.ExpectNothingProcessorSupplier, ProcessorMetaSupplier.RandomMemberPms, ProcessorMetaSupplier.SpecificMemberPms
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Returnstrue
if theProcessorMetaSupplier.close(Throwable)
method of this instance is cooperative.Function<? super Address,
? extends ProcessorSupplier> Called to create a mapping from memberAddress
to theProcessorSupplier
that will be sent to that member.int
Returns type identifier for this class.int
Returns DataSerializableFactory factory ID for this class.void
init
(ProcessorMetaSupplier.Context context) Called on the cluster member that receives the job request.boolean
Returnstrue
if both theProcessorMetaSupplier.init(Context)
andProcessorMetaSupplier.get(List)
methods of this instance are cooperative.boolean
Returnstrue
if the same instance can be reused in different job executions or in different vertices.void
Reads fields from the input streamvoid
Writes object fields to output streamMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.hazelcast.jet.core.ProcessorMetaSupplier
close, getRequiredPermission, getTags, preferredLocalParallelism
-
Method Details
-
init
Description copied from interface:ProcessorMetaSupplier
Called on the cluster member that receives the job request. Gives access to the Hazelcast instance's services and provides the parallelism parameters determined from the cluster size.- Specified by:
init
in interfaceProcessorMetaSupplier
- Throws:
Exception
- See Also:
-
get
@Nonnull public Function<? super Address,? extends ProcessorSupplier> get(@Nonnull List<Address> addresses) Description copied from interface:ProcessorMetaSupplier
Called to create a mapping from memberAddress
to theProcessorSupplier
that will be sent to that member. Jet calls this method with a list of all cluster members' addresses and the returned function must be a mapping that returns a non-null value for each given address.The method will be called once per job execution on the job's coordinator member.
init()
will have already been called.- Specified by:
get
in interfaceProcessorMetaSupplier
- See Also:
-
isReusable
public boolean isReusable()Description copied from interface:ProcessorMetaSupplier
Returnstrue
if the same instance can be reused in different job executions or in different vertices. In that case,ProcessorMetaSupplier.init(com.hazelcast.jet.core.ProcessorMetaSupplier.Context)
,ProcessorMetaSupplier.get(java.util.List<com.hazelcast.cluster.Address>)
andProcessorMetaSupplier.close(java.lang.Throwable)
methods must be thread-safe and obey additional conditions defined below.When a job is submitted from a client, the job definition is serialized, so the job coordinator will receive a different copy of processor meta-suppliers even if they are used multiple times within the same DAG, or across different DAGs, or submitted through different jobs. While this serialization mechanism ensures that processor meta-supplier instances do not share any internal state, it is unnecessary —and avoided— for jobs consisting of reusable meta-suppliers and submitted from the job coordinator —which is always the case for member-originated light jobs.
Non-reusable meta-suppliers (default) have a simple order of method executions:
ProcessorMetaSupplier.init(com.hazelcast.jet.core.ProcessorMetaSupplier.Context)
(once),ProcessorMetaSupplier.get(java.util.List<com.hazelcast.cluster.Address>)
(at most once afterProcessorMetaSupplier.init(com.hazelcast.jet.core.ProcessorMetaSupplier.Context)
,ProcessorMetaSupplier.close(java.lang.Throwable)
(last).Reusable meta-suppliers differ because the meta supplier instance may be shared and reused. That is why:
-
ProcessorMetaSupplier.init(com.hazelcast.jet.core.ProcessorMetaSupplier.Context)
can be invoked multiple times (also afterProcessorMetaSupplier.close(java.lang.Throwable)
). -
ProcessorMetaSupplier.get(java.util.List<com.hazelcast.cluster.Address>)
can be invoked multiple times, but eachProcessorMetaSupplier.get(java.util.List<com.hazelcast.cluster.Address>)
invocation will be preceded byProcessorMetaSupplier.init(com.hazelcast.jet.core.ProcessorMetaSupplier.Context)
invocation for given job execution. -
ProcessorMetaSupplier.close(java.lang.Throwable)
can be invoked multiple times with or without preceding invocations of the other methods. - Meta-supplier method invocation sequences for different concurrent job executions may be interleaved.
ProcessorMetaSupplier.init(com.hazelcast.jet.core.ProcessorMetaSupplier.Context)
method, for example, save some constant data fromProcessorMetaSupplier.Context
for further usage. Note, however, that cluster topology may change and should not be stored.- Specified by:
isReusable
in interfaceProcessorMetaSupplier
-
-
initIsCooperative
public boolean initIsCooperative()Description copied from interface:ProcessorMetaSupplier
Returnstrue
if both theProcessorMetaSupplier.init(Context)
andProcessorMetaSupplier.get(List)
methods of this instance are cooperative. If they are not, the call to theinit()
andget()
method is off-loaded to another thread.- Specified by:
initIsCooperative
in interfaceProcessorMetaSupplier
-
closeIsCooperative
public boolean closeIsCooperative()Description copied from interface:ProcessorMetaSupplier
Returnstrue
if theProcessorMetaSupplier.close(Throwable)
method of this instance is cooperative. If it's not, the call to theclose()
method is off-loaded to another thread.- Specified by:
closeIsCooperative
in interfaceProcessorMetaSupplier
-
writeData
Description copied from interface:DataSerializable
Writes object fields to output stream- Specified by:
writeData
in interfaceDataSerializable
- Parameters:
out
- output- Throws:
IOException
- if an I/O error occurs. In particular, anIOException
may be thrown if the output stream has been closed.
-
readData
Description copied from interface:DataSerializable
Reads fields from the input stream- Specified by:
readData
in interfaceDataSerializable
- Parameters:
in
- input- Throws:
IOException
- if an I/O error occurs. In particular, anIOException
may be thrown if the input stream has been closed.
-
getFactoryId
public int getFactoryId()Description copied from interface:IdentifiedDataSerializable
Returns DataSerializableFactory factory ID for this class.- Specified by:
getFactoryId
in interfaceIdentifiedDataSerializable
- Returns:
- factory ID
-
getClassId
public int getClassId()Description copied from interface:IdentifiedDataSerializable
Returns type identifier for this class. It should be unique per DataSerializableFactory.- Specified by:
getClassId
in interfaceIdentifiedDataSerializable
- Returns:
- type ID
-