Skip to content

Commit

Permalink
Use getAddress instead of getSocketAddress, fixes hazelcast#8463
Browse files Browse the repository at this point in the history
  • Loading branch information
emrahkocaman committed Jul 22, 2016
1 parent b2fe91c commit 8ca6308
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 3 deletions.
Expand Up @@ -21,7 +21,6 @@
import com.hazelcast.internal.management.JsonSerializable;
import com.hazelcast.nio.Address;
import com.hazelcast.partition.InternalPartitionService;
import java.net.InetSocketAddress;

import static com.hazelcast.util.JsonUtil.getInt;

Expand All @@ -38,9 +37,9 @@ public PartitionServiceBeanDTO() {

public PartitionServiceBeanDTO(InternalPartitionService partitionService,
HazelcastInstanceImpl hazelcastInstance) {
InetSocketAddress address = hazelcastInstance.getCluster().getLocalMember().getSocketAddress();
Address address = hazelcastInstance.getCluster().getLocalMember().getAddress();
this.partitionCount = partitionService.getPartitionCount();
this.activePartitionCount = partitionService.getMemberPartitions(new Address(address)).size();
this.activePartitionCount = partitionService.getMemberPartitions(address).size();
}

public int getPartitionCount() {
Expand Down
Expand Up @@ -56,4 +56,5 @@ public void testCleanupUrl_needsCleanup() {
public void testCleanupUrl_withNull() {
assertNull(cleanupUrl(null));
}

}
@@ -0,0 +1,38 @@
package com.hazelcast.internal.management;

import com.hazelcast.config.Config;
import com.hazelcast.core.Hazelcast;
import com.hazelcast.core.HazelcastInstance;
import com.hazelcast.internal.management.dto.PartitionServiceBeanDTO;
import com.hazelcast.monitor.impl.MemberStateImpl;
import com.hazelcast.test.HazelcastParallelClassRunner;
import com.hazelcast.test.HazelcastTestSupport;
import com.hazelcast.test.annotation.QuickTest;
import org.junit.After;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.runner.RunWith;

import static org.junit.Assert.assertEquals;

@RunWith(HazelcastParallelClassRunner.class)
@Category(QuickTest.class)
public class PartitionServiceBeanDTOTest extends HazelcastTestSupport {

@After
public void tearDown() {
Hazelcast.shutdownAll();
}

@Test //https://github.com/hazelcast/hazelcast/issues/8463
public void testJMXStatsWithPublicAdressHostName() {
Config config = new Config();
config.getNetworkConfig().setPublicAddress("hazelcast.org");
HazelcastInstance instance = Hazelcast.newHazelcastInstance(config);
MemberStateImpl memberState = new MemberStateImpl();
TimedMemberStateFactoryHelper.registerJMXBeans(getNode(instance).hazelcastInstance, memberState);
PartitionServiceBeanDTO partitionServiceDTO = memberState.getMXBeans().getPartitionServiceBean();
assertEquals(partitionServiceDTO.getPartitionCount(), partitionServiceDTO.getActivePartitionCount());
}

}

0 comments on commit 8ca6308

Please sign in to comment.