Skip to content
This repository has been archived by the owner on Nov 3, 2017. It is now read-only.

Configuring HazelcastTicketRegistry

Dmitriy Kopylenko edited this page Jan 30, 2015 · 9 revisions

Version 1.9 introduces distributed ticket registry implementation based on the pure Java in-memory data grid library called Hazelcast. Version 3.x of this library is used. This TicketRegistry implementation is based on Hazelcast's distributed map that is cluster-aware and is able to auto-join a cluster of this Map instance on all the CAS nodes that expose this TicketRegistry. Hazelcast will use port auto-increment feature to assign a TCP port to each member of a cluster starting from initially provided arbitrary port (5701 by convention)

Hazelcast will evenly distribute the Map's data among all the members of a cluster in a very efficient manner. Also, by default, the Map on each node is configured with 1 backup copy, so that Hazelcast will use it to make strong data consistency guarantees i.e. the loss of data on live nodes will not occur should any other primary data owner members die. The data will be re-partitioned among the remaining live cluster members.

Configuration

Configure the HazelcastInstance bean as well as HazelcastTicketRegistry bean using Hazelcast and cas-addons custom XML schema elements in WEB-INF/spring-configuration/ticketRegistry.xml Sample configuration:

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:hz="http://www.hazelcast.com/schema/spring" xmlns:cas="http://unicon.net/schema/cas"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
                           http://www.springframework.org/schema/beans/spring-beans.xsd
                           http://www.hazelcast.com/schema/spring
                           http://www.hazelcast.com/schema/spring/hazelcast-spring-3.1.xsd
                           http://unicon.net/schema/cas
                           http://unicon.net/schema/cas/cas-addons.xsd">


    <hz:hazelcast id="hazelcast">
        <hz:config>
            <hz:properties>
                <hz:property name="hazelcast.logging.type">slf4j</hz:property>                
                <hz:property name="hazelcast.max.no.heartbeat.seconds">5</hz:property>
            </hz:properties>
            <hz:network port="5701" port-auto-increment="true">
                <hz:join>
                    <hz:multicast enabled="false"/>
                    <hz:tcp-ip enabled="true">
                        <hz:members>${hz.cluster.members:localhost}</hz:members>
                    </hz:tcp-ip>
                </hz:join>
            </hz:network>
            <hz:map name="tickets"
                            max-idle-seconds="${tgt.timeToKillInSeconds:7200}"
                            max-size-policy="USED_HEAP_PERCENTAGE"
                            max-size="85"
                            eviction-policy="LRU"
                            eviction-percentage="10"/>
        </hz:config>
    </hz:hazelcast>

    <cas:hazelcast-ticket-registry hazelcast-instance="hazelcast"
                                   tgt-entries-ttl-seconds="${tgt.maxTimeToLiveInSeconds:28800}"
                                   st-entries-ttl-seconds="${st.timeToKillInSeconds:10}"/>

</beans>

Add ALL the cluster member nodes (comma-separated hostnames or ip addresses) in hz.cluster.members property of the externalized cas.properties file (distributed on all the participated CAS nodes):

hz.cluster.members=cas1.example.com,cas2.example.com

For further details about Hazelcast features and configuration options refer to the Hazelcast documentation

Clone this wiki locally