Here are the slides of Jahia's Developers Meetup held online, via Cisco WebEx, on March 15, 2017.
The topic of this meetup was: Sharing of Distributed Objects in a DX Cluster, thanks to Hazelcast.
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
Â
Sharing of Distributed Objects in a DX Cluster, thanks to Hazelcast - Online Developers Meetup - March 2017
1. Hazelcast in DX 7.2 1
Hazelcast
How to share Java objects in a cluster
2. Hazelcast in DX 7.2 2
DX 7.2
Sharing objects across servers
1
3. Hazelcast in DX 7.2 3
1 Why do we want to share objects?
âą Replicated object = Highly Available object
o No Single Point of Failure
o Servers can be restarted and shutdown without data loss
âą Better load balancing
o Load Balancer redirects traffic to the less busy server,
and not to the one containing the data
âą Because we need it!
o Prevents race conditions between servers
o Some features simply need to share data cluster-wide
4. Hazelcast in DX 7.2 4
1 Why do we want to share objects?
Sticky Session Stateless
VS
5. Hazelcast in DX 7.2 5
What are the solutions?
1 âą Externalize objects to a dedicated backend
âą Synchronize objects across the cluster
Digital Experience Manager offers out of the box support for both!
6. Hazelcast in DX 7.2 6
What are the solutions?
1
VS
Offloaded objects Synchronized objects
7. Hazelcast in DX 7.2 7
1
Pros & Cons
âą Externalized objects to a dedicated backend:
- No development required for some objects (user sessions...)
- Specific development required when storing custom objects
- More complex architecture (additional servers)
- Highly scalable
âą Synchronized objects across the cluster:
- Needs to be taken into account in the code
- No architecture change required
- Very granular: specific objects can be synchronized while others arenât
- Very efficient with few servers, wonât scale to hundreds of nodes
8. Hazelcast in DX 7.2 8
1
Hazelcast
âThe Leading Open Source In-Memory Data Gridâ
There is much more to Hazelcast than what we are going to talk about today:
Hazelcast is Open Source under Apache license (we love open source!)
9. Hazelcast in DX 7.2 9
1
Hazelcast in Digital Experience Manager
7.2
âą Hazelcast 3.7.3 is available out of the box in Digital Experience
Manager 7.2
âą Available as a service: no custom integration required (Use it in less
than 5 minutes)
âą Hazelcast is masterless: killing a server wonât alter the service
10. Hazelcast in DX 7.2 10
1
Hazelcast server discovery
How do servers know about each other?
âą Multicast
âą TCP
âą EC2 Cloud
DX 7.2 uses the TCP option. Everything is done for you and you can
start using the service without worrying about the server discovery.
11. Hazelcast in DX 7.2 11
1
DX 7.2 server architecture with Hazelcast
12. Hazelcast in DX 7.2 12
1
Hazelcast usages in 7.2
Hazelcast is already widely used inside Digital Experience Manager 7.2:
âą Clustered module deployment: shared module states across
the cluster
âą Oauth authentification modules: authentication token shared
across the cluster to authenticate users on all servers at once
âą More custom modules we havenât heard of!
14. Hazelcast in DX 7.2 14
2
Hazelcast architecture
âą Hazelcast uses TCP communication to replicate the objects
âą Hazelcast is event-based
âą Hazelcast handles concurrent access to objects out of the box
âą Hazelcast is instantiated by DX and exposed as an OSGi Service
Any DX 7.2 module can import Hazelcastâs OSGi service and start using it right away.
16. Hazelcast in DX 7.2 16
2
OSGi Services
<osgi:reference id="com.hazelcast.core.HazelcastInstance" interface="com.hazelcast.core.HazelcastInstance"/>
<bean id="HazelcastExampleActionâ class="org.jahia.modules.hazelcastexample.beans.HazelcastExampleBean">
<property name="hazelcastInstance" ref="com.hazelcast.core.HazelcastInstance"/>
</bean>
Spring file declaration:
Imports the Hazelcast OSGi Service and injects it in a Spring Bean.
17. Hazelcast in DX 7.2 17
2
Simple shared object declaration
Java class declaration:
public class HazelcastExampleBean {
}
First access to the getMap(String) method will instantiate the shared object
private HazelcastInstance hazelcastInstance;
public void setHazelcastInstance(HazelcastInstance hi) {
this.hazelcastInstance = hi;
}
public HazelcastExampleBean () {
Map<Integer, String> sharedData = hazelcastInstance.getMap("sharedObject");
sharedData.put(sharedData.size()+1, âmyContentâ);
}
18. Hazelcast in DX 7.2 18
2
Thatâs all. All the heavy lifting is handled internally by DX 7.2
Of course, there is much more to Hazelcast than sharing objects. If you want to know more,
more documentation is available at
http://docs.hazelcast.org/docs/3.7/manual/html-single/index.html
19. Hazelcast in DX 7.2 19
2
Distributed Events
âą Membership Listener for cluster membership events.
âą Distributed Object Listener for distributed object creation and destroy events.
âą Migration Listener for partition migration start and complete events.
âą Partition Lost Listener for partition lost events.
âą Lifecycle Listener for HazelcastInstance lifecycle events.
âą Entry Listener for IMap and MultiMap entry events.
âą Item Listener for IQueue, ISet and IList item events.
âą Message Listener for ITopic message events.
âą Client Listener for client connection events.
Event distribution is a big part of Hazelcast. Even though you might not use
them at the beginning, listening to events might come in handy someday.
20. Hazelcast in DX 7.2 20
2
Configuration fine tuning
The configuration is stored in
/digital-factory-
data/karaf/etc/hazelcast.xml
21. Hazelcast in DX 7.2 21
2
Performances
âą Hazelcast is designed to play well under high read and write load
âą Network performance is a key aspect of Hazelcastâs perfs
If you are designing a highly demanding application with lots of
accesses, load performance testing is a key aspect of the project.