Class SubFusingActorMaterializerImpl
- java.lang.Object
-
- akka.stream.Materializer
-
- akka.stream.impl.SubFusingActorMaterializerImpl
-
public class SubFusingActorMaterializerImpl extends Materializer
This materializer replaces the default phase with one that will fuse operators into an existing interpreter (viaregisterShell
), rather than start a new actor for each of them.The default phases are left in-tact since we still respect
.async
and other tags that were marked within a sub-fused graph.
-
-
Constructor Summary
Constructors Constructor Description SubFusingActorMaterializerImpl(ExtendedActorMaterializer delegate, scala.Function1<GraphInterpreterShell,ActorRef> registerShell)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ActorRef
actorOf(MaterializationContext context, Props props)
INTERNAL APIExtendedActorMaterializer
delegate()
scala.concurrent.ExecutionContextExecutor
executionContext()
Running a flow graph will require execution resources, as will computations within Sources, Sinks, etc.boolean
isShutdown()
Indicates if the materializer has been shut down.LoggingAdapter
logger()
INTERNAL API<Mat> Mat
materialize(Graph<ClosedShape,Mat> runnable)
This method interprets the given Flow description and creates the running stream.<Mat> Mat
materialize(Graph<ClosedShape,Mat> runnable, Attributes defaultAttributes)
This method interprets the given Flow description and creates the running stream using an explicitly providedAttributes
as top level (least specific) attributes that will be defaults for the materialized stream.Cancellable
scheduleAtFixedRate(scala.concurrent.duration.FiniteDuration initialDelay, scala.concurrent.duration.FiniteDuration interval, java.lang.Runnable task)
Interface for operators that need timer services for their functionality.Cancellable
scheduleOnce(scala.concurrent.duration.FiniteDuration delay, java.lang.Runnable task)
Interface for operators that need timer services for their functionality.Cancellable
schedulePeriodically(scala.concurrent.duration.FiniteDuration initialDelay, scala.concurrent.duration.FiniteDuration interval, java.lang.Runnable task)
Interface for operators that need timer services for their functionality.Cancellable
scheduleWithFixedDelay(scala.concurrent.duration.FiniteDuration initialDelay, scala.concurrent.duration.FiniteDuration delay, java.lang.Runnable task)
Interface for operators that need timer services for their functionality.ActorMaterializerSettings
settings()
void
shutdown()
Shuts down this materializer and all the operators that have been materialized through this materializer.java.lang.Object
subFusingPhase()
ActorRef
supervisor()
INTERNAL APIActorSystem
system()
The classic actor system this materializer is backed by (and in which the streams materialized with the materializer will run)SubFusingActorMaterializerImpl
withNamePrefix(java.lang.String name)
ThenamePrefix
shall be used for deriving the names of processing entities that are created during materialization.-
Methods inherited from class akka.stream.Materializer
apply, apply, createMaterializer, createMaterializer, matFromSystem
-
-
-
-
Constructor Detail
-
SubFusingActorMaterializerImpl
public SubFusingActorMaterializerImpl(ExtendedActorMaterializer delegate, scala.Function1<GraphInterpreterShell,ActorRef> registerShell)
-
-
Method Detail
-
actorOf
public ActorRef actorOf(MaterializationContext context, Props props)
Description copied from class:Materializer
INTERNAL API- Specified by:
actorOf
in classMaterializer
-
delegate
public ExtendedActorMaterializer delegate()
-
executionContext
public scala.concurrent.ExecutionContextExecutor executionContext()
Description copied from class:Materializer
Running a flow graph will require execution resources, as will computations within Sources, Sinks, etc. ThisExecutionContextExecutor
can be used by parts of the flow to submit processing jobs for execution, run Future callbacks, etc.Note that this is not necessarily the same execution context the stream operator itself is running on.
- Specified by:
executionContext
in classMaterializer
-
isShutdown
public boolean isShutdown()
Description copied from class:Materializer
Indicates if the materializer has been shut down.- Specified by:
isShutdown
in classMaterializer
-
logger
public LoggingAdapter logger()
Description copied from class:Materializer
INTERNAL APICustom
GraphStage
s that needs logging should useStageLogging
(Scala) orGraphStageLogicWithLogging
(Java) instead.- Specified by:
logger
in classMaterializer
-
materialize
public <Mat> Mat materialize(Graph<ClosedShape,Mat> runnable)
Description copied from class:Materializer
This method interprets the given Flow description and creates the running stream. The result can be highly implementation specific, ranging from local actor chains to remote-deployed processing networks.- Specified by:
materialize
in classMaterializer
-
materialize
public <Mat> Mat materialize(Graph<ClosedShape,Mat> runnable, Attributes defaultAttributes)
Description copied from class:Materializer
This method interprets the given Flow description and creates the running stream using an explicitly providedAttributes
as top level (least specific) attributes that will be defaults for the materialized stream. The result can be highly implementation specific, ranging from local actor chains to remote-deployed processing networks.- Specified by:
materialize
in classMaterializer
-
scheduleAtFixedRate
public Cancellable scheduleAtFixedRate(scala.concurrent.duration.FiniteDuration initialDelay, scala.concurrent.duration.FiniteDuration interval, java.lang.Runnable task)
Description copied from class:Materializer
Interface for operators that need timer services for their functionality.Schedules a
Runnable
to be run repeatedly with an initial delay and a frequency. E.g. if you would like the function to be run after 2 seconds and thereafter every 100ms you would setdelay=Duration(2, TimeUnit.SECONDS)
andinterval=Duration(100, TimeUnit.MILLISECONDS)
.It will compensate the delay for a subsequent task if the previous tasks took too long to execute. In such cases, the actual execution interval will differ from the interval passed to the method.
If the execution of the tasks takes longer than the
interval
, the subsequent execution will start immediately after the prior one completes (there will be no overlap of executions). This also has the consequence that after long garbage collection pauses or other reasons when the JVM was suspended all "missed" tasks will execute when the process wakes up again.In the long run, the frequency of execution will be exactly the reciprocal of the specified
interval
.Warning:
scheduleAtFixedRate
can result in bursts of scheduled tasks after long garbage collection pauses, which may in worst case cause undesired load on the system. ThereforescheduleWithFixedDelay
is often preferred.If the
Runnable
throws an exception the repeated scheduling is aborted, i.e. the function will not be invoked any more.- Specified by:
scheduleAtFixedRate
in classMaterializer
- Returns:
- A
Cancellable
that allows cancelling the timer. Cancelling is best effort, if the event has been already enqueued it will not have an effect.
-
scheduleOnce
public Cancellable scheduleOnce(scala.concurrent.duration.FiniteDuration delay, java.lang.Runnable task)
Description copied from class:Materializer
Interface for operators that need timer services for their functionality. Schedules a single task with the given delay.- Specified by:
scheduleOnce
in classMaterializer
- Returns:
- A
Cancellable
that allows cancelling the timer. Cancelling is best effort, if the event has been already enqueued it will not have an effect.
-
schedulePeriodically
public Cancellable schedulePeriodically(scala.concurrent.duration.FiniteDuration initialDelay, scala.concurrent.duration.FiniteDuration interval, java.lang.Runnable task)
Description copied from class:Materializer
Interface for operators that need timer services for their functionality. Schedules a repeated task with the given interval between invocations.- Specified by:
schedulePeriodically
in classMaterializer
- Returns:
- A
Cancellable
that allows cancelling the timer. Cancelling is best effort, if the event has been already enqueued it will not have an effect.
-
scheduleWithFixedDelay
public Cancellable scheduleWithFixedDelay(scala.concurrent.duration.FiniteDuration initialDelay, scala.concurrent.duration.FiniteDuration delay, java.lang.Runnable task)
Description copied from class:Materializer
Interface for operators that need timer services for their functionality.Schedules a
Runnable
to be run repeatedly with an initial delay and a fixeddelay
between subsequent executions.It will not compensate the delay between tasks if the execution takes a long time or if scheduling is delayed longer than specified for some reason. The delay between subsequent execution will always be (at least) the given
delay
. In the long run, the frequency of execution will generally be slightly lower than the reciprocal of the specifieddelay
.If the
Runnable
throws an exception the repeated scheduling is aborted, i.e. the function will not be invoked any more.- Specified by:
scheduleWithFixedDelay
in classMaterializer
- Returns:
- A
Cancellable
that allows cancelling the timer. Cancelling is best effort, if the event has been already enqueued it will not have an effect.
-
settings
public ActorMaterializerSettings settings()
- Specified by:
settings
in classMaterializer
-
shutdown
public void shutdown()
Description copied from class:Materializer
Shuts down this materializer and all the operators that have been materialized through this materializer. After having shut down, this materializer cannot be used again. Any attempt to materialize operators after having shut down will result in an IllegalStateException being thrown at materialization time.- Specified by:
shutdown
in classMaterializer
-
subFusingPhase
public java.lang.Object subFusingPhase()
-
supervisor
public ActorRef supervisor()
Description copied from class:Materializer
INTERNAL API- Specified by:
supervisor
in classMaterializer
-
system
public ActorSystem system()
Description copied from class:Materializer
The classic actor system this materializer is backed by (and in which the streams materialized with the materializer will run)- Specified by:
system
in classMaterializer
-
withNamePrefix
public SubFusingActorMaterializerImpl withNamePrefix(java.lang.String name)
Description copied from class:Materializer
ThenamePrefix
shall be used for deriving the names of processing entities that are created during materialization. This is meant to aid logging and failure reporting both during materialization and while the stream is running.- Specified by:
withNamePrefix
in classMaterializer
-
-