Class ActorUtils


  • public class ActorUtils
    extends Object
    The ActorUtils class contains utility methods which could be used by non-actors (like DistributedDataStore) to work with actors a little more easily. An ActorContext can be freely passed around to local object instances but should not be passed to actors especially remote actors.
    • Method Detail

      • getActorSystem

        public akka.actor.ActorSystem getActorSystem()
      • getShardManager

        public akka.actor.ActorRef getShardManager()
      • actorSelection

        public akka.actor.ActorSelection actorSelection​(String actorPath)
      • actorSelection

        public akka.actor.ActorSelection actorSelection​(akka.actor.ActorPath actorPath)
      • setSchemaContext

        public void setSchemaContext​(org.opendaylight.yangtools.yang.model.api.SchemaContext schemaContext)
      • getSchemaContext

        public org.opendaylight.yangtools.yang.model.api.SchemaContext getSchemaContext()
      • findPrimaryShardAsync

        public scala.concurrent.Future<PrimaryShardInfo> findPrimaryShardAsync​(String shardName)
      • findLocalShard

        public Optional<akka.actor.ActorRef> findLocalShard​(String shardName)
        Finds a local shard given its shard name and return it's ActorRef.
        Parameters:
        shardName - the name of the local shard that needs to be found
        Returns:
        a reference to a local shard actor which represents the shard specified by the shardName
      • findLocalShardAsync

        public scala.concurrent.Future<akka.actor.ActorRef> findLocalShardAsync​(String shardName)
        Finds a local shard async given its shard name and return a Future from which to obtain the ActorRef.
        Parameters:
        shardName - the name of the local shard that needs to be found
      • executeOperation

        public Object executeOperation​(akka.actor.ActorRef actor,
                                       Object message)
        Executes an operation on a local actor and wait for it's response.
        Parameters:
        actor - the actor
        message - the message to send
        Returns:
        The response of the operation
      • executeOperation

        public Object executeOperation​(akka.actor.ActorSelection actor,
                                       Object message)
        Execute an operation on a remote actor and wait for it's response.
        Parameters:
        actor - the actor
        message - the message
        Returns:
        the response message
      • executeOperationAsync

        public scala.concurrent.Future<Object> executeOperationAsync​(akka.actor.ActorRef actor,
                                                                     Object message,
                                                                     akka.util.Timeout timeout)
      • executeOperationAsync

        public scala.concurrent.Future<Object> executeOperationAsync​(akka.actor.ActorSelection actor,
                                                                     Object message,
                                                                     akka.util.Timeout timeout)
        Execute an operation on a remote actor asynchronously.
        Parameters:
        actor - the ActorSelection
        message - the message to send
        timeout - the operation timeout
        Returns:
        a Future containing the eventual result
      • executeOperationAsync

        public scala.concurrent.Future<Object> executeOperationAsync​(akka.actor.ActorSelection actor,
                                                                     Object message)
        Execute an operation on a remote actor asynchronously.
        Parameters:
        actor - the ActorSelection
        message - the message to send
        Returns:
        a Future containing the eventual result
      • sendOperationAsync

        public void sendOperationAsync​(akka.actor.ActorSelection actor,
                                       Object message)
        Sends an operation to be executed by a remote actor asynchronously without waiting for a reply (essentially set and forget).
        Parameters:
        actor - the ActorSelection
        message - the message to send
      • shutdown

        public void shutdown()
      • getCurrentMemberName

        public org.opendaylight.controller.cluster.access.concepts.MemberName getCurrentMemberName()
      • broadcast

        public void broadcast​(Function<Short,​Object> messageSupplier,
                              Class<?> messageClass)
        Send the message to each and every shard.
      • getOperationDuration

        public scala.concurrent.duration.FiniteDuration getOperationDuration()
      • getOperationTimeout

        public akka.util.Timeout getOperationTimeout()
      • isPathLocal

        public boolean isPathLocal​(String path)
      • getOperationTimer

        public com.codahale.metrics.Timer getOperationTimer​(String operationName)
        This is a utility method that lets us get a Timer object for any operation. This is a little open-ended to allow us to create a timer for pretty much anything.
        Parameters:
        operationName - the name of the operation
        Returns:
        the Timer instance
      • getOperationTimer

        public com.codahale.metrics.Timer getOperationTimer​(String dataStoreType,
                                                            String operationName)
      • getDataStoreName

        public String getDataStoreName()
        Get the name of the data store to which this ActorContext belongs.
        Returns:
        the data store name
      • getTxCreationLimit

        public double getTxCreationLimit()
        Get the current transaction creation rate limit.
        Returns:
        the rate limit
      • acquireTxCreationPermit

        public void acquireTxCreationPermit()
        Try to acquire a transaction creation permit. Will block if no permits are available.
      • getTransactionCommitOperationTimeout

        public akka.util.Timeout getTransactionCommitOperationTimeout()
        Returns the operation timeout to be used when committing transactions.
        Returns:
        the operation timeout
      • getClientDispatcher

        public scala.concurrent.ExecutionContext getClientDispatcher()
        An akka dispatcher that is meant to be used when processing ask Futures which were triggered by client code on the datastore.
        Returns:
        the dispatcher
      • getNotificationDispatcherPath

        public String getNotificationDispatcherPath()
      • doAsk

        protected scala.concurrent.Future<Object> doAsk​(akka.actor.ActorRef actorRef,
                                                        Object message,
                                                        akka.util.Timeout timeout)
      • doAsk

        protected scala.concurrent.Future<Object> doAsk​(akka.actor.ActorSelection actorRef,
                                                        Object message,
                                                        akka.util.Timeout timeout)