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);
}
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");
}
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);
}
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());
}
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);
}
Aggregations