Search in sources :

Example 86 with MapConfig

use of com.hazelcast.config.MapConfig in project hazelcast by hazelcast.

the class QuorumListenerTest method testDifferentQuorumsGetCorrectEvents.

@Test
public void testDifferentQuorumsGetCorrectEvents() {
    TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(3);
    final CountDownLatch quorumFailureLatch = new CountDownLatch(2);
    String fourNodeQuorumName = "fourNode";
    QuorumConfig fourNodeQuorumConfig = new QuorumConfig(fourNodeQuorumName, true, 4);
    fourNodeQuorumConfig.addListenerConfig(new QuorumListenerConfig(new QuorumListener() {

        public void onChange(QuorumEvent quorumEvent) {
            if (!quorumEvent.isPresent()) {
                quorumFailureLatch.countDown();
            }
        }
    }));
    String threeNodeQuorumName = "threeNode";
    QuorumConfig threeNodeQuorumConfig = new QuorumConfig(threeNodeQuorumName, true, 3);
    threeNodeQuorumConfig.addListenerConfig(new QuorumListenerConfig(new QuorumListener() {

        public void onChange(QuorumEvent quorumEvent) {
            if (!quorumEvent.isPresent()) {
                quorumFailureLatch.countDown();
            }
        }
    }));
    MapConfig fourNodeMapConfig = new MapConfig("fourNode");
    fourNodeMapConfig.setQuorumName(fourNodeQuorumName);
    MapConfig threeNodeMapConfig = new MapConfig("threeNode");
    threeNodeMapConfig.setQuorumName(threeNodeQuorumName);
    Config config = new Config();
    config.addMapConfig(fourNodeMapConfig);
    config.addQuorumConfig(fourNodeQuorumConfig);
    config.addMapConfig(threeNodeMapConfig);
    config.addQuorumConfig(threeNodeQuorumConfig);
    factory.newHazelcastInstance(config);
    factory.newHazelcastInstance(config);
    assertOpenEventually(quorumFailureLatch);
}
Also used : QuorumConfig(com.hazelcast.config.QuorumConfig) QuorumListenerConfig(com.hazelcast.config.QuorumListenerConfig) Config(com.hazelcast.config.Config) QuorumListenerConfig(com.hazelcast.config.QuorumListenerConfig) MapConfig(com.hazelcast.config.MapConfig) QuorumConfig(com.hazelcast.config.QuorumConfig) QuorumEvent(com.hazelcast.quorum.QuorumEvent) QuorumListener(com.hazelcast.quorum.QuorumListener) MapConfig(com.hazelcast.config.MapConfig) CountDownLatch(java.util.concurrent.CountDownLatch) TestHazelcastInstanceFactory(com.hazelcast.test.TestHazelcastInstanceFactory) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 87 with MapConfig

use of com.hazelcast.config.MapConfig in project hazelcast by hazelcast.

the class NestedPredicateWithExtractorTest method setup.

@Before
public void setup() {
    bodyExtractorExecutions = 0;
    limbExtractorExecutions = 0;
    Config config = new Config();
    MapConfig mapConfig = new MapConfig();
    mapConfig.setName("map");
    mapConfig.addMapAttributeConfig(extractor("name", "com.hazelcast.query.impl.predicates.NestedPredicateWithExtractorTest$BodyNameExtractor"));
    mapConfig.addMapAttributeConfig(extractor("limbname", "com.hazelcast.query.impl.predicates.NestedPredicateWithExtractorTest$LimbNameExtractor"));
    config.addMapConfig(mapConfig);
    HazelcastInstance instance = createHazelcastInstance(config);
    map = instance.getMap("map");
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) MapAttributeConfig(com.hazelcast.config.MapAttributeConfig) MapConfig(com.hazelcast.config.MapConfig) Config(com.hazelcast.config.Config) MapConfig(com.hazelcast.config.MapConfig) Before(org.junit.Before)

Example 88 with MapConfig

use of com.hazelcast.config.MapConfig in project hazelcast by hazelcast.

the class TransactionalMapReadQuorumTest method initialize.

@BeforeClass
public static void initialize() throws Exception {
    QuorumConfig quorumConfig = new QuorumConfig();
    quorumConfig.setEnabled(true);
    quorumConfig.setSize(3);
    quorumConfig.setName(QUORUM_ID);
    quorumConfig.setType(QuorumType.READ);
    MapConfig mapConfig = new MapConfig(MAP_NAME_PREFIX + "*");
    mapConfig.setQuorumName(QUORUM_ID);
    cluster = new PartitionedCluster(new TestHazelcastInstanceFactory()).partitionFiveMembersThreeAndTwo(mapConfig, quorumConfig);
}
Also used : QuorumConfig(com.hazelcast.config.QuorumConfig) PartitionedCluster(com.hazelcast.quorum.PartitionedCluster) MapConfig(com.hazelcast.config.MapConfig) TestHazelcastInstanceFactory(com.hazelcast.test.TestHazelcastInstanceFactory) BeforeClass(org.junit.BeforeClass)

