55
Riding Jet Streams @gAmUssA @hazelcast #jfokus #hazelcastjet http://bit.ly/streams_jfokus2017

[Jfokus] Riding the Jet Streams

Embed Size (px)

Citation preview

Page 1: [Jfokus] Riding the Jet Streams

RidingJet Streams

@gAmUssA @hazelcast #jfokus #hazelcastjet

http://bit.ly/streams_jfokus2017

Page 2: [Jfokus] Riding the Jet Streams

@gAmUssA @hazelcast #jfokus #hazelcastjet

Solutions Architect @Hazelcast

Developer Advocate @Hazelcast

@gamussa in internetz

Please, follow me on TwitterI’m very interesting ©

> whoami

Page 3: [Jfokus] Riding the Jet Streams

@gAmUssA @hazelcast #jfokus #hazelcastjet

AgendaQuick refresh on Java 8 StreamsDistribute and Conquer Distributed DataDistributed StreamsHow we did all this

Page 4: [Jfokus] Riding the Jet Streams

@gAmUssA @hazelcast #jfokus #hazelcastjet

Example: Word Count

Map<Integer, String> where keys are line numbers and values are lines.

Find how many times each word occurs

Page 5: [Jfokus] Riding the Jet Streams

@gAmUssA @hazelcast #jfokus #hazelcastjet

What needs to be done?

Iterate through all the linesSplit the line into wordsUpdate running total of counts with new word

Page 6: [Jfokus] Riding the Jet Streams

fillMapWithData("war_and_peace_eng.txt", source);

for (String line : source.values()) {for (String word : PATTERN.split(line)) {if (word.length() >= 5)count.compute(

cleanWord(word).toLowerCase(),(w, c) -> c == null ? 1 : c + 1

);}

}System.out.println(count.get("andrew"));

Iterate through all the lines

Page 7: [Jfokus] Riding the Jet Streams

fillMapWithData("war_and_peace_eng.txt", source);

for (String line : source.values()) {for (String word : PATTERN.split(line)) {if (word.length() >= 5)count.compute(

cleanWord(word).toLowerCase(),(w, c) -> c == null ? 1 : c + 1

);}

}System.out.println(count.get("andrew"));

Split the line into words

Page 8: [Jfokus] Riding the Jet Streams

fillMapWithData("war_and_peace_eng.txt", source);

for (String line : source.values()) {for (String word : PATTERN.split(line)) {if (word.length() >= 5)count.compute(

cleanWord(word).toLowerCase(),(w, c) -> c == null ? 1 : c + 1

);}

}System.out.println(count.get("andrew"));

Update running total of counts with new word

Page 9: [Jfokus] Riding the Jet Streams

fillMapWithData("war_and_peace_eng.txt", source);

for (String line : source.values()) {for (String word : PATTERN.split(line)) {if (word.length() >= 5)count.compute(

cleanWord(word).toLowerCase(),(w, c) -> c == null ? 1 : c + 1

);}

}System.out.println(count.get("andrew"));

Print the result

Page 10: [Jfokus] Riding the Jet Streams

java.util.stream

Page 11: [Jfokus] Riding the Jet Streams

@gAmUssA @hazelcast #jfokus #hazelcastjet

Java 8 Streams…An abstraction represents a sequence of elementsIs not a data structure Convey elements from a source through a pipeline of operationsOperation doesn’t modify a source

Page 12: [Jfokus] Riding the Jet Streams

@gAmUssA @hazelcast #jfokus #hazelcastjet

Why I should care about Stream API?

You’re Java developer

Page 13: [Jfokus] Riding the Jet Streams

What does regular Java developer think about Scala?

advanced

Page 14: [Jfokus] Riding the Jet Streams

@gAmUssA @hazelcast #jfokus #hazelcastjet

Why I should care about Stream API?

You’re Java developerMany Java developers know JavaIt’s all about data processing

Page 15: [Jfokus] Riding the Jet Streams

@gAmUssA @hazelcast #jfokus #hazelcastjet

java.util.stream

map(), flatMap(), filter()

reduce(), collect()

sorted(), distinct()

Intermediate operation

Terminal operation

Stateful Intermediate (Blocking) operation

Page 16: [Jfokus] Riding the Jet Streams
Page 17: [Jfokus] Riding the Jet Streams
Page 18: [Jfokus] Riding the Jet Streams
Page 19: [Jfokus] Riding the Jet Streams

@gAmUssA @hazelcast #jfokus #hazelcastjet

Why would one need a cluster?

One does not simply fit all Big Data in one machine

Page 20: [Jfokus] Riding the Jet Streams

@gAmUssA @hazelcast #jfokus #hazelcastjet

Problem

Data doesn’t fit just one machine

Page 21: [Jfokus] Riding the Jet Streams

@gAmUssA @hazelcast #jfokus #hazelcastjet

Why would one need a cluster?

One does not simply put all Big Datain one machineData is too important to have it only one machine

Page 22: [Jfokus] Riding the Jet Streams
Page 23: [Jfokus] Riding the Jet Streams
Page 24: [Jfokus] Riding the Jet Streams

Replication on Sharding?

