lasp, goto chicago 2015 · gubbi, jayavardhana, et al. "internet of things (iot): a vision,...

134
Coordination-Free Computations Christopher Meiklejohn

Upload: others

Post on 04-Jul-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

Coordination-Free ComputationsChristopher Meiklejohn

Page 2: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

DISTRIBUTED, EVENTUALLY CONSISTENT COMPUTATIONS

LASP

2

CHRISTOPHER MEIKLEJOHN (BASHO TECHNOLOGIES, INC.) PETER VAN ROY (UNIVERSITÉ CATHOLIQUE DE LOUVAIN)

Page 3: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

LASP MOTIVATION

3

Page 4: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

EXPENSIVE / IMPRACTICALSYNCHRONIZATION IS

4

Page 5: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

MOBILE GAMES:SHARED STATE BETWEEN CLIENTS CLIENTS GO OFFLINE

5

http://www.rovio.com/en/news/blog/261/263-million-monthly-active-users-in-december/

Page 6: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

DISJOINT STATE AGGREGATED UPSTREAM CLIENTS GO OFFLINE

“INTERNET OF THINGS”:

6

Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7 (2013): 1645-1660.

Page 7: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

NO TOTAL ORDER:REPLICATED SHARED STATE WITH OFFLINE CLIENTS CLIENTS NEED TO MAKE PROGRESS

7

Gilbert, Seth, and Nancy Lynch. "Brewer's conjecture and the feasibility of consistent, available, partition-tolerant web services." ACM SIGACT News 33.2 (2002): 51-59.

Page 8: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

WALL CLOCKS:UNRELIABLE AT BEST NON-DETERMINISTIC IF USED IN COMPUTATIONS

8

Corbett, James C., et al. "Spanner: Google’s globally distributed database." ACM Transactions on Computer Systems (TOCS) 31.3 (2013): 8.

Page 9: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

RECONCILED BY USERCONCURRENCY

9

Page 10: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

RA

RB

1

3

2

?

?

set(1) set(2)

set(3)

10

Page 11: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

RA

RB

1

3

2

?

?

set(1) set(2)

set(3)

11

Page 12: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

RA

RB

1

3

2

?

?

set(1) set(2)

set(3)

12

Page 13: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

RA

RB

1

3

2

?

?

set(1) set(2)

set(3)

13

Page 14: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

CRDTs

14

Page 15: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

DETERMINISTIC RESOLUTIONCRDTs PROVIDE

15

Page 16: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

CRDTs:MAPS, SETS, COUNTERS, REGISTERS, GRAPHS DETERMINISTIC RESOLUTION

16

Page 17: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

“CORRECT REPLICAS THAT HAVE DELIVERED THE SAME UPDATES HAVE EQUIVALENT STATE”

Shapiro, Marc, et al. "Conflict-free replicated data types." Stabilization, Safety, and Security of Distributed Systems. Springer Berlin Heidelberg, 2011. 386-400.

MONOTONIC STRONG EVENTUAL CONSISTENCY

CRDTs REALIZE

17

Page 18: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

‘MAX’ REGISTERCRDTs EXAMPLE

18

Page 19: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

RA

RB

1

3

2

3

3

set(1) set(2)

set(3)

max(2,3)

max(2,3)

19

Page 20: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

‘ORSET’ SETCRDTs EXAMPLE

20

Page 21: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

RA

RB

RC

{1}

(1, {a}, {})

{1}

(1, {b}, {})

{}

(1, {b}, {b})

{1}

{1}

{1}

(1, {a, b}, {b})

(1, {a, b}, {b})

(1, {a, b}, {b})

add(1)

add(1) remove(1)

21

Page 22: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

RA

RB

RC

{1}

(1, {a}, {})

{1}

(1, {b}, {})

{}

(1, {b}, {b})

{1}

{1}

{1}

(1, {a, b}, {b})

(1, {a, b}, {b})

(1, {a, b}, {b})

add(1)

add(1) remove(1)

22

Page 23: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

RA

RB

RC

{1}

(1, {a}, {})

{1}

(1, {b}, {})

{}

(1, {b}, {b})

{1}

{1}

{1}

(1, {a, b}, {b})

(1, {a, b}, {b})

(1, {a, b}, {b})

add(1)

add(1) remove(1)

23

Page 24: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

RA

RB

RC

{1}

(1, {a}, {})

{1}

(1, {b}, {})

{}

(1, {b}, {b})

{1}

{1}

{1}

(1, {a, b}, {b})

(1, {a, b}, {b})

(1, {a, b}, {b})

add(1)

add(1) remove(1)

24

Page 25: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

FRAGMENTS & PROGRAMS

25

Page 26: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

{1,2,3}

{3,4,5}

26

Page 27: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

{1,2,3}

{3,4,5}

Intersection {3}

27

Page 28: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

{1,2,3}

{3,4,5}

Intersection {3} Map {9}

28

Page 29: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

{1,2,3}

{3,4,5}

Intersection {3} Map {9}

29

Page 30: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

{1,2,3}

{3,4,5}

Intersection {3} Map {9}

30

Page 31: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

{1,2,3}

{3,4,5}

Intersection {3} Map {9}

31

Page 32: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

{1,2,3}

{3,4,5}

Intersection {3} Map {9}

{1,2,3}

{3,4,5}

Intersection {3} Map {9}

32

Page 33: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

{1,2,3}

{3,4,5}

Intersection {3} Map {9}

{1,2,3}

{3,4,5}

Intersection {3} Map {9}

33

Page 34: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

{1,2,3}

{3,4,5}

Intersection {3} Map {9}

{1,2,3}

{3,4,5}

Intersection {3} Map {9}

34

Page 35: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

NONTRIVIALFUNCTION APPLICATION AND DATA COMPOSITION IS

35

Page 36: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

RA

RB

RC

{1}

(1, {a}, {})

{1}

(1, {b}, {})

{}

(1, {b}, {b})

{1}

{1}

{1}

(1, {a, b}, {b})

(1, {a, b}, {b})

(1, {a, b}, {b})

add(1)

add(1) remove(1)

F(RC) {2}

fun(X) -> 2 end

{2} {}

36

Page 37: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

RA

RC

{1}

(1, {a}, {})

{1}

(1, {b}, {})

{}

(1, {b}, {b})

{1}

{1}

(1, {a, b}, {b})

(1, {a, b}, {b})

add(1)

add(1) remove(1)

F(RC) {2}

fun(X) -> 2 end

{2} {}

F(RA) {2}

fun(X) -> 2 end

{2} {2} {2}

37

Page 38: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

RA

RC

{1}

(1, {a}, {})

{1}

(1, {b}, {})

{}

(1, {b}, {b})

{1}

{1}

(1, {a, b}, {b})

(1, {a, b}, {b})

add(1)

add(1) remove(1)

F(RC) {2}

fun(X) -> 2 end

{2} {}

F(RA) {2}

fun(X) -> 2 end

{2} {2} {2}

38

Page 39: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

RA

RC

{1}

(1, {a}, {})

{1}

(1, {b}, {})

{}

(1, {b}, {b})

{1}

{1}

(1, {a, b}, {b})

(1, {a, b}, {b})

add(1)

add(1) remove(1)

F(RC) {2}

fun(X) -> 2 end

{2} {}

F(RA) {2}

fun(X) -> 2 end

{2} {2} {2}

39

Page 40: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

RA

RC

{1}

(1, {a}, {})

{1}

(1, {b}, {})

{}

(1, {b}, {b})

{1}

{1}

(1, {a, b}, {b})

(1, {a, b}, {b})

add(1)

add(1) remove(1)

F(RC) {2}

fun(X) -> 2 end

{2} {}

F(RA) {2}

fun(X) -> 2 end

{2} {2} {2}

40

Page 41: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

COMPOSITION:USER OBSERVABLE VALUE VS. STATE METADATA MAPPING IS NONTRIVIAL WITHOUT MAPPING METADATA; UNMERGABLE

41

Brown, Russell, et al. "Riak dt map: A composable, convergent replicated dictionary." Proceedings of the First Workshop on Principles and Practice of Eventual Consistency. ACM, 2014. Conway, Neil, et al. "Logic and lattices for distributed programming." Proceedings of the Third ACM Symposium on Cloud Computing. ACM, 2012. Meiklejohn, Christopher. "On the composability of the Riak DT map: expanding from embedded to multi-key structures." Proceedings of the First Workshop on Principles and Practice of Eventual Consistency. ACM, 2014.

Page 42: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

LASP LANGUAGE

42

Page 43: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

LASP:DISTRIBUTED RUNTIME IMPLEMENTED AS ERLANG LIBRARY USES RIAK-CORE

43

Page 44: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

LASP:CRDTS AS STREAMS OF STATE CHANGES CRDTS CONNECTED BY MONOTONIC PROCESSES MANY TO ONE MAPPING OF CRDTS

44

Page 45: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

PRIMITIVE OPERATIONS:MONOTONIC READ, UPDATE FUNCTIONAL: MAP, FILTER, FOLD SET-THEORETIC: PRODUCT, UNION, INTERSECTION LIFTED TO OPERATE OVER METADATA

45

Page 46: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

MAPEXAMPLE

46

Page 47: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

RA

RB

RC

{1}

(1, {a}, {})

{1}

(1, {b}, {})

{}

(1, {b}, {b})

{1}

{1}

{1}

(1, {a, b}, {b})

(1, {a, b}, {b})

(1, {a, b}, {b})

add(1)

add(1) remove(1)

F(RB) {2}

fun(X) -> 2 end

{2} {}

(2, {b}, {}) (2, {b}, {b})

{}

(2, {a, b}, {b}) (2, {a, b}, {b})

F(RC) {2}

fun(X) -> 2 end

(2, {a, b}, {b})

{2} {} {2}

(2, {b}, {}) (2, {b}, {b}) (2, {a, b}, {b})

F(RA) {2}

fun(X) -> 2 end

(2, {a, b}, {b})

{2} {2} {2}

(2, {a}, {}) (2, {a, b}, {}) (2, {a, b}, {b})

47

Page 48: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

RA

RB

RC

{1}

(1, {a}, {})

{1}

(1, {b}, {})

{}

(1, {b}, {b})

{1}

{1}

{1}

(1, {a, b}, {b})

(1, {a, b}, {b})

(1, {a, b}, {b})

add(1)

add(1) remove(1)

F(RB) {2}

fun(X) -> 2 end

{2} {}

(2, {b}, {}) (2, {b}, {b})

{}

(2, {a, b}, {b}) (2, {a, b}, {b})

F(RC) {2}

fun(X) -> 2 end

(2, {a, b}, {b})

{2} {} {2}

(2, {b}, {}) (2, {b}, {b}) (2, {a, b}, {b})

F(RA) {2}

fun(X) -> 2 end

(2, {a, b}, {b})

{2} {2} {2}

(2, {a}, {}) (2, {a, b}, {}) (2, {a, b}, {b})

48

Page 49: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

RA

RB

RC

{1}

(1, {a}, {})

{1}

(1, {b}, {})

{}

(1, {b}, {b})

{1}

{1}

{1}

(1, {a, b}, {b})

(1, {a, b}, {b})

(1, {a, b}, {b})

add(1)

add(1) remove(1)

F(RB) {2}

fun(X) -> 2 end

{2} {}

(2, {b}, {}) (2, {b}, {b})

{}

