DistributedAnswer<ProtobufSystemInfo.SystemInfo> distributedAnswer = hzMember.call(ProcessInfoProvider::provide, memberSelector, DISTRIBUTED_TIMEOUT_MS);
for (Member member : distributedAnswer.getMembers()) {
String nodeName = member.getStringAttribute(NODE_NAME.getKey());
- NodeInfo nodeInfo = nodesByName.computeIfAbsent(nodeName, NodeInfo::new);
+ NodeInfo nodeInfo = nodesByName.computeIfAbsent(nodeName, name -> {
+ NodeInfo info = new NodeInfo(name);
+ info.setHost(member.getAddress().getHost());
+ return info;
+ });
completeNodeInfo(distributedAnswer, member, nodeInfo);
}
return nodesByName.values();
import com.hazelcast.core.Member;
import com.hazelcast.core.MemberSelector;
+import com.hazelcast.nio.Address;
import java.io.IOException;
+import java.net.InetAddress;
import java.util.Collection;
import org.junit.Rule;
import org.junit.Test;
public class AppNodesInfoLoaderImplTest {
+ private static final InetAddress AN_ADDRESS = InetAddress.getLoopbackAddress();
+
@Rule
public ExpectedException expectedException = ExpectedException.none();
NodeInfo successfulNodeInfo = findNode(nodes, "foo");
assertThat(successfulNodeInfo.getName()).isEqualTo("foo");
+ assertThat(successfulNodeInfo.getHost()).hasValue(AN_ADDRESS.getHostAddress());
assertThat(successfulNodeInfo.getErrorMessage()).isEmpty();
assertThat(successfulNodeInfo.getSections()).hasSize(1);
}
private Member newMember(String name) {
- Member member = mock(Member.class, Mockito.RETURNS_DEEP_STUBS);
+ Member member = mock(Member.class, Mockito.RETURNS_MOCKS);
when(member.getStringAttribute(HazelcastMember.Attribute.NODE_NAME.getKey())).thenReturn(name);
+ when(member.getAddress()).thenReturn(new Address(AN_ADDRESS, 6789));
return member;
}
}