Search in sources :

Example 1 with HazelcastConfigurationFactory

use of org.apereo.cas.hz.HazelcastConfigurationFactory 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)

Example 2 with HazelcastConfigurationFactory

use of org.apereo.cas.hz.HazelcastConfigurationFactory in project cas by apereo.

the class HazelcastTicketRegistryConfiguration method buildHazelcastMapConfigurations.

private Map<String, MapConfig> buildHazelcastMapConfigurations(final TicketCatalog ticketCatalog) {
    final Map<String, MapConfig> mapConfigs = new HashMap<>();
    final HazelcastTicketRegistryProperties hz = casProperties.getTicket().getRegistry().getHazelcast();
    final HazelcastConfigurationFactory factory = new HazelcastConfigurationFactory();
    final Collection<TicketDefinition> definitions = ticketCatalog.findAll();
    definitions.forEach(t -> {
        final MapConfig mapConfig = factory.buildMapConfig(hz, t.getProperties().getStorageName(), t.getProperties().getStorageTimeout());
        LOGGER.debug("Created Hazelcast map configuration for [{}]", t);
        mapConfigs.put(t.getProperties().getStorageName(), mapConfig);
    });
    return mapConfigs;
}
Also used : HazelcastConfigurationFactory(org.apereo.cas.hz.HazelcastConfigurationFactory) HashMap(java.util.HashMap) TicketDefinition(org.apereo.cas.ticket.TicketDefinition) HazelcastTicketRegistryProperties(org.apereo.cas.configuration.model.support.hazelcast.HazelcastTicketRegistryProperties) MapConfig(com.hazelcast.config.MapConfig)

Example 3 with HazelcastConfigurationFactory

use of org.apereo.cas.hz.HazelcastConfigurationFactory in project cas by apereo.

the class HazelcastTicketRegistryConfiguration method getConfig.

private Config getConfig(final TicketCatalog ticketCatalog) {
    final HazelcastTicketRegistryProperties hz = casProperties.getTicket().getRegistry().getHazelcast();
    final Map<String, MapConfig> configs = buildHazelcastMapConfigurations(ticketCatalog);
    final HazelcastConfigurationFactory factory = new HazelcastConfigurationFactory();
    return factory.build(hz, configs);
}
Also used : HazelcastConfigurationFactory(org.apereo.cas.hz.HazelcastConfigurationFactory) HazelcastTicketRegistryProperties(org.apereo.cas.configuration.model.support.hazelcast.HazelcastTicketRegistryProperties) MapConfig(com.hazelcast.config.MapConfig)

Aggregations

MapConfig (com.hazelcast.config.MapConfig)3 HazelcastConfigurationFactory (org.apereo.cas.hz.HazelcastConfigurationFactory)3 HazelcastTicketRegistryProperties (org.apereo.cas.configuration.model.support.hazelcast.HazelcastTicketRegistryProperties)2 Config (com.hazelcast.config.Config)1 HashMap (java.util.HashMap)1 StringBean (org.apereo.cas.StringBean)1 BaseHazelcastProperties (org.apereo.cas.configuration.model.support.hazelcast.BaseHazelcastProperties)1 StreamServicesHazelcastProperties (org.apereo.cas.configuration.model.support.services.stream.hazelcast.StreamServicesHazelcastProperties)1 TicketDefinition (org.apereo.cas.ticket.TicketDefinition)1 Bean (org.springframework.context.annotation.Bean)1