public class AkkaUtils$ extends Object
Modifier and Type | Field and Description |
---|---|
static AkkaUtils$ |
MODULE$
Static reference to the singleton instance of this Scala object.
|
Constructor and Description |
---|
AkkaUtils$() |
Modifier and Type | Method and Description |
---|---|
akka.actor.ActorSystem |
createActorSystem(com.typesafe.config.Config akkaConfig)
Creates an actor system with the given akka config.
|
akka.actor.ActorSystem |
createActorSystem(Configuration configuration,
scala.Option<scala.Tuple2<String,Object>> listeningAddress)
Creates an actor system.
|
akka.actor.ActorSystem |
createActorSystem(Configuration configuration,
String hostname,
int port)
Creates an actor system bound to the given hostname and port.
|
akka.actor.ActorSystem |
createDefaultActorSystem()
Creates an actor system with the default config and listening on a random port of the
localhost.
|
akka.actor.ActorSystem |
createLocalActorSystem(Configuration configuration)
Creates a local actor system without remoting.
|
String |
formatDurationParingErrorMessage() |
akka.actor.ActorRef |
getActorRef(String path,
akka.actor.ActorSystem system,
scala.concurrent.duration.FiniteDuration timeout)
Returns an
ActorRef for the actor specified by the path parameter. |
scala.concurrent.Future<akka.actor.ActorRef> |
getActorRefFuture(String path,
akka.actor.ActorSystem system,
scala.concurrent.duration.FiniteDuration timeout)
Returns a
Future to the ActorRef of an actor. |
akka.actor.Address |
getAddress(akka.actor.ActorSystem system)
Returns the address of the given
ActorSystem . |
com.typesafe.config.Config |
getAkkaConfig(Configuration configuration)
Return a local Akka config for the given configuration values.
|
com.typesafe.config.Config |
getAkkaConfig(Configuration configuration,
scala.Option<scala.Tuple2<String,Object>> externalAddress)
Creates an akka config with the provided configuration values.
|
com.typesafe.config.Config |
getAkkaConfig(Configuration configuration,
String hostname,
int port)
Return a remote Akka config for the given configuration values.
|
String |
getAkkaURL(akka.actor.ActorSystem system,
akka.actor.ActorRef actor)
Returns the given
ActorRef 's path string representation with host and port of the
ActorSystem in which the actor is running. |
String |
getAkkaURL(akka.actor.ActorSystem system,
String path)
Returns the AkkaURL for a given
ActorSystem and a path describing a running Actor in
the actor system. |
scala.concurrent.Future<akka.actor.ActorRef> |
getChild(akka.actor.ActorRef parent,
String child,
akka.actor.ActorSystem system,
scala.concurrent.duration.FiniteDuration timeout)
Returns a
Future to the ActorRef of the child of a given actor. |
scala.concurrent.duration.FiniteDuration |
getClientTimeout(Configuration config) |
com.typesafe.config.Config |
getDefaultAkkaConfig()
Creates the default akka configuration which listens on a random port on the local machine.
|
scala.concurrent.duration.FiniteDuration |
getDefaultClientTimeout() |
scala.concurrent.duration.FiniteDuration |
getDefaultLookupTimeout() |
Time |
getDefaultTimeout() |
scala.concurrent.duration.FiniteDuration |
getDefaultTimeoutAsFiniteDuration() |
InetSocketAddress |
getInetSockeAddressFromAkkaURL(String akkaURL)
Extracts the hostname and the port of the remote actor system from the given Akka URL.
|
String |
getLocalAkkaURL(String actorName)
Returns the local akka url for the given actor name.
|
String |
getLogLevel() |
scala.concurrent.duration.FiniteDuration |
getLookupTimeout(Configuration config) |
scala.concurrent.duration.FiniteDuration |
getTimeout(Configuration config) |
scala.concurrent.duration.FiniteDuration |
INF_TIMEOUT() |
org.slf4j.Logger |
LOG() |
scala.concurrent.Future<Object> |
retry(akka.actor.ActorRef target,
Object message,
int tries,
scala.concurrent.ExecutionContext executionContext,
scala.concurrent.duration.FiniteDuration timeout)
Utility function to construct a future which tries multiple times to execute itself if it
fails.
|
<T> scala.concurrent.Future<T> |
retry(Callable<T> callable,
int tries,
scala.concurrent.ExecutionContext executionContext)
Utility function to construct a future which tries multiple times to execute itself if it
fails.
|
<T> scala.concurrent.Future<T> |
retry(scala.Function0<T> body,
int tries,
scala.concurrent.ExecutionContext executionContext)
Utility function to construct a future which tries multiple times to execute itself if it
fails.
|
com.typesafe.config.Config |
testDispatcherConfig() |
public static final AkkaUtils$ MODULE$
public org.slf4j.Logger LOG()
public scala.concurrent.duration.FiniteDuration INF_TIMEOUT()
public akka.actor.ActorSystem createLocalActorSystem(Configuration configuration)
configuration
- instance containing the user provided configuration valuespublic akka.actor.ActorSystem createActorSystem(Configuration configuration, String hostname, int port)
configuration
- instance containing the user provided configuration valueshostname
- of the network interface to bind toport
- of to bind topublic akka.actor.ActorSystem createActorSystem(Configuration configuration, scala.Option<scala.Tuple2<String,Object>> listeningAddress)
configuration
- instance containing the user provided configuration valueslisteningAddress
- an optional tuple containing a bindAddress and a port to bind to.
If the parameter is None, then a local actor system will be created.public akka.actor.ActorSystem createActorSystem(com.typesafe.config.Config akkaConfig)
akkaConfig
- configuration for the actor systempublic akka.actor.ActorSystem createDefaultActorSystem()
public com.typesafe.config.Config getAkkaConfig(Configuration configuration, String hostname, int port)
configuration
- containing the user provided configuration valueshostname
- to bind against. If null, then the loopback interface is usedport
- to bind againstpublic com.typesafe.config.Config getAkkaConfig(Configuration configuration)
configuration
- containing the user provided configuration valuespublic com.typesafe.config.Config getAkkaConfig(Configuration configuration, scala.Option<scala.Tuple2<String,Object>> externalAddress) throws UnknownHostException
configuration
- instance containing the user provided configuration valuesexternalAddress
- optional tuple of bindAddress and port to be reachable at.
If None is given, then an Akka config for local actor system
will be returnedUnknownHostException
public com.typesafe.config.Config getDefaultAkkaConfig()
public com.typesafe.config.Config testDispatcherConfig()
public String getLogLevel()
public scala.concurrent.Future<akka.actor.ActorRef> getChild(akka.actor.ActorRef parent, String child, akka.actor.ActorSystem system, scala.concurrent.duration.FiniteDuration timeout)
Future
to the ActorRef
of the child of a given actor. The child is specified
by providing its actor name.
parent
- ActorRef
to the parent of the child to be retrievedchild
- Name of the child actorsystem
- ActorSystem
to be usedtimeout
- Maximum timeout for the futureFuture
to the ActorRef
of the child actorpublic scala.concurrent.Future<akka.actor.ActorRef> getActorRefFuture(String path, akka.actor.ActorSystem system, scala.concurrent.duration.FiniteDuration timeout)
Future
to the ActorRef
of an actor. The actor is specified by its path.
path
- Path to the actor to be retrievedsystem
- ActorSystem
to be usedtimeout
- Maximum timeout for the futureFuture
to the ActorRef
of the actorpublic akka.actor.ActorRef getActorRef(String path, akka.actor.ActorSystem system, scala.concurrent.duration.FiniteDuration timeout) throws IOException
ActorRef
for the actor specified by the path parameter.
path
- Path to the actor to be retrievedsystem
- ActorSystem
to be usedtimeout
- Maximum timeout for the futureActorRef
of the requested Actor
IOException
public <T> scala.concurrent.Future<T> retry(scala.Function0<T> body, int tries, scala.concurrent.ExecutionContext executionContext)
body
- function describing the future actiontries
- number of maximum tries before the future failsexecutionContext
- which shall execute the futurepublic <T> scala.concurrent.Future<T> retry(Callable<T> callable, int tries, scala.concurrent.ExecutionContext executionContext)
callable
- future actiontries
- maximum number of tries before the future failsexecutionContext
- which shall execute the futurepublic scala.concurrent.Future<Object> retry(akka.actor.ActorRef target, Object message, int tries, scala.concurrent.ExecutionContext executionContext, scala.concurrent.duration.FiniteDuration timeout)
target
- actor which receives the messagemessage
- to be sent to the target actortries
- maximum number of tries before the future failsexecutionContext
- which shall execute the futuretimeout
- of the futurepublic scala.concurrent.duration.FiniteDuration getTimeout(Configuration config)
public Time getDefaultTimeout()
public scala.concurrent.duration.FiniteDuration getDefaultTimeoutAsFiniteDuration()
public scala.concurrent.duration.FiniteDuration getLookupTimeout(Configuration config)
public scala.concurrent.duration.FiniteDuration getDefaultLookupTimeout()
public scala.concurrent.duration.FiniteDuration getClientTimeout(Configuration config)
public scala.concurrent.duration.FiniteDuration getDefaultClientTimeout()
public akka.actor.Address getAddress(akka.actor.ActorSystem system)
ActorSystem
. The Address
object contains
the port and the host under which the actor system is reachable
system
- ActorSystem
for which the Address
shall be retrievedAddress
of the given ActorSystem
public String getAkkaURL(akka.actor.ActorSystem system, akka.actor.ActorRef actor)
ActorRef
's path string representation with host and port of the
ActorSystem
in which the actor is running.
system
- ActorSystem
in which the given ActorRef
is runningactor
- ActorRef
of the Actor
for which the URL has to be generatedActorSystem
independent URL of the Actor
public String getAkkaURL(akka.actor.ActorSystem system, String path)
ActorSystem
and a path describing a running Actor
in
the actor system.
system
- ActorSystem
in which the given Actor
is runningpath
- Path describing an Actor
for which the URL has to be generatedActorSystem
independent URL of an Actor
specified by
path.public InetSocketAddress getInetSockeAddressFromAkkaURL(String akkaURL) throws Exception
InetSocketAddress
instance containing the extracted hostname and port. If
the Akka URL does not contain the hostname and port information, e.g. a local Akka URL is
provided, then an Exception
is thrown.
akkaURL
- The URL to extract the host and port from.Exception
- Thrown, if the given string does not represent a proper urlpublic String formatDurationParingErrorMessage()
Copyright © 2014–2018 The Apache Software Foundation. All rights reserved.