Class ActorUtils
- java.lang.Object
-
- org.opendaylight.controller.cluster.datastore.utils.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.
-
-
Field Summary
Fields Modifier and Type Field Description static StringBOUNDED_MAILBOXstatic StringCOMMIT
-
Constructor Summary
Constructors Constructor Description ActorUtils(akka.actor.ActorSystem actorSystem, akka.actor.ActorRef shardManager, ClusterWrapper clusterWrapper, Configuration configuration)ActorUtils(akka.actor.ActorSystem actorSystem, akka.actor.ActorRef shardManager, ClusterWrapper clusterWrapper, Configuration configuration, DatastoreContext datastoreContext, PrimaryShardInfoFutureCache primaryShardInfoCache)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidacquireTxCreationPermit()Try to acquire a transaction creation permit.akka.actor.ActorSelectionactorSelection(akka.actor.ActorPath actorPath)akka.actor.ActorSelectionactorSelection(String actorPath)voidbroadcast(Function<Short,Object> messageSupplier, Class<?> messageClass)Send the message to each and every shard.protected scala.concurrent.Future<Object>doAsk(akka.actor.ActorRef actorRef, Object message, akka.util.Timeout timeout)protected scala.concurrent.Future<Object>doAsk(akka.actor.ActorSelection actorRef, Object message, akka.util.Timeout timeout)ObjectexecuteOperation(akka.actor.ActorRef actor, Object message)Executes an operation on a local actor and wait for it's response.ObjectexecuteOperation(akka.actor.ActorSelection actor, Object message)Execute an operation on a remote actor and wait for it's response.scala.concurrent.Future<Object>executeOperationAsync(akka.actor.ActorRef actor, Object message, akka.util.Timeout timeout)scala.concurrent.Future<Object>executeOperationAsync(akka.actor.ActorSelection actor, Object message)Execute an operation on a remote actor asynchronously.scala.concurrent.Future<Object>executeOperationAsync(akka.actor.ActorSelection actor, Object message, akka.util.Timeout timeout)Execute an operation on a remote actor asynchronously.Optional<akka.actor.ActorRef>findLocalShard(String shardName)Finds a local shard given its shard name and return it's ActorRef.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.scala.concurrent.Future<PrimaryShardInfo>findPrimaryShardAsync(String shardName)akka.actor.ActorSystemgetActorSystem()longgetAskTimeoutExceptionCount()scala.concurrent.ExecutionContextgetClientDispatcher()An akka dispatcher that is meant to be used when processing ask Futures which were triggered by client code on the datastore.ClusterWrappergetClusterWrapper()ConfigurationgetConfiguration()org.opendaylight.controller.cluster.access.concepts.MemberNamegetCurrentMemberName()DatastoreContextgetDatastoreContext()StringgetDataStoreName()Get the name of the data store to which this ActorContext belongs.StringgetNotificationDispatcherPath()scala.concurrent.duration.FiniteDurationgetOperationDuration()akka.util.TimeoutgetOperationTimeout()com.codahale.metrics.TimergetOperationTimer(String operationName)This is a utility method that lets us get a Timer object for any operation.com.codahale.metrics.TimergetOperationTimer(String dataStoreType, String operationName)PrimaryShardInfoFutureCachegetPrimaryShardInfoCache()org.opendaylight.yangtools.yang.model.api.EffectiveModelContextgetSchemaContext()akka.actor.ActorRefgetShardManager()ShardStrategyFactorygetShardStrategyFactory()akka.util.TimeoutgetTransactionCommitOperationTimeout()Returns the operation timeout to be used when committing transactions.doublegetTxCreationLimit()Get the current transaction creation rate limit.booleanisPathLocal(String path)voidresetAskTimeoutExceptionCount()voidsendOperationAsync(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).voidsetDatastoreContext(DatastoreContextFactory contextFactory)voidsetSchemaContext(org.opendaylight.yangtools.yang.model.api.EffectiveModelContext schemaContext)voidshutdown()
-
-
-
Field Detail
-
BOUNDED_MAILBOX
public static final String BOUNDED_MAILBOX
- See Also:
- Constant Field Values
-
COMMIT
public static final String COMMIT
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ActorUtils
public ActorUtils(akka.actor.ActorSystem actorSystem, akka.actor.ActorRef shardManager, ClusterWrapper clusterWrapper, Configuration configuration)
-
ActorUtils
public ActorUtils(akka.actor.ActorSystem actorSystem, akka.actor.ActorRef shardManager, ClusterWrapper clusterWrapper, Configuration configuration, DatastoreContext datastoreContext, PrimaryShardInfoFutureCache primaryShardInfoCache)
-
-
Method Detail
-
getDatastoreContext
public DatastoreContext getDatastoreContext()
-
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.EffectiveModelContext schemaContext)
-
setDatastoreContext
public void setDatastoreContext(DatastoreContextFactory contextFactory)
-
getSchemaContext
public org.opendaylight.yangtools.yang.model.api.EffectiveModelContext 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 actormessage- 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 actormessage- 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 ActorSelectionmessage- the message to sendtimeout- 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 ActorSelectionmessage- 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 ActorSelectionmessage- the message to send
-
shutdown
public void shutdown()
-
getClusterWrapper
public ClusterWrapper getClusterWrapper()
-
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
-
getAskTimeoutExceptionCount
public long getAskTimeoutExceptionCount()
-
resetAskTimeoutExceptionCount
public void resetAskTimeoutExceptionCount()
-
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()
-
getConfiguration
public Configuration getConfiguration()
-
getShardStrategyFactory
public ShardStrategyFactory getShardStrategyFactory()
-
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)
-
getPrimaryShardInfoCache
public PrimaryShardInfoFutureCache getPrimaryShardInfoCache()
-
-