Revert source incompatible sharding changes (#24126)

* Revert "fix entityPropsFactory id param, #21809"
This reverts commit cd7eae28f6.
* Revert "Merge pull request #24058 from talpr/talpr-24053-add-entity-id-to-sharding-props"
This reverts commit 8417e70460, reversing
changes made to 22e85f869d.
This commit is contained in:
Johan Andrén 2017-12-07 17:49:29 +01:00 committed by GitHub
parent cd7eae28f6
commit 582f6a4836
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 81 additions and 276 deletions

View file

@ -7,8 +7,6 @@ package jdocs.sharding;
import static java.util.concurrent.TimeUnit.SECONDS;
import java.util.Optional;
import java.util.function.Function;
import scala.concurrent.duration.Duration;
import akka.actor.AbstractActor;
@ -19,6 +17,7 @@ import akka.actor.OneForOneStrategy;
import akka.actor.PoisonPill;
import akka.actor.Props;
import akka.actor.SupervisorStrategy;
import akka.actor.Terminated;
import akka.actor.ReceiveTimeout;
//#counter-extractor
import akka.cluster.sharding.ShardRegion;
@ -32,6 +31,7 @@ import akka.cluster.sharding.ClusterShardingSettings;
//#counter-start
import akka.persistence.AbstractPersistentActor;
import akka.cluster.Cluster;
import akka.japi.pf.DeciderBuilder;
// Doc code, compile only
@ -85,12 +85,12 @@ public class ClusterShardingTest {
//#counter-start
Option<String> roleOption = Option.none();
ClusterShardingSettings settings = ClusterShardingSettings.create(system);
ActorRef startedCounterRegion = ClusterSharding.get(system).start(Counter.ShardingTypeName,
entityId -> Counter.props(entityId), settings, messageExtractor);
ActorRef startedCounterRegion = ClusterSharding.get(system).start("Counter",
Props.create(Counter.class), settings, messageExtractor);
//#counter-start
//#counter-usage
ActorRef counterRegion = ClusterSharding.get(system).shardRegion(Counter.ShardingTypeName);
ActorRef counterRegion = ClusterSharding.get(system).shardRegion("Counter");
counterRegion.tell(new Counter.Get(123), getSelf());
counterRegion.tell(new Counter.EntityEnvelope(123,
@ -99,14 +99,14 @@ public class ClusterShardingTest {
//#counter-usage
//#counter-supervisor-start
ClusterSharding.get(system).start(CounterSupervisor.ShardingTypeName,
entityId -> CounterSupervisor.props(entityId), settings, messageExtractor);
ClusterSharding.get(system).start("SupervisedCounter",
Props.create(CounterSupervisor.class), settings, messageExtractor);
//#counter-supervisor-start
//#proxy-dc
ActorRef counterProxyDcB =
ClusterSharding.get(system).startProxy(
Counter.ShardingTypeName,
"Counter",
Optional.empty(),
Optional.of("B"), // data center name
messageExtractor);
@ -189,22 +189,12 @@ public class ClusterShardingTest {
}
}
public static final String ShardingTypeName = "Counter";
public static Props props(String id) {
return Props.create(() -> new Counter(id));
}
final String entityId;
int count = 0;
public Counter(String entityId) {
this.entityId = entityId;
}
// getSelf().path().name() is the entity identifier (utf-8 URL-encoded)
@Override
public String persistenceId() {
return ShardingTypeName + "-" + entityId;
return "Counter-" + getSelf().path().name();
}
@Override
@ -257,17 +247,9 @@ public class ClusterShardingTest {
static//#supervisor
public class CounterSupervisor extends AbstractActor {
public static final String ShardingTypeName = "CounterSupervisor";
public static Props props(String entityId) {
return Props.create(() -> new CounterSupervisor(entityId));
}
private final ActorRef counter;
public CounterSupervisor(String entityId) {
counter = getContext().actorOf(Counter.props(entityId), "theCounter");
}
private final ActorRef counter = getContext().actorOf(
Props.create(Counter.class), "theCounter");
private static final SupervisorStrategy strategy =
new OneForOneStrategy(DeciderBuilder.