本文整理汇总了Java中akka.cluster.ClusterEvent.CurrentClusterState类的典型用法代码示例。如果您正苦于以下问题:Java CurrentClusterState类的具体用法?Java CurrentClusterState怎么用?Java CurrentClusterState使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CurrentClusterState类属于akka.cluster.ClusterEvent包,在下文中一共展示了CurrentClusterState类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createReceive
import akka.cluster.ClusterEvent.CurrentClusterState; //导入依赖的package包/类
@Override
public Receive createReceive() {
return receiveBuilder()
.match(ClusterMetricsChanged.class, clusterMetrics -> {
for (NodeMetrics nodeMetrics : clusterMetrics.getNodeMetrics()) {
if (nodeMetrics.address().equals(cluster.selfAddress())) {
logHeap(nodeMetrics);
logCpu(nodeMetrics);
}
}
})
.match(CurrentClusterState.class, message -> {
// Ignore.
})
.build();
}
示例2: waitForMembersUp
import akka.cluster.ClusterEvent.CurrentClusterState; //导入依赖的package包/类
public void waitForMembersUp(final String... otherMembers) {
Set<String> otherMembersSet = Sets.newHashSet(otherMembers);
Stopwatch sw = Stopwatch.createStarted();
while (sw.elapsed(TimeUnit.SECONDS) <= 10) {
CurrentClusterState state = Cluster.get(getSystem()).state();
for (Member m: state.getMembers()) {
if (m.status() == MemberStatus.up() && otherMembersSet.remove(m.getRoles().iterator().next())
&& otherMembersSet.isEmpty()) {
return;
}
}
Uninterruptibles.sleepUninterruptibly(100, TimeUnit.MILLISECONDS);
}
fail("Member(s) " + otherMembersSet + " are not Up");
}
示例3: waitForMembersUp
import akka.cluster.ClusterEvent.CurrentClusterState; //导入依赖的package包/类
static void waitForMembersUp(final ActorSystem node, final UniqueAddress... addresses) {
Set<UniqueAddress> otherMembersSet = Sets.newHashSet(addresses);
Stopwatch sw = Stopwatch.createStarted();
while (sw.elapsed(TimeUnit.SECONDS) <= 10) {
CurrentClusterState state = Cluster.get(node).state();
for (Member m : state.getMembers()) {
if (m.status() == MemberStatus.up() && otherMembersSet.remove(m.uniqueAddress())
&& otherMembersSet.isEmpty()) {
return;
}
}
Uninterruptibles.sleepUninterruptibly(100, TimeUnit.MILLISECONDS);
}
fail("Member(s) " + otherMembersSet + " are not Up");
}