Skip to content

Commit 2809ea4

Browse files
committed
Updated example
1 parent 9902a6e commit 2809ea4

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

examples/src/main/java/io/scalecube/examples/ClusterMetadataExample.java

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import io.scalecube.cluster.Member;
77
import io.scalecube.cluster.transport.api.Message;
88
import java.util.Collections;
9-
import java.util.Map;
109
import java.util.Optional;
1110
import java.util.concurrent.TimeUnit;
1211

@@ -44,17 +43,10 @@ public void onMessage(Message message) {
4443
.startAwait();
4544

4645
// Scan the list of members in the cluster and find Joe there
47-
Optional<Member> joeMemberOptional =
48-
alice.otherMembers().stream()
49-
.filter(
50-
member -> {
51-
//noinspection unchecked,OptionalGetWithoutIsPresent
52-
Map<String, String> metadata = (Map<String, String>) alice.metadata(member).get();
53-
return "Joe".equals(metadata.get("name"));
54-
})
55-
.findAny();
46+
Optional<Member> joeMemberOptional = alice.otherMembers().stream().findAny();
5647

5748
System.err.println("### joeMemberOptional: " + joeMemberOptional);
49+
System.err.println("### joeMetadata: " + alice.metadata(joeMemberOptional.get()));
5850

5951
// Send hello to Joe
6052
joeMemberOptional.ifPresent(

0 commit comments

Comments
 (0)