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

Add deprecated annotation to untyped APIs #96

Merged
merged 7 commits into from
Jul 15, 2021
Merged
Show file tree
Hide file tree
Changes from 5 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
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class ClusterReplication private (system: ExtendedActorSystem) extends Extension
private[this] lazy val guardian: ActorRef =
system.systemActorOf(ClusterReplicationGuardian.props(), "clusterReplicationGuardian")

@deprecated(message = "Use typed.ClusterReplication.init() instead", since = "2.0.0")
tksugimoto marked this conversation as resolved.
Show resolved Hide resolved
def start(
typeName: String,
entityProps: Props,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ import scala.concurrent.duration.FiniteDuration

object ClusterReplicationSettings {

def apply(system: ActorSystem): ClusterReplicationSettings = {
@deprecated("Use typed.ClusterReplicationSettings instead", since = "2.0.0")
def apply(system: ActorSystem): ClusterReplicationSettings = create(system)

// for internal use
private[entityreplication] def create(system: ActorSystem): ClusterReplicationSettings = {
val cluster = Cluster(system)
ClusterReplicationSettingsImpl(system.settings.config, cluster.settings.Roles)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@ private[entityreplication] object ReplicationActor {
private def generateInstanceId(): EntityInstanceId = EntityInstanceId(instanceIdCounter.getAndIncrement())
}

@deprecated(message = "Use typed.ReplicatedEntityBehavior instead", since = "2.0.0")
trait ReplicationActor[StateData] extends Actor with Stash with akka.lerna.StashFactory {
import context.dispatcher

private val internalStash = createStash()

private val instanceId = ReplicationActor.generateInstanceId()

private[this] val settings = ClusterReplicationSettings(context.system)
private[this] val settings = ClusterReplicationSettings.create(context.system)

private[this] val log = Logging(context.system, this)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import lerna.akka.entityreplication.ReplicationActor
/**
* The [[TestReplicationActorProps]] allows to test [[ReplicationActor]] like a normal Actor.
*/
@deprecated(message = "Use typed.testkit.ReplicatedEntityBehaviorTestKit instead", since = "2.0.0")
object TestReplicationActorProps {

def apply(replicationActorProps: Props): Props = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ private[entityreplication] class ClusterReplicationImpl(system: ActorSystem[_])

private[this] def internalInit[M, E](entity: ReplicatedEntity[M, E]): ActorRef[E] = {
val classicSystem = system.toClassic
val settings = entity.settings.getOrElse(untyped.ClusterReplicationSettings(classicSystem))
val settings = entity.settings.getOrElse(untyped.ClusterReplicationSettings.create(classicSystem))
val extractEntityId: untyped.ReplicationRegion.ExtractEntityId = {
case ReplicationEnvelope(entityId, message) => (entityId, message)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ private[entityreplication] final case class ReplicatedEntityBehaviorImpl[Command

override def apply(ctx: TypedActorContext[Command]): Behavior[Command] = {
try {
val settings = ClusterReplicationSettings(ctx.asScala.system.toClassic)
val settings = ClusterReplicationSettings.create(ctx.asScala.system.toClassic)
Behaviors.intercept(() => interceptor)(createBehavior(entityContext.shard, settings)).narrow
} catch {
case NonFatal(e) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import akka.remote.testconductor.RoleName
import akka.remote.testkit.MultiNodeConfig
import com.typesafe.config.ConfigFactory

import scala.annotation.nowarn

object ConsistencyTestBase {

object ConsistencyTestBaseConfig extends MultiNodeConfig {
Expand Down Expand Up @@ -71,6 +73,7 @@ object ConsistencyTestBase {
}
}

@nowarn("msg=Use typed.ReplicatedEntityBehavior instead")
class ConsistencyTestReplicationActor() extends ReplicationActor[Int] {

import ConsistencyTestReplicationActor._
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package lerna.akka.entityreplication

import java.util.concurrent.atomic.AtomicInteger

import akka.actor.{ ActorRef, Props }
import akka.remote.testkit.MultiNodeSpec
import lerna.akka.entityreplication.ConsistencyTestBase.{ ConsistencyTestBaseConfig, ConsistencyTestReplicationActor }
import org.scalatest.Inside

import scala.annotation.nowarn
import scala.concurrent.duration._

class ConsistencyTestNormalMultiJvmNode1 extends ConsistencyTestNormal
Expand All @@ -14,6 +15,7 @@ class ConsistencyTestNormalMultiJvmNode3 extends ConsistencyTestNormal
class ConsistencyTestNormalMultiJvmNode4 extends ConsistencyTestNormal
class ConsistencyTestNormalMultiJvmNode5 extends ConsistencyTestNormal

@nowarn("msg=method start in class ClusterReplication is deprecated")
class ConsistencyTestNormal extends MultiNodeSpec(ConsistencyTestBaseConfig) with STMultiNodeSpec with Inside {

import ConsistencyTestBaseConfig._
Expand All @@ -38,7 +40,7 @@ class ConsistencyTestNormal extends MultiNodeSpec(ConsistencyTestBaseConfig) wit
clusterReplication = ClusterReplication(system).start(
typeName = "sample",
entityProps = Props[ConsistencyTestReplicationActor](),
settings = ClusterReplicationSettings(system),
settings = ClusterReplicationSettings.create(system),
extractEntityId = ConsistencyTestReplicationActor.extractEntityId,
extractShardId = ConsistencyTestReplicationActor.extractShardId,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import lerna.akka.entityreplication.RaftActorCompactionSpec.DummyReplicationActo
import lerna.akka.entityreplication.raft.protocol.SnapshotOffer

import java.util.concurrent.atomic.AtomicInteger
import scala.annotation.nowarn
import scala.concurrent.duration._

object RaftActorCompactionSpecConfig extends MultiNodeConfig {
Expand All @@ -23,9 +24,9 @@ object RaftActorCompactionSpecConfig extends MultiNodeConfig {
.withFallback(ConfigFactory.parseString("""
akka.actor.provider = cluster
akka.test.single-expect-default = 15s

lerna.akka.entityreplication.raft.multi-raft-roles = ["replica-group-1", "replica-group-2", "replica-group-3"]

// triggers compaction each event replications
lerna.akka.entityreplication.raft.compaction.log-size-threshold = 2
lerna.akka.entityreplication.raft.compaction.preserve-log-size = 1
Expand Down Expand Up @@ -79,6 +80,7 @@ object RaftActorCompactionSpec {

import DummyReplicationActor._

@nowarn("msg=Use typed.ReplicatedEntityBehavior instead")
class DummyReplicationActor extends ReplicationActor[State] {

private[this] var state: State = State(0)
Expand Down Expand Up @@ -207,12 +209,13 @@ class RaftActorCompactionSpec extends MultiNodeSpec(RaftActorCompactionSpecConfi
}
}

@nowarn("msg=method start in class ClusterReplication is deprecated")
def createReplication(typeName: String): ActorRef =
planAutoKill {
ClusterReplication(system).start(
typeName = typeName,
entityProps = DummyReplicationActor.props(),
settings = ClusterReplicationSettings(system),
settings = ClusterReplicationSettings.create(system),
extractEntityId = DummyReplicationActor.extractEntityId,
extractShardId = DummyReplicationActor.extractShardId,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import com.typesafe.config.ConfigFactory
import lerna.akka.entityreplication.raft.protocol.SnapshotOffer

import java.util.concurrent.atomic.AtomicInteger
import scala.annotation.nowarn

object RaftEventSourcedSpecConfig extends MultiNodeConfig {
val node1: RoleName = role("node1")
Expand All @@ -24,7 +25,7 @@ object RaftEventSourcedSpecConfig extends MultiNodeConfig {
akka.test.single-expect-default = 15s
lerna.akka.entityreplication.raft.multi-raft-roles = ["member-1", "member-2", "member-3"]
lerna.akka.entityreplication.recovery-entity-timeout = 1s

inmemory-journal {
event-adapters {
dummy-event-adapter = "lerna.akka.entityreplication.RaftEventSourcedSpec$DummyEventAdapter"
Expand Down Expand Up @@ -91,6 +92,7 @@ object RaftEventSourcedSpec {

import DummyReplicationActor._

@nowarn("msg=Use typed.ReplicatedEntityBehavior instead")
class DummyReplicationActor extends ReplicationActor[State] {

private[this] var state: State = State(count = 0, knownRequestId = Set.empty)
Expand Down Expand Up @@ -150,6 +152,7 @@ object RaftEventSourcedSpec {
}
}

@nowarn("msg=method start in class ClusterReplication is deprecated")
class RaftEventSourcedSpec extends MultiNodeSpec(RaftEventSourcedSpecConfig) with STMultiNodeSpec {

import RaftEventSourcedSpec._
Expand All @@ -173,7 +176,7 @@ class RaftEventSourcedSpec extends MultiNodeSpec(RaftEventSourcedSpecConfig) wit
ClusterReplication(system).start(
typeName,
entityProps = DummyReplicationActor.props(),
settings = ClusterReplicationSettings(system),
settings = ClusterReplicationSettings.create(system),
DummyReplicationActor.extractEntityId,
DummyReplicationActor.extractShardId,
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package lerna.akka.entityreplication

import java.util.concurrent.atomic.AtomicInteger

import akka.{ Done, NotUsed }
import akka.actor.{ ActorRef, PoisonPill, Props }
import akka.cluster.Cluster
Expand All @@ -13,6 +12,7 @@ import com.typesafe.config.ConfigFactory
import lerna.akka.entityreplication.raft.protocol.SnapshotOffer
import lerna.akka.entityreplication.raft.routing.MemberIndex

import scala.annotation.nowarn
import scala.concurrent.duration._
import scala.collection.Set

Expand Down Expand Up @@ -71,6 +71,7 @@ object ReplicationActorMultiNodeSpec {
}
}

@nowarn("msg=Use typed.ReplicatedEntityBehavior instead")
class PingPongReplicationActor extends ReplicationActor[Int] {

import PingPongReplicationActor._
Expand Down Expand Up @@ -124,6 +125,7 @@ object ReplicationActorMultiNodeSpec {
}
}

@nowarn("msg=Use typed.ReplicatedEntityBehavior instead")
class LockReplicationActor extends ReplicationActor[NotUsed] {
import LockReplicationActor._

Expand Down Expand Up @@ -183,6 +185,7 @@ object ReplicationActorMultiNodeSpec {
}
}

@nowarn("msg=Use typed.ReplicatedEntityBehavior instead")
class EphemeralReplicationActor extends ReplicationActor[Int] {

import EphemeralReplicationActor._
Expand Down Expand Up @@ -220,6 +223,7 @@ class ReplicationActorMultiNodeSpecMultiJvmNode1 extends ReplicationActorMultiNo
class ReplicationActorMultiNodeSpecMultiJvmNode2 extends ReplicationActorMultiNodeSpec
class ReplicationActorMultiNodeSpecMultiJvmNode3 extends ReplicationActorMultiNodeSpec

@nowarn("msg=method start in class ClusterReplication is deprecated")
class ReplicationActorMultiNodeSpec extends MultiNodeSpec(ReplicationActorSpecConfig) with STMultiNodeSpec {
import ReplicationActorMultiNodeSpec._
import ReplicationActorSpecConfig._
Expand Down Expand Up @@ -252,7 +256,7 @@ class ReplicationActorMultiNodeSpec extends MultiNodeSpec(ReplicationActorSpecCo
ClusterReplication(system).start(
typeName = "ping-pong-sample",
entityProps = Props[PingPongReplicationActor](),
settings = ClusterReplicationSettings(system),
settings = ClusterReplicationSettings.create(system),
extractEntityId = PingPongReplicationActor.extractEntityId,
extractShardId = PingPongReplicationActor.extractShardId,
)
Expand Down Expand Up @@ -281,7 +285,7 @@ class ReplicationActorMultiNodeSpec extends MultiNodeSpec(ReplicationActorSpecCo
ClusterReplication(system).start(
typeName = "ping-pong-sample-2",
entityProps = Props[PingPongReplicationActor](),
settings = ClusterReplicationSettings(system),
settings = ClusterReplicationSettings.create(system),
extractEntityId = PingPongReplicationActor.extractEntityId,
extractShardId = PingPongReplicationActor.extractShardId,
)
Expand Down Expand Up @@ -315,7 +319,7 @@ class ReplicationActorMultiNodeSpec extends MultiNodeSpec(ReplicationActorSpecCo
ClusterReplication(system).start(
typeName = "lock-sample",
entityProps = Props[LockReplicationActor](),
settings = ClusterReplicationSettings(system),
settings = ClusterReplicationSettings.create(system),
extractEntityId = LockReplicationActor.extractEntityId,
extractShardId = LockReplicationActor.extractShardId,
)
Expand Down Expand Up @@ -352,7 +356,7 @@ class ReplicationActorMultiNodeSpec extends MultiNodeSpec(ReplicationActorSpecCo
ClusterReplication(system).start(
typeName = "passivate-sample",
entityProps = Props[EphemeralReplicationActor](),
settings = ClusterReplicationSettings(system),
settings = ClusterReplicationSettings.create(system),
extractEntityId = EphemeralReplicationActor.extractEntityId,
extractShardId = EphemeralReplicationActor.extractShardId,
)
Expand Down Expand Up @@ -392,7 +396,7 @@ class ReplicationActorMultiNodeSpec extends MultiNodeSpec(ReplicationActorSpecCo
ClusterReplication(system).start(
typeName = "recovery-sample",
entityProps = Props[EphemeralReplicationActor](),
settings = ClusterReplicationSettings(system),
settings = ClusterReplicationSettings.create(system),
extractEntityId = EphemeralReplicationActor.extractEntityId,
extractShardId = EphemeralReplicationActor.extractShardId,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import lerna.akka.entityreplication.raft.RaftProtocol.Command
import lerna.akka.entityreplication.raft.protocol.SnapshotOffer
import lerna.akka.entityreplication.raft.routing.MemberIndex

import scala.annotation.nowarn
import scala.concurrent.Future
import scala.jdk.CollectionConverters._
import scala.concurrent.duration._
Expand Down Expand Up @@ -47,6 +48,7 @@ object ReplicationRegionSpec {
}
}

@nowarn("msg=Use typed.ReplicatedEntityBehavior instead")
class DummyReplicationActor(probe: TestProbe) extends DiagnosticActorLogging with ReplicationActor[Int] {

import DummyReplicationActor._
Expand Down Expand Up @@ -114,7 +116,7 @@ object ReplicationRegionSpecConfig extends MultiNodeConfig {
.withFallback(ConfigFactory.parseString(s"""
akka.actor.provider = cluster
akka.test.single-expect-default = 15s

lerna.akka.entityreplication.raft.compaction.log-size-threshold = 2
lerna.akka.entityreplication.raft.compaction.preserve-log-size = 1
lerna.akka.entityreplication.raft.compaction.log-size-check-interval = 0.1s
Expand Down Expand Up @@ -176,12 +178,13 @@ class ReplicationRegionSpec extends MultiNodeSpec(ReplicationRegionSpecConfig) w

val raftActorProbe = TestProbe("RaftActor")

@nowarn("msg=method start in class ClusterReplication is deprecated")
def createReplication(typeName: String): ActorRef =
planAutoKill {
ClusterReplication(system).start(
typeName = typeName,
entityProps = DummyReplicationActor.props(entityProbe),
settings = ClusterReplicationSettings(system),
settings = ClusterReplicationSettings.create(system),
extractEntityId = DummyReplicationActor.extractEntityId,
extractShardId = DummyReplicationActor.extractShardId,
)
Expand All @@ -194,7 +197,7 @@ class ReplicationRegionSpec extends MultiNodeSpec(ReplicationRegionSpecConfig) w
new ReplicationRegion(
typeName = typeName,
_ => DummyReplicationActor.props(entityProbe),
ClusterReplicationSettings(system),
ClusterReplicationSettings.create(system),
DummyReplicationActor.extractEntityId,
DummyReplicationActor.extractShardId,
maybeCommitLogStore = None,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,7 @@ class RaftActorMultiNodeSpec extends MultiNodeSpec(RaftActorSpecConfig) with STM
new ReplicationRegion(
typeName = typeName,
_ => replicationActorProps,
ClusterReplicationSettings(system),
ClusterReplicationSettings.create(system),
extractEntityId,
extractShardId,
maybeCommitLogStore = None,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ import lerna.akka.entityreplication.ReplicationActorSpec.{ config, ExampleReplic
import lerna.akka.entityreplication.model.EntityInstanceId
import lerna.akka.entityreplication.raft.model.{ EntityEvent, LogEntry, LogEntryIndex, Term }
import lerna.akka.entityreplication.raft.{ ActorSpec, RaftProtocol }

import java.util.concurrent.atomic.AtomicInteger
import scala.annotation.nowarn

object ReplicationActorSpec {

Expand All @@ -29,6 +31,7 @@ object ReplicationActorSpec {
case class Counted() extends Event
}

@nowarn("msg=Use typed.ReplicatedEntityBehavior instead")
class ExampleReplicationActor extends ReplicationActor[Int] {
import ExampleReplicationActor._

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ class RaftActorLeaderSpec extends TestKit(ActorSystem()) with RaftActorSpecBase
}
}

private[this] val settings = ClusterReplicationSettings(system)
private[this] val settings = ClusterReplicationSettings.create(system)

private[this] val eventStore = system.actorOf(EventStore.props(settings), "eventStore")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import java.util.concurrent.atomic.AtomicInteger

class SnapshotSyncManagerSpec extends TestKit(ActorSystem()) with ActorSpec with BeforeAndAfterEach {

private[this] val settings = ClusterReplicationSettings(system)
private[this] val settings = ClusterReplicationSettings.create(system)

private[this] val shardId = NormalizedShardId("test-shard")

Expand Down
Loading