use of org.apereo.cas.configuration.model.support.hazelcast.HazelcastProperties in project cas by apereo.
the class HazelcastMonitor method getStatistics.
@Override
protected CacheStatistics[] getStatistics() {
final List<CacheStatistics> statsList = new ArrayList<>();
final HazelcastProperties hz = casProperties.getTicket().getRegistry().getHazelcast();
LOGGER.debug("Locating hazelcast instance [{}]...", hz.getCluster().getInstanceName());
final HazelcastInstance instance = Hazelcast.getHazelcastInstanceByName(hz.getCluster().getInstanceName());
instance.getConfig().getMapConfigs().keySet().forEach(key -> {
final IMap map = instance.getMap(key);
LOGGER.debug("Starting to collect hazelcast statistics for map [{}] identified by key [{}]...", map, key);
statsList.add(new HazelcastStatistics(map, hz.getCluster().getMembers().size()));
});
return statsList.toArray(new CacheStatistics[statsList.size()]);
}
use of org.apereo.cas.configuration.model.support.hazelcast.HazelcastProperties in project cas by apereo.
the class HazelcastTicketRegistryConfiguration method ticketRegistry.
@Autowired
@Bean
public TicketRegistry ticketRegistry(@Qualifier("ticketCatalog") final TicketCatalog ticketCatalog) {
final HazelcastProperties hz = casProperties.getTicket().getRegistry().getHazelcast();
final HazelcastTicketRegistry r = new HazelcastTicketRegistry(hazelcast(ticketCatalog), ticketCatalog, hz.getPageSize());
r.setCipherExecutor(Beans.newTicketRegistryCipherExecutor(hz.getCrypto()));
return r;
}
use of org.apereo.cas.configuration.model.support.hazelcast.HazelcastProperties in project cas by apereo.
the class HazelcastTicketRegistryConfiguration method getConfig.
private Config getConfig(final TicketCatalog ticketCatalog) {
final HazelcastProperties hz = casProperties.getTicket().getRegistry().getHazelcast();
final HazelcastProperties.Cluster cluster = hz.getCluster();
final Config config;
if (hz.getConfigLocation() != null && hz.getConfigLocation().exists()) {
try {
final URL configUrl = hz.getConfigLocation().getURL();
LOGGER.debug("Loading Hazelcast configuration from [{}]", configUrl);
config = new XmlConfigBuilder(hz.getConfigLocation().getInputStream()).build();
config.setConfigurationUrl(configUrl);
} catch (final Exception e) {
throw Throwables.propagate(e);
}
} else {
// No config location, so do a default config programmatically with handful of properties exposed by CAS
config = new Config();
config.setProperty("hazelcast.prefer.ipv4.stack", String.valueOf(cluster.isIpv4Enabled()));
// TCP config
final TcpIpConfig tcpIpConfig = new TcpIpConfig().setEnabled(cluster.isTcpipEnabled()).setMembers(cluster.getMembers()).setConnectionTimeoutSeconds(cluster.getTimeout());
LOGGER.debug("Created Hazelcast TCP/IP configuration [{}]", tcpIpConfig);
// Multicast config
final MulticastConfig multicastConfig = new MulticastConfig().setEnabled(cluster.isMulticastEnabled());
if (cluster.isMulticastEnabled()) {
multicastConfig.setMulticastGroup(cluster.getMulticastGroup());
multicastConfig.setMulticastPort(cluster.getMulticastPort());
final Set<String> trustedInterfaces = StringUtils.commaDelimitedListToSet(cluster.getMulticastTrustedInterfaces());
if (!trustedInterfaces.isEmpty()) {
multicastConfig.setTrustedInterfaces(trustedInterfaces);
}
multicastConfig.setMulticastTimeoutSeconds(cluster.getMulticastTimeout());
multicastConfig.setMulticastTimeToLive(cluster.getMulticastTimeToLive());
}
LOGGER.debug("Created Hazelcast Multicast configuration [{}]", multicastConfig);
// Join config
final JoinConfig joinConfig = new JoinConfig().setMulticastConfig(multicastConfig).setTcpIpConfig(tcpIpConfig);
LOGGER.debug("Created Hazelcast join configuration [{}]", joinConfig);
// Network config
final NetworkConfig networkConfig = new NetworkConfig().setPort(cluster.getPort()).setPortAutoIncrement(cluster.isPortAutoIncrement()).setJoin(joinConfig);
LOGGER.debug("Created Hazelcast network configuration [{}]", networkConfig);
// Finally aggregate all those config into the main Config
config.setMapConfigs(buildHazelcastMapConfigurations(ticketCatalog)).setNetworkConfig(networkConfig);
}
// Add additional default config properties regardless of the configuration source
return config.setInstanceName(cluster.getInstanceName()).setProperty(HazelcastProperties.LOGGING_TYPE_PROP, cluster.getLoggingType()).setProperty(HazelcastProperties.MAX_HEARTBEAT_SECONDS_PROP, String.valueOf(cluster.getMaxNoHeartbeatSeconds()));
}
use of org.apereo.cas.configuration.model.support.hazelcast.HazelcastProperties in project cas by apereo.
the class HazelcastTicketRegistryConfiguration method createMapConfig.
private MapConfig createMapConfig(final TicketDefinition definition) {
final HazelcastProperties hz = casProperties.getTicket().getRegistry().getHazelcast();
final HazelcastProperties.Cluster cluster = hz.getCluster();
final EvictionPolicy evictionPolicy = EvictionPolicy.valueOf(cluster.getEvictionPolicy());
LOGGER.debug("Creating Hazelcast map configuration for [{}] with idle timeout [{}] second(s)", definition.getProperties().getStorageName(), definition.getProperties().getStorageTimeout());
return new MapConfig().setName(definition.getProperties().getStorageName()).setMaxIdleSeconds((int) definition.getProperties().getStorageTimeout()).setBackupCount(cluster.getBackupCount()).setAsyncBackupCount(cluster.getAsyncBackupCount()).setEvictionPolicy(evictionPolicy).setMaxSizeConfig(new MaxSizeConfig().setMaxSizePolicy(MaxSizeConfig.MaxSizePolicy.valueOf(cluster.getMaxSizePolicy())).setSize(cluster.getMaxHeapSizePercentage()));
}
Aggregations