(2, {a, b}, {b}) (2, {a, b}, {b})

F(RC) {2}

fun(X) -> 2 end

(2, {a, b}, {b})

{2} {} {2}

(2, {b}, {}) (2, {b}, {b}) (2, {a, b}, {b})

F(RA) {2}

fun(X) -> 2 end

(2, {a, b}, {b})

{2} {2} {2}

(2, {a}, {}) (2, {a, b}, {}) (2, {a, b}, {b})

49

Page 50: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

RA

RB

RC

{1}

(1, {a}, {})

{1}

(1, {b}, {})

{}

(1, {b}, {b})

{1}

{1}

{1}

(1, {a, b}, {b})

(1, {a, b}, {b})

(1, {a, b}, {b})

add(1)

add(1) remove(1)

F(RB) {2}

fun(X) -> 2 end

{2} {}

(2, {b}, {}) (2, {b}, {b})

{}

(2, {a, b}, {b}) (2, {a, b}, {b})

F(RC) {2}

fun(X) -> 2 end

(2, {a, b}, {b})

{2} {} {2}

(2, {b}, {}) (2, {b}, {b}) (2, {a, b}, {b})

F(RA) {2}

fun(X) -> 2 end

(2, {a, b}, {b})

{2} {2} {2}

(2, {a}, {}) (2, {a, b}, {}) (2, {a, b}, {b})

50

Page 51: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

ARCHITECTURE

51

Page 52: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

SHARED VARIABLE STORELASP STORE

52

Page 53: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

LEVELDB, BITCASK, ETSLASP BACKENDS

53

Page 54: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

PROVIDED BY RIAK DTLASP CRDTs

54

Page 55: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

CENTRALIZED SEMANTICSLASP ARCHITECTURE

55

Page 56: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

STORE:SHARED VARIABLE STORE PROCESSESS SYNCHRONIZE ON VARIABLES

56

Page 57: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

DISTRIBUTED SEMANTICSLASP ARCHITECTURE

57

Page 58: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

STORE:REPLICATED, SHARDED VARIABLE STORE PROCESSESS SYNCHRONIZE ON VARIABLES

58

Page 59: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

REPLICATED:DISTRIBUTED WITH RIAK CORE QUORUM REQUESTS; ANTI-ENTROPY PROTOCOL

59

Page 60: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

HYBRID:DISTRIBUTE PROGRAMS; R/W WITH LOCAL STORE CENTRALIZED EXECUTION

60

Page 61: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

EXAMPLES

61

Page 62: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

%% Create initial set. {ok, S1} = lasp:declare(Type),

%% Add elements to initial set and update. {ok, _} = lasp:update(S1, {add_all, [1,2,3]}, a),

%% Create second set. {ok, S2} = lasp:declare(Type),

%% Apply map. ok = lasp:map(S1, fun(X) -> X * 2 end, S2),

Page 63: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

%% Create initial set. {ok, S1} = lasp_core:declare(Type, Store),

%% Add elements to initial set and update. {ok, _} = lasp_core:update(S1, {add_all, [1,2,3]}, a, Store),

%% Create second set. {ok, S2} = lasp_core:declare(Type, Store),

%% Apply map. ok = lasp_core:map(S1, fun(X) -> X * 2 end, S2, Store),

Page 64: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

AD COUNTER

64

Page 65: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

AD COUNTER:TRACKS AD IMPRESSIONS PUSHES ADVERTISEMENTS TO THE CLIENT DISABLES AD AT 50,000+ IMPRESSIONS CLIENTS DISPLAY ADS WHEN OFFLINE

65

Page 66: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

INFORMATION FLOWAD COUNTER

66

Page 67: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

Ads

Rovio Ad Counter

Rovio Ad Counter

Riot Ad Counter

Riot Ad Counter

Contracts

AdsContracts

AdsWith

Contracts

Riot Ads

Rovio Ads

FilterProduct

Read � 50,000

Remove

Increment

Read

Union

Lasp Operation

User-Maintained CRDT

Lasp-Maintained CRDT

Counter1 Counter2 Counter3

Counter1 Counter2 Counter3

Counter1 Counter2 Counter3

Counter1 Counter2 Counter3

67

Page 68: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

Ads

Rovio Ad Counter

Rovio Ad Counter

Riot Ad Counter

Riot Ad Counter

Contracts

AdsContracts

AdsWith

Contracts

Riot Ads

Rovio Ads

FilterProduct

Read � 50,000

Remove

Increment

Read

Union

Lasp Operation

User-Maintained CRDT

Lasp-Maintained CRDT

Counter1 Counter2 Counter3

Counter1 Counter2 Counter3

Counter1 Counter2 Counter3

Counter1 Counter2 Counter3

68

Page 69: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

Ads

Rovio Ad Counter

Rovio Ad Counter

Riot Ad Counter

Riot Ad Counter

Contracts

AdsContracts

AdsWith

Contracts

Riot Ads

Rovio Ads

FilterProduct

Read � 50,000

Remove

Increment

Read

Union

Lasp Operation

User-Maintained CRDT

Lasp-Maintained CRDT

Counter1 Counter2 Counter3

Counter1 Counter2 Counter3

Counter1 Counter2 Counter3

Counter1 Counter2 Counter3

69

Page 70: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

Ads

Rovio Ad Counter

Rovio Ad Counter

Riot Ad Counter

Riot Ad Counter

Contracts

AdsContracts

AdsWith

Contracts

Riot Ads

Rovio Ads

FilterProduct

Read � 50,000

Remove

Increment

Read

Union

Lasp Operation

User-Maintained CRDT

Lasp-Maintained CRDT

Counter1 Counter2 Counter3

Counter1 Counter2 Counter3

Counter1 Counter2 Counter3

Counter1 Counter2 Counter3

