本文整理汇总了Java中akka.actor.ActorPath类的典型用法代码示例。如果您正苦于以下问题:Java ActorPath类的具体用法?Java ActorPath怎么用?Java ActorPath使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ActorPath类属于akka.actor包,在下文中一共展示了ActorPath类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testMajorityPropose
import akka.actor.ActorPath; //导入依赖的package包/类
@Test
public void testMajorityPropose() throws Exception {
final List<TestPriest> majorityTestPriests = Stream.generate(this::testPriest)
.limit(PRIESTS_COUNT - MINORITY)
.collect(toList());
final List<TestPriest> minorityTestPriests = Stream.generate(this::testPriest)
.limit(MINORITY)
.collect(toList());
final Set<ActorPath> priestsPaths = Stream
.concat(majorityTestPriests.stream(), minorityTestPriests.stream())
.map(p -> p.path)
.collect(toSet());
final List<TestKit> majorityKits = majorityTestPriests.stream().map(p -> p.kit).collect(toList());
minorityTestPriests.forEach(p -> p.priest.tell(PoisonPill.getInstance(), ActorRef.noSender()));
final ActorRef leader = system.actorOf(DecreePresident.props(new Cluster(priestsPaths), 1));
leader.tell(new PaxosAPI.Propose("VALUE", 1), ActorRef.noSender());
majorityKits.forEach(kit -> kit.expectMsg(new PaxosAPI.Decide("VALUE", 1)));
}
示例2: testMinorityPropose
import akka.actor.ActorPath; //导入依赖的package包/类
@Test
public void testMinorityPropose() throws Exception {
final List<TestPriest> majorityTestPriests = Stream.generate(this::testPriest)
.limit(PRIESTS_COUNT - MINORITY)
.collect(toList());
final List<TestPriest> minorityTestPriests = Stream.generate(this::testPriest)
.limit(MINORITY)
.collect(toList());
final Set<ActorPath> priestsPaths = Stream
.concat(majorityTestPriests.stream(), minorityTestPriests.stream())
.map(p -> p.path)
.collect(toSet());
final List<TestKit> majorityKits = majorityTestPriests.stream().map(p -> p.kit).collect(toList());
majorityTestPriests.forEach(p -> p.priest.tell(PoisonPill.getInstance(), ActorRef.noSender()));
final ActorRef leader = system.actorOf(DecreePresident.props(new Cluster(priestsPaths), 1));
leader.tell(new PaxosAPI.Propose("VALUE", 1), ActorRef.noSender());
majorityKits.forEach(kit -> kit.expectNoMsg(Duration.create(1, SECONDS)));
}
示例3: singleLeaderBroadcastTest
import akka.actor.ActorPath; //导入依赖的package包/类
@Test
public void singleLeaderBroadcastTest() {
final String prefix = "simpleLeader";
final Set<ActorPath> broadcastPaths = LongStream.range(0, PRIESTS_COUNT)
.boxed().map(l -> system.child(prefix + l))
.collect(Collectors.toSet());
final List<TestBroadcast> testPriests = LongStream.range(0, PRIESTS_COUNT)
.boxed()
.map(l -> testBroadcast(prefix, l, new Cluster(broadcastPaths)))
.collect(toList());
final List<String> decrees = Stream
.generate(UUID::randomUUID)
.map(UUID::toString)
.limit(1000)
.collect(toList());
for (String v : decrees) {
testPriests.get(0).broadcast.tell(new AtomicBroadcastAPI.Broadcast(v), ActorRef.noSender());
testPriests.forEach(p -> p.kit.expectMsg(new AtomicBroadcastAPI.Deliver(v)));
}
}
示例4: startCommandClient
import akka.actor.ActorPath; //导入依赖的package包/类
public static ActorSystem startCommandClient(ClientConfig clientConfig) {
Config conf = ConfigFactory.parseString("akka.cluster.roles=[" + clientConfig.getRole() + "]")
.withFallback(ConfigFactory.parseString("akka.remote.netty.tcp.port=" + clientConfig.getPort()))
.withFallback(ConfigFactory.parseString("akka.remote.netty.tcp.hostname=" + HostUtils.lookupIp()))
.withFallback(ConfigFactory.load("application"));
ActorSystem system = ActorSystem.create(Constants.PerformanceSystem, conf);
Set<ActorPath> initialContacts = new HashSet<>(clientConfig.getContactPoint()
.map(p->ActorPaths.fromString(p))
.collect(Collectors.toList()));
ClusterClientSettings settings = ClusterClientSettings.create(system).withInitialContacts(initialContacts);
final ActorRef clusterClient = system.actorOf(ClusterClient.props(settings), "clusterClient");
system.actorOf(CommandClientActor.props(clusterClient, clientConfig), clientConfig.getRole() );
return system;
}
示例5: testSimplePropose
import akka.actor.ActorPath; //导入依赖的package包/类
@Test
public void testSimplePropose() throws Exception {
final List<TestPriest> testPriests = Stream.generate(this::testPriest)
.limit(PRIESTS_COUNT)
.collect(toList());
final Set<ActorPath> priestsPaths = testPriests.stream().map(p -> p.path).collect(toSet());
final ActorRef leader = system.actorOf(DecreePresident.props(new Cluster(priestsPaths), 1));
leader.tell(new PaxosAPI.Propose("VALUE", 1), ActorRef.noSender());
final List<TestKit> kits = testPriests.stream().map(p -> p.kit).collect(toList());
kits.forEach(kit -> kit.expectMsg(new PaxosAPI.Decide("VALUE", 1)));
}
示例6: path
import akka.actor.ActorPath; //导入依赖的package包/类
private ActorPath path(String host) {
final String[] split = host.split(":");
final String hostname = split[0];
final int port = Integer.parseInt(split[1]);
final Address actorSystemAddress = new Address("akka.tcp", "concierge", hostname, port);
return RootActorPath.apply(actorSystemAddress, "/").child("user");
}
示例7: killOneByOneTest
import akka.actor.ActorPath; //导入依赖的package包/类
@Test
public void killOneByOneTest() {
final String prefix = "killOneByOneTest";
final Set<ActorPath> broadcastPaths = LongStream.range(0, PRIESTS_COUNT)
.boxed()
.map(l -> system.child(prefix + l))
.collect(Collectors.toSet());
final List<TestBroadcast> testPriests = LongStream.range(0, PRIESTS_COUNT)
.boxed()
.map(l -> testBroadcast(prefix, l, new Cluster(broadcastPaths)))
.collect(toList());
while (testPriests.size() > PRIESTS_COUNT / 2) {
final TestBroadcast currentLeader = testPriests.get(0);
final List<String> decrees = Stream
.generate(UUID::randomUUID)
.map(UUID::toString)
.limit(1000)
.collect(toList());
for (String v : decrees) {
currentLeader.broadcast.tell(new AtomicBroadcastAPI.Broadcast(v), ActorRef.noSender());
testPriests.forEach(p -> p.kit.expectMsg(new AtomicBroadcastAPI.Deliver(v)));
}
currentLeader.broadcast.tell(PoisonPill.getInstance(), ActorRef.noSender());
testPriests.remove(currentLeader);
}
}
示例8: storage
import akka.actor.ActorPath; //导入依赖的package包/类
private ActorRef storage(String prefix) {
final Set<ActorPath> storagePaths = LongStream.range(0, PRIEST_COUNT)
.boxed()
.map(l -> system.child(prefix + l))
.collect(toSet());
final List<ActorRef> testPriests = LongStream.range(0, PRIEST_COUNT)
.boxed()
.map(l -> system.actorOf(LinearizableStorage.props(new Cluster(storagePaths)), prefix + l))
.collect(toList());
return testPriests.get(0);
}
示例9: findLogger
import akka.actor.ActorPath; //导入依赖的package包/类
protected Logger findLogger(Optional<ActorPath> origin) {
ActorPath path = origin.orElse(getContext().parent().path());
return loggers.computeIfAbsent(
path,
key -> {
return LoggerFactory.getLogger(key.toString());
}
);
}
示例10: TestPriest
import akka.actor.ActorPath; //导入依赖的package包/类
public TestPriest(ActorRef priest, ActorPath path, TestKit kit) {
this.priest = priest;
this.path = path;
this.kit = kit;
}
示例11: integrityAndTotalOrderTest
import akka.actor.ActorPath; //导入依赖的package包/类
@Test
public void integrityAndTotalOrderTest() {
final String prefix = "integrityAndTotalOrderTest";
final Set<ActorPath> broadcastPaths = LongStream.range(0, PRIESTS_COUNT)
.boxed()
.map(l -> system.child(prefix + l))
.collect(Collectors.toSet());
final List<TestBroadcast> testPriests = LongStream.range(0, PRIESTS_COUNT)
.boxed()
.map(l -> testBroadcast(prefix, l, new Cluster(broadcastPaths)))
.collect(toList());
final List<String> decrees = Stream
.generate(UUID::randomUUID)
.map(UUID::toString)
.limit(1000)
.collect(toList());
final Random rd = new Random();
for (String v : decrees) {
testPriests.get(rd.nextInt(testPriests.size())).broadcast
.tell(new AtomicBroadcastAPI.Broadcast(v), ActorRef.noSender());
}
final Set<List<String>> resultSet = new HashSet<>();
testPriests.stream().map(t -> t.kit).forEach(k -> {
final List<String> received = new ArrayList<>();
k.receiveWhile(
Duration.create(1, MINUTES),
Duration.create(10, SECONDS),
1000,
o -> received.add((String) ((AtomicBroadcastAPI.Deliver) o).value())
);
resultSet.add(received);
});
Assert.assertEquals(resultSet.size(), 1);
final List<String> representative = resultSet.stream().findAny().orElseThrow(IllegalStateException::new);
Assert.assertTrue(decrees.containsAll(representative));
Assert.assertTrue(representative.containsAll(decrees));
}
示例12: Cluster
import akka.actor.ActorPath; //导入依赖的package包/类
public Cluster(Set<ActorPath> paths, String suffix) {
this.paths = paths.stream()
.map(p -> p.child(suffix))
.collect(toSet());
}
示例13: paths
import akka.actor.ActorPath; //导入依赖的package包/类
public Set<ActorPath> paths() {
return unmodifiableSet(paths);
}
示例14: selectActor
import akka.actor.ActorPath; //导入依赖的package包/类
protected final ActorSelection selectActor(ActorPath path) {
return shard.getContext().system().actorSelection(path);
}
示例15: actorSelection
import akka.actor.ActorPath; //导入依赖的package包/类
public ActorSelection actorSelection(ActorPath actorPath) {
return actorSystem.actorSelection(actorPath);
}