Hazelcast is an easy to use but scalable in-memory datagrid and distributed executor framework. It enables you to build applications having a big requirement on memory or that needs to scale horizontally.
2. WHO AM I
Christoph Engelbert (@noctarius2k)
8+ years of professional Java development
5+ years of backend development
Specialized to performance, GC, traffic topics
Was working for int. companies as Ubisoft and HRS
Since November 2013 official Hazelcast Hacker
Apache DirectMemory / Lightning Committer and PMC
Developer CastMapR - MapReduce on Hazelcast 3
www.hazelcast.com
5. USECASES
Scale your application
Distribute and share data
Partition your data
Distribute messages
Process in parallel on multiple machines
Load balancing
www.hazelcast.com
8. FEATURES
Java Collection API
Map, Queue, Set, List
MultiMap
Topic (PubSub)
Java Concurrency API
Lock, Semaphore, CountDownLatch, ExecutorService
Transactions
Custom Serialization
Off-Heap support
Native client: C#, C++, Java, REST, memcached
www.hazelcast.com
9. EASY API
/ Cetn anwHzlatnd
/ raig
e aecs oe
Hzlatntneh =HzlatnwaecsIsac(;
aecsIsac z
aecs.eHzlatntne)
/ GtigaMp Ls,Tpc ..
/ etn
a, it oi, .
Mpmp=h.eMp"aNm";
a a
zgta(Mpae)
Ls ls =h.eLs(LsNm";
it it
zgtit"itae)
Ioi tpc=h.eTpc"oiNm";
Tpc oi
zgtoi(Tpcae)
/ Sutn dw tend
/ htig on h oe
h.hton)
zsudw(;
www.hazelcast.com
11. DATA PARTITIONING (1/2)
Multiple partitions per node
Consistent Hashing: hash(key) % partitioncount
Option to control partitioning: "key@partitionkey"
Possibility to find key owner for every key
Support for Near-Caching and executions on key owner
Automatic Fault-Tolerance
Synchronous and Asynchronous backups
Define sync / async backup counts
www.hazelcast.com
12. DATA PARTITIONING (2/2)
With 4 cluster nodes every server holds
1/4 real data and 1/4 of backups
www.hazelcast.com
14. HAZELCAST IN NUMBERS
Default partition amount 271
Any partition amount possible
Biggest cluster 100+ members
Handles 100k+/sec messages using a topic
Max datasize depends on RAM
Off-Heap for low GC overhead
www.hazelcast.com
15. COMMUNITY VS. ENTERPRISE
Feature
Java Collection API
Java Concurrency API
SSL Socket
Elastic Memory (Off-Heap)
JAAS Security / Authentication
Management Center
Community
X
X
X
Enterprise
X
X
X
X
X
X
www.hazelcast.com
17. EASY TO UNITTEST
pbi casSmTsCs {
ulc ls oeetae
piaeHzlatntne]isacs
rvt aecsIsac[ ntne;
@eoe
Bfr
pbi vi bfr( trw Ecpin{
ulc od eoe) hos xeto
/ Mlil isacso tesm JM
/ utpe ntne n h ae V
isacs=nwHzlatntne2;
ntne
e aecsIsac[]
isacs0 =HzlatnwaecsIsac(;
ntne[]
aecs.eHzlatntne)
isacs1 =HzlatnwaecsIsac(;
ntne[]
aecs.eHzlatntne)
}
@fe
Atr
pbi vi atr)trw Ecpin{
ulc od fe( hos xeto
HzlatsudwAl)
aecs.htonl(;
}
}
www.hazelcast.com
18. SERIALIZATION
/ jv.oSraial
/ aai.eilzbe
pbi casUe ipeet Sraial {
ulc ls sr mlmns eilzbe }
/ o jv.oEtraial
/ r aai.xenlzbe
pbi casUe ipeet Etraial {
ulc ls sr mlmns xenlzbe }
/ o (o.aecs.i.eilzto)DtSraial
/ r cmhzlatnosraiain.aaeilzbe
pbi casUe ipeet DtSraial {
ulc ls sr mlmns aaeilzbe }
/ o nwi Hzlat3(ut vrinspot Pral
/ r e n aecs
mli eso upr) otbe
pbi casUe ipeet Pral {
ulc ls sr mlmns otbe }
www.hazelcast.com
19. MAP
itraecmhzlatcr.MpK V
nefc o.aecs.oeIa<, >
etnsjv.tlMp jv.tlCnurnMp
xed aaui.a, aaui.ocreta
Hzlatntneh =gtaecsIsac(;
aecsIsac z
eHzlatntne)
Ia<tig Ue>hMp=h.eMp"sr";
MpSrn, sr za
zgta(ues)
hMppt"ee" nwUe(Ptr,"enjr);
za.u(Ptr, e sr"ee" Vete")
MpSrn,Ue>mp=h.eMp"sr";
a<tig sr a
zgta(ues)
mppt"ee" nwUe(Ptr,"enjr);
a.u(Ptr, e sr"ee" Vete")
CnurnMpSrn,Ue>cnurnMp=h.eMp"sr";
ocreta<tig sr ocreta
zgta(ues)
cnurnMpptfbet"ee" nwUe(Ptr,"enjr);
ocreta.uIAsn(Ptr, e sr"ee" Vete")
Ue ptr=mpgt"ee";
sr ee
a.e(Ptr)
www.hazelcast.com
23. LOCK (2/3)
Hzlatntneh =gtaecsIsac(;
aecsIsac z
eHzlatntne)
/ DsrbtdRetat
/ itiue enrn
Lc lc =h.eLc(mLc";
o
k k
o
zgtok"yok)
lc.ok)
o
klc(;
ty{
r
/ D smtig
/ o oehn
}fnly{
ial
lc.nok)
o
kulc(;
}
www.hazelcast.com
24. LOCK (3/3)
Hzlatntneh =gtaecsIsac(;
aecsIsac z
eHzlatntne)
/ Mp(o-lcs
/ a Rw)ok
Ia<tig Ue>mp=h.eMp"sr";
MpSrn, sr a
zgta(ues)
mplc(Ptr)
a.ok"ee";
ty{
r
/ D smtigwt Ptr
/ o oehn ih ee
}fnly{
ial
mpulc(Ptr)
a.nok"ee";
}
www.hazelcast.com
25. TOPIC / PUBSUB
pbi casEapeipeet MsaeitnrSrn>{
ulc ls xml mlmns esgLsee<tig
pbi vi snMsae{
ulc od edesg
Hzlatntneh =gtaecsIsac(;
aecsIsac z
eHzlatntne)
Ioi<tig tpc=h.eTpc"oi";
TpcSrn> oi
zgtoi(tpc)
tpcadesgLsee(hs;
oi.dMsaeitnrti)
tpcpbih"el Wrd)
oi.uls(Hlo ol";
}
@vrie
Oerd
pbi vi oMsaeMsaeSrn>msae {
ulc od nesg(esg<tig esg)
Sse.u.rnl(Gtmsae "+msaegtesgOjc()
ytmotpitn"o esg:
esg.eMsaebet);
}
}
www.hazelcast.com
28. ADVANCED TECHNIQUES
Indexing keys, values and value properties
Distributed SQL-like query
Write-Behind / Write-Through persistence
Read-Through (if key not loaded use MapLoader)
Transactions
EntryListeners / EntryProcessors
Automatic eviction
Control partitioning (Version 3.1)
and many more ...
www.hazelcast.com
31. DISTRIBUTED SQL-LIKE QUERIES
Ia<tig Ue>mp=Hzlatgta(ues)
MpSrn, sr a
aecs.eMp"sr";
Peiaepeiae=nwSlrdct(atv ADae< 3";
rdct rdct
e qPeiae"cie N g = 0)
StUe>ues=mpvle(rdct)
e<sr sr
a.auspeiae;
StEtySrn,Ue> etis=mpetye(rdct)
e<nr<tig sr> nre
a.nrStpeiae;
www.hazelcast.com
32. MAPLOADER / MAPSTORE
pbi casMptrg
ulc ls aSoae
ipeet Mptr<tig Ue> MpodrSrn,Ue>{
mlmns aSoeSrn, sr, aLae<tig sr
/ Sm mtosmsig..
/ oe ehd isn .
@vriepbi Ue la(tigky {rtr laVleBky;}
Oerd ulc sr odSrn e)
eun odauD(e)
@vriepbi StSrn>laAles){rtr laKyD(;}
Oerd ulc e<tig odlKy(
eun odesB)
@vriepbi vi dlt(tigky {dltD(e) }
Oerd ulc od eeeSrn e)
eeeBky;
@vriepbi vi soeSrn ky Ue vle {
Oerd ulc od tr(tig e, sr au)
soeoaaaeky vle;
trTDtbs(e, au)
}
}
<a nm=ues>
mp ae"sr"
<a-tr eald"re>
mpsoe nbe=tu"
<ls-aecmhzlateapeMptrg<casnm>
casnm>o.aecs.xml.aSoae/ls-ae
<rt-ea-eod><wiedlyscns
wiedlyscns0/rt-ea-eod>
<mpsoe
/a-tr>
<mp
/a>
www.hazelcast.com
33. TRANSACTION (1/2)
Hzlatntneh =gtaecsIsac(;
aecsIsac z
eHzlatntne)
fnlMpmp=h.eMp"eal";
ia a a
zgta(dfut)
fnlQeeqee=h.eQee"eal";
ia uu uu
zgtuu(dfut)
h.xctTascinnwTascinlakVi>){
zeeuernato(e rnatoaTs<od(
@vrie
Oerd
pbi Vi eeueTascinlakotx cnet {
ulc od xct(rnatoaTsCnet otx)
Tettet=(we)qeepl(;
we we
Tet uu.ol)
poeswe(we)
rcsTettet;
mpptbide(we) tet;
a.u(ulKytet, we)
rtr nl;
eun ul
}
};
)
www.hazelcast.com
34. TRANSACTION (2/2)
Hzlatntneh =gtaecsIsac(;
aecsIsac z
eHzlatntne)
Tascinotx cnet=h.eTascinotx(;
rnatoCnet otx
znwrnatoCnet)
cnetbgnrnato(;
otx.eiTascin)
Tascinla mp=cnetgta(dfut)
rnatoaMp a
otx.eMp"eal";
Tascinluu qee=cnetgtuu(dfut)
rnatoaQee uu
otx.eQee"eal";
ty{
r
Tettet=(we)qeepl(;
we we
Tet uu.ol)
poeswe(we)
rcsTettet;
mpptbide(we) tet;
a.u(ulKytet, we)
cnetcmiTascin)
otx.omtrnato(;
}cth(xeto e {
ac Ecpin )
cnetrlbcTascin)
otx.olakrnato(;
}
www.hazelcast.com
35. CONTROL PARTITIONING
Force location of corresponding data in the same partition
by providing a special partition key
Hzlatntneh =gtaecsIsac(;
aecsIsac z
eHzlatntne)
Mpues=h.eMp"sr";
a sr
zgta(ues)
uespt"ee@ee" nwUe(Ptr,"enjr);
sr.u(PtrPtr, e sr"ee" Vete")
Mpfins=h.eMp"red";
a red
zgta(fins)
finspt"ee-hi@ee" nwUe(Crsoh,"nebr")
red.u(PtrCrsPtr, e sr"hitp" Eglet);
finspt"ee-udPtr,nwUe(Fa" "aio")
red.u(PtrFa@ee" e sr"ud, Mlkv);
www.hazelcast.com
37. SPI (NEW IN HAZELCAST 3)
Possibility to build own distributed datastructures
Hook into datastructure events
Implement your own services (like RemoteInvocation,
MapReduce)
React on membership events
Manipulate migrations on your purpose
Handle splitbrain events
and many more ...
www.hazelcast.com