adds serializer for akka.Done. #23854
(cherry picked from commit 53a543788494d7b6457f129b1ad4ff57ff530584)
This commit is contained in:
parent
74b5866f60
commit
2837ebba6e
5 changed files with 27 additions and 4 deletions
|
|
@ -3,12 +3,15 @@
|
||||||
*/
|
*/
|
||||||
package akka
|
package akka
|
||||||
|
|
||||||
|
import java.io.Serializable
|
||||||
|
import akka.annotation.DoNotInherit
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Typically used together with `Future` to signal completion
|
* Typically used together with `Future` to signal completion
|
||||||
* but there is no actual value completed. More clearly signals intent
|
* but there is no actual value completed. More clearly signals intent
|
||||||
* than `Unit` and is available both from Scala and Java (which `Unit` is not).
|
* than `Unit` and is available both from Scala and Java (which `Unit` is not).
|
||||||
*/
|
*/
|
||||||
sealed abstract class Done
|
@DoNotInherit sealed abstract class Done extends Serializable
|
||||||
|
|
||||||
case object Done extends Done {
|
case object Done extends Done {
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -41,11 +41,16 @@ depending on the akka-remote module), so normally you don't need to add
|
||||||
configuration for that; since `com.google.protobuf.GeneratedMessage`
|
configuration for that; since `com.google.protobuf.GeneratedMessage`
|
||||||
implements `java.io.Serializable`, protobuf messages will always be
|
implements `java.io.Serializable`, protobuf messages will always be
|
||||||
serialized using the protobuf protocol unless specifically overridden. In order
|
serialized using the protobuf protocol unless specifically overridden. In order
|
||||||
to disable a default serializer, map its marker type to “none”:
|
to disable a default serializer, see @ref:[Disabling the Java Serializer](remoting.md#disable-java-serializer)
|
||||||
|
|
||||||
|
### Enable additional bindings
|
||||||
|
|
||||||
|
`akka.Done` is by default serialized by the Java serializer, add the following binding to avoid that.
|
||||||
|
It's not enabled by default for compatibility reasons.
|
||||||
|
|
||||||
```
|
```
|
||||||
akka.actor.serialization-bindings {
|
akka.actor.serialization-bindings {
|
||||||
"java.io.Serializable" = none
|
"akka.Done" = akka-misc
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
@ -251,4 +256,4 @@ incompatibility as Java serialization does.
|
||||||
|
|
||||||
[Akka-kryo by Roman Levenstein](https://github.com/romix/akka-kryo-serialization)
|
[Akka-kryo by Roman Levenstein](https://github.com/romix/akka-kryo-serialization)
|
||||||
|
|
||||||
[Twitter Chill Scala extensions for Kryo (based on Akka Version 2.3.x but due to backwards compatibility of the Serializer Interface this extension also works with 2.4.x)](https://github.com/twitter/chill)
|
[Twitter Chill Scala extensions for Kryo (based on Akka Version 2.3.x but due to backwards compatibility of the Serializer Interface this extension also works with 2.4.x)](https://github.com/twitter/chill)
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,12 @@ akka {
|
||||||
"com.google.protobuf.GeneratedMessage" = proto
|
"com.google.protobuf.GeneratedMessage" = proto
|
||||||
|
|
||||||
"java.util.Optional" = akka-misc
|
"java.util.Optional" = akka-misc
|
||||||
|
|
||||||
|
# akka.Done is handled by the MiscMessageSerializer, but it is not enabled for
|
||||||
|
# compatibility reasons (it was added in Akka 2.5.8). Enable by adding
|
||||||
|
# akka.actor.serialization-bindings {
|
||||||
|
# "akka.Done" = akka-misc
|
||||||
|
# }
|
||||||
}
|
}
|
||||||
|
|
||||||
# Additional serialization-bindings that are replacing Java serialization are
|
# Additional serialization-bindings that are replacing Java serialization are
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ import java.nio.charset.StandardCharsets
|
||||||
import java.util.Optional
|
import java.util.Optional
|
||||||
import java.util.concurrent.TimeUnit
|
import java.util.concurrent.TimeUnit
|
||||||
|
|
||||||
|
import akka.Done
|
||||||
import akka.actor._
|
import akka.actor._
|
||||||
import akka.dispatch.Dispatchers
|
import akka.dispatch.Dispatchers
|
||||||
import akka.remote.routing.RemoteRouterConfig
|
import akka.remote.routing.RemoteRouterConfig
|
||||||
|
|
@ -43,6 +44,7 @@ class MiscMessageSerializer(val system: ExtendedActorSystem) extends SerializerW
|
||||||
case PoisonPill ⇒ ParameterlessSerializedMessage
|
case PoisonPill ⇒ ParameterlessSerializedMessage
|
||||||
case Kill ⇒ ParameterlessSerializedMessage
|
case Kill ⇒ ParameterlessSerializedMessage
|
||||||
case RemoteWatcher.Heartbeat ⇒ ParameterlessSerializedMessage
|
case RemoteWatcher.Heartbeat ⇒ ParameterlessSerializedMessage
|
||||||
|
case Done ⇒ ParameterlessSerializedMessage
|
||||||
case hbrsp: RemoteWatcher.HeartbeatRsp ⇒ serializeHeartbeatRsp(hbrsp)
|
case hbrsp: RemoteWatcher.HeartbeatRsp ⇒ serializeHeartbeatRsp(hbrsp)
|
||||||
case rs: RemoteScope ⇒ serializeRemoteScope(rs)
|
case rs: RemoteScope ⇒ serializeRemoteScope(rs)
|
||||||
case LocalScope ⇒ ParameterlessSerializedMessage
|
case LocalScope ⇒ ParameterlessSerializedMessage
|
||||||
|
|
@ -253,6 +255,7 @@ class MiscMessageSerializer(val system: ExtendedActorSystem) extends SerializerW
|
||||||
private val PoisonPillManifest = "P"
|
private val PoisonPillManifest = "P"
|
||||||
private val KillManifest = "K"
|
private val KillManifest = "K"
|
||||||
private val RemoteWatcherHBManifest = "RWHB"
|
private val RemoteWatcherHBManifest = "RWHB"
|
||||||
|
private val DoneManifest = "DONE"
|
||||||
private val RemoteWatcherHBRespManifest = "RWHR"
|
private val RemoteWatcherHBRespManifest = "RWHR"
|
||||||
private val ActorInitializationExceptionManifest = "AIEX"
|
private val ActorInitializationExceptionManifest = "AIEX"
|
||||||
private val LocalScopeManifest = "LS"
|
private val LocalScopeManifest = "LS"
|
||||||
|
|
@ -281,6 +284,7 @@ class MiscMessageSerializer(val system: ExtendedActorSystem) extends SerializerW
|
||||||
PoisonPillManifest → ((_) ⇒ PoisonPill),
|
PoisonPillManifest → ((_) ⇒ PoisonPill),
|
||||||
KillManifest → ((_) ⇒ Kill),
|
KillManifest → ((_) ⇒ Kill),
|
||||||
RemoteWatcherHBManifest → ((_) ⇒ RemoteWatcher.Heartbeat),
|
RemoteWatcherHBManifest → ((_) ⇒ RemoteWatcher.Heartbeat),
|
||||||
|
DoneManifest → ((_) ⇒ Done),
|
||||||
RemoteWatcherHBRespManifest → deserializeHeartbeatRsp,
|
RemoteWatcherHBRespManifest → deserializeHeartbeatRsp,
|
||||||
ActorInitializationExceptionManifest → deserializeActorInitializationException,
|
ActorInitializationExceptionManifest → deserializeActorInitializationException,
|
||||||
LocalScopeManifest → ((_) ⇒ LocalScope),
|
LocalScopeManifest → ((_) ⇒ LocalScope),
|
||||||
|
|
@ -311,6 +315,7 @@ class MiscMessageSerializer(val system: ExtendedActorSystem) extends SerializerW
|
||||||
case PoisonPill ⇒ PoisonPillManifest
|
case PoisonPill ⇒ PoisonPillManifest
|
||||||
case Kill ⇒ KillManifest
|
case Kill ⇒ KillManifest
|
||||||
case RemoteWatcher.Heartbeat ⇒ RemoteWatcherHBManifest
|
case RemoteWatcher.Heartbeat ⇒ RemoteWatcherHBManifest
|
||||||
|
case Done ⇒ DoneManifest
|
||||||
case _: RemoteWatcher.HeartbeatRsp ⇒ RemoteWatcherHBRespManifest
|
case _: RemoteWatcher.HeartbeatRsp ⇒ RemoteWatcherHBRespManifest
|
||||||
case LocalScope ⇒ LocalScopeManifest
|
case LocalScope ⇒ LocalScopeManifest
|
||||||
case _: RemoteScope ⇒ RemoteScopeManifest
|
case _: RemoteScope ⇒ RemoteScopeManifest
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ import scala.concurrent.duration._
|
||||||
import java.util.Optional
|
import java.util.Optional
|
||||||
import java.io.NotSerializableException
|
import java.io.NotSerializableException
|
||||||
|
|
||||||
|
import akka.Done
|
||||||
import akka.remote.routing.RemoteRouterConfig
|
import akka.remote.routing.RemoteRouterConfig
|
||||||
import akka.routing._
|
import akka.routing._
|
||||||
|
|
||||||
|
|
@ -23,6 +24,8 @@ object MiscMessageSerializerSpec {
|
||||||
"""
|
"""
|
||||||
akka.actor.serialization-bindings {
|
akka.actor.serialization-bindings {
|
||||||
"akka.remote.serialization.MiscMessageSerializerSpec$TestException" = akka-misc
|
"akka.remote.serialization.MiscMessageSerializerSpec$TestException" = akka-misc
|
||||||
|
# not enabled by default
|
||||||
|
"akka.Done" = akka-misc
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
@ -85,6 +88,7 @@ class MiscMessageSerializerSpec extends AkkaSpec(MiscMessageSerializerSpec.testC
|
||||||
"PoisonPill" → PoisonPill,
|
"PoisonPill" → PoisonPill,
|
||||||
"RemoteWatcher.Heartbeat" → RemoteWatcher.Heartbeat,
|
"RemoteWatcher.Heartbeat" → RemoteWatcher.Heartbeat,
|
||||||
"RemoteWatcher.HertbeatRsp" → RemoteWatcher.HeartbeatRsp(65537),
|
"RemoteWatcher.HertbeatRsp" → RemoteWatcher.HeartbeatRsp(65537),
|
||||||
|
"Done" → Done,
|
||||||
"LocalScope" → LocalScope,
|
"LocalScope" → LocalScope,
|
||||||
"RemoteScope" → RemoteScope(Address("akka", "system", "localhost", 2525)),
|
"RemoteScope" → RemoteScope(Address("akka", "system", "localhost", 2525)),
|
||||||
"Config" → system.settings.config,
|
"Config" → system.settings.config,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue