本文整理匯總了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");
}