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

akka => pekko #799

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,5 @@ project/build/target/
project/plugins/target/
project/plugins/lib_managed/
project/plugins/src_managed/
/.bsp
.bsp/sbt.json
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,28 +139,28 @@ KryoInjection can be composed with Bijections and Injections from `com.twitter.b

To use, add a key to your config like:
```
akka.actor.serializers {
kryo = "com.twitter.chill.akka.AkkaSerializer"
pekko.actor.serializers {
kryo = "com.twitter.chill.pekko.PekkoSerializer"
}
```

Then for the super-classes of all your message types, for instance, `java.io.Serializable` (all case classes and case objects are serializable), write:
```scala
akka.actor.serialization-bindings {
pekko.actor.serialization-bindings {
"java.io.Serializable" = kryo
}
```

With this in place you can now [disable Java serialization entirely](https://doc.akka.io/docs/akka/current/remoting.html#disable-java-serializer):

```scala
akka.actor {
pekko.actor {
# Set this to on to enable serialization-bindings defined in
# additional-serialization-bindings. Those are by default not included
# for backwards compatibility reasons. They are enabled by default if
# akka.remote.artery.enabled=on.
enable-additional-serialization-bindings = on
# pekko.remote.artery.enabled=on.
enable-additional-serialization-bindings = on

allow-java-serialization = off
}
```
Expand Down
52 changes: 24 additions & 28 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import com.typesafe.tools.mima.plugin.MimaPlugin.mimaDefaultSettings

val akkaVersion = "2.6.20"
val pekkoVersion = "1.0.2"
val algebirdVersion = "0.13.9"
val bijectionVersion = "0.9.7"
val kryoVersion = "4.0.2"
val kryoVersion = "4.0.3"
val scroogeVersion = "21.2.0"
val asmVersion = "4.16"
val protobufVersion = "3.22.2"
Expand All @@ -19,8 +19,8 @@ def scalaVersionSpecificFolders(srcBaseDir: java.io.File, scalaVersion: String):

val sharedSettings = Seq(
organization := "com.twitter",
scalaVersion := "2.11.12",
crossScalaVersions := Seq("2.11.12", "2.12.17", "2.13.8"),
scalaVersion := "2.12.17",
crossScalaVersions := Seq("2.12.17", "2.13.8"),
scalacOptions ++= Seq("-unchecked", "-deprecation"),
scalacOptions ++= {
scalaVersion.value match {
Expand Down Expand Up @@ -57,26 +57,26 @@ val sharedSettings = Seq(
),
Test / parallelExecution := true,
pomExtra := <url>https://github.com/twitter/chill</url>
<licenses>
<licenses>
<license>
<name>Apache 2</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
<name>Apache 2</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
<distribution>repo</distribution>
<comments>A business-friendly OSS license</comments>
<comments>A business-friendly OSS license</comments>
</license>
</licenses>
<developers>
</licenses>
<developers>
<developer>
<id>oscar</id>
<name>Oscar Boykin</name>
<url>http://twitter.com/posco</url>
</developer>
<id>oscar</id>
<name>Oscar Boykin</name>
<url>http://twitter.com/posco</url>
</developer>
<developer>
<id>sritchie</id>
<name>Sam Ritchie</name>
<url>http://twitter.com/sritchie</url>
</developer>
</developers>,
<id>sritchie</id>
<name>Sam Ritchie</name>
<url>http://twitter.com/sritchie</url>
</developer>
</developers>,
Compile / unmanagedSourceDirectories ++= scalaVersionSpecificFolders(
(Compile / scalaSource).value,
scalaVersion.value
Expand Down Expand Up @@ -110,7 +110,7 @@ lazy val chillAll = Project(
chillHadoop,
chillThrift,
chillProtobuf,
chillAkka,
chillPekko,
chillAvro,
chillAlgebird
)
Expand All @@ -126,7 +126,7 @@ lazy val noPublishSettings = Seq(
/**
* This returns the youngest jar we released that is compatible with the current.
*/
val unreleasedModules = Set[String]("akka")
val unreleasedModules = Set[String]("pekko")
val javaOnly = Set[String]("storm", "java", "hadoop", "thrift", "protobuf")
val binaryCompatVersion = "0.9.2"

Expand Down Expand Up @@ -186,18 +186,14 @@ lazy val chill = Project(
)
.dependsOn(chillJava)

def akka(scalaVersion: String) =
(scalaVersion match {
case s if s.startsWith("2.11.") => "com.typesafe.akka" %% "akka-actor" % "2.5.32"
case _ => "com.typesafe.akka" %% "akka-actor" % akkaVersion
}) % "provided"
def pekko(scalaVersion: String) = "org.apache.pekko" %% "pekko-actor" % pekkoVersion % "provided"

lazy val chillAkka = module("akka")
lazy val chillPekko = module("pekko")
.settings(
resolvers += Resolver.typesafeRepo("releases"),
libraryDependencies ++= Seq(
"com.typesafe" % "config" % "1.4.2",
scalaVersion(sv => akka(sv)).value
scalaVersion(sv => pekko(sv)).value
)
)
.dependsOn(chill % "test->test;compile->compile")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.twitter.chill.akka
package com.twitter.chill.pekko

/**
* Copyright 2012 Roman Levenstein
Expand All @@ -12,15 +12,15 @@ package com.twitter.chill.akka
* distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and limitations under the License.
*/
import akka.actor.{ActorPath, ActorRef, ExtendedActorSystem}
import akka.serialization.Serialization
import org.apache.pekko.actor.{ActorPath, ActorRef, ExtendedActorSystem}
import org.apache.pekko.serialization.Serialization
import com.esotericsoftware.kryo.{Kryo, Serializer}
import com.esotericsoftware.kryo.io.{Input, Output}

import com.twitter.chill.{toRich, IKryoRegistrar}

/**
* * This module provides helper classes for serialization of Akka-specific classes.
* * This module provides helper classes for serialization of Pekko-specific classes.
*
* @author
* Roman Levenstein
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package com.twitter.chill.akka
package com.twitter.chill.pekko

import com.twitter.chill.config.{Config => ChillConfig}
import com.typesafe.config.{Config => TypesafeConfig}
Expand All @@ -26,7 +26,7 @@ import scala.util.Try
* Wraps the immutable typesafe.config.Config in a wrapper that keeps track of the state and follows the
* semantics of ChillConfig
*/
class AkkaConfig(var typesafeConfig: TypesafeConfig) extends ChillConfig {
class PekkoConfig(var typesafeConfig: TypesafeConfig) extends ChillConfig {
/* This is implementing a Java API so that has an assy format */
def get(key: String): String =
Try(typesafeConfig.getString(key)).toOption.orNull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package com.twitter.chill.akka
package com.twitter.chill.pekko

import akka.actor.ExtendedActorSystem
import akka.serialization.Serializer
import org.apache.pekko.actor.ExtendedActorSystem
import org.apache.pekko.serialization.Serializer

import com.twitter.chill._
import com.twitter.chill.config.ConfiguredInstantiator
Expand All @@ -27,21 +27,21 @@ import com.twitter.chill.config.ConfiguredInstantiator
*
* {{{
*
* akka.actor.serializers {
* kryo = "com.twitter.chill.akka.AkkaSerializer"
* org.apache.pekko.actor.serializers {
* kryo = "com.twitter.chill.org.apache.pekko.PekkoSerializer"
* }
* }}}
*
* Then for the super-classes of all your message types, for instance, scala.Product, write:
* {{{
* akka.actor.serialization-bindings {
* org.apache.pekko.actor.serialization-bindings {
* "scala.Product" = kryo
* }
* }}}
*
* Kryo is not thread-safe so we use an object pool to avoid over allocating.
*/
class AkkaSerializer(system: ExtendedActorSystem) extends Serializer {
class PekkoSerializer(system: ExtendedActorSystem) extends Serializer {

/**
* You can override this to easily change your serializers. If you do so, make sure to change the config to
Expand Down Expand Up @@ -75,8 +75,8 @@ class AkkaSerializer(system: ExtendedActorSystem) extends Serializer {
* ConfiguredInstantiator static methods for how to build up a correct Config with your reflected or
* serialized instantiators.
*/
class ConfiguredAkkaSerializer(system: ExtendedActorSystem) extends AkkaSerializer(system) {
class ConfiguredPekkoSerializer(system: ExtendedActorSystem) extends PekkoSerializer(system) {
override def kryoInstantiator: KryoInstantiator =
new ConfiguredInstantiator(new AkkaConfig(system.settings.config))
new ConfiguredInstantiator(new PekkoConfig(system.settings.config))
.withRegistrar(new ActorRefSerializer(system))
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package com.twitter.chill.akka
package com.twitter.chill.pekko

import akka.actor.{Actor, ActorRef, ActorSystem, Props}
import akka.serialization._
import org.apache.pekko.actor.{Actor, ActorRef, ActorSystem, Props}
import org.apache.pekko.serialization._
import com.typesafe.config.ConfigFactory
import org.scalatest.matchers.should.Matchers
import org.scalatest.wordspec.AnyWordSpec

class AkkaTests extends AnyWordSpec with Matchers {
class PekkoTests extends AnyWordSpec with Matchers {
object IncActor {
def props: Props = Props(IncActor())
}
Expand All @@ -36,32 +36,32 @@ class AkkaTests extends AnyWordSpec with Matchers {
val system: ActorSystem = ActorSystem(
"example",
ConfigFactory.parseString("""
akka.actor.serializers {
kryo = "com.twitter.chill.akka.AkkaSerializer"
pekko.actor.serializers {
kryo = "com.twitter.chill.pekko.PekkoSerializer"
}

akka.actor.serialization-bindings {
pekko.actor.serialization-bindings {
"scala.Product" = kryo
"akka.actor.ActorRef" = kryo
"org.apache.pekko.actor.ActorRef" = kryo
}
""")
)

// Get the Serialization Extension
val serialization: Serialization = SerializationExtension(system)

"AkkaSerializer" should {
"PekkoSerializer" should {
"be selected for tuples" in {
// Find the Serializer for it
val serializer = serialization.findSerializerFor((1, 2, 3))
serializer.getClass.equals(classOf[AkkaSerializer]) should equal(true)
serializer.getClass.equals(classOf[PekkoSerializer]) should equal(true)
}

def actorRef(i: Int) = system.actorOf(IncActor.props, "incActor" + i)

"be selected for ActorRef" in {
val serializer = serialization.findSerializerFor(actorRef(1))
serializer.getClass.equals(classOf[AkkaSerializer]) should equal(true)
serializer.getClass.equals(classOf[PekkoSerializer]) should equal(true)
}

"serialize and deserialize ActorRef successfully" in {
Expand Down