70

Page 71: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

Ads

Rovio Ad Counter

Rovio Ad Counter

Riot Ad Counter

Riot Ad Counter

Contracts

AdsContracts

AdsWith

Contracts

Riot Ads

Rovio Ads

FilterProduct

Read � 50,000

Remove

Increment

Read

Union

Lasp Operation

User-Maintained CRDT

Lasp-Maintained CRDT

Counter1 Counter2 Counter3

Counter1 Counter2 Counter3

Counter1 Counter2 Counter3

Counter1 Counter2 Counter3

71

Page 72: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

Ads

Rovio Ad Counter

Rovio Ad Counter

Riot Ad Counter

Riot Ad Counter

Contracts

AdsContracts

AdsWith

Contracts

Riot Ads

Rovio Ads

FilterProduct

Read � 50,000

Remove

Increment

Read

Union

Lasp Operation

User-Maintained CRDT

Lasp-Maintained CRDT

Counter1 Counter2 Counter3

Counter1 Counter2 Counter3

Counter1 Counter2 Counter3

Counter1 Counter2 Counter3

72

Page 73: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

Ads

Rovio Ad Counter

Rovio Ad Counter

Riot Ad Counter

Riot Ad Counter

Contracts

AdsContracts

AdsWith

Contracts

Riot Ads

Rovio Ads

FilterProduct

Read � 50,000

Remove

Increment

Read

Union

Lasp Operation

User-Maintained CRDT

Lasp-Maintained CRDT

Counter1 Counter2 Counter3

Counter1 Counter2 Counter3

Counter1 Counter2 Counter3

Counter1 Counter2 Counter3

73

Page 74: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

Ads

Rovio Ad Counter

Rovio Ad Counter

Riot Ad Counter

Riot Ad Counter

Contracts

AdsContracts

AdsWith

Contracts

Riot Ads

Rovio Ads

FilterProduct

Read � 50,000

Remove

Increment

Read

Union

Lasp Operation

User-Maintained CRDT

Lasp-Maintained CRDT

Counter1 Counter2 Counter3

Counter1 Counter2 Counter3

Counter1 Counter2 Counter3

Counter1 Counter2 Counter3

74

Page 75: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

Ads

Rovio Ad Counter

Rovio Ad Counter

Riot Ad Counter

Riot Ad Counter

Contracts

AdsContracts

AdsWith

Contracts

Riot Ads

Rovio Ads

FilterProduct

Read � 50,000

Remove

Increment

Read

Union

Lasp Operation

User-Maintained CRDT

Lasp-Maintained CRDT

Counter1 Counter2 Counter3

Counter1 Counter2 Counter3

Counter1 Counter2 Counter3

Counter1 Counter2 Counter3

75

Page 76: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

INFORMATION FLOW:MONOTONIC METADATA TO PREVENT DUPLICATE PROPAGATION

76

Page 77: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

EXAMPLE CODEAD COUNTER

77

Page 78: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

%% @doc Client process; standard recursive looping server. client(Id, AdsWithContracts, PreviousValue) -> receive view_ad -> %% Get current ad list. {ok, {_, _, AdList0}} = lasp:read(AdsWithContracts, PreviousValue), AdList = riak_dt_orset:value(AdList0),

