Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UDP-11073 : Switched from Akka 2.6.20 to Pekko 1.0.2 #396

Merged
merged 1 commit into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions odata_service/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,21 +56,21 @@
<artifactId>jakarta.annotation-api</artifactId>
</dependency>
<dependency>
<groupId>com.typesafe.akka</groupId>
<artifactId>akka-actor_2.12</artifactId>
<groupId>org.apache.pekko</groupId>
<artifactId>pekko-actor_2.12</artifactId>
</dependency>
<dependency>
<groupId>com.typesafe.akka</groupId>
<artifactId>akka-slf4j_2.12</artifactId>
<groupId>org.apache.pekko</groupId>
<artifactId>pekko-slf4j_2.12</artifactId>
</dependency>
<dependency>
<groupId>org.scalatest</groupId>
<artifactId>scalatest_2.12</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.typesafe.akka</groupId>
<artifactId>akka-testkit_2.12</artifactId>
<groupId>org.apache.pekko</groupId>
<artifactId>pekko-testkit_2.12</artifactId>
</dependency>
</dependencies>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@

import javax.annotation.PostConstruct;

import static com.sdl.odata.service.util.AkkaUtil.registerRoute;
import static com.sdl.odata.service.util.PekkoUtil.registerRoute;

/**
* The OData Service Configuration.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,20 @@
*/
package com.sdl.odata.service.spring;

import akka.actor.ActorContext;
import akka.actor.ActorRef;
import akka.actor.ActorSystem;
import akka.actor.Props;
import org.apache.pekko.actor.ActorContext;
import org.apache.pekko.actor.ActorRef;
import org.apache.pekko.actor.ActorSystem;
import org.apache.pekko.actor.Props;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
* The ActorProducer is responsible for creating Akka actors that are using Spring dependency injection.
* The ActorProducer is responsible for creating Pekko actors that are using Spring dependency injection.
*/
@Component
public class ActorProducer {
@Autowired
private AkkaSpringExtension akkaSpringExtension;
private PekkoSpringExtension pekkoSpringExtension;

@Autowired
private ActorSystem actorSystem;
Expand All @@ -55,6 +55,6 @@ public ActorRef actorRef(String actorId, ActorContext context) {
}

public Props create(String actorId) {
return akkaSpringExtension.get(actorSystem).props(actorId);
return pekkoSpringExtension.get(actorSystem).props(actorId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
package com.sdl.odata.service.spring;

import akka.actor.ActorSystem;
import org.apache.pekko.actor.ActorSystem;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
Expand All @@ -24,23 +24,23 @@
import org.springframework.stereotype.Component;

/**
* The AkkaConfiguration initializes an Akka Spring configured ActorSystem using the Spring extension.
* The PekkoConfiguration initializes an Pekko Spring configured ActorSystem using the Spring extension.
*/
@Component
public class AkkaConfiguration {
private static final Logger LOG = LoggerFactory.getLogger(AkkaConfiguration.class);
public class PekkoConfiguration {
private static final Logger LOG = LoggerFactory.getLogger(PekkoConfiguration.class);

@Autowired
private ApplicationContext applicationContext;

@Autowired
private AkkaSpringExtension akkaSpringExtension;
private PekkoSpringExtension pekkoSpringExtension;

@Bean(destroyMethod = "terminate")
public ActorSystem actorSystem() {
LOG.info("Creating actor system");
ActorSystem system = ActorSystem.create("ODataAkkaSpringContext");
akkaSpringExtension.get(system).initialize(applicationContext);
ActorSystem system = ActorSystem.create("ODataPekkoSpringContext");
pekkoSpringExtension.get(system).initialize(applicationContext);
return system;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,19 @@
*/
package com.sdl.odata.service.spring;

import akka.actor.Actor;
import akka.actor.IndirectActorProducer;
import org.apache.pekko.actor.Actor;
import org.apache.pekko.actor.IndirectActorProducer;
import org.springframework.context.ApplicationContext;

/**
* The AkkaSpringActorProducer has a reference to the spring context and is responsible
* The PekkoSpringActorProducer has a reference to the spring context and is responsible
* for retrieving the actor based Bean from the Spring context.
*/
public class AkkaSpringActorProducer implements IndirectActorProducer {
public class PekkoSpringActorProducer implements IndirectActorProducer {
private ApplicationContext applicationContext;
private String beanName;

public AkkaSpringActorProducer(ApplicationContext applicationContext, String beanName) {
public PekkoSpringActorProducer(ApplicationContext applicationContext, String beanName) {
this.applicationContext = applicationContext;
this.beanName = beanName;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,36 +15,36 @@
*/
package com.sdl.odata.service.spring;

import akka.actor.AbstractExtensionId;
import akka.actor.ExtendedActorSystem;
import akka.actor.Extension;
import akka.actor.Props;
import org.apache.pekko.actor.AbstractExtensionId;
import org.apache.pekko.actor.ExtendedActorSystem;
import org.apache.pekko.actor.Extension;
import org.apache.pekko.actor.Props;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;

/**
* The AkkaSpringExtension registers the Spring hook into the Akka extension system.
* The PekkoSpringExtension registers the Spring hook into the Pekko extension system.
*/
@Component
public class AkkaSpringExtension extends AbstractExtensionId<AkkaSpringExtension.AkkaExtension> {
public class PekkoSpringExtension extends AbstractExtensionId<PekkoSpringExtension.PekkoExtension> {

@Override
public AkkaExtension createExtension(ExtendedActorSystem system) {
return new AkkaExtension();
public PekkoExtension createExtension(ExtendedActorSystem system) {
return new PekkoExtension();
}

/**
* The Akka Extension.
* The Pekko Extension.
*/
public static class AkkaExtension implements Extension {
public static class PekkoExtension implements Extension {
private volatile ApplicationContext applicationContext;

public void initialize(ApplicationContext ctx) {
this.applicationContext = ctx;
}

public Props props(String actor) {
return Props.create(AkkaSpringActorProducer.class, applicationContext, actor);
return Props.create(PekkoSpringActorProducer.class, applicationContext, actor);
}
}
}
8 changes: 4 additions & 4 deletions odata_service/src/main/resources/application.conf
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
akka {
loggers = ["akka.event.slf4j.Slf4jLogger"]
pekko {
loggers = ["org.apache.pekko.event.slf4j.Slf4jLogger"]

loglevel = "ERROR"

# Log level for the very basic logger activated during AkkaApplication startup
# Log level for the very basic logger activated during PekkoApplication startup
# Options: OFF, ERROR, WARNING, INFO, DEBUG
stdout-loglevel = "ERROR"
actor {
Expand Down Expand Up @@ -53,4 +53,4 @@ akka {
}
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ package com.sdl.odata.service

import java.util.concurrent.TimeUnit.MILLISECONDS

import akka.actor.PoisonPill
import akka.pattern.ask
import akka.util.Timeout
import org.apache.pekko.actor.PoisonPill
import org.apache.pekko.pattern.ask
import org.apache.pekko.util.Timeout
import com.sdl.odata.api.service.{ODataRequest, ODataResponse, ODataService}
import com.sdl.odata.service.actor.ODataMessageRouter
import com.sdl.odata.service.protocol.{InitialServiceRequest, ServiceResponse}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
*/
package com.sdl.odata.service.actor

import akka.actor.SupervisorStrategy.Escalate
import akka.actor.{Actor, ActorLogging, OneForOneStrategy, SupervisorStrategy}
import org.apache.pekko.actor.SupervisorStrategy.Escalate
import org.apache.pekko.actor.{Actor, ActorLogging, OneForOneStrategy, SupervisorStrategy}

trait ODataActor extends Actor with ActorLogging {
override def supervisorStrategy: SupervisorStrategy = OneForOneStrategy() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import com.sdl.odata.unmarshaller.atom.ODataAtomParser
import com.sdl.odata.unmarshaller.json.ODataJsonParser
import com.sdl.odata.service.protocol.{BatchOperation, BatchOperationResult}
import com.sdl.odata.service.spring.ActorProducer
import com.sdl.odata.service.util.AkkaUtil._
import com.sdl.odata.service.util.PekkoUtil._
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.context.annotation.Scope
import org.springframework.stereotype.Component
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
*/
package com.sdl.odata.service.actor

import akka.actor.SupervisorStrategy.{Resume, Stop}
import akka.actor._
import org.apache.pekko.actor.SupervisorStrategy.{Resume, Stop}
import org.apache.pekko.actor._
import com.sdl.odata.api.edm.registry.ODataEdmRegistry
import com.sdl.odata.api.service.ODataRequestContext
import com.sdl.odata.service.protocol._
import com.sdl.odata.service.spring.ActorProducer
import com.sdl.odata.service.util.AkkaUtil
import com.sdl.odata.service.util.PekkoUtil
import org.slf4j.{Logger, LoggerFactory}
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.context.annotation.Scope
Expand All @@ -38,7 +38,7 @@ import org.springframework.stereotype.Component
class ODataMessageRouter @Autowired()(serviceRegistry: ODataEdmRegistry, actorProducer: ActorProducer) extends ODataActor {
import com.sdl.odata.service.actor.MessageHandlerRegistry._
import com.sdl.odata.service.actor.ODataMessageRouter._
import AkkaUtil._
import PekkoUtil._

var origin: Option[ActorRef] = None
var requestContext: Option[ODataRequestContext] = None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import org.springframework.stereotype.Component
@Scope("prototype")
class ODataParserActor @Autowired()(actorProducer: ActorProducer, parser: ODataParser) extends ODataActor {

import com.sdl.odata.service.util.AkkaUtil.routeMessage
import com.sdl.odata.service.util.PekkoUtil.routeMessage

def receive = {
case ServiceRequest(actorContext) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import com.sdl.odata.api.parser.ODataUriUtil.isFunctionCallUri
import com.sdl.odata.api.processor.{ODataFunctionProcessor, ODataQueryProcessor}
import com.sdl.odata.service.protocol.{ReadOperation, Render}
import com.sdl.odata.service.spring.ActorProducer
import com.sdl.odata.service.util.AkkaUtil._
import com.sdl.odata.service.util.PekkoUtil._
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.context.annotation.Scope
import org.springframework.stereotype.Component
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import com.sdl.odata.api.service.ODataRequestContextUtil.{checkSupportedType, is
import com.sdl.odata.parser.ODataBatchRequestContent
import com.sdl.odata.service.protocol._
import com.sdl.odata.service.spring.ActorProducer
import com.sdl.odata.service.util.AkkaUtil._
import com.sdl.odata.service.util.PekkoUtil._
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.context.annotation.Scope
import org.springframework.stereotype.Component
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import com.sdl.odata.api.ODataSystemException
import com.sdl.odata.api.unmarshaller.{ODataUnmarshaller, UnmarshallerFactory}
import com.sdl.odata.service.protocol.{ODataActorContext, Unmarshall, UnmarshallResult}
import com.sdl.odata.service.spring.ActorProducer
import com.sdl.odata.service.util.AkkaUtil._
import com.sdl.odata.service.util.PekkoUtil._
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.context.annotation.Scope
import org.springframework.stereotype.Component
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ package com.sdl.odata.service.actor
import com.sdl.odata.api.processor.ODataWriteProcessor
import com.sdl.odata.service.protocol.{OperationResult, WriteOperation}
import com.sdl.odata.service.spring.ActorProducer
import com.sdl.odata.service.util.AkkaUtil._
import com.sdl.odata.service.util.PekkoUtil._
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.context.annotation.Scope
import org.springframework.stereotype.Component
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
package com.sdl.odata.service.protocol

import akka.actor.ActorRef
import org.apache.pekko.actor.ActorRef
import com.sdl.odata.api.parser.ODataUri
import com.sdl.odata.api.processor.ProcessorResult
import com.sdl.odata.api.service.{ODataRequest, ODataRequestContext, ODataResponse}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,19 @@
*/
package com.sdl.odata.service.util

import akka.actor.{Actor, ActorContext, ActorRef}
import org.apache.pekko.actor.{Actor, ActorContext, ActorRef}
import com.sdl.odata.service.actor.MessageHandlerRegistry._
import com.sdl.odata.service.actor.ODataMessageRouter
import com.sdl.odata.service.protocol.{ODataActorMessage, RegisterMessageHandler}
import com.sdl.odata.service.spring.ActorProducer
import org.slf4j.{Logger, LoggerFactory}

/**
* Akka Util Class is resppnsible for registering routes for actors.
* Pekko Util Class is responsible for registering routes for actors.
*
*/
object AkkaUtil {
private val logger: Logger = LoggerFactory.getLogger("AkkaUtil")
object PekkoUtil {
private val logger: Logger = LoggerFactory.getLogger("PekkoUtil")

def registerRoute(messageType: Class[_ <: ODataActorMessage], actorType: Class[_ <: Actor])(implicit producer: ActorProducer) {
messageRouter().tell(RegisterMessageHandler(messageType, actorType.getSimpleName), null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
package com.sdl.odata.service

import org.scalatest.{Suite, BeforeAndAfterAll}
import akka.testkit.TestKit
import org.apache.pekko.testkit.TestKit

trait StopSystemAfterAll extends BeforeAndAfterAll {
this: TestKit with Suite =>
Expand Down
Loading
Loading