Skip to content

Commit

Permalink
Merge pull request #721 from ie3-institute/ms/#666-convert-GridAgent-…
Browse files Browse the repository at this point in the history
…and-DBFSAlgorithm-to-pekko-typed

Convert `GridAgent` & `DBFSAlgorithm` to pekko typed
  • Loading branch information
sebastian-peter authored Feb 27, 2024
2 parents 46cdb88 + 6cd336a commit 5cf53d0
Show file tree
Hide file tree
Showing 38 changed files with 2,061 additions and 2,011 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Unified consideration of scaling factor when simulating system participants [#81](https://github.com/ie3-institute/simona/issues/81)
- Small improvements in `ResultEventListener` [#738](https://github.com/ie3-institute/simona/issues/738)
- Converting `SimonaSim` to pekko typed/terminating SimonSim when initialization fails [#210](https://github.com/ie3-institute/simona/issues/210)
- Converting the `GridAgent` and the `DBFSAlgorithm` to `pekko typed` [#666](https://github.com/ie3-institute/simona/issues/666)

### Fixed
- Removed a repeated line in the documentation of vn_simona config [#658](https://github.com/ie3-institute/simona/issues/658)
Expand Down
20 changes: 15 additions & 5 deletions src/main/scala/edu/ie3/simona/actor/SimonaActorNaming.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@

package edu.ie3.simona.actor

import org.apache.pekko.actor.{ActorRef, ActorRefFactory, Props}
import org.apache.pekko.actor.typed.ActorRef
import org.apache.pekko.actor.typed.scaladsl.adapter.TypedActorRefOps
import org.apache.pekko.actor.{ActorRefFactory, Props, ActorRef => ClassicRef}

import java.util.UUID

Expand All @@ -15,10 +17,10 @@ object SimonaActorNaming {
implicit class RichActorRefFactory(private val refFactory: ActorRefFactory)
extends AnyVal {

def simonaActorOf(props: Props, actorId: String): ActorRef =
def simonaActorOf(props: Props, actorId: String): ClassicRef =
refFactory.actorOf(props, actorName(props, actorId))

def simonaActorOf(props: Props): ActorRef =
def simonaActorOf(props: Props): ClassicRef =
refFactory.actorOf(props, actorName(props, simonaActorUuid))
}

Expand Down Expand Up @@ -62,13 +64,13 @@ object SimonaActorNaming {
def actorName(typeName: String, actorId: String): String =
s"${typeName}_${cleanActorIdForPekko(actorId)}"

/** Extracts the actor name from given [[ActorRef]]. Cluster singletons are
/** Extracts the actor name from given [[ClassicRef]]. Cluster singletons are
* taken care of separately.
*
* @return
* the actor name extract from the ActorRef
*/
def actorName(actorRef: ActorRef): String =
def actorName(actorRef: ClassicRef): String =
actorRef.path.name match {
case "singleton" =>
// singletons end in /${actorName}/singleton
Expand All @@ -77,6 +79,14 @@ object SimonaActorNaming {
other
}

/** Extracts the actor name from given [[ActorRef]]. Cluster singletons are
* taken care of separately.
*
* @return
* the actor name extract from the ActorRef
*/
def actorName(actorRef: ActorRef[_]): String = actorName(actorRef.toClassic)

/** Constructs the type name from given props.
*
* @return
Expand Down
3 changes: 2 additions & 1 deletion src/main/scala/edu/ie3/simona/agent/EnvironmentRefs.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

package edu.ie3.simona.agent

import edu.ie3.simona.event.RuntimeEvent
import edu.ie3.simona.ontology.messages.SchedulerMessage
import org.apache.pekko.actor.typed.ActorRef
import org.apache.pekko.actor.{ActorRef => ClassicRef}
Expand All @@ -26,7 +27,7 @@ import org.apache.pekko.actor.{ActorRef => ClassicRef}
*/
final case class EnvironmentRefs(
scheduler: ActorRef[SchedulerMessage],
runtimeEventListener: ClassicRef,
runtimeEventListener: ActorRef[RuntimeEvent],
primaryServiceProxy: ClassicRef,
weather: ClassicRef,
evDataService: Option[ClassicRef],
Expand Down
Loading

0 comments on commit 5cf53d0

Please sign in to comment.