Search in sources :

Example 6 with Address

use of com.hazelcast.cluster.Address in project hazelcast by hazelcast.

the class MemberImplTest method setUp.

@BeforeClass
public static void setUp() throws Exception {
    HazelcastInstance instance = new TestHazelcastInstanceFactory().newHazelcastInstance();
    hazelcastInstance = getHazelcastInstanceImpl(instance);
    address = new Address("127.0.0.1", 5701);
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) Address(com.hazelcast.cluster.Address) TestHazelcastInstanceFactory(com.hazelcast.test.TestHazelcastInstanceFactory) BeforeClass(org.junit.BeforeClass)

Example 7 with Address

use of com.hazelcast.cluster.Address in project hazelcast by hazelcast.

the class MemberImplTest method testSerialization_whenMultiAddress.

@Test
public void testSerialization_whenMultiAddress() throws Exception {
    Map<EndpointQualifier, Address> addressMap = new HashMap<EndpointQualifier, Address>();
    addressMap.put(EndpointQualifier.MEMBER, address);
    addressMap.put(EndpointQualifier.REST, new Address("127.0.0.1", 8080));
    MemberImpl member = new MemberImpl.Builder(addressMap).version(MemberVersion.of("3.12.0")).build();
    testSerialization(member);
}
Also used : Address(com.hazelcast.cluster.Address) HashMap(java.util.HashMap) EndpointQualifier(com.hazelcast.instance.EndpointQualifier) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 8 with Address

use of com.hazelcast.cluster.Address in project hazelcast by hazelcast.

the class CPLiteMemberTest method liteMembers_canBePromotedToCPMember_afterPromotedToDataMember.

@Test
public void liteMembers_canBePromotedToCPMember_afterPromotedToDataMember() throws Exception {
    Config config = createConfig(3, 3);
    HazelcastInstance hz1 = factory.newHazelcastInstance(config);
    HazelcastInstance hz2 = factory.newHazelcastInstance(config);
    HazelcastInstance hz3 = factory.newHazelcastInstance(config);
    HazelcastInstance hz_lite = factory.newHazelcastInstance(createConfig(3, 3).setLiteMember(true));
    assertTrue(awaitUntilDiscoveryCompleted(hz1, 60));
    assertTrue(awaitUntilDiscoveryCompleted(hz_lite, 60));
    hz_lite.getCluster().promoteLocalLiteMember();
    hz_lite.getCPSubsystem().getCPSubsystemManagementService().promoteToCPMember().toCompletableFuture().get();
    Collection<CPMember> cpMembers = hz1.getCPSubsystem().getCPSubsystemManagementService().getCPMembers().toCompletableFuture().get();
    assertEquals(4, cpMembers.size());
    Set<Address> cpAddresses = cpMembers.stream().map(CPMember::getAddress).collect(Collectors.toSet());
    assertThat(cpAddresses, hasItem(getAddress(hz_lite)));
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) Address(com.hazelcast.cluster.Address) Accessors.getAddress(com.hazelcast.test.Accessors.getAddress) Config(com.hazelcast.config.Config) CPMember(com.hazelcast.cp.CPMember) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 9 with Address

use of com.hazelcast.cluster.Address in project hazelcast by hazelcast.

the class MetadataRaftGroupTest method when_clusterStartsWithNonCPNodes_then_metadataClusterIsInitialized.

@Test
public void when_clusterStartsWithNonCPNodes_then_metadataClusterIsInitialized() {
    int cpNodeCount = 3;
    instances = newInstances(cpNodeCount, cpNodeCount, 2);
    List<Address> raftAddresses = new ArrayList<>();
    for (int i = 0; i < cpNodeCount; i++) {
        raftAddresses.add(getAddress(instances[i]));
    }
    assertTrueEventually(() -> {
        for (HazelcastInstance instance : instances) {
            if (raftAddresses.contains(getAddress(instance))) {
                assertNotNull(getRaftNode(instance, getMetadataGroupId(instance)));
            }
        }
    });
    assertTrueAllTheTime(() -> {
        for (HazelcastInstance instance : instances) {
            if (!raftAddresses.contains(getAddress(instance))) {
                assertNull(getRaftNode(instance, getMetadataGroupId(instance)));
            }
        }
    }, 10);
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) Address(com.hazelcast.cluster.Address) Accessors.getAddress(com.hazelcast.test.Accessors.getAddress) ArrayList(java.util.ArrayList) RaftEndpoint(com.hazelcast.cp.internal.raft.impl.RaftEndpoint) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 10 with Address

use of com.hazelcast.cluster.Address in project hazelcast by hazelcast.

the class MapEvictAllMessageTask method reduce.

@Override
protected Object reduce(Map<Integer, Object> map) {
    MapService mapService = getService(MapService.SERVICE_NAME);
    MapServiceContext mapServiceContext = mapService.getMapServiceContext();
    int evictedTotal = 0;
    for (Object result : map.values()) {
        Integer size = (Integer) mapServiceContext.toObject(result);
        evictedTotal += size;
    }
    if (evictedTotal > 0) {
        Address thisAddress = mapServiceContext.getNodeEngine().getThisAddress();
        MapEventPublisher mapEventPublisher = mapServiceContext.getMapEventPublisher();
        mapEventPublisher.publishMapEvent(thisAddress, parameters, EVICT_ALL, evictedTotal);
    }
    return null;
}
Also used : Address(com.hazelcast.cluster.Address) MapService(com.hazelcast.map.impl.MapService) MapServiceContext(com.hazelcast.map.impl.MapServiceContext) MapEventPublisher(com.hazelcast.map.impl.event.MapEventPublisher)

Aggregations

Address (com.hazelcast.cluster.Address)540 Test (org.junit.Test)211 QuickTest (com.hazelcast.test.annotation.QuickTest)191 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)178 HazelcastInstance (com.hazelcast.core.HazelcastInstance)92 InetAddress (java.net.InetAddress)75 ArrayList (java.util.ArrayList)66 Member (com.hazelcast.cluster.Member)63 Accessors.getAddress (com.hazelcast.test.Accessors.getAddress)54 MemberImpl (com.hazelcast.cluster.impl.MemberImpl)48 Config (com.hazelcast.config.Config)43 PartitionReplica (com.hazelcast.internal.partition.PartitionReplica)43 UUID (java.util.UUID)43 ILogger (com.hazelcast.logging.ILogger)37 HashMap (java.util.HashMap)36 Operation (com.hazelcast.spi.impl.operationservice.Operation)35 List (java.util.List)35 OperationService (com.hazelcast.spi.impl.operationservice.OperationService)34 Map (java.util.Map)33 InetSocketAddress (java.net.InetSocketAddress)32