case length(AdList) of 0 -> %% No advertisements left to display; ignore %% message. client(Id, AdsWithContracts, AdList0); _ -> %% Select a random advertisement from the list of %% active advertisements. {#ad{counter=Ad}, _} = lists:nth( random:uniform(length(AdList)), AdList),

%% Increment it. {ok, _} = lasp:update(Ad, increment, Id), lager:info("Incremented ad counter: ~p", [Ad]),

client(Id, AdsWithContracts, AdList0) end end.

Page 79: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

%% @doc Server functions for the advertisement counter. After 5 views, %% disable the advertisement. %% server({#ad{counter=Counter}=Ad, _}, Ads) -> %% Blocking threshold read for 5 advertisement impressions. {ok, _} = lasp:read(Counter, 5),

%% Remove the advertisement. {ok, _} = lasp:update(Ads, {remove, Ad}, Ad),

lager:info("Removing ad: ~p", [Ad]).

Page 80: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

%% Generate a series of unique identifiers. RovioAdIds = lists:map(fun(_) -> druuid:v4() end, lists:seq(1, 10)), lager:info("Rovio Ad Identifiers are: ~p", [RovioAdIds]),

TriforkAdIds = lists:map(fun(_) -> druuid:v4() end, lists:seq(1, 10)), lager:info("Trifork Ad Identifiers are: ~p", [TriforkAdIds]),

Ids = RovioAdIds ++ TriforkAdIds, lager:info("Ad Identifiers are: ~p", [Ids]),

%% Generate Rovio's advertisements. {ok, RovioAds} = lasp:declare(?SET), lists:map(fun(Id) -> %% Generate a G-Counter. {ok, CounterId} = lasp:declare(?COUNTER), %% Add it to the advertisement set. {ok, _} = lasp:update(RovioAds, {add, #ad{id=Id, counter=CounterId}}, undefined)

end, RovioAdIds),

%% Generate Trifork's advertisements. {ok, TriforkAds} = lasp:declare(?SET), lists:map(fun(Id) -> %% Generate a G-Counter. {ok, CounterId} = lasp:declare(?COUNTER), %% Add it to the advertisement set. {ok, _} = lasp:update(TriforkAds, {add, #ad{id=Id, counter=CounterId}}, undefined)

end, TriforkAdIds),

%% Union ads. {ok, Ads} = lasp:declare(?SET), ok = lasp:union(RovioAds, TriforkAds, Ads),

%% For each identifier, generate a contract. {ok, Contracts} = lasp:declare(?SET), lists:map(fun(Id) -> {ok, _} = lasp:update(Contracts, {add, #contract{id=Id}}, undefined) end, Ids),

%% Compute the Cartesian product of both ads and contracts. {ok, AdsContracts} = lasp:declare(?SET), ok = lasp:product(Ads, Contracts, AdsContracts),

%% Filter items by join on item it. {ok, AdsWithContracts} = lasp:declare(?SET), FilterFun = fun({#ad{id=Id1}, #contract{id=Id2}}) -> Id1 =:= Id2 end, ok = lasp:filter(AdsContracts, FilterFun, AdsWithContracts),

%% Launch a series of client processes, each of which is responsible %% for displaying a particular advertisement.

%% Generate a OR-set for tracking clients. {ok, Clients} = lasp:declare(?SET),

%% Each client takes the full list of ads when it starts, and reads %% from the variable store. lists:map(fun(Id) -> ClientPid = spawn_link(?MODULE, client, [Id, AdsWithContracts, undefined]), {ok, _} = lasp:update(Clients, {add, ClientPid}, undefined) end, lists:seq(1,5)),

%% Launch a server process for each advertisement, which will block %% until the advertisement should be disabled.

%% Create a OR-set for the server list. {ok, Servers} = lasp:declare(?SET),

%% Get the current advertisement list. {ok, {_, _, AdList0}} = lasp:read(AdsWithContracts), AdList = riak_dt_orset:value(AdList0),

%% For each advertisement, launch one server for tracking it's %% impressions and wait to disable. lists:map(fun(Ad) -> ServerPid = spawn_link(?MODULE, server, [Ad, Ads]), {ok, _} = lasp:update(Servers, {add, ServerPid}, undefined) end, AdList),

Page 81: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

%% Generate a series of unique identifiers. RovioAdIds = lists:map(fun(_) -> druuid:v4() end, lists:seq(1, 10)), lager:info("Rovio Ad Identifiers are: ~p", [RovioAdIds]),

TriforkAdIds = lists:map(fun(_) -> druuid:v4() end, lists:seq(1, 10)), lager:info("Trifork Ad Identifiers are: ~p", [TriforkAdIds]),

Ids = RovioAdIds ++ TriforkAdIds, lager:info("Ad Identifiers are: ~p", [Ids]),

%% Generate Rovio's advertisements. {ok, RovioAds} = lasp:declare(?SET), lists:map(fun(Id) -> %% Generate a G-Counter. {ok, CounterId} = lasp:declare(?COUNTER), %% Add it to the advertisement set. {ok, _} = lasp:update(RovioAds, {add, #ad{id=Id, counter=CounterId}}, undefined)

end, RovioAdIds),

%% Generate Trifork's advertisements. {ok, TriforkAds} = lasp:declare(?SET), lists:map(fun(Id) -> %% Generate a G-Counter. {ok, CounterId} = lasp:declare(?COUNTER), %% Add it to the advertisement set. {ok, _} = lasp:update(TriforkAds, {add, #ad{id=Id, counter=CounterId}}, undefined)

end, TriforkAdIds),

%% Union ads. {ok, Ads} = lasp:declare(?SET), ok = lasp:union(RovioAds, TriforkAds, Ads),

%% For each identifier, generate a contract. {ok, Contracts} = lasp:declare(?SET), lists:map(fun(Id) -> {ok, _} = lasp:update(Contracts, {add, #contract{id=Id}}, undefined) end, Ids),

%% Compute the Cartesian product of both ads and contracts. {ok, AdsContracts} = lasp:declare(?SET), ok = lasp:product(Ads, Contracts, AdsContracts),

%% Filter items by join on item it. {ok, AdsWithContracts} = lasp:declare(?SET), FilterFun = fun({#ad{id=Id1}, #contract{id=Id2}}) -> Id1 =:= Id2 end, ok = lasp:filter(AdsContracts, FilterFun, AdsWithContracts),

%% Launch a series of client processes, each of which is responsible %% for displaying a particular advertisement.

%% Generate a OR-set for tracking clients. {ok, Clients} = lasp:declare(?SET),

%% Each client takes the full list of ads when it starts, and reads %% from the variable store. lists:map(fun(Id) -> ClientPid = spawn_link(?MODULE, client, [Id, AdsWithContracts, undefined]), {ok, _} = lasp:update(Clients, {add, ClientPid}, undefined) end, lists:seq(1,5)),

%% Launch a server process for each advertisement, which will block %% until the advertisement should be disabled.

%% Create a OR-set for the server list. {ok, Servers} = lasp:declare(?SET),

%% Get the current advertisement list. {ok, {_, _, AdList0}} = lasp:read(AdsWithContracts), AdList = riak_dt_orset:value(AdList0),

%% For each advertisement, launch one server for tracking it's %% impressions and wait to disable. lists:map(fun(Ad) -> ServerPid = spawn_link(?MODULE, server, [Ad, Ads]), {ok, _} = lasp:update(Servers, {add, ServerPid}, undefined) end, AdList),

Page 82: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

%% Generate a series of unique identifiers. RovioAdIds = lists:map(fun(_) -> druuid:v4() end, lists:seq(1, 10)), lager:info("Rovio Ad Identifiers are: ~p", [RovioAdIds]),

TriforkAdIds = lists:map(fun(_) -> druuid:v4() end, lists:seq(1, 10)), lager:info("Trifork Ad Identifiers are: ~p", [TriforkAdIds]),

Ids = RovioAdIds ++ TriforkAdIds, lager:info("Ad Identifiers are: ~p", [Ids]),

%% Generate Rovio's advertisements. {ok, RovioAds} = lasp:declare(?SET), lists:map(fun(Id) -> %% Generate a G-Counter. {ok, CounterId} = lasp:declare(?COUNTER), %% Add it to the advertisement set. {ok, _} = lasp:update(RovioAds, {add, #ad{id=Id, counter=CounterId}}, undefined)

end, RovioAdIds),

%% Generate Trifork's advertisements. {ok, TriforkAds} = lasp:declare(?SET), lists:map(fun(Id) -> %% Generate a G-Counter. {ok, CounterId} = lasp:declare(?COUNTER), %% Add it to the advertisement set. {ok, _} = lasp:update(TriforkAds, {add, #ad{id=Id, counter=CounterId}}, undefined)

end, TriforkAdIds),

%% Union ads. {ok, Ads} = lasp:declare(?SET), ok = lasp:union(RovioAds, TriforkAds, Ads),

%% For each identifier, generate a contract. {ok, Contracts} = lasp:declare(?SET), lists:map(fun(Id) -> {ok, _} = lasp:update(Contracts, {add, #contract{id=Id}}, undefined) end, Ids),

%% Compute the Cartesian product of both ads and contracts. {ok, AdsContracts} = lasp:declare(?SET), ok = lasp:product(Ads, Contracts, AdsContracts),

%% Filter items by join on item it. {ok, AdsWithContracts} = lasp:declare(?SET), FilterFun = fun({#ad{id=Id1}, #contract{id=Id2}}) -> Id1 =:= Id2 end, ok = lasp:filter(AdsContracts, FilterFun, AdsWithContracts),

%% Launch a series of client processes, each of which is responsible %% for displaying a particular advertisement.

%% Generate a OR-set for tracking clients. {ok, Clients} = lasp:declare(?SET),

%% Each client takes the full list of ads when it starts, and reads %% from the variable store. lists:map(fun(Id) -> ClientPid = spawn_link(?MODULE, client, [Id, AdsWithContracts, undefined]), {ok, _} = lasp:update(Clients, {add, ClientPid}, undefined) end, lists:seq(1,5)),

%% Launch a server process for each advertisement, which will block %% until the advertisement should be disabled.

%% Create a OR-set for the server list. {ok, Servers} = lasp:declare(?SET),

%% Get the current advertisement list. {ok, {_, _, AdList0}} = lasp:read(AdsWithContracts), AdList = riak_dt_orset:value(AdList0),

%% For each advertisement, launch one server for tracking it's %% impressions and wait to disable. lists:map(fun(Ad) -> ServerPid = spawn_link(?MODULE, server, [Ad, Ads]), {ok, _} = lasp:update(Servers, {add, ServerPid}, undefined) end, AdList),

Page 83: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

%% Generate a series of unique identifiers. RovioAdIds = lists:map(fun(_) -> druuid:v4() end, lists:seq(1, 10)), lager:info("Rovio Ad Identifiers are: ~p", [RovioAdIds]),

TriforkAdIds = lists:map(fun(_) -> druuid:v4() end, lists:seq(1, 10)), lager:info("Trifork Ad Identifiers are: ~p", [TriforkAdIds]),

Ids = RovioAdIds ++ TriforkAdIds, lager:info("Ad Identifiers are: ~p", [Ids]),

%% Generate Rovio's advertisements. {ok, RovioAds} = lasp:declare(?SET), lists:map(fun(Id) -> %% Generate a G-Counter. {ok, CounterId} = lasp:declare(?COUNTER), %% Add it to the advertisement set. {ok, _} = lasp:update(RovioAds, {add, #ad{id=Id, counter=CounterId}}, undefined)

end, RovioAdIds),

%% Generate Trifork's advertisements. {ok, TriforkAds} = lasp:declare(?SET), lists:map(fun(Id) -> %% Generate a G-Counter. {ok, CounterId} = lasp:declare(?COUNTER), %% Add it to the advertisement set. {ok, _} = lasp:update(TriforkAds, {add, #ad{id=Id, counter=CounterId}}, undefined)

end, TriforkAdIds),

%% Union ads. {ok, Ads} = lasp:declare(?SET), ok = lasp:union(RovioAds, TriforkAds, Ads),

%% For each identifier, generate a contract. {ok, Contracts} = lasp:declare(?SET), lists:map(fun(Id) -> {ok, _} = lasp:update(Contracts, {add, #contract{id=Id}}, undefined) end, Ids),

%% Compute the Cartesian product of both ads and contracts. {ok, AdsContracts} = lasp:declare(?SET), ok = lasp:product(Ads, Contracts, AdsContracts),

%% Filter items by join on item it. {ok, AdsWithContracts} = lasp:declare(?SET), FilterFun = fun({#ad{id=Id1}, #contract{id=Id2}}) -> Id1 =:= Id2 end, ok = lasp:filter(AdsContracts, FilterFun, AdsWithContracts),

%% Launch a series of client processes, each of which is responsible %% for displaying a particular advertisement.

%% Generate a OR-set for tracking clients. {ok, Clients} = lasp:declare(?SET),

%% Each client takes the full list of ads when it starts, and reads %% from the variable store. lists:map(fun(Id) -> ClientPid = spawn_link(?MODULE, client, [Id, AdsWithContracts, undefined]), {ok, _} = lasp:update(Clients, {add, ClientPid}, undefined) end, lists:seq(1,5)),

%% Launch a server process for each advertisement, which will block %% until the advertisement should be disabled.

%% Create a OR-set for the server list. {ok, Servers} = lasp:declare(?SET),

%% Get the current advertisement list. {ok, {_, _, AdList0}} = lasp:read(AdsWithContracts), AdList = riak_dt_orset:value(AdList0),

%% For each advertisement, launch one server for tracking it's %% impressions and wait to disable. lists:map(fun(Ad) -> ServerPid = spawn_link(?MODULE, server, [Ad, Ads]), {ok, _} = lasp:update(Servers, {add, ServerPid}, undefined) end, AdList),

Page 84: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

%% Generate a series of unique identifiers. RovioAdIds = lists:map(fun(_) -> druuid:v4() end, lists:seq(1, 10)), lager:info("Rovio Ad Identifiers are: ~p", [RovioAdIds]),

TriforkAdIds = lists:map(fun(_) -> druuid:v4() end, lists:seq(1, 10)), lager:info("Trifork Ad Identifiers are: ~p", [TriforkAdIds]),

Ids = RovioAdIds ++ TriforkAdIds, lager:info("Ad Identifiers are: ~p", [Ids]),

%% Generate Rovio's advertisements. {ok, RovioAds} = lasp:declare(?SET), lists:map(fun(Id) -> %% Generate a G-Counter. {ok, CounterId} = lasp:declare(?COUNTER), %% Add it to the advertisement set. {ok, _} = lasp:update(RovioAds, {add, #ad{id=Id, counter=CounterId}}, undefined)

end, RovioAdIds),

%% Generate Trifork's advertisements. {ok, TriforkAds} = lasp:declare(?SET), lists:map(fun(Id) -> %% Generate a G-Counter. {ok, CounterId} = lasp:declare(?COUNTER), %% Add it to the advertisement set. {ok, _} = lasp:update(TriforkAds, {add, #ad{id=Id, counter=CounterId}}, undefined)

end, TriforkAdIds),

%% Union ads. {ok, Ads} = lasp:declare(?SET), ok = lasp:union(RovioAds, TriforkAds, Ads),

%% For each identifier, generate a contract. {ok, Contracts} = lasp:declare(?SET), lists:map(fun(Id) -> {ok, _} = lasp:update(Contracts, {add, #contract{id=Id}}, undefined) end, Ids),

%% Compute the Cartesian product of both ads and contracts. {ok, AdsContracts} = lasp:declare(?SET), ok = lasp:product(Ads, Contracts, AdsContracts),

%% Filter items by join on item it. {ok, AdsWithContracts} = lasp:declare(?SET), FilterFun = fun({#ad{id=Id1}, #contract{id=Id2}}) -> Id1 =:= Id2 end, ok = lasp:filter(AdsContracts, FilterFun, AdsWithContracts),

%% Launch a series of client processes, each of which is responsible %% for displaying a particular advertisement.

%% Generate a OR-set for tracking clients. {ok, Clients} = lasp:declare(?SET),

%% Each client takes the full list of ads when it starts, and reads %% from the variable store. lists:map(fun(Id) -> ClientPid = spawn_link(?MODULE, client, [Id, AdsWithContracts, undefined]), {ok, _} = lasp:update(Clients, {add, ClientPid}, undefined) end, lists:seq(1,5)),

%% Launch a server process for each advertisement, which will block %% until the advertisement should be disabled.

%% Create a OR-set for the server list. {ok, Servers} = lasp:declare(?SET),

%% Get the current advertisement list. {ok, {_, _, AdList0}} = lasp:read(AdsWithContracts), AdList = riak_dt_orset:value(AdList0),

%% For each advertisement, launch one server for tracking it's %% impressions and wait to disable. lists:map(fun(Ad) -> ServerPid = spawn_link(?MODULE, server, [Ad, Ads]), {ok, _} = lasp:update(Servers, {add, ServerPid}, undefined) end, AdList),

Page 85: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

DISTRIBUTIONAD COUNTER

85

Page 86: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

Ads

Rovio Ad Counter

Rovio Ad Counter

Riot Ad Counter

Riot Ad Counter

Contracts

AdsContracts

AdsWith

Contracts

Riot Ads

Rovio Ads

FilterProduct

Read � 50,000

Remove

Increment

Read

Union

Lasp Operation

User-Maintained CRDT

Lasp-Maintained CRDT

Counter1 Counter2 Counter3

Counter1 Counter2 Counter3

Counter1 Counter2 Counter3

Counter1 Counter2 Counter3

86

Page 87: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

Ads

Rovio Ad Counter

Rovio Ad Counter

Riot Ad Counter

Riot Ad Counter

Contracts

AdsContracts

AdsWith

Contracts

Riot Ads

Rovio Ads

FilterProduct

Read � 50,000

Remove

Increment

Read

Union

Lasp Operation

User-Maintained CRDT

Lasp-Maintained CRDT

Counter1 Counter2 Counter3

Counter1 Counter2 Counter3

Counter1 Counter2 Counter3

Counter1 Counter2 Counter3

87

Page 88: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

Ads

Rovio Ad Counter

Rovio Ad Counter

Riot Ad Counter

Riot Ad Counter

Contracts

AdsContracts

AdsWith

Contracts

Riot Ads

Rovio Ads

FilterProduct

Read � 50,000

Remove

Increment

Read

Union

Lasp Operation

User-Maintained CRDT

Lasp-Maintained CRDT

Counter1 Counter2 Counter3

Counter1 Counter2 Counter3

Counter1 Counter2 Counter3

Counter1 Counter2 Counter3

88

Page 89: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

Ads

Rovio Ad Counter

Rovio Ad Counter

Riot Ad Counter

Riot Ad Counter

Contracts

AdsContracts

AdsWith

Contracts

Riot Ads

Rovio Ads

FilterProduct

Read � 50,000

Remove

Increment

Read

Union

Lasp Operation

User-Maintained CRDT

Lasp-Maintained CRDT

Counter1 Counter2 Counter3

Counter1 Counter2 Counter3

Counter1 Counter2 Counter3

Counter1 Counter2 Counter3

89

Page 90: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

DISTRIBUTION BOUNDARIES:ARBITRARY ALLOWS COMPOSITION OF ENTIRE SYSTEM

90

Page 91: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

MATERIALIZED VIEWS

91

Page 92: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

MATERIALIZED VIEWS:INCREMENTALLY UPDATING, DELTA PROPAGATION SCHEMA BASED OR DYNAMIC; 2I IN RIAK

92

Page 93: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

DATABASE AS STREAM OF UPDATES

93

Page 94: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

Riak

K1 K2 K3 K1 K2

94

Page 95: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

Riak

K1 K2 K3 K1 K2

RS1

RS2

RS3

95

Page 96: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

Riak

K1 K2 K3 K1 K2

RS1

RS2

RS3

K1K1

K2 K2

K3

96

Page 97: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

Riak

K1 K2 K3 K1 K2RS2

RS3

K1K1

K2 K2

K3

N1

N2N3

97

Page 98: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

COMPOSE PROGRAMS

98

Page 99: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

Riak

K1 K2 K3 K1 K2RS2

RS3

K1K1

K2 K2

K3

N1

N2N3

Lasp Stream ProcessorTemplate

99

Page 100: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

Riak

K1 K2 K3 K1 K2RS2

RS3

K1K1

K2 K2

K3

N1

N2N3

Lasp Stream ProcessorTemplate

Lasp All ObjectsProgram

100

Page 101: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

Riak

K1 K2 K3 K1 K2RS2

RS3

K1K1

K2 K2

K3

N1

N2N3

Lasp Stream ProcessorTemplate

Lasp All ObjectsProgram

Lasp“Over 65”

Filter

101

Page 102: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

Riak

K1 K2 K3 K1 K2RS2

RS3

K1K1

K2 K2

K3

N1

N2N3

Lasp Stream ProcessorTemplate

Lasp All ObjectsProgram

Lasp“Over 65”

Filter

Lasp“Over 80”

Filter

102

Page 103: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

Riak

K1 K2 K3 K1 K2RS2

RS3

K1K1

K2 K2

K3

N1

N2N3

Lasp Stream ProcessorTemplate

Lasp All ObjectsProgram

Lasp“Over 65”

Filter

Lasp“Over 80”

Filter

Lasp“Named Chris”

Filter (L)

103

Page 104: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

DISTRIBUTE APPLICATIONS

104

Page 105: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

Riak

K1 K2 K3 K1 K2RS2

RS3

K1K1

K2 K2

K3

N1

N2N3

Lasp“Named Chris”

Filter (L)

L’’’

L’’

L’

105

Page 106: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

MERGE RESULTS

(SEC)

106

N1

N2

N3

L’

L’

L’

Page 107: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

SUM RESULTS

107

RS1

L’

RS2

L’’

Page 108: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

Riak

K1 K2 K3 K1 K2RS2

RS3

K1K1

K2 K2

K3

N1

N2N3

Execution ofLasp

“Named Chris”Filter (L)

L’’’

L’’

L’

108

Page 109: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

CACHE:CACHE RESULTS OF MERGE SPECULATIVELY EXECUTE BASED ON DIVERGENCE

109

Page 110: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

“INTERNET OF THINGS”

110

Page 111: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

Riak

K1 K2 K3 K1 K2RS2

RS3

K1K1

K2 K2

K3

N1

N2N3

Execution ofLasp

“Named Chris”Filter (L)

L’’’

L’’

L’

111

Page 112: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

IoT Network

K1 K2 K3 K1 K2

S1

S2

S3

U1U1

U2 U2

U3

Execution ofLasp

Temperature Sensor > 90 F

L’’’

L’’

L’

112

Page 113: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

IoT Network

S1

S2

S3

U1U1

U2 U2

U3

Execution ofLasp

Temperature Sensor > 90 F

L’’’

L’’

L’

113

Page 114: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

IOT:EXECUTE AT THE EDGE WRITE CODE THINKING ABOUT “ALL” DATA

114

Page 115: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

RELATED WORK

115

Page 116: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

DISTRIBUTED OZRELATED WORK

116

Page 117: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

DERFLOWL

RELATED WORK

117

Page 118: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

BLOOMLRELATED WORK

118

Page 119: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

LVARSRELATED WORK

119

Page 120: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

D-STREAMSRELATED WORK

120

Page 121: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

SUMMINGBIRDRELATED WORK

121

Page 122: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

FUTURE WORK

122

Page 123: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

INVARIANT PRESERVATIONFUTURE WORK

123

Page 124: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

CAUSAL+ CONSISTENCYFUTURE WORK

124

Page 125: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

ORSWOT OPTIMIZATIONFUTURE WORK

125

Page 126: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

DELTA STATE-CRDTsFUTURE WORK

126

Page 127: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

OPERATION-BASED CRDTsFUTURE WORK

127

Page 128: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

DEFORESTATIONFUTURE WORK

128

Page 129: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

GITHUB.COM/CMEIKLEJOHN/LASPSOURCE

129

Page 130: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

DERFLOW DISTRIBUTED DETERMINISTIC DATAFLOW

PROGRAMMING FOR ERLANG

ERLANG WORKSHOP 2014

130

Page 131: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

LASP A LANGUAGE FOR DISTRIBUTED, EVENTUALLY CONSISTENT COMPUTATIONS WITH CRDTs

PAPOC / EUROSYS 2015

131

Page 132: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

NOVEMBER 4-6, 2015 SAN FRANCISCO, CA

RICON 2015

132

Page 133: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

SYNCFREE IS A EUROPEAN RESEARCH PROJECT TAKING PLACE FOR 3 YEARS, STARING OCTOBER 2013, AND IS FUNDED BY

THE EUROPEAN UNION, GRANT AGREEMENT N°609551.

SYNCFREE

133

Page 134: Lasp, GOTO Chicago 2015 · Gubbi, Jayavardhana, et al. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future Generation Computer Systems 29.7

Questions?Please remember to evaluate via the GOTO

Guide App