http://book.mixu.net/distsys/single-page.html

Page 25: [Jfokus] Riding the Jet Streams

@gAmUssA @hazelcast #jfokus #hazelcastjet

Another RequirementsEasy to use Simple APIEmbeddableCloud Native

Page 26: [Jfokus] Riding the Jet Streams

@gAmUssA @hazelcast #jfokus #hazelcastjet

What’s Hazelcast IMDG?

In-memory Data Grid

Apache v2 Licensed

Distributed Caches (IMap, JCache)

Java Collections (IList, ISet, IQueue)

Messaging (Topic, RingBuffer)

Computation (ExecutorService, M-R)

Page 27: [Jfokus] Riding the Jet Streams

1 900 Stars On GitHub

100%Open Source

134 contributors

Page 28: [Jfokus] Riding the Jet Streams
Page 29: [Jfokus] Riding the Jet Streams
Page 30: [Jfokus] Riding the Jet Streams
Page 31: [Jfokus] Riding the Jet Streams

@gAmUssA @hazelcast #jfokus #hazelcastjet

GreenPrimary

GreenBackup

GreenShard

Page 32: [Jfokus] Riding the Jet Streams
Page 33: [Jfokus] Riding the Jet Streams

@gAmUssA @hazelcast #jfokus #hazelcastjet

What’s the problem?

Use IMap.values().stream() ?Or IMap.entrySet().stream() ?

33

Page 34: [Jfokus] Riding the Jet Streams

@gAmUssA @hazelcast #jfokus #hazelcastjet

Problem

Data doesn’t fit just one machine

Page 35: [Jfokus] Riding the Jet Streams
Page 36: [Jfokus] Riding the Jet Streams
Page 37: [Jfokus] Riding the Jet Streams

@gAmUssA @hazelcast #jfokus #hazelcastjet

EASY (actually, not)!

Implement serializable version of the interfacesIntroducing DistributedStream

37

Page 38: [Jfokus] Riding the Jet Streams

38

Page 39: [Jfokus] Riding the Jet Streams
Page 40: [Jfokus] Riding the Jet Streams

40

Jet Streams

Page 41: [Jfokus] Riding the Jet Streams

jet.hazelcast.org

Page 42: [Jfokus] Riding the Jet Streams

@gAmUssA @hazelcast #jfokus #hazelcastjet

What’s Hazelcast Jet?General purpose distributed data processing frameworkBased on Direct Acyclic Graph to model data flowBuilt on top of Hazelcast IMDGComparable to Apache Spark or Apache Flink

42

Page 43: [Jfokus] Riding the Jet Streams
Page 44: [Jfokus] Riding the Jet Streams

@gAmUssA @hazelcast #jfokus #hazelcastjet

DAG

vertex vertex

vertex vertex

SOURCE

SINK

Page 45: [Jfokus] Riding the Jet Streams
Page 46: [Jfokus] Riding the Jet Streams

BenchmarksCompared to Spark, Flink, Hadoop doing word count, running on a

cluster of 9 nodes, 40 cores each

Page 47: [Jfokus] Riding the Jet Streams
Page 48: [Jfokus] Riding the Jet Streams

@gAmUssA @hazelcast #jfokus #hazelcastjet

Future (It’s bright!)

Processing guarantees for stream processingStreaming features (windowing, triggering)Higher level streaming and batching APIsIntegration with additional Hazelcaststructures (ICache, IQueue ..)

Page 49: [Jfokus] Riding the Jet Streams

@gAmUssA @hazelcast #jfokus #hazelcastjet

Future (It’s bright!)

Event sourcing / CQRSOff-heap memory supportRxJavaMore connectors to additional sources (JMS, JDBC..)

Page 50: [Jfokus] Riding the Jet Streams

@gAmUssA @hazelcast #jfokus #hazelcastjet

Grab while it’s hot!

jet.hazelcast.org

hazelcast/hazelcast-jet

http://bit.ly/streams_jfokus2017

documentation

Source on Github

Presentation materials

Page 51: [Jfokus] Riding the Jet Streams

@gAmUssA @hazelcast #jfokus #hazelcastjet

ConclusionJava Stream API provides very white range of data processing toolsWar And Piece – is a Big (a lot of data) Book!Now we’re pretty sure that Andrew and Pierre are the main characters

Page 52: [Jfokus] Riding the Jet Streams
Page 53: [Jfokus] Riding the Jet Streams

SlidesCarnival icons are editable shapes.

This means that you can:● Resize them without losing quality.● Change fill color and opacity.

Isn’t that nice? :)

Examples:

Page 54: [Jfokus] Riding the Jet Streams

Now you can use any emoji as an icon!And of course it resizes without losing quality and you can change the color.

How? Follow Google instructions https://twitter.com/googledocs/status/730087240156643328

✋👆👉👍👤👦👧👨👩👪💃🏃💑❤😂

😉😋😒😭👶😸🐟🍒🍔💣📌📖🔨🎃🎈

🎨🏈🏰🌏🔌🔑 and many more...

😉

Page 55: [Jfokus] Riding the Jet Streams

@gAmUssA @hazelcast #jfokus #hazelcastjet

Extra graphics