Example 89 with MapConfig

use of com.hazelcast.config.MapConfig in project cas by apereo.

the class ProvidedHazelcastInstanceConfigurationTests method hazelcastInstanceIsCreatedNormally.

@Test
public void hazelcastInstanceIsCreatedNormally() throws Exception {
    assertNotNull(this.hzInstance);
    final Config config = this.hzInstance.getConfig();
    assertTrue(config.getNetworkConfig().getJoin().getMulticastConfig().isEnabled());
    assertEquals(Arrays.asList("127.0.0.1"), config.getNetworkConfig().getJoin().getTcpIpConfig().getMembers());
    assertFalse(config.getNetworkConfig().isPortAutoIncrement());
    assertEquals(5801, config.getNetworkConfig().getPort());
    final MapConfig mapConfig = config.getMapConfig("tickets-from-external-config");
    assertNotNull(mapConfig);
    assertEquals(20000, mapConfig.getMaxIdleSeconds());
    assertEquals(EvictionPolicy.LFU, mapConfig.getEvictionPolicy());
    assertEquals(99, mapConfig.getEvictionPercentage());
}
Also used : MapConfig(com.hazelcast.config.MapConfig) Config(com.hazelcast.config.Config) MapConfig(com.hazelcast.config.MapConfig) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 90 with MapConfig

use of com.hazelcast.config.MapConfig in project cas by apereo.

the class CasServicesStreamingHazelcastConfiguration method casRegisteredServiceHazelcastInstance.

@Bean
public HazelcastInstance casRegisteredServiceHazelcastInstance() {
    final String name = CasRegisteredServiceHazelcastStreamPublisher.class.getSimpleName();
    LOGGER.debug("Creating Hazelcast instance [{}] to publish service definitions", name);
    final HazelcastConfigurationFactory factory = new HazelcastConfigurationFactory();
    final StreamServicesHazelcastProperties stream = casProperties.getServiceRegistry().getStream().getHazelcast();
    final BaseHazelcastProperties hz = stream.getConfig();
    final long duration = Beans.newDuration(stream.getDuration()).toMillis();
    final MapConfig mapConfig = factory.buildMapConfig(hz, name, TimeUnit.MILLISECONDS.toSeconds(duration));
    final Config cfg = factory.build(hz, mapConfig);
    LOGGER.debug("Created hazelcast instance [{}] with publisher id [{}] to publish service definitions", name, casRegisteredServiceStreamPublisherIdentifier);
    return Hazelcast.newHazelcastInstance(cfg);
}
Also used : HazelcastConfigurationFactory(org.apereo.cas.hz.HazelcastConfigurationFactory) MapConfig(com.hazelcast.config.MapConfig) Config(com.hazelcast.config.Config) StreamServicesHazelcastProperties(org.apereo.cas.configuration.model.support.services.stream.hazelcast.StreamServicesHazelcastProperties) BaseHazelcastProperties(org.apereo.cas.configuration.model.support.hazelcast.BaseHazelcastProperties) MapConfig(com.hazelcast.config.MapConfig) StringBean(org.apereo.cas.StringBean) Bean(org.springframework.context.annotation.Bean)

Aggregations

MapConfig (com.hazelcast.config.MapConfig)182 Config (com.hazelcast.config.Config)125 HazelcastInstance (com.hazelcast.core.HazelcastInstance)78 Test (org.junit.Test)75 QuickTest (com.hazelcast.test.annotation.QuickTest)68 ParallelTest (com.hazelcast.test.annotation.ParallelTest)62 MapStoreConfig (com.hazelcast.config.MapStoreConfig)43 TestHazelcastInstanceFactory (com.hazelcast.test.TestHazelcastInstanceFactory)41 MaxSizeConfig (com.hazelcast.config.MaxSizeConfig)28 NearCacheConfig (com.hazelcast.config.NearCacheConfig)27 MapIndexConfig (com.hazelcast.config.MapIndexConfig)20 QuorumConfig (com.hazelcast.config.QuorumConfig)19 EntryListenerConfig (com.hazelcast.config.EntryListenerConfig)18 QueryCacheConfig (com.hazelcast.config.QueryCacheConfig)16 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)14 NightlyTest (com.hazelcast.test.annotation.NightlyTest)12 PartitionedCluster (com.hazelcast.quorum.PartitionedCluster)10 CountDownLatch (java.util.concurrent.CountDownLatch)10 BeforeClass (org.junit.BeforeClass)10 AssertTask (com.hazelcast.test.AssertTask)9