!cto #17454 Introduce ClusterSingletonManagerSettings and ClusterSingletonProxySettings
This commit is contained in:
parent
ebc39ef9ab
commit
7ab5da21d3
16 changed files with 288 additions and 160 deletions
|
|
@ -7,7 +7,9 @@ import akka.actor.ActorSystem;
|
|||
import akka.actor.PoisonPill;
|
||||
import akka.actor.Props;
|
||||
import akka.cluster.singleton.ClusterSingletonManager;
|
||||
import akka.cluster.singleton.ClusterSingletonManagerSettings;
|
||||
import akka.cluster.singleton.ClusterSingletonProxy;
|
||||
import akka.cluster.singleton.ClusterSingletonProxySettings;
|
||||
|
||||
public class StatsSampleOneMasterMain {
|
||||
|
||||
|
|
@ -32,14 +34,18 @@ public class StatsSampleOneMasterMain {
|
|||
ActorSystem system = ActorSystem.create("ClusterSystem", config);
|
||||
|
||||
//#create-singleton-manager
|
||||
system.actorOf(ClusterSingletonManager.defaultProps(
|
||||
Props.create(StatsService.class), "statsService",
|
||||
PoisonPill.getInstance(), "compute"), "singleton");
|
||||
ClusterSingletonManagerSettings settings = ClusterSingletonManagerSettings.create(system)
|
||||
.withSingletonName("statsService").withRole("compute");
|
||||
system.actorOf(ClusterSingletonManager.props(
|
||||
Props.create(StatsService.class), PoisonPill.getInstance(), settings),
|
||||
"singleton");
|
||||
//#create-singleton-manager
|
||||
|
||||
//#singleton-proxy
|
||||
system.actorOf(ClusterSingletonProxy.defaultProps("/user/singleton/statsService",
|
||||
"compute"), "statsServiceProxy");
|
||||
ClusterSingletonProxySettings proxySettings =
|
||||
ClusterSingletonProxySettings.create(system).withRole("compute");
|
||||
system.actorOf(ClusterSingletonProxy.props("/user/singleton/statsService",
|
||||
proxySettings), "statsServiceProxy");
|
||||
//#singleton-proxy
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -15,11 +15,13 @@ import akka.cluster.MemberStatus
|
|||
import akka.cluster.ClusterEvent.CurrentClusterState
|
||||
import akka.cluster.ClusterEvent.MemberUp
|
||||
import akka.cluster.singleton.ClusterSingletonManager
|
||||
import akka.cluster.singleton.ClusterSingletonManagerSettings
|
||||
import akka.cluster.singleton.ClusterSingletonProxy
|
||||
import akka.remote.testkit.MultiNodeConfig
|
||||
import akka.remote.testkit.MultiNodeSpec
|
||||
import akka.testkit.ImplicitSender
|
||||
import sample.cluster.stats.StatsMessages._
|
||||
import akka.cluster.singleton.ClusterSingletonProxySettings
|
||||
|
||||
object StatsSampleSingleMasterSpecConfig extends MultiNodeConfig {
|
||||
// register the named roles (nodes) of the test
|
||||
|
|
@ -100,14 +102,14 @@ abstract class StatsSampleSingleMasterSpec extends MultiNodeSpec(StatsSampleSing
|
|||
|
||||
Cluster(system).unsubscribe(testActor)
|
||||
|
||||
system.actorOf(ClusterSingletonManager.defaultProps(
|
||||
system.actorOf(ClusterSingletonManager.props(
|
||||
Props[StatsService],
|
||||
singletonName = "statsService",
|
||||
terminationMessage = PoisonPill,
|
||||
role = null), name = "singleton")
|
||||
settings = ClusterSingletonManagerSettings(system).withSingletonName("statsService")),
|
||||
name = "singleton")
|
||||
|
||||
system.actorOf(ClusterSingletonProxy.defaultProps("/user/singleton/statsService",
|
||||
"compute"), "statsServiceProxy");
|
||||
system.actorOf(ClusterSingletonProxy.props("/user/singleton/statsService",
|
||||
ClusterSingletonProxySettings(system).withRole("compute")), "statsServiceProxy")
|
||||
|
||||
testConductor.enter("all-up")
|
||||
}
|
||||
|
|
@ -126,4 +128,4 @@ abstract class StatsSampleSingleMasterSpec extends MultiNodeSpec(StatsSampleSing
|
|||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue