Skip to content

Commit

Permalink
misc: Fixes after bumping kryo serialization
Browse files Browse the repository at this point in the history
  • Loading branch information
Szymon Matejczyk committed Jul 30, 2020
1 parent 697c02a commit 9aab3cd
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,6 @@ private[filodb] trait FilodbClusterNode extends NodeConfiguration with StrictLog
case ClusterRole.Cli => ConfigFactory.parseString(
"""# akka.actor.provider=akka.remote.RemoteActorRefProvider
|akka.coordinated-shutdown.run-by-jvm-shutdown-hook=off
|akka.extensions = ["com.romix.akka.serialization.kryo.KryoSerializationExtension$"]
""".stripMargin)
case _ => ConfigFactory.parseString(s"""akka.cluster.roles=["${role.roleName}"]""")
}).withFallback(systemConfig)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
package filodb.coordinator.client

import com.esotericsoftware.kryo.{Serializer => KryoSerializer}
import com.esotericsoftware.kryo.Kryo
import com.esotericsoftware.kryo.io._
import com.esotericsoftware.kryo.{Kryo, Serializer => KryoSerializer}
import com.esotericsoftware.minlog.Log
import de.javakaffee.kryoserializers.UnmodifiableCollectionsSerializer

import filodb.coordinator.FilodbSettings
import filodb.core._
import filodb.core.binaryrecord2.{RecordSchema => RecordSchema2}
import filodb.core.metadata.{Column, PartitionSchema, Schema, Schemas}
import filodb.core.query.ColumnInfo
import filodb.memory.format.ZeroCopyUTF8String
import io.altoo.akka.serialization.kryo.DefaultKryoInitializer
import io.altoo.akka.serialization.kryo.serializer.scala.ScalaKryo

/**
* Register commonly used classes for efficient Kryo serialization. If this is not done then Kryo might have to
Expand All @@ -30,8 +30,8 @@ import filodb.memory.format.ZeroCopyUTF8String
* - Recreating original class and injecting base, offset, any at runtime is a possibility, but we don't want
* to reinstantiate things like GrowableVector, wrappers, and appendable types
*/
class KryoInit {
def customize(kryo: Kryo): Unit = {
class KryoInit extends DefaultKryoInitializer {
override def postInit(kryo: ScalaKryo): Unit = {
kryo.addDefaultSerializer(classOf[Column.ColumnType], classOf[ColumnTypeSerializer])
val colTypeSer = new ColumnTypeSerializer
Column.ColumnType.values.zipWithIndex.foreach { case (ct, i) => kryo.register(ct.getClass, colTypeSer, 100 + i) }
Expand Down Expand Up @@ -161,4 +161,4 @@ class PartSchemaSerializer extends KryoSerializer[PartitionSchema] {
val schemas = FilodbSettings.globalOrDefault.schemas
require(schema == schemas.part)
}
}
}
57 changes: 29 additions & 28 deletions core/src/main/resources/filodb-defaults.conf
Original file line number Diff line number Diff line change
Expand Up @@ -423,8 +423,7 @@ akka {

test.single-expect-default = 10s

extensions = ["filodb.coordinator.FilodbCluster",
"com.romix.akka.serialization.kryo.KryoSerializationExtension$"]
extensions = ["filodb.coordinator.FilodbCluster"]

# Use SLF4J for deployed environment logging
loggers = ["akka.event.slf4j.Slf4jLogger"]
Expand All @@ -451,34 +450,10 @@ akka {
lifecycle = on
}

# For details of kryo section see https://github.com/romix/akka-kryo-serialization
kryo {
implicit-registration-logging = "false"
kryo-trace = "false"

kryo-custom-serializer-init = "filodb.coordinator.client.KryoInit"

# Make the buffer size bigger as we send out chunks quite often
buffer-size = 65536

# automatic means fall back to FQCN's if class is not pre-registered. This is safer.
idstrategy = "automatic"

mappings {
# Set standard IDs here from say Scala up to 99.
# DO NOT INCLUDE FiloDB classes here. Those are better to put in Serializer.scala so they can be typechecked.
"scala.Some" = 64
"scala.Tuple2" = 65
"scala.None$" = 66
"scala.collection.immutable.Nil$" = 67
"scala.collection.immutable.$colon$colon" = 68
"scala.collection.mutable.ArrayBuffer" = 69
"scala.collection.immutable.Vector" = 70
}
}


serializers {
kryo = "com.romix.akka.serialization.kryo.KryoSerializer"
kryo = "io.altoo.akka.serialization.kryo.KryoSerializer"
}

serialization-bindings {
Expand Down Expand Up @@ -569,6 +544,32 @@ akka {
coordinated-shutdown.exit-jvm = on
}

akka-kryo-serialization {
# For details of kryo section see https://github.com/altoo-ag/akka-kryo-serialization
implicit-registration-logging = "false"
kryo-trace = "false"

kryo-initializer = "filodb.coordinator.client.KryoInit"

# Make the buffer size bigger as we send out chunks quite often
buffer-size = 65536

# automatic means fall back to FQCN's if class is not pre-registered. This is safer.
id-strategy = "automatic"

mappings {
# Set standard IDs here from say Scala up to 99.
# DO NOT INCLUDE FiloDB classes here. Those are better to put in Serializer.scala so they can be typechecked.
"scala.Some" = 64
"scala.Tuple2" = 65
"scala.None$" = 66
"scala.collection.immutable.Nil$" = 67
"scala.collection.immutable.$colon$colon" = 68
"scala.collection.mutable.ArrayBuffer" = 69
"scala.collection.immutable.Vector" = 70
}
}


custom-downing {
stable-after = 20s
Expand Down

0 comments on commit 9aab3cd

Please sign in to comment.