├── content ├── book │ └── Makefile ├── ch_00 │ ├── Makefile │ ├── figures │ │ ├── Makefile │ │ ├── structure.tex │ │ └── teaching.tex │ └── ch_00-slides.org ├── ch_16_gfs │ ├── Makefile │ └── ch_16_gfs-slides.org ├── ch_24_ml │ ├── Makefile │ ├── ch_24_ml.org │ └── ch_24_ml-slides.org ├── ch_01_basic_CS │ ├── Makefile │ ├── figures │ │ ├── Makefile │ │ ├── cs_basic.tex │ │ ├── asyncReq.tex │ │ ├── syncReq.tex │ │ └── idl.tex │ └── ch_01_basic_CS-slides.org ├── ch_02_web_CS │ ├── Makefile │ ├── figures │ │ ├── Makefile │ │ ├── http2_adoption.png │ │ ├── ajax_vergleich_en.png │ │ ├── angular_tree.tex │ │ ├── mvc.tex │ │ └── uwsgi.tex │ └── ch_02_web_CS-slides.org ├── ch_03_RPC_CS │ ├── Makefile │ ├── figures │ │ ├── Makefile │ │ ├── typesafe.png │ │ ├── rpc_rrp-0.png │ │ ├── rpc_rrp-1.png │ │ ├── rpc_rrp-2.png │ │ ├── rpc_rrp-3.png │ │ ├── rpc_rrp-4.png │ │ ├── swagger-screenshot.png │ │ ├── wsdl.tex │ │ ├── localcall.tex │ │ ├── ideaRPC.tex │ │ ├── rmi.tex │ │ ├── acks.tex │ │ ├── RPCproxy.tex │ │ ├── orch_choreo.tex │ │ └── rpc_rrp.tex │ └── ch_03_RPC_CS-slides.org ├── ch_05_practical │ ├── Makefile │ ├── figures │ │ ├── Makefile │ │ ├── travis1.png │ │ ├── travis2.png │ │ ├── nagios_tactical.png │ │ └── ci_workflow.tex │ └── ch_05_practical-slides.org ├── ch_06_p2p_ncs │ ├── Makefile │ ├── figures │ │ ├── Makefile │ │ ├── plaxton_fc.tex │ │ └── dht.tex │ └── ch_06_p2p_ncs-slides.org ├── ch_07_mcast_ncs │ ├── Makefile │ ├── figures │ │ ├── Makefile │ │ ├── to_classes.tex │ │ ├── mcast_protocol.tex │ │ └── logicalTime.tex │ └── ch_07_mcast_ncs-slides.org ├── ch_10_oddsEnds_ncs │ ├── figures │ │ └── Makefile │ ├── Makefile │ ├── ch_10_oddsEnds_ncs-slides.org │ └── ch_10_oddsEnds_ncs.org ├── ch_13_consensus │ ├── Makefile │ ├── figures │ │ ├── Makefile │ │ ├── raft_log.pdf │ │ ├── raft_no_commit.pdf │ │ ├── raft_two_leaders.pdf │ │ ├── raft_log_leader_change.pdf │ │ ├── raft_commit_previous_terms.pdf │ │ ├── consensus.tex │ │ ├── impossible.tex │ │ └── byzantine.tex │ └── ch_13_consensus-slides.org ├── ch_14_nosql │ ├── Makefile │ ├── figures │ │ ├── Makefile │ │ ├── kerberos.tex │ │ ├── tmp.tex │ │ ├── cap.tex │ │ └── nosql.tex │ └── ch_14_nosql-slides.org ├── ch_17_websearch │ ├── Makefile │ ├── ch_17_websearch-slides.org │ └── ch_17_websearch.org ├── ch_20_clouds │ ├── Makefile │ ├── ch_20_clouds-slides.org │ └── ch_20_clouds.org ├── ch_21_bigdata │ ├── Makefile │ ├── figures │ │ ├── Makefile │ │ ├── mapreduce.listing │ │ ├── CERN.png │ │ ├── bd_store_files.png │ │ ├── bigDataProcess.tex │ │ ├── kmeans.tex │ │ ├── bdAnalyticsFlowChart.tex │ │ └── mapreduce.tex │ └── ch_21_bigdata-slides.org ├── ch_22_spark │ ├── Makefile │ ├── ch_22_spark-slides.org │ └── ch_22_spark.org ├── ch_23_streaming │ ├── Makefile │ ├── ch_23_streaming.org │ └── ch_23_streaming-slides.org ├── ch_04_improving_CS │ ├── Makefile │ ├── figures │ │ ├── Makefile │ │ ├── consistentHashing │ │ │ ├── hashing.tex │ │ │ ├── ch.py │ │ │ └── figure.py │ │ ├── steadystate_markov.tex │ │ ├── proxyServer.tex │ │ ├── serverFarm.tex │ │ ├── bathtub.tex │ │ ├── mtServer.tex │ │ ├── serverGroup.tex │ │ ├── three_tier.tex │ │ ├── serverGroup_Database.tex │ │ ├── failure_detector.tex │ │ ├── proxy.tex │ │ ├── proxy_2s.tex │ │ ├── strawman.tex │ │ └── LB.tex │ └── ch_04_improving_CS-slides.org ├── ch_08_des_pubsub │ ├── Makefile │ ├── figures │ │ ├── Makefile │ │ └── zeromq_pubsub.png │ ├── ch_08_des_pubsub-slides.org │ └── code │ │ └── redis_ps.py ├── ch_09_msqQueuing │ ├── Makefile │ ├── figures │ │ ├── Makefile │ │ ├── raft_performance.pdf │ │ ├── raft_LE.tex │ │ ├── bully_fsm.tex │ │ ├── leaderelect_graph_FSM.tex │ │ ├── lcr_example.tex │ │ ├── rabbit_mq.tex │ │ ├── leaderelect_ring.tex │ │ ├── bully.tex │ │ ├── mq_broker_topologies.tex │ │ └── kafka.tex │ └── ch_09_msqQueuing-slides.org ├── ch_11_distStorage │ ├── Makefile │ ├── figures │ │ ├── Makefile │ │ ├── zookeeper.tex │ │ └── consistency_mscs.tex │ └── ch_11_distStorage-slides.org ├── ch_15_filesystems │ ├── Makefile │ ├── figures │ │ ├── Makefile │ │ └── fileaccess.tex │ └── ch_15_filesystems-slides.org ├── ch_18_elasticStack │ ├── Makefile │ ├── ch_18_elasticStack.org │ └── ch_18_elasticStack-slides.org ├── ch_19_virtualization │ ├── Makefile │ ├── ch_19_virtualization-slides.org │ └── ch_19_virtualization.org ├── ch_25_comparisons │ ├── Makefile │ ├── ch_25_comparisons.org │ └── ch_25_comparisons-slides.org ├── ch_12_distTransactions │ ├── Makefile │ ├── figures │ │ ├── Makefile │ │ ├── mutex.tex │ │ ├── deadlock.tex │ │ ├── cuts.tex │ │ └── 2pc.tex │ └── ch_12_distTransactions-slides.org ├── hpi-slides ├── backgrounds ├── templates │ ├── emptyTikz.tex │ ├── emptyMSC.tex │ ├── tikzFigureHeader.tex │ └── emacs_init.el ├── references.org ├── newChapter.sh ├── external_documents.org ├── slidehead.org ├── acronyms.tex └── Makefile ├── Makefile ├── homework └── WireTransfer │ ├── message.fbs │ ├── README.md │ ├── Java │ └── WTExample.java │ └── C │ └── WTExample.c ├── README.md └── .gitignore /content/book/Makefile: -------------------------------------------------------------------------------- 1 | ../Makefile -------------------------------------------------------------------------------- /content/ch_00/Makefile: -------------------------------------------------------------------------------- 1 | ../Makefile -------------------------------------------------------------------------------- /content/ch_16_gfs/Makefile: -------------------------------------------------------------------------------- 1 | ../Makefile -------------------------------------------------------------------------------- /content/ch_24_ml/Makefile: -------------------------------------------------------------------------------- 1 | ../Makefile -------------------------------------------------------------------------------- /content/ch_01_basic_CS/Makefile: -------------------------------------------------------------------------------- 1 | ../Makefile -------------------------------------------------------------------------------- /content/ch_02_web_CS/Makefile: -------------------------------------------------------------------------------- 1 | ../Makefile -------------------------------------------------------------------------------- /content/ch_03_RPC_CS/Makefile: -------------------------------------------------------------------------------- 1 | ../Makefile -------------------------------------------------------------------------------- /content/ch_05_practical/Makefile: -------------------------------------------------------------------------------- 1 | ../Makefile -------------------------------------------------------------------------------- /content/ch_06_p2p_ncs/Makefile: -------------------------------------------------------------------------------- 1 | ../Makefile -------------------------------------------------------------------------------- /content/ch_07_mcast_ncs/Makefile: -------------------------------------------------------------------------------- 1 | ../Makefile -------------------------------------------------------------------------------- /content/ch_10_oddsEnds_ncs/figures/Makefile: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /content/ch_13_consensus/Makefile: -------------------------------------------------------------------------------- 1 | ../Makefile -------------------------------------------------------------------------------- /content/ch_14_nosql/Makefile: -------------------------------------------------------------------------------- 1 | ../Makefile -------------------------------------------------------------------------------- /content/ch_17_websearch/Makefile: -------------------------------------------------------------------------------- 1 | ../Makefile -------------------------------------------------------------------------------- /content/ch_20_clouds/Makefile: -------------------------------------------------------------------------------- 1 | ../Makefile -------------------------------------------------------------------------------- /content/ch_21_bigdata/Makefile: -------------------------------------------------------------------------------- 1 | ../Makefile -------------------------------------------------------------------------------- /content/ch_22_spark/Makefile: -------------------------------------------------------------------------------- 1 | ../Makefile -------------------------------------------------------------------------------- /content/ch_23_streaming/Makefile: -------------------------------------------------------------------------------- 1 | ../Makefile -------------------------------------------------------------------------------- /content/ch_04_improving_CS/Makefile: -------------------------------------------------------------------------------- 1 | ../Makefile -------------------------------------------------------------------------------- /content/ch_08_des_pubsub/Makefile: -------------------------------------------------------------------------------- 1 | ../Makefile -------------------------------------------------------------------------------- /content/ch_09_msqQueuing/Makefile: -------------------------------------------------------------------------------- 1 | ../Makefile -------------------------------------------------------------------------------- /content/ch_10_oddsEnds_ncs/Makefile: -------------------------------------------------------------------------------- 1 | ../Makefile -------------------------------------------------------------------------------- /content/ch_11_distStorage/Makefile: -------------------------------------------------------------------------------- 1 | ../Makefile -------------------------------------------------------------------------------- /content/ch_15_filesystems/Makefile: -------------------------------------------------------------------------------- 1 | ../Makefile -------------------------------------------------------------------------------- /content/ch_18_elasticStack/Makefile: -------------------------------------------------------------------------------- 1 | ../Makefile -------------------------------------------------------------------------------- /content/ch_19_virtualization/Makefile: -------------------------------------------------------------------------------- 1 | ../Makefile -------------------------------------------------------------------------------- /content/ch_25_comparisons/Makefile: -------------------------------------------------------------------------------- 1 | ../Makefile -------------------------------------------------------------------------------- /content/ch_12_distTransactions/Makefile: -------------------------------------------------------------------------------- 1 | ../Makefile -------------------------------------------------------------------------------- /content/ch_01_basic_CS/figures/Makefile: -------------------------------------------------------------------------------- 1 | ../../ch_00/figures/Makefile -------------------------------------------------------------------------------- /content/ch_02_web_CS/figures/Makefile: -------------------------------------------------------------------------------- 1 | ../../ch_00/figures/Makefile -------------------------------------------------------------------------------- /content/ch_03_RPC_CS/figures/Makefile: -------------------------------------------------------------------------------- 1 | ../../ch_00/figures/Makefile -------------------------------------------------------------------------------- /content/ch_05_practical/figures/Makefile: -------------------------------------------------------------------------------- 1 | ../../ch_00/figures/Makefile -------------------------------------------------------------------------------- /content/ch_06_p2p_ncs/figures/Makefile: -------------------------------------------------------------------------------- 1 | ../../ch_00/figures/Makefile -------------------------------------------------------------------------------- /content/ch_07_mcast_ncs/figures/Makefile: -------------------------------------------------------------------------------- 1 | ../../ch_00/figures/Makefile -------------------------------------------------------------------------------- /content/ch_13_consensus/figures/Makefile: -------------------------------------------------------------------------------- 1 | ../../ch_00/figures/Makefile -------------------------------------------------------------------------------- /content/ch_14_nosql/figures/Makefile: -------------------------------------------------------------------------------- 1 | ../../ch_00/figures/Makefile -------------------------------------------------------------------------------- /content/ch_21_bigdata/figures/Makefile: -------------------------------------------------------------------------------- 1 | ../../ch_00/figures/Makefile -------------------------------------------------------------------------------- /content/ch_04_improving_CS/figures/Makefile: -------------------------------------------------------------------------------- 1 | ../../ch_00/figures/Makefile -------------------------------------------------------------------------------- /content/ch_08_des_pubsub/figures/Makefile: -------------------------------------------------------------------------------- 1 | ../../ch_00/figures/Makefile -------------------------------------------------------------------------------- /content/ch_09_msqQueuing/figures/Makefile: -------------------------------------------------------------------------------- 1 | ../../ch_00/figures/Makefile -------------------------------------------------------------------------------- /content/ch_11_distStorage/figures/Makefile: -------------------------------------------------------------------------------- 1 | ../../ch_00/figures/Makefile -------------------------------------------------------------------------------- /content/ch_15_filesystems/figures/Makefile: -------------------------------------------------------------------------------- 1 | ../../ch_00/figures/Makefile -------------------------------------------------------------------------------- /content/ch_12_distTransactions/figures/Makefile: -------------------------------------------------------------------------------- 1 | ../../ch_00/figures/Makefile -------------------------------------------------------------------------------- /content/hpi-slides: -------------------------------------------------------------------------------- 1 | /Users/hkarl/lectures/GDS/gds_vorlesung/slides/hpi-slides -------------------------------------------------------------------------------- /content/backgrounds: -------------------------------------------------------------------------------- 1 | /Users/hkarl/lectures/GDS/gds_vorlesung/slides/hpi-slides/backgrounds -------------------------------------------------------------------------------- /content/ch_21_bigdata/figures/mapreduce.listing: -------------------------------------------------------------------------------- 1 | [ (k1, u1) 2 | (k2, u2), 3 | (k3, u3), 4 | ... ] 5 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: all cleanall 2 | 3 | all: 4 | make -C content all 5 | 6 | cleanall: 7 | make -C content cleanall 8 | -------------------------------------------------------------------------------- /content/ch_23_streaming/ch_23_streaming.org: -------------------------------------------------------------------------------- 1 | #+BIBLIOGRAPHY: ../bib plain 2 | 3 | - Apache Flink 4 | - Apache Storm 5 | -------------------------------------------------------------------------------- /content/ch_21_bigdata/figures/CERN.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hkarl/DistributedSystems/HEAD/content/ch_21_bigdata/figures/CERN.png -------------------------------------------------------------------------------- /content/ch_24_ml/ch_24_ml.org: -------------------------------------------------------------------------------- 1 | #+BIBLIOGRAPHY: ../bib plain 2 | ** Machine learning on big data as example? 3 | 4 | - TensorFlow 5 | -------------------------------------------------------------------------------- /content/ch_03_RPC_CS/figures/typesafe.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hkarl/DistributedSystems/HEAD/content/ch_03_RPC_CS/figures/typesafe.png -------------------------------------------------------------------------------- /content/ch_03_RPC_CS/figures/rpc_rrp-0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hkarl/DistributedSystems/HEAD/content/ch_03_RPC_CS/figures/rpc_rrp-0.png -------------------------------------------------------------------------------- /content/ch_03_RPC_CS/figures/rpc_rrp-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hkarl/DistributedSystems/HEAD/content/ch_03_RPC_CS/figures/rpc_rrp-1.png -------------------------------------------------------------------------------- /content/ch_03_RPC_CS/figures/rpc_rrp-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hkarl/DistributedSystems/HEAD/content/ch_03_RPC_CS/figures/rpc_rrp-2.png -------------------------------------------------------------------------------- /content/ch_03_RPC_CS/figures/rpc_rrp-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hkarl/DistributedSystems/HEAD/content/ch_03_RPC_CS/figures/rpc_rrp-3.png -------------------------------------------------------------------------------- /content/ch_03_RPC_CS/figures/rpc_rrp-4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hkarl/DistributedSystems/HEAD/content/ch_03_RPC_CS/figures/rpc_rrp-4.png -------------------------------------------------------------------------------- /content/ch_05_practical/figures/travis1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hkarl/DistributedSystems/HEAD/content/ch_05_practical/figures/travis1.png -------------------------------------------------------------------------------- /content/ch_05_practical/figures/travis2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hkarl/DistributedSystems/HEAD/content/ch_05_practical/figures/travis2.png -------------------------------------------------------------------------------- /content/ch_13_consensus/figures/raft_log.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hkarl/DistributedSystems/HEAD/content/ch_13_consensus/figures/raft_log.pdf -------------------------------------------------------------------------------- /content/ch_02_web_CS/figures/http2_adoption.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hkarl/DistributedSystems/HEAD/content/ch_02_web_CS/figures/http2_adoption.png -------------------------------------------------------------------------------- /content/ch_21_bigdata/figures/bd_store_files.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hkarl/DistributedSystems/HEAD/content/ch_21_bigdata/figures/bd_store_files.png -------------------------------------------------------------------------------- /content/ch_25_comparisons/ch_25_comparisons.org: -------------------------------------------------------------------------------- 1 | #+BIBLIOGRAPHY: ../bib plain 2 | ** Questions: 3 | 4 | - compare and contrast Kafka, Storm, and Spark 5 | -------------------------------------------------------------------------------- /content/ch_02_web_CS/figures/ajax_vergleich_en.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hkarl/DistributedSystems/HEAD/content/ch_02_web_CS/figures/ajax_vergleich_en.png -------------------------------------------------------------------------------- /content/ch_03_RPC_CS/figures/swagger-screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hkarl/DistributedSystems/HEAD/content/ch_03_RPC_CS/figures/swagger-screenshot.png -------------------------------------------------------------------------------- /content/ch_05_practical/figures/nagios_tactical.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hkarl/DistributedSystems/HEAD/content/ch_05_practical/figures/nagios_tactical.png -------------------------------------------------------------------------------- /content/ch_08_des_pubsub/figures/zeromq_pubsub.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hkarl/DistributedSystems/HEAD/content/ch_08_des_pubsub/figures/zeromq_pubsub.png -------------------------------------------------------------------------------- /content/ch_13_consensus/figures/raft_no_commit.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hkarl/DistributedSystems/HEAD/content/ch_13_consensus/figures/raft_no_commit.pdf -------------------------------------------------------------------------------- /content/ch_09_msqQueuing/figures/raft_performance.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hkarl/DistributedSystems/HEAD/content/ch_09_msqQueuing/figures/raft_performance.pdf -------------------------------------------------------------------------------- /content/ch_13_consensus/figures/raft_two_leaders.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hkarl/DistributedSystems/HEAD/content/ch_13_consensus/figures/raft_two_leaders.pdf -------------------------------------------------------------------------------- /content/ch_13_consensus/figures/raft_log_leader_change.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hkarl/DistributedSystems/HEAD/content/ch_13_consensus/figures/raft_log_leader_change.pdf -------------------------------------------------------------------------------- /content/ch_13_consensus/figures/raft_commit_previous_terms.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hkarl/DistributedSystems/HEAD/content/ch_13_consensus/figures/raft_commit_previous_terms.pdf -------------------------------------------------------------------------------- /content/ch_18_elasticStack/ch_18_elasticStack.org: -------------------------------------------------------------------------------- 1 | #+BIBLIOGRAPHY: ../bib plain 2 | 3 | 4 | - Was: ELK stack (ElasticSearch, logstash, kibana) 5 | - https://www.elastic.co/elk-stack 6 | - Here, or in big data section? 7 | -------------------------------------------------------------------------------- /content/ch_20_clouds/ch_20_clouds-slides.org: -------------------------------------------------------------------------------- 1 | #+TITLE: Clouds 2 | #+include: "../slidehead.org" 3 | 4 | \begin{frame} 5 | \titlepage 6 | \end{frame} 7 | 8 | 9 | #+include: "./ch_20_clouds.org" 10 | #+include: "../references.org" 11 | -------------------------------------------------------------------------------- /content/ch_24_ml/ch_24_ml-slides.org: -------------------------------------------------------------------------------- 1 | #+TITLE: Machine learning on big data 2 | #+include: "../slidehead.org" 3 | 4 | \begin{frame} 5 | \titlepage 6 | \end{frame} 7 | 8 | 9 | #+include: "./ch_24_ml.org" 10 | #+include: "../references.org" 11 | -------------------------------------------------------------------------------- /content/templates/emptyTikz.tex: -------------------------------------------------------------------------------- 1 | % Created 2016-08-17 Wed 14:38 2 | \documentclass[tikz]{standalone} 3 | 4 | \input{../../templates/tikzFigureHeader} 5 | 6 | \begin{document} 7 | \begin{tikzpicture} 8 | % 9 | \end{tikzpicture} 10 | \end{document} -------------------------------------------------------------------------------- /content/ch_16_gfs/ch_16_gfs-slides.org: -------------------------------------------------------------------------------- 1 | #+TITLE: Big file systems: GFS and HDFS 2 | #+include: "../slidehead.org" 3 | 4 | \begin{frame} 5 | \titlepage 6 | \end{frame} 7 | 8 | 9 | #+include: "./ch_16_gfs.org" 10 | #+include: "../references.org" 11 | -------------------------------------------------------------------------------- /content/ch_22_spark/ch_22_spark-slides.org: -------------------------------------------------------------------------------- 1 | #+TITLE: Big data in memory: Spark 2 | #+include: "../slidehead.org" 3 | 4 | \begin{frame} 5 | \titlepage 6 | \end{frame} 7 | 8 | 9 | #+include: "./ch_22_spark.org" 10 | #+include: "../references.org" 11 | -------------------------------------------------------------------------------- /content/ch_17_websearch/ch_17_websearch-slides.org: -------------------------------------------------------------------------------- 1 | #+TITLE: Web search engines 2 | #+include: "../slidehead.org" 3 | 4 | \begin{frame} 5 | \titlepage 6 | \end{frame} 7 | 8 | 9 | #+include: "./ch_17_websearch.org" 10 | #+include: "../references.org" 11 | -------------------------------------------------------------------------------- /content/ch_18_elasticStack/ch_18_elasticStack-slides.org: -------------------------------------------------------------------------------- 1 | #+TITLE: Elastic Stack 2 | #+include: "../slidehead.org" 3 | 4 | \begin{frame} 5 | \titlepage 6 | \end{frame} 7 | 8 | 9 | #+include: "./ch_18_elasticStack.org" 10 | #+include: "../references.org" 11 | -------------------------------------------------------------------------------- /content/ch_23_streaming/ch_23_streaming-slides.org: -------------------------------------------------------------------------------- 1 | #+TITLE: Streaming big data: Storm 2 | #+include: "../slidehead.org" 3 | 4 | \begin{frame} 5 | \titlepage 6 | \end{frame} 7 | 8 | 9 | #+include: "./ch_23_streaming.org" 10 | #+include: "../references.org" 11 | -------------------------------------------------------------------------------- /content/ch_15_filesystems/ch_15_filesystems-slides.org: -------------------------------------------------------------------------------- 1 | #+TITLE: Distributed file systems 2 | #+include: "../slidehead.org" 3 | 4 | \begin{frame} 5 | \titlepage 6 | \end{frame} 7 | 8 | 9 | #+include: "./ch_15_filesystems.org" 10 | #+include: "../references.org" 11 | -------------------------------------------------------------------------------- /content/ch_25_comparisons/ch_25_comparisons-slides.org: -------------------------------------------------------------------------------- 1 | #+TITLE: Comparisons between different systems 2 | #+include: "../slidehead.org" 3 | 4 | \begin{frame} 5 | \titlepage 6 | \end{frame} 7 | 8 | 9 | #+include: "./ch_25_comparisons.org" 10 | #+include: "../references.org" 11 | -------------------------------------------------------------------------------- /content/ch_19_virtualization/ch_19_virtualization-slides.org: -------------------------------------------------------------------------------- 1 | #+TITLE: Virtualization as a base technology 2 | #+include: "../slidehead.org" 3 | 4 | \begin{frame} 5 | \titlepage 6 | \end{frame} 7 | 8 | 9 | #+include: "./ch_19_virtualization.org" 10 | #+include: "../references.org" 11 | -------------------------------------------------------------------------------- /content/ch_00/figures/Makefile: -------------------------------------------------------------------------------- 1 | 2 | 3 | .PHONY: build clean 4 | 5 | SOURCE := $(wildcard *.tex) 6 | PICS := $(patsubst %.tex,%.pdf,$(wildcard *.tex)) 7 | 8 | build: $(PICS) 9 | 10 | $(PICS): %.pdf: %.tex 11 | pdflatex -shell-escape $< 12 | 13 | clean: 14 | -rm *aux *log *.synctex.gz 15 | -------------------------------------------------------------------------------- /content/ch_10_oddsEnds_ncs/ch_10_oddsEnds_ncs-slides.org: -------------------------------------------------------------------------------- 1 | #+TITLE: Odds and ends in non-client/server systems 2 | #+include: "../slidehead.org" 3 | 4 | \begin{frame} 5 | \titlepage 6 | \end{frame} 7 | 8 | \setcounter{chapter}{9} 9 | \refstepcounter{chapter} 10 | 11 | #+include: "./ch_10_oddsEnds_ncs.org" 12 | #+include: "../references.org" 13 | -------------------------------------------------------------------------------- /homework/WireTransfer/message.fbs: -------------------------------------------------------------------------------- 1 | namespace VS.wire_transfer; 2 | 3 | enum Type : byte {CONTROL, PUSH, PULL} 4 | 5 | struct MessageHeader { 6 | request:Type; 7 | seq_num:int; 8 | } 9 | 10 | table Message { 11 | header:MessageHeader; 12 | from:string; 13 | hasContent:bool; 14 | content:[byte]; 15 | } 16 | 17 | root_type Message; 18 | 19 | -------------------------------------------------------------------------------- /content/references.org: -------------------------------------------------------------------------------- 1 | 2 | * Material 3 | 4 | ** References 5 | 6 | *** References 7 | :PROPERTIES: 8 | :BEAMER_OPT: allowframebreaks 9 | :END: 10 | 11 | \printbibliography[heading=none] 12 | 13 | ** Acronyms 14 | 15 | *** Acronyms 16 | :PROPERTIES: 17 | :BEAMER_OPT: allowframebreaks 18 | :END: 19 | 20 | \input{../acronyms} 21 | -------------------------------------------------------------------------------- /content/ch_13_consensus/ch_13_consensus-slides.org: -------------------------------------------------------------------------------- 1 | #+TITLE: Dealing with failures: Consensus 2 | #+include: "../slidehead.org" 3 | 4 | #+BEAMER_HEADER: \author[H.\ Karl]{Holger Karl} 5 | #+BEAMER_HEADER: \date{SS 22} 6 | 7 | \setcounter{chapter}{12} 8 | \refstepcounter{chapter} 9 | 10 | 11 | #+include: "./ch_13_consensus.org" 12 | #+include: "../references.org" 13 | -------------------------------------------------------------------------------- /content/ch_11_distStorage/ch_11_distStorage-slides.org: -------------------------------------------------------------------------------- 1 | #+TITLE: Distributed storage and consistency 2 | #+include: "../slidehead.org" 3 | 4 | #+BEAMER_HEADER: \author[H.\ Karl]{Holger Karl} 5 | #+BEAMER_HEADER: \date{SS 24} 6 | 7 | \setcounter{chapter}{10} 8 | \refstepcounter{chapter} 9 | 10 | 11 | #+include: "./ch_11_distStorage.org" 12 | #+include: "../references.org" 13 | -------------------------------------------------------------------------------- /content/ch_12_distTransactions/ch_12_distTransactions-slides.org: -------------------------------------------------------------------------------- 1 | #+TITLE: Distributed transactions 2 | #+include: "../slidehead.org" 3 | 4 | #+BEAMER_HEADER: \author[H.\ Karl]{Holger Karl} 5 | #+BEAMER_HEADER: \date{SS 22} 6 | 7 | \setcounter{chapter}{11} 8 | \refstepcounter{chapter} 9 | 10 | 11 | #+include: "./ch_12_distTransactions.org" 12 | #+include: "../references.org" 13 | -------------------------------------------------------------------------------- /content/ch_21_bigdata/ch_21_bigdata-slides.org: -------------------------------------------------------------------------------- 1 | #+TITLE: Big data analytics and the Map/Reduce programming model 2 | #+include: "../slidehead.org" 3 | 4 | #+BEAMER_HEADER: \author[H.\ Karl]{Holger Karl} 5 | #+BEAMER_HEADER: \date{SS 22} 6 | 7 | \setcounter{chapter}{20} 8 | \refstepcounter{chapter} 9 | 10 | 11 | #+include: "./ch_21_bigdata.org" 12 | #+include: "../references.org" 13 | -------------------------------------------------------------------------------- /content/ch_03_RPC_CS/ch_03_RPC_CS-slides.org: -------------------------------------------------------------------------------- 1 | #+TITLE: Ch. 3: Remote Procedure Call 2 | #+include: "../slidehead.org" 3 | #+BEAMER_HEADER: \author[H.\ Karl]{Holger Karl} 4 | #+BEAMER_HEADER: \date{SS 24} 5 | #+BEAMER_HEADER: \title[VS \thechapter: RPC]{Ch. \thechapter: Remote Procedure Call} 6 | 7 | \setcounter{chapter}{2} 8 | \refstepcounter{chapter} 9 | 10 | 11 | #+include: "./ch_03_RPC_CS.org" 12 | #+include: "../references.org" 13 | -------------------------------------------------------------------------------- /content/ch_04_improving_CS/figures/consistentHashing/hashing.tex: -------------------------------------------------------------------------------- 1 | % Created 2016-08-17 Wed 14:38 2 | \documentclass[tikz]{standalone} 3 | 4 | \usepackage[utf8]{inputenc} 5 | \usepackage[T1]{fontenc} 6 | \usepackage{helvet} 7 | 8 | \renewcommand{\familydefault}{\sfdefault} 9 | 10 | \usepackage{tikz} 11 | \author{Holger Karl} 12 | \date{\today} 13 | \title{} 14 | 15 | \begin{document} 16 | 17 | \input{simple.tex} 18 | 19 | \end{document} -------------------------------------------------------------------------------- /content/ch_06_p2p_ncs/ch_06_p2p_ncs-slides.org: -------------------------------------------------------------------------------- 1 | #+TITLE: Peer-to-peer systems 2 | #+include: "../slidehead.org" 3 | #+BEAMER_HEADER: \author[H.\ Karl]{Holger Karl} 4 | #+BEAMER_HEADER: \date{SS 24} 5 | #+BEAMER_HEADER: \title[VS \thechapter: P2P]{Ch. \thechapter: Peer-to-peer systems } 6 | 7 | 8 | 9 | \setcounter{chapter}{5} 10 | \refstepcounter{chapter} 11 | 12 | #+include: "./ch_06_p2p_ncs.org" 13 | #+include: "../references.org" 14 | -------------------------------------------------------------------------------- /content/ch_07_mcast_ncs/ch_07_mcast_ncs-slides.org: -------------------------------------------------------------------------------- 1 | #+TITLE: Group communication 2 | #+include: "../slidehead.org" 3 | 4 | #+BEAMER_HEADER: \author[H.\ Karl]{Holger Karl} 5 | #+BEAMER_HEADER: \date{SS 24} 6 | #+BEAMER_HEADER: \title[VS \thechapter: Groups]{Ch. \thechapter: Group communication} 7 | 8 | 9 | \setcounter{chapter}{6} 10 | \refstepcounter{chapter} 11 | 12 | #+include: "./ch_07_mcast_ncs.org" 13 | #+include: "../references.org" 14 | -------------------------------------------------------------------------------- /content/ch_22_spark/ch_22_spark.org: -------------------------------------------------------------------------------- 1 | #+BIBLIOGRAPHY: ../bib plain 2 | - Apache Spark (Crunch as well?) 3 | 4 | 5 | 6 | *** Post-Map/Reduce: Apache Spark 7 | 65 8 | https://databricks.com/blog/2014/10/10/spark-petabyte-sort.html 9 | *** Apache Spark Logistic regression (similar to k-means) 10 | 66 11 | http://spark.apache.org/examples.html 12 | *** Apache Spark/Mlib: kmeans 13 | 14 | 15 | 16 | 17 | Issue: More slides needed here! 18 | -------------------------------------------------------------------------------- /content/ch_09_msqQueuing/ch_09_msqQueuing-slides.org: -------------------------------------------------------------------------------- 1 | #+TITLE: Message queueing 2 | #+include: "../slidehead.org" 3 | 4 | 5 | #+BEAMER_HEADER: \author[H.\ Karl]{Holger Karl} 6 | #+BEAMER_HEADER: \date{SS 24} 7 | #+BEAMER_HEADER: \title[VS \thechapter: MQ]{Ch. \thechapter: Message queueing } 8 | 9 | \setcounter{chapter}{8} 10 | \refstepcounter{chapter} 11 | 12 | 13 | 14 | #+include: "./ch_09_msqQueuing.org" 15 | #+include: "../references.org" 16 | -------------------------------------------------------------------------------- /content/ch_21_bigdata/figures/bigDataProcess.tex: -------------------------------------------------------------------------------- 1 | \documentclass[tikz,convert]{standalone} 2 | \usepackage[utf8]{inputenc} 3 | \usepackage[T1]{fontenc} 4 | \usepackage{tikz} 5 | \usepackage{smartdiagram} 6 | \author{Holger Karl} 7 | \date{\today} 8 | \title{} 9 | \begin{document} 10 | \smartdiagramset{ 11 | back arrow disabled=true, 12 | } 13 | \smartdiagram[flow diagram:horizontal] 14 | {Data,Information,Know\-ledge,Decisions 15 | } 16 | \end{document} -------------------------------------------------------------------------------- /content/ch_00/ch_00-slides.org: -------------------------------------------------------------------------------- 1 | #+TITLE: Distributed Systems @@latex:\endash{}@@ Ch. 0: Organizational matters 2 | #+include: "../slidehead.org" 3 | #+BEAMER_HEADER: \author[H.\ Karl]{Holger Karl} 4 | #+BEAMER_HEADER: \date{SS 24} 5 | #+BEAMER_HEADER: \title[VS \thechapter: Org]{Ch. \thechapter: Organizational matters } 6 | 7 | \setcounter{chapter}{-1} 8 | \refstepcounter{chapter} 9 | 10 | 11 | #+include: "./ch_00.org" 12 | #+include: "../references.org" 13 | -------------------------------------------------------------------------------- /content/ch_02_web_CS/ch_02_web_CS-slides.org: -------------------------------------------------------------------------------- 1 | #+TITLE: Ch. 2: World-Wide Web as Client/Server example 2 | #+include: "../slidehead.org" 3 | #+BEAMER_HEADER: \author[H.\ Karl]{Holger Karl} 4 | #+BEAMER_HEADER: \date{SS 24} 5 | #+BEAMER_HEADER: \title[VS \thechapter: WWW as C/S]{Ch. \thechapter: World-Wide Web as Client/Server example} 6 | 7 | \setcounter{chapter}{1} 8 | \refstepcounter{chapter} 9 | 10 | #+include: "./ch_02_web_CS.org" 11 | #+include: "../references.org" 12 | -------------------------------------------------------------------------------- /content/ch_01_basic_CS/ch_01_basic_CS-slides.org: -------------------------------------------------------------------------------- 1 | 2 | 3 | #+TITLE: Ch. 1: Basic client/server systems 4 | #+include: "../slidehead.org" 5 | 6 | #+BEAMER_HEADER: \author[H.\ Karl]{Holger Karl} 7 | #+BEAMER_HEADER: \date{SS 24} 8 | #+BEAMER_HEADER: \title[VS \thechapter: Basic C/S]{Ch. \thechapter: Basic client/server systems} 9 | 10 | \setcounter{chapter}{0} 11 | \refstepcounter{chapter} 12 | 13 | 14 | 15 | #+include: "./ch_01_basic_CS.org" 16 | #+include: "../references.org" 17 | -------------------------------------------------------------------------------- /content/ch_14_nosql/ch_14_nosql-slides.org: -------------------------------------------------------------------------------- 1 | #+TITLE: Limits of distributed data bases: NoSQL 2 | #+include: "../slidehead.org" 3 | 4 | #+BEAMER_HEADER: \author[H.\ Karl]{Holger Karl} 5 | #+BEAMER_HEADER: \date{SS 24} 6 | 7 | #+BEAMER_HEADER: \title[VS \thechapter: NoSQL]{Ch. \thechapter: Limits of distributed data bases: NoSQL} 8 | 9 | 10 | 11 | \setcounter{chapter}{13} 12 | \refstepcounter{chapter} 13 | 14 | #+include: "./ch_14_nosql.org" 15 | #+include: "../references.org" 16 | -------------------------------------------------------------------------------- /content/ch_05_practical/ch_05_practical-slides.org: -------------------------------------------------------------------------------- 1 | #+TITLE: Practical deployment tools: A remark in passing 2 | #+include: "../slidehead.org" 3 | #+BEAMER_HEADER: \author[H.\ Karl]{Holger Karl} 4 | #+BEAMER_HEADER: \date{SS 24} 5 | #+BEAMER_HEADER: \title[VS \thechapter: Deployment ]{Ch. \thechapter: Practical deployment tools: A remark in passing } 6 | 7 | \setcounter{chapter}{4} 8 | \refstepcounter{chapter} 9 | 10 | #+include: "./ch_05_practical.org" 11 | #+include: "../references.org" 12 | -------------------------------------------------------------------------------- /content/ch_08_des_pubsub/ch_08_des_pubsub-slides.org: -------------------------------------------------------------------------------- 1 | #+TITLE: Distributed event systems and publish/subscribe 2 | 3 | #+include: "../slidehead.org" 4 | 5 | #+BEAMER_HEADER: \author[H.\ Karl]{Holger Karl} 6 | #+BEAMER_HEADER: \date{SS 24} 7 | 8 | #+BEAMER_HEADER: \title[VS \thechapter: DES \& PubSubS]{Ch. \thechapter: Distributed event systems and publish/subscribe } 9 | 10 | \setcounter{chapter}{7} 11 | \refstepcounter{chapter} 12 | 13 | #+include: "./ch_08_des_pubsub.org" 14 | #+include: "../references.org" 15 | -------------------------------------------------------------------------------- /content/newChapter.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | mkdir $1 4 | echo "#+BIBLIOGRAPHY: ../bib plain\n\n" $1/$1.org 5 | 6 | echo "#+TITLE: $2" > $1/$1-slides.org 7 | echo -e "#+include: \"../slidehead.org\"\n\n\\\\begin{frame}\n\\\\titlepage\n\\end{frame}\n\n" >> $1/$1-slides.org 8 | echo "#+include: \"./$1.org\"" >> $1/$1-slides.org 9 | echo "\n* References\n *** References\n\\bibliography{../bib}" >> $1/$1-slides.org 10 | 11 | ln -s ../Makefile $1/Makefile 12 | 13 | echo "** $2" 14 | echo " " 15 | echo "#+include: \"../$1/$1.org\"" 16 | 17 | aquamacs $1/$1.org 18 | 19 | -------------------------------------------------------------------------------- /content/ch_19_virtualization/ch_19_virtualization.org: -------------------------------------------------------------------------------- 1 | #+BIBLIOGRAPHY: ../bib plain 2 | ** Virtualization 3 | 4 | - Virtualbox 5 | - VMWare ESX? 6 | - Containers, Docker 7 | - Briefly! 8 | - Example: Vagrant 9 | 10 | ** Server Configuration / IaC 11 | 12 | - Infrastructure as code 13 | - Context: DevOps 14 | - Briefly! Just to compensate for Software Engineering Shortcomings 15 | - Chef, Puppet, Ansible, Salt? 16 | - Discuss delta to container approach; why are these competing approaches 17 | 18 | ** Service configuration 19 | 20 | - Example: Canonical Juju 21 | -------------------------------------------------------------------------------- /content/ch_04_improving_CS/ch_04_improving_CS-slides.org: -------------------------------------------------------------------------------- 1 | #+TITLE: Ch. 4: Improving Client/Server systems: Latency, throughput, dependability, consistency 2 | #+include: "../slidehead.org" 3 | #+BEAMER_HEADER: \author[H.\ Karl]{Holger Karl} 4 | #+BEAMER_HEADER: \date{SS 24} 5 | #+BEAMER_HEADER: \title[VS \thechapter: Improvements]{Ch. \thechapter: Improving Client/Server systems: Latency, throughput, dependability, consistency} 6 | 7 | 8 | \setcounter{chapter}{3} 9 | \refstepcounter{chapter} 10 | 11 | 12 | 13 | #+include: "./ch_04_improving_CS.org" 14 | #+include: "../references.org" 15 | -------------------------------------------------------------------------------- /content/templates/emptyMSC.tex: -------------------------------------------------------------------------------- 1 | 2 | \documentclass[tikz]{standalone} 3 | 4 | 5 | \input{../../templates/tikzFigureHeader} 6 | 7 | \begin{document} 8 | \begin{msc}{MSC TITLE} 9 | % example: + 10 | % \declinst{c}{}{Client} 11 | % \declinst{cc}{}{Channel API} 12 | % \declinst{sc}{}{Channel API} 13 | % \declinst{s}{}{Server} 14 | % % 15 | % \regionstart{suspension}{s} 16 | % \nextlevel 17 | % \mess{Pass request to channel}{c}{cc} 18 | % \regionstart{activation}{c} 19 | % \msccomment[side=left]{Do something}{c} 20 | % \nextlevel 21 | % \msccomment[side=left]{Block for reply}{c} 22 | 23 | \end{msc} 24 | \end{document} -------------------------------------------------------------------------------- /content/ch_00/figures/structure.tex: -------------------------------------------------------------------------------- 1 | % Created 2016-08-17 Wed 14:38 2 | \documentclass[tikz]{standalone} 3 | \usepackage[utf8]{inputenc} 4 | \usepackage[T1]{fontenc} 5 | \usepackage{tikz} 6 | \usepackage{smartdiagram} 7 | \author{Holger Karl} 8 | \date{\today} 9 | \title{} 10 | \begin{document} 11 | \smartdiagramset{ 12 | bubble node font=\sffamily, 13 | bubble center node font=\large\sffamily, 14 | font=\sffamily, back arrow disabled=true 15 | } 16 | \smartdiagram[flow diagram:horizontal] 17 | {Client-\\server\\systems, 18 | Non-client-\\server\\systems, 19 | Distributed\\data storage\\and transactions, 20 | Examples of\\large-scale\\systems, 21 | Virtualization, 22 | Big data \& \\machine learning 23 | } 24 | \end{document} -------------------------------------------------------------------------------- /content/ch_04_improving_CS/figures/steadystate_markov.tex: -------------------------------------------------------------------------------- 1 | % Created 2016-08-17 Wed 14:38 2 | \documentclass[tikz]{standalone} 3 | 4 | \input{../../templates/tikzFigureHeader} 5 | \usetikzlibrary{automata, positioning} 6 | 7 | 8 | \begin{document} 9 | 10 | \begin{tikzpicture} 11 | % Add the states 12 | \node[state] (w) {works}; 13 | \node[state, right=of w] (r) {in repair}; 14 | 15 | % Connect the states with arrows 16 | \draw[every loop] 17 | (w) edge[bend left] node[above] {$\lambda$} (r) 18 | (r) edge[bend left] node[below] {$\mu$} (w) 19 | (w) edge[loop left] node {$1-\lambda$} (w) 20 | (r) edge[loop right] node {$1-\mu$} (r); 21 | \end{tikzpicture} 22 | 23 | \end{document} -------------------------------------------------------------------------------- /content/ch_01_basic_CS/figures/cs_basic.tex: -------------------------------------------------------------------------------- 1 | % Created 2016-08-17 Wed 14:38 2 | \documentclass[tikz,varwidth]{standalone} 3 | \usepackage[utf8]{inputenc} 4 | \usepackage[T1]{fontenc} 5 | \usepackage{minted} 6 | \usepackage{tikz} 7 | \usetikzlibrary{tikzmark} 8 | \author{Holger Karl} 9 | \date{\today} 10 | \title{} 11 | 12 | 13 | 14 | \begin{document} 15 | 16 | 17 | \begin{minted}[]{py} 18 | def f(x): 19 | y = x + 2 20 | return y 21 | \end{minted} 22 | 23 | % \begin{minted}[escapeinside=??]{py} 24 | % def f(x): 25 | % y = x?\tikzmark{here}?2 26 | % return y 27 | % \end{minted} 28 | 29 | 30 | % See this bit: 31 | % \begin{tikzpicture}[remember picture] 32 | % \draw[overlay, ->, line width=5pt, red] (0,0) -- (pic cs:here); 33 | % \end{tikzpicture} 34 | 35 | \end{document} -------------------------------------------------------------------------------- /content/templates/tikzFigureHeader.tex: -------------------------------------------------------------------------------- 1 | \usepackage[utf8]{inputenc} 2 | \usepackage[T1]{fontenc} 3 | \usepackage{marvosym} 4 | 5 | \usepackage{helvet} 6 | \usepackage{../../templates/msc} 7 | \usepackage{tikzsymbols} 8 | \usepackage{tikzpeople} 9 | \usepackage{comment} 10 | 11 | \renewcommand{\familydefault}{\sfdefault} 12 | 13 | \tikzset{ 14 | every picture/.style={ 15 | line width=1pt 16 | }, 17 | database/.style={ 18 | cylinder, 19 | cylinder uses custom fill, 20 | cylinder body fill=yellow!50, 21 | cylinder end fill=yellow!50, 22 | shape border rotate=90, 23 | aspect=0.25, 24 | draw 25 | } 26 | } 27 | 28 | 29 | \usepackage{tikz} 30 | 31 | 32 | \author{Holger Karl} 33 | \date{\today} 34 | \title{} 35 | -------------------------------------------------------------------------------- /content/ch_04_improving_CS/figures/proxyServer.tex: -------------------------------------------------------------------------------- 1 | % Created 2016-08-17 Wed 14:38 2 | \documentclass[tikz]{standalone} 3 | 4 | \input{../../templates/tikzFigureHeader} 5 | 6 | \begin{document} 7 | \begin{tikzpicture}[auto, xscale=3, 8 | block/.style = {rectangle, draw=black, thick, align=left}] 9 | \node[block] at (0,0) (c1) {Client 1}; 10 | \node[block] at (0,4) (c2) {Client 2}; 11 | \node[block] at (1,2) (pr) {Proxy}; 12 | \node[block] at (3,2) (s) {Server}; 13 | % \draw ([xshift=-0.5mm,yshift=-1mm]s1.south west) rectangle ([xshift=+0.5mm,yshift=+1mm]s3.north 14 | % east); 15 | % \node at (2,3.5) {Server group}; 16 | % \draw [->] (c1) -- () 17 | % \draw (2,3) node[minimum width=4cm, minimum 18 | % height=4cm,draw,label={Server group}] (sg) {}; 19 | \draw [<->] (c1) -- (pr); 20 | \draw [<->] (c2) -- (pr); 21 | \draw [<->] (pr) -- (s); 22 | 23 | \end{tikzpicture} 24 | \end{document} -------------------------------------------------------------------------------- /content/ch_02_web_CS/figures/angular_tree.tex: -------------------------------------------------------------------------------- 1 | % Created 2016-08-17 Wed 14:38 2 | \documentclass[tikz]{standalone} 3 | 4 | \input{../../templates/tikzFigureHeader} 5 | \usepackage{forest} 6 | \begin{document} 7 | 8 | \begin{forest} 9 | for tree={ 10 | font=\ttfamily, 11 | grow'=0, 12 | child anchor=west, 13 | parent anchor=south, 14 | anchor=west, 15 | calign=first, 16 | edge path={ 17 | \noexpand\path [draw, \forestoption{edge}] 18 | (!u.south west) +(7.5pt,0) |- node[fill,inner sep=1.25pt] {} (.child anchor)\forestoption{edge label}; 19 | }, 20 | before typesetting nodes={ 21 | if n=1 22 | {insert before={[,phantom]}} 23 | {} 24 | }, 25 | fit=band, 26 | before computing xy={l=15pt}, 27 | } 28 | [text1[text1.1 29 | [text1.1.1] 30 | [text1.1.2] 31 | [text1.1.3] 32 | ] 33 | [text1.2 34 | [text1.2.1] 35 | [text1.2.2] 36 | ] 37 | ] 38 | \end{forest} 39 | \end{document} -------------------------------------------------------------------------------- /content/ch_04_improving_CS/figures/serverFarm.tex: -------------------------------------------------------------------------------- 1 | % Created 2016-08-17 Wed 14:38 2 | \documentclass[tikz]{standalone} 3 | 4 | \input{../../templates/tikzFigureHeader} 5 | 6 | \begin{document} 7 | \begin{tikzpicture}[auto, xscale=3, 8 | block/.style = {rectangle, draw=black, thick, align=left}] 9 | 10 | 11 | \node[block] at (1,1) (fe) {Front end}; 12 | \node[block] at (0,1) (router) {Router}; 13 | 14 | \draw (-0.5,0) -- (4.5,0); 15 | \draw (router.south) -- (0,0); 16 | \draw (fe.south) -- (1,0); 17 | 18 | 19 | \foreach \x \in in {1, ..., 4} { 20 | \node[block] at (\x, -1) (wt\x) {Worker machine} ; 21 | \draw [-] (\x, 0) -- (wt\x.north); 22 | } 23 | 24 | 25 | 26 | \node [above left= of router] (incoming) {}; 27 | \node [left = of router] (outgoing) {}; 28 | \draw [<-] (router) -- (incoming) node [above] {Incoming requests}; 29 | \draw [->] (router) -- (outgoing) node [below] {Outgoing reply}; 30 | 31 | 32 | 33 | \end{tikzpicture} 34 | \end{document} -------------------------------------------------------------------------------- /content/ch_13_consensus/figures/consensus.tex: -------------------------------------------------------------------------------- 1 | % Created 2016-08-17 Wed 14:38 2 | \documentclass[tikz]{standalone} 3 | 4 | \input{../../templates/tikzFigureHeader} 5 | 6 | \begin{document} 7 | \begin{tikzpicture} 8 | % 9 | \node [cowboy] (c1) at (-3, 2) {}; 10 | \node [cowboy, right=0.1cm of c1] (c2) {}; 11 | \node [cowboy] (c3) at (3, 2) {}; 12 | \node [cowboy, right=0.1cm of c3] (c4) {}; 13 | 14 | 15 | \node [guard] (g1) at (-1, 0) {}; 16 | \node [guard, right=0.1cm of g1] (g2) {}; 17 | \node [guard, right=0.1cm of g2] (g3) {}; 18 | \node [guard, right=0.1cm of g3] (g4) {}; 19 | \node [guard, right=0.1cm of g4] (g5) {}; 20 | \node [guard, right=0.1cm of g5] (g6) {}; 21 | 22 | \draw [rounded corners] (c1.south) -- (c2.south) -- ([shift={(0,.5)}] g1.north) -- ([shift={(0,.3)}] g5.north) -- (c3.south) -- (c4.south); 23 | 24 | 25 | \node [cloud, draw, aspect=6, fill=gray!20] at (0, 2) {}; 26 | \end{tikzpicture} 27 | 28 | 29 | 30 | \end{document} -------------------------------------------------------------------------------- /content/ch_09_msqQueuing/figures/raft_LE.tex: -------------------------------------------------------------------------------- 1 | % Created 2016-08-17 Wed 14:38 2 | \documentclass[tikz]{standalone} 3 | 4 | \input{../../templates/tikzFigureHeader} 5 | 6 | \usetikzlibrary{arrows,automata} 7 | 8 | \begin{document} 9 | 10 | \begin{tikzpicture}[->,>=stealth',shorten >=1pt,auto,node distance=3cm, 11 | semithick] 12 | 13 | 14 | \node[initial, state] (f) {Follower}; 15 | \node[state] (l) [above right = of f] {Leader}; 16 | \node[state] (c) [below right = of f] {Candidate}; 17 | 18 | \path 19 | (f) edge [bend right=40] node [align=center, below, rotate=-45] {time out, \\start election} (c) 20 | (c) edge [out=240, in=300, looseness=3 ] node [align=center, below] {time out\\new election} (c) 21 | (c) edge [bend right=40] node [align=center, right] {receive \\majority\\ vote} (l) 22 | (c) edge [bend right=40] node [align=center, above, rotate=-45] {current\\ leader \\discovered} (f) 23 | (l) edge [bend right=40] node [align=center, above, rotate=45] {discover leader \\with higher term} (f) 24 | ; 25 | 26 | \end{tikzpicture} 27 | 28 | 29 | \end{document} -------------------------------------------------------------------------------- /content/ch_04_improving_CS/figures/bathtub.tex: -------------------------------------------------------------------------------- 1 | % Created 2016-08-17 Wed 14:38 2 | \documentclass[tikz]{standalone} 3 | 4 | \input{../../templates/tikzFigureHeader} 5 | \usetikzlibrary{decorations.pathreplacing} 6 | 7 | \begin{document} 8 | 9 | \begin{tikzpicture} 10 | \draw (0,0) grid (7, 5); 11 | \draw [thick, ->] (0,0) -- (6.5, 0); 12 | \draw [thick, ->] (0,0) -- (0, 4.5); 13 | \node at (7, -0.5) {$t$}; 14 | \node at (-0.5, 5) {$h(t)$}; 15 | % \draw [thick](0,4) -- (1, 1) -- (5, 1) -- (6,4); 16 | \draw [thick, red] plot [smooth ] coordinates {(0,4) (0.5, 3.5) 17 | (1, 1) (5, 18 | 1) (6.2,4.2)}; 19 | \draw [thick, decorate, decoration={brace}] 20 | (0.95, -0.5) -- (0, -0.5) node 21 | [below,midway] {Burn in}; 22 | \draw [thick, decorate, decoration={brace}] (6, -0.5) -- (5.05, -0.5) node 23 | [below,midway] {EoL}; 24 | \draw [thick, decorate, decoration={brace}] (4.95, -0.5) -- (1, -0.5) node 25 | [below,midway] {Regular operation}; 26 | \end{tikzpicture} 27 | 28 | \end{document} -------------------------------------------------------------------------------- /content/ch_04_improving_CS/figures/mtServer.tex: -------------------------------------------------------------------------------- 1 | % Created 2016-08-17 Wed 14:38 2 | \documentclass[tikz]{standalone} 3 | 4 | \input{../../templates/tikzFigureHeader} 5 | 6 | \begin{document} 7 | \begin{tikzpicture}[auto, xscale=3, 8 | block/.style = {rectangle, draw=black, thick, align=center}] 9 | 10 | 11 | \node[block] at (1,1) (fe) {Dispatcher thread}; 12 | 13 | 14 | \draw (0.5,0) to node [above] {Shared memory} (4.5,0) ; 15 | %\draw (fe.south) -- (0,0); 16 | \draw (fe.south) -- (1,0); 17 | 18 | 19 | \foreach \x \in in {1, ..., 4} { 20 | \node[block] at (\x, -1) (wt\x) {Worker \\thread} ; 21 | \draw [-] (\x, 0) -- (wt\x.north); 22 | } 23 | 24 | \node [circle, draw] (socket) at (0.5, 0) {}; 25 | \node [below=0.1cm of socket] {Socket}; 26 | 27 | \node [above left= 0.5 and 1.5 of socket] (incoming) {}; 28 | \node [below left = 0.5 and 1.5 of socket] (outgoing) {}; 29 | \draw [<-] (socket) -- (incoming) node [above, align=center] {Incoming \\ request}; 30 | \draw [->] (socket) -- (outgoing) node [below, align=center] {Outgoing \\ reply}; 31 | 32 | 33 | 34 | \end{tikzpicture} 35 | \end{document} -------------------------------------------------------------------------------- /content/ch_03_RPC_CS/figures/wsdl.tex: -------------------------------------------------------------------------------- 1 | 2 | \documentclass[tikz]{standalone} 3 | 4 | 5 | \input{../../templates/tikzFigureHeader} 6 | 7 | \begin{document} 8 | 9 | \newcommand{\centerbox}[4]{ % 10 | % xstart, ystart, xwidth, text 11 | \draw [thick, fill=gray!5] (#1+0.05, #2+0.05) rectangle (#1+#3-0.05, #2+1-0.05); % 12 | \draw ( #1+#3/2, #2+0.5) node {#4}; 13 | % 14 | } 15 | 16 | \begin{tikzpicture} 17 | % \draw (0, 0) rectangle (3,1); 18 | % \draw (1.5, 0.5) node {center a long text}; 19 | 20 | % \draw (0, 1) rectangle (2,2); 21 | % \draw (1, 1.5) node {bla}; 22 | 23 | % \draw (3, 0) rectangle (4,1); 24 | % \draw (3.5, 0.5) node {blib}; 25 | 26 | 27 | \centerbox{0}{0}{8}{URIs, XML, HTTP} 28 | \centerbox{0}{1}{8}{SOAP} 29 | \centerbox{0}{2}{8}{WebServices \& Service description} 30 | \centerbox{4}{3}{4}{Directory service} 31 | 32 | \draw [thick, fill=gray!5] (0+0.05, 3+0.05) -- (4-0.05, 3+0.05) -- (4-0.05, 4 + 0.05) -- 33 | (8-0.05, 4+ 0.05) -- (8-0.05, 5-0.05) -- (0+0.05, 5-0.05) -- cycle; 34 | \draw (4, 4.5) node {Applications}; 35 | % \node (0.5,1.5) {Hallo}; 36 | \end{tikzpicture} 37 | \end{document} -------------------------------------------------------------------------------- /content/ch_09_msqQueuing/figures/bully_fsm.tex: -------------------------------------------------------------------------------- 1 | % Created 2016-08-17 Wed 14:38 2 | \documentclass[tikz]{standalone} 3 | 4 | \input{../../templates/tikzFigureHeader} 5 | 6 | \usetikzlibrary{arrows,automata} 7 | 8 | \begin{document} 9 | 10 | \begin{tikzpicture}[->,>=stealth',shorten >=1pt,auto,node distance=4cm, 11 | semithick] 12 | 13 | 14 | \node[initial, state] (e) {Electing}; 15 | \node[state] (l) [above right = of e] {Leader}; 16 | \node[state] (f) [below right = of e] {Follower}; 17 | \node[state] (d) [below right = of l] {Down}; 18 | 19 | 20 | \path (l) edge node {fail} (d) 21 | (f) edge node [swap]{fail} (d) 22 | (d) edge node [near start] {recover} (e) 23 | (l) edge node [near start] {overruled} (f) 24 | (e) edge [bend left=10] node [near start, auto] {overruled} (f) 25 | (e) edge node {all agreed} (l) 26 | (f) edge [bend left=10] node [align=center, near start] {suspect\\leader} (e) 27 | (f) edge [bend left=70] node [align=center] {smaller\\leader } (e) 28 | (e) edge [bend left=20]node [near start, auto] {fail} (d) 29 | ; 30 | \end{tikzpicture} 31 | 32 | 33 | \end{document} -------------------------------------------------------------------------------- /content/ch_12_distTransactions/figures/mutex.tex: -------------------------------------------------------------------------------- 1 | % Created 2016-08-17 Wed 14:38 2 | \documentclass[tikz]{standalone} 3 | 4 | \input{../../templates/tikzFigureHeader} 5 | 6 | \begin{document} 7 | \begin{msc}{Ricart-Agrawala example} 8 | % 9 | \declinst{a}{}{A} 10 | \declinst{b}{}{B} 11 | \declinst{c}{}{C} 12 | 13 | \action{SN = 7}{a} 14 | \action{SN = 3}{b} 15 | \action{SN = 9}{c} 16 | \nextlevel[3] 17 | 18 | \condition{RELEASED}{b} 19 | \condition{WANTED}{a} 20 | 21 | \nextlevel[2] 22 | \mess[auto,below, near start]{WANT, 7}{a}{c}[3] 23 | \mess{}{a}{b}[6] 24 | 25 | 26 | \condition{WANTED}{c} 27 | \nextlevel[2] 28 | \mess[auto,below, near start]{WANT, 9}{c}{b}[2] 29 | \mess{}{c}{a}[3] 30 | 31 | 32 | \nextlevel[2] 33 | 34 | \mess[below]{CLEAR}{b}{c}[1] 35 | 36 | \nextlevel[1] 37 | \msccomment[side=left]{queue}{a} 38 | \nextlevel[1] 39 | \mess[below]{CLEAR}{b}{a}[1] 40 | \nextlevel[1] 41 | \mess{CLEAR}{c}{a}[3] 42 | \nextlevel[3] 43 | 44 | \condition{HELD}{a} 45 | \nextlevel[3] 46 | 47 | \condition{RELEASED}{a} 48 | \nextlevel[2] 49 | \msccomment[side=left]{clear queue}{a} 50 | \mess{CLEAR}{a}{c}[3] 51 | 52 | \nextlevel[3] 53 | \condition{HELD}{c} 54 | \nextlevel[2] 55 | 56 | \end{msc} 57 | \end{document} -------------------------------------------------------------------------------- /content/ch_15_filesystems/figures/fileaccess.tex: -------------------------------------------------------------------------------- 1 | 2 | \documentclass[tikz]{standalone} 3 | 4 | 5 | \input{../../templates/tikzFigureHeader} 6 | 7 | \begin{document} 8 | \begin{msc}{Remote access model} 9 | \declinst{u}{}{User process} 10 | \declinst{c}{}{Client } 11 | \declinst{s}{}{Server} 12 | 13 | \mess{Read}{u}{c} 14 | \nextlevel 15 | \mess{Read}{c}{s} 16 | \nextlevel[2] 17 | \mess{Result}{s}{c} 18 | \nextlevel 19 | \mess{Result}{c}{u} 20 | \nextlevel[4] 21 | 22 | \mess{Write}{u}{c} 23 | \nextlevel 24 | \mess{Write}{c}{s} 25 | \nextlevel[2] 26 | \mess{Result}{s}{c} 27 | \nextlevel 28 | \mess{Result}{c}{u} 29 | \end{msc} 30 | 31 | \begin{msc}{Data-caching model} 32 | \declinst{u}{}{User process} 33 | \declinst{c}{}{Client } 34 | \declinst{s}{}{Server} 35 | 36 | \mess{Read}{u}{c} 37 | \nextlevel 38 | \mess{Get file}{c}{s} 39 | \nextlevel[2] 40 | \mess{Send file}{s}{c} 41 | \nextlevel 42 | \mess{Result}{c}{u} 43 | \nextlevel[4] 44 | 45 | \mess{Write}{u}{c} 46 | \nextlevel 47 | \mess{Write}{c}{c} 48 | \nextlevel[3] 49 | \mess{Result}{c}{u} 50 | \end{msc} 51 | 52 | \end{document} -------------------------------------------------------------------------------- /content/ch_01_basic_CS/figures/asyncReq.tex: -------------------------------------------------------------------------------- 1 | % Created 2016-08-17 Wed 14:38 2 | \documentclass[tikz]{standalone} 3 | 4 | 5 | \input{../../templates/tikzFigureHeader} 6 | 7 | \begin{document} 8 | \begin{msc}{Asynchronous request} 9 | \declinst{c}{}{Client} 10 | \declinst{cc}{}{Channel API} 11 | \declinst{sc}{}{Channel API} 12 | \declinst{s}{}{Server} 13 | % 14 | \regionstart{suspension}{s} 15 | \nextlevel 16 | \mess{Pass request to channel}{c}{cc} 17 | \regionstart{activation}{c} 18 | \msccomment[side=left]{Do something}{c} 19 | \nextlevel 20 | \mess{Transport request}{cc}{sc}[1] 21 | \nextlevel[1] 22 | \regionend{s} 23 | \mess{Receive request}{sc}{s} 24 | \nextlevel 25 | \regionstart{activation}{s} 26 | \nextlevel[2] 27 | \regionend{s} 28 | \mess{Pass reply}{s}{sc} 29 | \nextlevel[2] 30 | \regionend{c} 31 | \regionstart{suspension}{c} 32 | \msccomment[side=left]{Block for reply}{c} 33 | 34 | \nextlevel[1] 35 | \mess{Transport reply}{sc}{cc}[1] 36 | \nextlevel[2] 37 | \regionend{c} 38 | \msccomment[side=left]{Msg unblocks}{c} 39 | \mess{Receive reply}{cc}{c} 40 | \nextlevel 41 | \end{msc} 42 | 43 | \end{document} -------------------------------------------------------------------------------- /content/ch_01_basic_CS/figures/syncReq.tex: -------------------------------------------------------------------------------- 1 | % Created 2016-08-17 Wed 14:38 2 | \documentclass[tikz]{standalone} 3 | 4 | 5 | \input{../../templates/tikzFigureHeader} 6 | 7 | \begin{document} 8 | \begin{msc}{Synchronous request} 9 | \declinst{c}{}{Client} 10 | \declinst{cc}{}{Channel API} 11 | \declinst{sc}{}{Channel API} 12 | \declinst{s}{}{Server} 13 | % 14 | % \action[action height=1.5cm]{Blocks}{s} 15 | \regionstart{suspension}{s} 16 | \msccomment[side=right]{Block for request}{s} 17 | \nextlevel 18 | \mess{Pass request to channel}{c}{cc} 19 | \regionstart{suspension}{c} 20 | \msccomment[side=left]{Block for reply}{c} 21 | \nextlevel 22 | \mess{Transport request}{cc}{sc}[1] 23 | \nextlevel[1] 24 | \regionend{s} 25 | \mess{Receive request}{sc}{s} 26 | \nextlevel 27 | \regionstart{activation}{s} 28 | \msccomment[side=right]{Process request}{s} 29 | \nextlevel[4] 30 | \regionend{s} 31 | \mess{Pass reply}{s}{sc} 32 | \nextlevel 33 | \mess{Transport reply}{sc}{cc}[1] 34 | \nextlevel[2] 35 | \regionend{c} 36 | \msccomment[side=left]{Msg unblocks}{c} 37 | \mess{Receive reply}{cc}{c} 38 | \nextlevel 39 | \end{msc} 40 | 41 | \end{document} -------------------------------------------------------------------------------- /content/ch_03_RPC_CS/figures/localcall.tex: -------------------------------------------------------------------------------- 1 | 2 | \documentclass[tikz]{standalone} 3 | 4 | 5 | \input{../../templates/tikzFigureHeader} 6 | 7 | \begin{document} 8 | \begin{msc}{Local procedure call} 9 | % example: + 10 | % \declinst{c}{}{Client} 11 | % \declinst{cc}{}{Channel API} 12 | % \declinst{sc}{}{Channel API} 13 | % \declinst{s}{}{Server} 14 | % % 15 | % \regionstart{suspension}{s} 16 | % \nextlevel 17 | % \mess{Pass request to channel}{c}{cc} 18 | % \regionstart{activation}{c} 19 | % \msccomment[side=left]{Do something}{c} 20 | % \nextlevel 21 | % \msccomment[side=left]{Block for reply}{c} 22 | \declinst{a}{}{Caller} 23 | \declinst{b}{}{Callee} 24 | % \regionstart{suspension}{a} 25 | \msccomment[side=left]{Put parameters, return address on stack}{a} 26 | \nextlevel 27 | \mess{Jump}{a}{b} 28 | \nextlevel 29 | \msccomment[side=right]{Access parameters on stack}{b} 30 | \nextlevel 31 | \msccomment[side=right]{Process}{b} 32 | \nextlevel 33 | \msccomment[side=right]{Put result on stack }{b} 34 | \nextlevel 35 | \mess{Jump}{b}{a} 36 | \nextlevel 37 | \msccomment[side=left]{Retrieve result from stack }{a} 38 | \end{msc} 39 | \end{document} -------------------------------------------------------------------------------- /content/ch_00/figures/teaching.tex: -------------------------------------------------------------------------------- 1 | % Created 2016-08-17 Wed 14:38 2 | \documentclass[tikz]{standalone} 3 | \usepackage[utf8]{inputenc} 4 | \usepackage[T1]{fontenc} 5 | \usepackage{tikz} 6 | \usetikzlibrary {matrix} 7 | 8 | \author{Holger Karl} 9 | \date{\today} 10 | \title{} 11 | \begin{document} 12 | 13 | \tikzset{ 14 | class/.style={draw, rounded corners}, 15 | project/.style={draw, rounded corners, fill=green!10}, 16 | thesis/.style={draw, rounded corners, fill=blue!10} 17 | } 18 | 19 | \begin{tikzpicture} 20 | \matrix (teaching) [matrix of nodes] { 21 | Master & every year &[1em] odd years &[1em] even years &[1em] some years\\ 22 | 4 / Summer & |[thesis]|Master thesis \\ 23 | 3 / Winter & & & & |[project]| Master project \\ 24 | 2 / Summer & |[class]|Future Internet & & & |[project]| Master project \\ 25 | 1 / Winter &|[class]|Mobile communications & & & |[class]|Performance evaluation \\ 26 | Bachelor \\ 27 | 6 & |[project]|Bachelor project \\ 28 | 5 & |[project]|Bachelor project \\ 29 | 4 & & |[class]|Rechnernetze & |[class]| Verteilte Systeme\\ 30 | 3 \\ 31 | 2 & & |[class]|Rechnernetze & |[class]| Verteilte Systeme\\ 32 | 1 &|[class]| GdS \\ 33 | }; 34 | \end{tikzpicture} 35 | 36 | \end{document} -------------------------------------------------------------------------------- /content/ch_04_improving_CS/figures/serverGroup.tex: -------------------------------------------------------------------------------- 1 | % Created 2016-08-17 Wed 14:38 2 | \documentclass[tikz]{standalone} 3 | 4 | \input{../../templates/tikzFigureHeader} 5 | 6 | \begin{document} 7 | \begin{tikzpicture}[auto, xscale=3, 8 | block/.style = {rectangle, draw=black, thick, align=left}] 9 | \node[block] at (1,0) (c1) {Client 1}; 10 | \node[block] at (1,4) (c2) {Client 2}; 11 | \node[block] at (2,1) (s1) {Server 1}; 12 | \node[block] at (2,2) (s2) {Server 2}; 13 | \node[block] at (2,3) (s3) {Server 3}; 14 | % \draw ([xshift=-0.5mm,yshift=-1mm]s1.south west) rectangle ([xshift=+0.5mm,yshift=+1mm]s3.north 15 | % east); 16 | % \node at (2,3.5) {Server group}; 17 | % \draw [->] (c1) -- () 18 | % \draw (2,3) node[minimum width=4cm, minimum 19 | % height=4cm,draw,label={Server group}] (sg) {}; 20 | \draw (s2) node[minimum width=2cm, minimum 21 | height=3cm,draw,label={Server group}] (sg) {}; 22 | 23 | % inside SG: 24 | \draw [->] ([xshift=-3pt]s1.north) -- ([xshift=-3pt]s2.south); 25 | \draw [->] ([xshift=+3pt]s2.south) -- ([xshift=+3pt]s1.north); 26 | \draw [->] ([xshift=-3pt]s2.north) -- ([xshift=-3pt]s3.south); 27 | \draw [->] ([xshift=+3pt]s3.south) -- ([xshift=+3pt]s2.north); 28 | 29 | \draw [<->] (c1) -- (sg); 30 | \draw [<->] (c2) -- (sg); 31 | 32 | \end{tikzpicture} 33 | \end{document} -------------------------------------------------------------------------------- /content/ch_03_RPC_CS/figures/ideaRPC.tex: -------------------------------------------------------------------------------- 1 | 2 | \documentclass[tikz]{standalone} 3 | 4 | 5 | \input{../../templates/tikzFigureHeader} 6 | 7 | \begin{document} 8 | \begin{msc}{Remote procedure call} 9 | % example: + 10 | % \declinst{c}{}{Client} 11 | % \declinst{cc}{}{Channel API} 12 | % \declinst{sc}{}{Channel API} 13 | % \declinst{s}{}{Server} 14 | % % 15 | % \regionstart{suspension}{s} 16 | % \nextlevel 17 | % \mess{Pass request to channel}{c}{cc} 18 | % \regionstart{activation}{c} 19 | % \msccomment[side=left]{Do something}{c} 20 | % \nextlevel 21 | % \msccomment[side=left]{Block for reply}{c} 22 | \declinst{a}{}{Caller in address space A} 23 | \declinst{b}{}{Callee in address space B} 24 | % \regionstart{suspension}{a} 25 | \msccomment[side=left]{Prepare parameters for transport}{a} 26 | \nextlevel 27 | \mess{Transport parameters, procedure ID}{a}{b} 28 | \nextlevel 29 | \msccomment[side=right]{Prepare parameters for use}{b} 30 | \nextlevel 31 | \msccomment[side=right]{Process}{b} 32 | \nextlevel 33 | \msccomment[side=right]{Prepare result for transport }{b} 34 | \nextlevel 35 | \mess{Transport result}{b}{a} 36 | \nextlevel 37 | \msccomment[side=left]{Retrieve result, prepare for use }{a} 38 | \end{msc} 39 | \end{document} -------------------------------------------------------------------------------- /content/ch_13_consensus/figures/impossible.tex: -------------------------------------------------------------------------------- 1 | % Created 2016-08-17 Wed 14:38 2 | \documentclass[tikz]{standalone} 3 | 4 | \input{../../templates/tikzFigureHeader} 5 | \usepackage{multirow} 6 | \usepackage{booktabs} 7 | \usepackage{adjustbox} 8 | \usepackage{marvosym} 9 | \begin{document} 10 | 11 | % tikzpicture is just necessary to get the bounding box width righ 12 | \begin{tikzpicture} 13 | \node {\begin{tabular}{llccccrr} 14 | \toprule 15 | \multicolumn{2}{}{} & 16 | \multicolumn{4}{c}{Message ordering} & 17 | \multicolumn{2}{}{} 18 | \\ 19 | \multicolumn{2}{}{} & 20 | \multicolumn{2}{c}{Unordered} & 21 | \multicolumn{2}{c}{Ordered} & 22 | \multicolumn{2}{}{} \\ 23 | \midrule 24 | \multirow{4}{*}{\rotatebox{90}{Process}} & \multirow{2}{*}{Synchronous} & ok& ok & ok & ok & Bounded & \multirow{4}{*}{\rotatebox{90}{Delay}} \\ 25 | && \Lightning & \Lightning & ok & ok & Unbounded & \\ 26 | %-------- 27 | & \multirow{2}{*}{Asynchronous} & \Lightning &\Lightning & \Lightning & ok &Bounded& \\ 28 | && \Lightning & \Lightning & \Lightning & ok & Unbounded& \\ 29 | \midrule 30 | && Unicast & Multicast & Unicast & Multicast && \\ 31 | \multicolumn{2}{}{} & 32 | \multicolumn{4}{c}{Message transmission} & 33 | \multicolumn{2}{}{} 34 | \\ 35 | \bottomrule 36 | \end{tabular}}; 37 | \end{tikzpicture} 38 | 39 | 40 | \end{document} -------------------------------------------------------------------------------- /content/ch_09_msqQueuing/figures/leaderelect_graph_FSM.tex: -------------------------------------------------------------------------------- 1 | % Created 2016-08-17 Wed 14:38 2 | \documentclass[tikz]{standalone} 3 | 4 | \input{../../templates/tikzFigureHeader} 5 | 6 | \usetikzlibrary{arrows,automata} 7 | 8 | \begin{document} 9 | 10 | \begin{tikzpicture}[->,>=stealth',shorten >=1pt,auto,node distance=4cm, semithick] 11 | 12 | \node[initial, state] (idle) {Idle}; 13 | \node[state] (invited) [below of=idle] {Invited}; 14 | \node[state, accepting] (done) [below of=invited] {Done}; 15 | 16 | \path (idle) edge node[align=left] {INVITE arrived: \\ parent=Sender; \\nNACK=nDONE=0 \\ Send INVITE to all \\but parent} (invited) 17 | (invited) edge [loop left] node [align=left] {NACK arrived and \\ nNACK+nDone < \#Neigh-1:\\nNACK++ \\ \\ 18 | DONE arrived and \\ nNACK+nDone < \#Neigh-1:\\nDONE++ 19 | } (invited) 20 | (invited) edge [loop right] node [align=left]{Smaller INVITE: Ignore \\ 21 | Equal INVITE: Return NACK\\ 22 | Bigger INVITE arrived:\\ 23 | Start new automaton} 24 | (invited) edge [bend right=45, auto,swap] node [align=left] {NACK arrived, else: \\ Send DONE to parent} (done) 25 | (invited) edge [bend left=45, auto] node [align=left] {DONE arrived, else: \\ Send DONE to parent} (done) 26 | (done) edge[loop below] node[align=left] {INVITE, NACK arrived:\\ Return NACK} (done) 27 | ; 28 | \end{tikzpicture} 29 | 30 | 31 | \end{document} -------------------------------------------------------------------------------- /content/ch_12_distTransactions/figures/deadlock.tex: -------------------------------------------------------------------------------- 1 | % Created 2016-08-17 Wed 14:38 2 | \documentclass[tikz]{standalone} 3 | 4 | \input{../../templates/tikzFigureHeader} 5 | 6 | \begin{document} 7 | \begin{tikzpicture} 8 | 9 | \node (t2) [fill=blue!20, draw, align=left, text width = 2cm] {Table 2}; 10 | \node (t2r1) [fill=blue!10, draw, align=left, below right, text width = 2cm] at (t2.south west) {Row 1}; 11 | \node (t2r2) [fill=blue!10, draw, align=left, below right, text width = 2cm] at (t2r1.south west) {Row 2}; 12 | 13 | \node (t1) [fill=yellow!20, draw, align=left, text width = 2cm] at (0, 2) {Table 1}; 14 | \node (t1r1) [fill=yellow!10, draw, align=left, below right, text width = 2cm] at (t1.south west) {Row 1}; 15 | \node (t1r2) [fill=yellow!10, draw, align=left, below right, text width = 2cm] at (t1r1.south west) {Row 2}; 16 | 17 | \node (tr1) [draw, rounded corners, fill=green!10] at (4,1.5) {Transaction 1}; 18 | \node (tr2) [draw, rounded corners, fill=cyan!10] at (4,-0.5) {Transaction 2}; 19 | 20 | \draw [->] ([yshift=+1pt]t2r1.east) -- ([yshift=-1pt]tr1.west); 21 | \draw [<-] ([yshift=+1pt]t1r2.east) -- ([yshift=1pt]tr1.west); 22 | 23 | \draw [<-] ([yshift=-1pt]t2r1.east) -- ([yshift=-1pt]tr2.west); 24 | \draw [->] ([yshift=-1pt]t1r2.east) -- ([yshift=+1pt]tr2.west); 25 | 26 | \end{tikzpicture} 27 | \end{document} -------------------------------------------------------------------------------- /content/ch_03_RPC_CS/figures/rmi.tex: -------------------------------------------------------------------------------- 1 | % RPC request/reply protocol 2 | 3 | 4 | \documentclass[tikz]{standalone} 5 | 6 | 7 | \input{../../templates/tikzFigureHeader} 8 | 9 | \begin{document} 10 | 11 | \begin{msc}{RPC -- no errors} 12 | \declinst{a}{}{Caller} 13 | \declinst{ap}{}{Stub} 14 | \declinst{reg}{}{Registry} 15 | \declinst{bp}{}{Skeleton} 16 | \declinst{b}{}{Callee} 17 | 18 | \inlinestart{register}{Register}{reg}{b} 19 | \nextlevel[2] 20 | \mess{Register}{b}{reg} 21 | \nextlevel 22 | \inlineend{register} 23 | \nextlevel 24 | 25 | 26 | \inlinestart{lookup}{Lookup}{a}{reg} 27 | \nextlevel[2] 28 | \mess{Lookup remote reference}{a}{reg} 29 | \nextlevel 30 | \mess{Reference}{reg}{a} 31 | \nextlevel 32 | \inlineend{lookup} 33 | \nextlevel 34 | 35 | \inlinestart{use}{Get stub}{a}{bp} 36 | \nextlevel[2] 37 | \mess{Get stub}{a}{bp} 38 | \nextlevel 39 | \mess{Stub}{bp}{a} 40 | \nextlevel 41 | \inlineend{use} 42 | \nextlevel 43 | 44 | 45 | \mess{Call}{a}{ap} 46 | \nextlevel 47 | \mess{Request}{ap}{bp} 48 | \nextlevel 49 | \mess{Call}{bp}{b} 50 | \nextlevel 51 | \mess{Result}{b}{bp} 52 | \nextlevel 53 | \mess{Reply}{bp}{ap} 54 | \nextlevel 55 | \mess{Result}{ap}{a} 56 | \end{msc} 57 | 58 | 59 | 60 | \end{document} -------------------------------------------------------------------------------- /content/ch_01_basic_CS/figures/idl.tex: -------------------------------------------------------------------------------- 1 | % Created 2016-08-17 Wed 14:38 2 | \documentclass[tikz]{standalone} 3 | \usepackage[utf8]{inputenc} 4 | \usepackage[T1]{fontenc} 5 | \usepackage{tikz} 6 | \author{Holger Karl} 7 | \date{\today} 8 | \title{} 9 | \begin{document} 10 | \begin{tikzpicture}[auto, xscale=3, 11 | block/.style = {rectangle, draw=black, thick, align=left}] 12 | \node [block] at (0,1) (sender) {\textbf{Sender:} \\x = native data;\\px = pack(x); 13 | \\send(px);}; 14 | \node [block] at (2,3) (idl) {Data definition file}; 15 | \node [block] at (2,2) (idlcomp) {IDL compiler}; 16 | \node [block] at (1,1) (pack) {pack()}; 17 | \node [block] at (3,1) (unpack) {unpack()}; 18 | \node [block] at (4,1) (receiver) {\textbf{Receiver:} \\px = receive();\\x = unpack(px); 19 | \\//use native data in x }; 20 | % 21 | \draw [->] (idl) -- (idlcomp); 22 | \draw [->] (idlcomp) -- (pack); 23 | \draw [->] (idlcomp) -- (unpack); 24 | \draw (-1,-1) -- (5,-1); 25 | \draw [->] (sender) -- (0, -1); 26 | \draw [->] (4, -1) -- (receiver); 27 | \draw [->] (sender.east) to [bend left=80] (pack.west) ; 28 | \draw [->] (pack.west) to [bend left=45] (sender.east) ; 29 | \draw [->] (receiver.west) to [bend left=45] (unpack.east) ; 30 | \draw [->] (unpack.east) to [bend left=45] (receiver.west) ; 31 | % \path (sender) edge [bend north ] node [right] {} (pack); 32 | \end{tikzpicture} 33 | \end{document} -------------------------------------------------------------------------------- /content/ch_08_des_pubsub/code/redis_ps.py: -------------------------------------------------------------------------------- 1 | import redis 2 | import threading 3 | import time 4 | 5 | class Listener(threading.Thread): 6 | def __init__(self, name, channels): 7 | threading.Thread.__init__(self, name=name) 8 | self.pubsub = redis.Redis().pubsub() 9 | self.pubsub.psubscribe(channels) 10 | 11 | def run(self): 12 | for item in self.pubsub.listen(): 13 | if item['type'] == "psubscribe": 14 | print(self.name, ": someone subscribed on channel {}", 15 | item['channel']) 16 | continue 17 | 18 | if item['data'] == b"KILL": 19 | self.pubsub.unsubscribe() 20 | print (self.name, ": unsubscribed and finished") 21 | break 22 | else: 23 | print("{} : channel {}, received: {}".format( 24 | self.name, item['channel'], item['data'])) 25 | 26 | if __name__ == "__main__": 27 | r = redis.Redis() 28 | clients = [Listener('A', ['test.1', 'control']), 29 | Listener('B', ['test.2', 'control']), 30 | Listener('C', ['test.*', '*.', 'control'])] 31 | [client.start() for client in clients] 32 | 33 | time.sleep(1) 34 | r.publish('test.1', 'for 1') 35 | time.sleep(1) 36 | r.publish('test.2', 'for 2 ') 37 | r.publish('test.', 'for neither') 38 | 39 | r.publish('control', 'KILL') 40 | -------------------------------------------------------------------------------- /content/ch_09_msqQueuing/figures/lcr_example.tex: -------------------------------------------------------------------------------- 1 | \documentclass[tikz]{standalone} 2 | 3 | \usepackage{tikz} 4 | 5 | \begin{document} 6 | 7 | \begin{tikzpicture} 8 | \draw [dotted] (0,0) circle (2cm); 9 | 10 | \foreach \angle/\value [count = \i] in {0/17, 45/22, 80/5, 140/12} { 11 | \node [circle, draw, fill=white] (p\i) at (\angle:2cm) {\value}; 12 | \ifnum\i=1 13 | \xdef\Lst{\value} 14 | \else 15 | \xdef\Lst{\Lst,\value} 16 | \fi 17 | } 18 | 19 | \foreach [evaluate = {\j=int(mod(\i, 4)+1)}] \i in {1,...,4} 20 | \draw [->] (p\i) to [bend right=45] node[midway] {\pgfkeysvalueof{/nodevalues/p\i}} (p\j) ; 21 | \end{tikzpicture} 22 | 23 | 24 | \begin{tikzpicture} 25 | \draw [dotted] (0,0) circle (2cm); 26 | % draw nodes on a circle, remembering their value no longer fails: 27 | \foreach \angle/\value [count = \i] in {0/17, 45/22, 80/5, 140/12} { 28 | \node [circle, draw, fill=white] (p\i) at (\angle:2cm) {\value}; 29 | \ifnum\i=1 30 | \xdef\Lst{\value} 31 | \else 32 | \xdef\Lst{\Lst,\value} 33 | \fi 34 | } 35 | % edges: 36 | \foreach [evaluate = {\j=int(mod(\i, 4)+1)}] \i in {1,...,4} 37 | \pgfmathsetmacro{\X}{{\Lst}[\i-1]} 38 | % \typeout{\X} 39 | \draw [->] (p\i) to [bend right=45] node[midway,auto,swap] 40 | {\X} (p\j) ; 41 | \end{tikzpicture} 42 | 43 | \end{document} -------------------------------------------------------------------------------- /content/ch_04_improving_CS/figures/three_tier.tex: -------------------------------------------------------------------------------- 1 | % Created 2016-08-17 Wed 14:38 2 | \documentclass[tikz]{standalone} 3 | 4 | \input{../../templates/tikzFigureHeader} 5 | 6 | \usepackage{fontawesome} 7 | 8 | \begin{document} 9 | \begin{tikzpicture}[auto, xscale=3, 10 | block/.style = {rectangle, draw=black, thick, align=left}] 11 | \node[block] at (0,0) (c1) {Client 1}; 12 | \node[block] at (0,1) (c2) {Client 2}; 13 | \node[block] at (1,1) (pr) {Proxy}; 14 | 15 | 16 | \node[block] at (1.5,2.5) (c3) {Client 3}; 17 | \node[block] at (1.5,3.5) (c4) {Client 4}; 18 | 19 | %server group: 20 | \node[block] at (3,1) (s1) {Server 1}; 21 | \node[block] at (3,2) (s2) {Server 2}; 22 | \node[block] at (3,3) (s3) {Server 3}; 23 | 24 | \draw (s2) node[minimum width=2cm, minimum 25 | height=3cm,draw,label={Server group}] (sg) {}; 26 | 27 | % inside SG: 28 | \draw [->] ([xshift=-3pt]s1.north) -- ([xshift=-3pt]s2.south); 29 | \draw [->] ([xshift=+3pt]s2.south) -- ([xshift=+3pt]s1.north); 30 | \draw [->] ([xshift=-3pt]s2.north) -- ([xshift=-3pt]s3.south); 31 | \draw [->] ([xshift=+3pt]s3.south) -- ([xshift=+3pt]s2.north); 32 | 33 | \draw [<->] (c1) -- (pr); 34 | \draw [<->] (c2) -- (pr); 35 | \draw [<->] (pr) -- (sg); 36 | 37 | \draw [<->] (c3) -- (sg); 38 | \draw [<->] (c4) -- (sg); 39 | 40 | 41 | % data base 42 | \node[block] at (4,2) (db) {\Huge \faDatabase}; 43 | \node at ([yshift=+6pt]db.north) {Data base}; 44 | \draw [<->] (s1.east) -- (db); 45 | \draw [<->] (s2.east) -- (db); 46 | \draw [<->] (s3.east) -- (db); 47 | 48 | 49 | \end{tikzpicture} 50 | \end{document} -------------------------------------------------------------------------------- /content/ch_04_improving_CS/figures/serverGroup_Database.tex: -------------------------------------------------------------------------------- 1 | % Created 2016-08-17 Wed 14:38 2 | \documentclass[tikz]{standalone} 3 | 4 | \input{../../templates/tikzFigureHeader} 5 | \usepackage{fontawesome} 6 | 7 | \begin{document} 8 | \begin{tikzpicture}[auto, xscale=3, 9 | block/.style = {rectangle, draw=black, thick, align=left}] 10 | \node[block] at (1,0) (c1) {Client 1}; 11 | \node[block] at (1,4) (c2) {Client 2}; 12 | \node[block] at (2,1) (s1) {Server 1}; 13 | \node[block] at (2,2) (s2) {Server 2}; 14 | \node[block] at (2,3) (s3) {Server 3}; 15 | % \draw ([xshift=-0.5mm,yshift=-1mm]s1.south west) rectangle ([xshift=+0.5mm,yshift=+1mm]s3.north 16 | % east); 17 | % \node at (2,3.5) {Server group}; 18 | % \draw [->] (c1) -- () 19 | % \draw (2,3) node[minimum width=4cm, minimum 20 | % height=4cm,draw,label={Server group}] (sg) {}; 21 | \draw (s2) node[minimum width=2cm, minimum 22 | height=3cm,draw,label={Server group}] (sg) {}; 23 | 24 | % inside SG: 25 | \draw [->] ([xshift=-3pt]s1.north) -- ([xshift=-3pt]s2.south); 26 | \draw [->] ([xshift=+3pt]s2.south) -- ([xshift=+3pt]s1.north); 27 | \draw [->] ([xshift=-3pt]s2.north) -- ([xshift=-3pt]s3.south); 28 | \draw [->] ([xshift=+3pt]s3.south) -- ([xshift=+3pt]s2.north); 29 | 30 | \draw [<->] (c1) -- (sg); 31 | \draw [<->] (c2) -- (sg); 32 | 33 | % data base 34 | \node[block] at (3,2) (db) {\Huge \faDatabase}; 35 | \node at ([yshift=+6pt]db.north) {Data base}; 36 | \draw [<->] (s1.east) -- (db); 37 | \draw [<->] (s2.east) -- (db); 38 | \draw [<->] (s3.east) -- (db); 39 | 40 | 41 | \end{tikzpicture} 42 | \end{document} -------------------------------------------------------------------------------- /content/ch_14_nosql/figures/kerberos.tex: -------------------------------------------------------------------------------- 1 | 2 | \documentclass[tikz]{standalone} 3 | 4 | 5 | \input{../../templates/tikzFigureHeader} 6 | 7 | \begin{document} 8 | \begin{msc}[instance distance=1.5cm]{Kerberos} 9 | \declinst{a}{}{Alice} 10 | \declinst{c}{}{Alice's machine} 11 | \declinst{as}{}{AS} 12 | \declinst{tgs}{}{TGS} 13 | \declinst{s}{}{Server S} 14 | 15 | \mess{login}{a}{c} 16 | \nextlevel 17 | \mess{Alice ID: A}{c}{as} 18 | \nextlevel[2] 19 | 20 | \mess{$K_{A, \mathrm{AS}} ( K_{A, \mathrm{TGS}}, K_{\mathrm{AS}, \mathrm{TGS}} (A, K_{A, \mathrm{TGS}}) ) $ }{as}{c} 21 | \nextlevel[2] 22 | 23 | \mess{Password?}{c}{a} 24 | \nextlevel[1] 25 | 26 | \mess{PWD}{a}{c} 27 | \nextlevel[2] 28 | 29 | \mess{$K_{\mathrm{AS}, \mathrm{TGS}} ( A, K_{A, \mathrm{TGS}}), S, K_{A, \mathrm{TGS}}(t) $ }{c}{tgs} 30 | \nextlevel[2] 31 | 32 | \mess{$K_{\mathrm{A}, \mathrm{TGS}} ( S, K_{A,S}), K_{\mathrm{A}, \mathrm{TGS}} (S, K_{A,S}) $ }{tgs}{c} 33 | \nextlevel[2] 34 | 35 | \mess{Use $K_{A, S}$}{c}{s} 36 | 37 | % example: + 38 | % \declinst{c}{}{Client} 39 | % \declinst{cc}{}{Channel API} 40 | % \declinst{sc}{}{Channel API} 41 | % \declinst{s}{}{Server} 42 | % % 43 | % \regionstart{suspension}{s} 44 | % \nextlevel 45 | % \mess{Pass request to channel}{c}{cc} 46 | % \regionstart{activation}{c} 47 | % \msccomment[side=left]{Do something}{c} 48 | % \nextlevel 49 | % \msccomment[side=left]{Block for reply}{c} 50 | 51 | \end{msc} 52 | \end{document} -------------------------------------------------------------------------------- /content/ch_07_mcast_ncs/figures/to_classes.tex: -------------------------------------------------------------------------------- 1 | % Created 2016-08-17 Wed 14:38 2 | \documentclass[tikz]{standalone} 3 | 4 | \input{../../templates/tikzFigureHeader} 5 | 6 | \usetikzlibrary{positioning, fit, chains} 7 | 8 | 9 | \begin{document} 10 | % \begin{tikzpicture}[auto, 11 | % block/.style = {rectangle, draw=black, thick, align=center}, 12 | % node distance = 0.5cm, 13 | % start chain= a going below] 14 | 15 | % \node[block, on chain] {fixed\\sequencer}; 16 | % \node[block, on chain] {moving\\sequencer}; 17 | % \node[block, on chain] {privilege-\\based}; 18 | % \node[block, on chain] {communication \\history}; 19 | % \node[block, on chain] {destinations \\agreement}; 20 | 21 | % \node (s1) [left=of a-1] {Sequencer}; 22 | % \node (s2) [left=of a-3] {Sender}; 23 | % \node (s3) [left=of a-5] {Destinations}; 24 | 25 | % \node[draw=red, fit = (s1) (a-1) (a-2)]; 26 | 27 | % \end{tikzpicture} 28 | \begin{tikzpicture}[auto, 29 | block/.style = {rectangle, draw=black, thick, align=center}, 30 | node distance = 0.5cm, 31 | start chain= a going below] 32 | 33 | \node[block, on chain] {fixed\\sequencer}; 34 | \node[block, on chain] {moving\\sequencer}; 35 | \node[block, on chain] {privilege-\\based}; 36 | \node[block, on chain] {communication \\history}; 37 | \node[block, on chain] {destinations \\agreement}; 38 | 39 | \node (s1) [left=of a-1] {Sequencer}; 40 | \node (s2) [left=of a-3] {Sender}; 41 | \node (s3) [left=of a-5] {Destinations}; 42 | 43 | \node[draw=red, fit = (s1) (a-1) (a-2)] {}; 44 | 45 | \end{tikzpicture} 46 | \end{document} -------------------------------------------------------------------------------- /homework/WireTransfer/README.md: -------------------------------------------------------------------------------- 1 | 2 | # FlatBuffers example 3 | 4 | ## What it is 5 | This example shows you, how to utilize FlatBuffers serialization library to exchange data across different languages. See [FlatBuffers](https://google.github.io/flatbuffers/) and [FlatCC](https://github.com/dvidelabs/flatcc) for more information. 6 | 7 | ## Interface Definition Language (IDL) 8 | FlatBuffers use a IDL called schema language to describe structured data. The file `message.fbs` is a schema, which has to be compiled to the target language. 9 | 10 | Use the [flatc](https://google.github.io/flatbuffers/flatbuffers_guide_building.html) compiler to generate Java code: 11 | `flatc --java message.fbs` 12 | 13 | The C language binding exists in a separate project named [FlatCC](https://github.com/dvidelabs/flatcc). So you have to use the [flatcc](https://github.com/dvidelabs/flatcc#building) compiler to generate C code: 14 | `flatcc -a message.fsb` 15 | 16 | ## Use FlatBuffers 17 | 18 | ### Java 19 | Beside the generated `.java` files you have to include FlatBuffers Java library found [here](https://github.com/google/flatbuffers/tree/master/java/com/google/flatbuffers). 20 | 21 | 22 | ### C 23 | For this example you have to include these generated header files: `message_C_builder.h`, `message_C_reader.h`, `flatbuffers_common_builder.h`, `flatbuffers_common_reader.h` in the compilation process. 24 | 25 | Besides that you need serveral files from the [FlatCC build](https://github.com/dvidelabs/flatcc#building): 26 | * Include headers from `flatcc-0.5.2/include/` 27 | * Link with library `flatcc-0.5.2/lib/libflatccrt.a`, the runtime library is needed for building messages. 28 | -------------------------------------------------------------------------------- /content/ch_09_msqQueuing/figures/rabbit_mq.tex: -------------------------------------------------------------------------------- 1 | % Created 2016-08-17 Wed 14:38 2 | \documentclass[tikz]{standalone} 3 | 4 | \input{../../templates/tikzFigureHeader} 5 | 6 | \usetikzlibrary{chains,shapes.multipart} 7 | \usetikzlibrary{shapes,calc} 8 | \usetikzlibrary{automata,positioning} 9 | 10 | \tikzset{ 11 | queue/.pic={ 12 | \draw[line width=1pt] 13 | (0,0) -- ++(2.75cm,0) -- ++(0,-1cm) -- ++(-2.75cm,0); 14 | \fill [fill=red!10] (2.75cm-#1*10pt, -1cm) -- (2.75cm-#1*10pt, 0) -- (2.75cm,0) -- (2.75cm,-1cm)-- cycle ; 15 | \foreach \Val in {1,...,#1} 16 | \draw ([xshift=-\Val*10pt]2.75cm,0) -- ++(0,-1cm); 17 | }} 18 | 19 | \begin{document} 20 | \begin{tikzpicture}[auto, 21 | block/.style = {rectangle, draw=black, thick, align=left}] 22 | 23 | \node [draw,circle, fill=blue!10] at (0,0) (p) {Producer}; 24 | \node [draw,circle, fill=green!10] at (3,0) (e) {Exchange}; 25 | \node [above=of e,yshift=-1cm] {type=topic}; 26 | 27 | \path (8,3) pic {queue=3}; 28 | \path (8,-2) pic {queue=5}; 29 | 30 | \node [draw,circle, fill=yellow!10] at (14,-3) (c3) {Consumer 3}; 31 | \node [draw,circle, fill=yellow!10] at (14,0) (c2) {Consumer 2}; 32 | \node [draw,circle, fill=yellow!10] at (14,3) (c1) {Consumer 1}; 33 | 34 | \draw[->, very thick] (p) -- (e); 35 | \draw[->, very thick] (e) -- (8,2.5) node [yshift=.25cm, above,midway] {*.key1.*}; 36 | \draw[->, very thick] (e) -- (8,-2.5) node [xshift=1cm, above,midway,align=center] {topic1.*.*,\\ topic2.notkey.*}; 37 | 38 | \draw[->, very thick] (11,-2.5) -- (c3); 39 | \draw[->, very thick] (11,-2.5) -- (c2); 40 | \draw[->, very thick] (11,2.5) -- (c1); 41 | 42 | 43 | \end{tikzpicture} 44 | \end{document} -------------------------------------------------------------------------------- /content/ch_21_bigdata/figures/kmeans.tex: -------------------------------------------------------------------------------- 1 | \documentclass[tikz]{standalone} 2 | 3 | \input{../../templates/tikzFigureHeader} 4 | \usetikzlibrary{calc} 5 | 6 | \begin{document} 7 | 8 | \begin{tikzpicture} 9 | \foreach \x in {1,2,...,30}{ 10 | \node[text=red] at (4*rand+1, 3*rand+4) {\Large \textbf X}; 11 | } 12 | \foreach \x in {1,2,...,20}{ 13 | \node[text=black] at (1*rand+7, 1*rand+1) {\Large \textbf O}; 14 | } 15 | \end{tikzpicture} 16 | 17 | 18 | \begin{tikzpicture} 19 | \foreach \x in {1,2,...,30}{ 20 | \node[text=red] at (4*rand+1, 3*rand+4) {\Large \textbf X}; 21 | } 22 | \foreach \x in {1,2,...,20}{ 23 | \node[text=black] at (1*rand+7, 1*rand+1) {\Large \textbf O}; 24 | } 25 | 26 | \node[text=black] at (7,5) {\Large \textbf O}; 27 | \node[text=black] at (7.5,6) {\Large \textbf O}; 28 | \end{tikzpicture} 29 | 30 | 31 | \begin{tikzpicture} 32 | \foreach \x in {1,2,...,30}{ 33 | \node[text=red] at (6*rand+1, 3*rand+4) {\Large \textbf X}; 34 | } 35 | \foreach \x in {1,2,...,20}{ 36 | \node[text=black] at (1*rand+7, 3*rand+1) {\Large \textbf O}; 37 | } 38 | \end{tikzpicture} 39 | 40 | \begin{tikzpicture} 41 | \foreach \x in {1,2,...,25}{ 42 | \node[text=red] at (6*rand+1, 3*rand+4) {\Large \textbf X}; 43 | } 44 | \foreach \x in {1,2,...,25}{ 45 | \node[text=red] at (6*rand+5, 1*rand+5) {\Large \textbf X}; 46 | } 47 | \foreach \x in {1,2,...,25}{ 48 | \node[text=red] at (2*rand+2, 3*rand+0) {\Large \textbf X}; 49 | } 50 | 51 | \foreach \x in {1,2,...,20}{ 52 | \node[text=black] at (1*rand+8, 3*rand+0) {\Large \textbf O}; 53 | } 54 | \end{tikzpicture} 55 | 56 | 57 | \end{document} -------------------------------------------------------------------------------- /content/ch_21_bigdata/figures/bdAnalyticsFlowChart.tex: -------------------------------------------------------------------------------- 1 | % Created 2016-08-17 Wed 14:38 2 | \documentclass[tikz]{standalone} 3 | 4 | \input{../../templates/tikzFigureHeader} 5 | \usetikzlibrary{arrows.meta, 6 | calc, chains, 7 | quotes, 8 | positioning, 9 | shapes.geometric} 10 | 11 | 12 | 13 | \begin{document} 14 | 15 | \begin{tikzpicture}[ 16 | node distance = 8mm and 16mm, 17 | start chain = A going below, 18 | base/.style = {draw, minimum width=32mm, minimum height=8mm, 19 | align=center, on chain=A}, 20 | startstop/.style = {base, rectangle, rounded corners, fill=red!10}, 21 | process/.style = {base, rectangle, fill=orange!30}, 22 | io/.style = {base, trapezium, 23 | trapezium left angle=70, trapezium right angle=110, 24 | fill=blue!30}, 25 | decision/.style = {base, diamond, fill=green!30, aspect=4}, 26 | db/.style = {base, database, fill=blue!10,aspect=0.15}, 27 | every edge quotes/.style = {auto=right}] 28 | ] 29 | \node [db] { Operational DB}; 30 | \node [process] { Collect, clean, integrate}; 31 | \node [db] { Data warehouse}; 32 | \node [process] { Preprocess}; 33 | \node [db] { Intermediate storage}; 34 | \node [process] { Analyse}; 35 | \node [db] { Models, patterns}; 36 | \node [process, right=of A-7] { Verify, evaluate}; 37 | %% 38 | \draw [->] (A-1) edge (A-2) 39 | (A-2) edge (A-3) 40 | (A-3) edge (A-4) 41 | (A-4) edge (A-5) 42 | (A-5) edge (A-6) 43 | (A-6) edge (A-7) 44 | (A-7) edge (A-8) 45 | (A-8) |- (A-4.east) 46 | ; 47 | \end{tikzpicture} 48 | 49 | 50 | 51 | \end{document} -------------------------------------------------------------------------------- /content/ch_02_web_CS/figures/mvc.tex: -------------------------------------------------------------------------------- 1 | % Created 2016-08-17 Wed 14:38 2 | \documentclass[tikz]{standalone} 3 | 4 | \input{../../templates/tikzFigureHeader} 5 | 6 | \begin{document} 7 | \begin{tikzpicture}[auto, xscale=3, 8 | block/.style = {rectangle, draw=black, thick, align=left}] 9 | \node[block] at (0,1) (u) {User}; 10 | \node[block] at (1,0) (c) {Controller}; 11 | \node[block] at (1,2) (v) {View}; 12 | \node[block] at (2,1) (m) {Model}; 13 | 14 | \draw[->] (c) -| node[below] {manipulates} (m); 15 | \draw[->] (m) |- node[above] {updates} (v); 16 | \draw[->] (u) -- node[above] {accesses} (v.west); 17 | \draw[->] (u) -- node[below] {sees} (c.west); 18 | 19 | % \node [block] at (0,1) (sender) {\textbf{Sender:} \\x = native data;\\px = pack(x); 20 | % \\send(px);}; 21 | % \node [block] at (2,3) (idl) {Data definition file}; 22 | % \node [block] at (2,2) (idlcomp) {IDL compiler}; 23 | % \node [block] at (1,1) (pack) {pack()}; 24 | % \node [block] at (3,1) (unpack) {unpack()}; 25 | % \node [block] at (4,1) (receiver) {\textbf{Receiver:} \\px = receive();\\x = unpack(px); 26 | % \\//use native data in x }; 27 | % % 28 | % \draw [->] (idl) -- (idlcomp); 29 | % \draw [->] (idlcomp) -- (pack); 30 | % \draw [->] (idlcomp) -- (unpack); 31 | % \draw (-1,-1) -- (5,-1); 32 | % \draw [->] (sender) -- (0, -1); 33 | % \draw [->] (4, -1) -- (receiver); 34 | % \draw [->] (sender.east) to [bend left=80] (pack.west) ; 35 | % \draw [->] (pack.west) to [bend left=45] (sender.east) ; 36 | % \draw [->] (receiver.west) to [bend left=45] (unpack.east) ; 37 | % \draw [->] (unpack.east) to [bend left=45] (receiver.west) ; 38 | % \path (sender) edge [bend north ] node [right] {} (pack); 39 | \end{tikzpicture} 40 | \end{document} -------------------------------------------------------------------------------- /content/ch_02_web_CS/figures/uwsgi.tex: -------------------------------------------------------------------------------- 1 | % Created 2016-08-17 Wed 14:38 2 | \documentclass[tikz]{standalone} 3 | 4 | \input{../../templates/tikzFigureHeader} 5 | \usetikzlibrary{positioning,fit,calc} 6 | 7 | \begin{document} 8 | \begin{tikzpicture}[auto, xscale=3, 9 | block/.style = {rectangle, draw=black, thick, align=left}] 10 | \node[block] at (0,0) (b) {Browser}; 11 | \node[block] at (1,0) (n) {nginx}; 12 | \node[block] at (2,0) (u) {uwsgi}; 13 | \node[block] at (3,0) (ac) {Application code}; 14 | \node[] (d) [above=of ac.north, yshift=-1cm] {django }; 15 | \node[draw=black, fit=(ac) (d)] (d) {}; 16 | \node[block] at (4,0) (p) {postgresql}; 17 | 18 | \draw[-] (b) --(n); 19 | \draw[-] (n) --(u); 20 | \draw[-] (u) --(d); 21 | \draw[-] (d) --(p); 22 | % \node [block] at (0,1) (sender) {\textbf{Sender:} \\x = native data;\\px = pack(x); 23 | % \\send(px);}; 24 | % \node [block] at (2,3) (idl) {Data definition file}; 25 | % \node [block] at (2,2) (idlcomp) {IDL compiler}; 26 | % \node [block] at (1,1) (pack) {pack()}; 27 | % \node [block] at (3,1) (unpack) {unpack()}; 28 | % \node [block] at (4,1) (receiver) {\textbf{Receiver:} \\px = receive();\\x = unpack(px); 29 | % \\//use native data in x }; 30 | % % 31 | % \draw [->] (idl) -- (idlcomp); 32 | % \draw [->] (idlcomp) -- (pack); 33 | % \draw [->] (idlcomp) -- (unpack); 34 | % \draw (-1,-1) -- (5,-1); 35 | % \draw [->] (sender) -- (0, -1); 36 | % \draw [->] (4, -1) -- (receiver); 37 | % \draw [->] (sender.east) to [bend left=80] (pack.west) ; 38 | % \draw [->] (pack.west) to [bend left=45] (sender.east) ; 39 | % \draw [->] (receiver.west) to [bend left=45] (unpack.east) ; 40 | % \draw [->] (unpack.east) to [bend left=45] (receiver.west) ; 41 | % \path (sender) edge [bend north ] node [right] {} (pack); 42 | \end{tikzpicture} 43 | \end{document} -------------------------------------------------------------------------------- /content/ch_07_mcast_ncs/figures/mcast_protocol.tex: -------------------------------------------------------------------------------- 1 | % Created 2016-08-17 Wed 14:38 2 | \documentclass[tikz]{standalone} 3 | 4 | \input{../../templates/tikzFigureHeader} 5 | 6 | \usetikzlibrary{positioning, fit} 7 | 8 | 9 | \begin{document} 10 | \begin{tikzpicture}[auto, 11 | block/.style = {rectangle, draw=black, thick, align=left}, 12 | node distance = 1cm] 13 | 14 | \begin{scope}[on grid] 15 | 16 | \node[block] (s_app) at (0,3) {Application}; 17 | \node[block] (s_mcast) [on grid, below=1.5 of s_app] {Multicast}; 18 | \node[block] (r1_app) [on grid, right=3.5cm of s_app] {Application}; 19 | \node[block] (r1_mcast) [on grid, below=1.5 of r1_app] {Multicast}; 20 | \node[block] (r2_app) [on grid, right=3.5cm of r1_app] {Application}; 21 | \node[block] (r2_mcast) [on grid, below=1.5 of r2_app] {Multicast}; 22 | 23 | \draw[thick] (-1,0) -- (10,0) node (network) {}; 24 | \node at (5, -0.5) {Network with unreliable multicast}; 25 | 26 | \node (sender) [on grid, above=of s_app] {Sender}; 27 | \node (r1) [on grid, above=of r1_app] {Receiver}; 28 | \node (r2) [on grid, above=of r2_app] {Receiver}; 29 | 30 | \node [draw, fit=(s_app) (s_mcast) (sender) ] {}; 31 | \node [draw, fit=(r1_app) (r1_mcast) (r1) ] {}; 32 | \node [draw, fit=(r2_app) (r2_mcast) (r2) ] {}; 33 | 34 | \draw [->](s_mcast) -> (s_mcast |- network) node [left,midway, text=red] {\textbf{Transmission}}; 35 | \draw [<-] (r1_mcast) -> (r1_mcast |- network) ; 36 | \draw [<-] (r2_mcast) -> (r2_mcast |- network) node [right,midway, text=red] {\textbf{Reception}}; 37 | 38 | \draw [->](s_app) -> (s_mcast) node [left,midway, text=red] {\textbf{Orgination}}; 39 | \draw [->] (r1_mcast) -> (r1_app) ; 40 | \draw [<-] (r2_app) -> (r2_mcast) node [right,midway, text=red] {\textbf{Delivery}}; 41 | 42 | \end{scope} 43 | \end{tikzpicture} 44 | \end{document} -------------------------------------------------------------------------------- /content/ch_03_RPC_CS/figures/acks.tex: -------------------------------------------------------------------------------- 1 | 2 | \documentclass[tikz]{standalone} 3 | 4 | 5 | \input{../../templates/tikzFigureHeader} 6 | 7 | \begin{document} 8 | \begin{msc}{Normal operation} 9 | \declinst{a}{}{A} 10 | \declinst{b}{}{B} 11 | 12 | \mess{P1}{a}{b}[1] 13 | \nextlevel[2] 14 | \mess{A1}{b}{a}[1] 15 | \nextlevel[2] 16 | 17 | \mess{P2}{a}{b}[1] 18 | \nextlevel[2] 19 | \mess{A2}{b}{a}[1] 20 | \nextlevel[2] 21 | \end{msc} 22 | 23 | 24 | \begin{msc}{Packet delayed} 25 | \declinst{a}{}{A} 26 | \declinst{b}{}{B} 27 | 28 | \mess{P1}{a}{b}[1] 29 | \nextlevel[2] 30 | \mess{A1}{b}{a}[1] 31 | \nextlevel[2] 32 | 33 | \mess{P2}{a}[0.1]{b}[7] 34 | \nextlevel[3] 35 | 36 | \timeout{}{a} 37 | 38 | \mess{P2}{a}{b}[1] 39 | \nextlevel[2] 40 | \mess{A2}{b}[0.2]{a}[1] 41 | \nextlevel[2] 42 | 43 | \msccomment[r]{Ignore duplicate}{b} 44 | 45 | \end{msc} 46 | \setlength{\instdist}{4cm} 47 | \begin{msc}{Paket and ACK delayed} 48 | \declinst{a}{}{A} 49 | \declinst{b}{}{B} 50 | 51 | \mess{P1 (SN 0)}{a}{b}[1] 52 | \nextlevel[2] 53 | \mess{A0}{b}[0.1]{a}[13] 54 | \nextlevel[2] 55 | \timeout{}{a} 56 | 57 | \mess{P1 (SN 0)}{a}{b}[1] 58 | \nextlevel[1] 59 | \msccomment[r]{Ignore duplicate}{b} 60 | \nextlevel[1] 61 | \mess{A0}{b}[0.1]{a}[1] 62 | \nextlevel[2] 63 | 64 | \mess{P2 (SN 1)}{a}{b}[1] 65 | \nextlevel[2] 66 | \mess{A1}{b}[0.1]{a}[1] 67 | \nextlevel[2] 68 | 69 | \mess{P3 (SN 0)}{a}[0.1]{b}[10] 70 | \nextlevel[4] 71 | 72 | \mess{P4 (SN 1)}{a}{b}[1] 73 | \nextlevel[1] 74 | \msccomment[r]{INCORRECTLY considered duplicate}{b} 75 | \nextlevel[1] 76 | \mess{A1}{b}[0.1]{a}[1] 77 | \nextlevel[2] 78 | 79 | 80 | % \msccomment[r]{Ignore duplicate}{b} 81 | 82 | \end{msc} 83 | 84 | \end{document} -------------------------------------------------------------------------------- /content/ch_05_practical/figures/ci_workflow.tex: -------------------------------------------------------------------------------- 1 | % Created 2016-08-17 Wed 14:38 2 | \documentclass[tikz]{standalone} 3 | 4 | \input{../../templates/tikzFigureHeader} 5 | \usepackage{tikzsymbols} 6 | 7 | 8 | \begin{document} 9 | \begin{tikzpicture}[auto, xscale=3, 10 | block/.style = {rectangle, draw=black, thick, align=left}] 11 | % \node [block] at (0,1) (sender) {\textbf{Sender:} \\x = native data;\\px = pack(x); 12 | % \\send(px);}; 13 | % \node [block] at (2,3) (idl) {Data definition file}; 14 | % \node [block] at (2,2) (idlcomp) {IDL compiler}; 15 | % \node [block] at (1,1) (pack) {pack()}; 16 | % \node [block] at (3,1) (unpack) {unpack()}; 17 | % \node [block] at (4,1) (receiver) {\textbf{Receiver:} \\px = receive();\\x = unpack(px); 18 | % \\//use native data in x }; 19 | % % 20 | % \draw [->] (idl) -- (idlcomp); 21 | % \draw [->] (idlcomp) -- (pack); 22 | % \draw [->] (idlcomp) -- (unpack); 23 | % \draw (-1,-1) -- (5,-1); 24 | % \draw [->] (sender) -- (0, -1); 25 | % \draw [->] (4, -1) -- (receiver); 26 | % \draw [->] (sender.east) to [bend left=80] (pack.west) ; 27 | % \draw [->] (pack.west) to [bend left=45] (sender.east) ; 28 | % \draw [->] (receiver.west) to [bend left=45] (unpack.east) ; 29 | % \draw [->] (unpack.east) to [bend left=45] (receiver.west) ; 30 | % \path (sender) edge [bend north ] node [right] {} (pack); 31 | 32 | \node at (-1,0) (h) {\Strichmaxerl[5]}; 33 | \node [block] at (0,0) (c) {Code\\update\\pushed}; 34 | \node [block] at (1,0) (v) {VCS\\triggers}; 35 | \node [block] at (2,0) (b) {Build \&\\test}; 36 | \node [block] at (3,0) (p) {Deploy to \\production}; 37 | \draw [->] (h) -- (c); 38 | \draw [->] (c) -- (v); 39 | \draw [->] (v) -- (b); 40 | \draw [->] (b) -- node [above] {Success} (p); 41 | \draw [->] (b) -- (2,1) -- node [above] {Fail, report} (-1,1) --(h); 42 | 43 | \end{tikzpicture} 44 | \end{document} -------------------------------------------------------------------------------- /content/ch_11_distStorage/figures/zookeeper.tex: -------------------------------------------------------------------------------- 1 | % Created 2016-08-17 Wed 14:38 2 | \documentclass[tikz]{standalone} 3 | 4 | \input{../../templates/tikzFigureHeader} 5 | 6 | 7 | 8 | \usetikzlibrary{graphs} 9 | 10 | \begin{document} 11 | \begin{tikzpicture} 12 | % 13 | 14 | 15 | 16 | % Servers: 17 | \node [draw, fill=blue!10] (s1) {Server}; 18 | \foreach \i [evaluate=\i as \previousi using \i-1] in {2,...,6} { 19 | \node [draw, fill=blue!10, right=of s\previousi] (s\i) {Server}; 20 | } 21 | \node [fill=red!10, draw, below= 0cm of s3] (l) {Leader}; 22 | \coordinate (tmp) at (1,1.5); 23 | \node at (0,1.5) (zs) {Zookeeper Service}; 24 | 25 | 26 | \begin{pgfonlayer}{background} 27 | \node [rounded corners, draw, fill=green!5, fit=(s1) (s6) (l) (zs) ] 28 | {}; 29 | \end{pgfonlayer} 30 | \foreach \i in {1,...,2} { 31 | \draw [->] (s\i.north) to[out=30] (s3.north); 32 | } 33 | \foreach \i in {4,...,6} { 34 | \draw [->] (s\i.north) to[out=150, in=30] (s3.north); 35 | } 36 | 37 | \node [below left=of s1, draw, fill=yellow!10] (c1) {Client}; 38 | \foreach \i [evaluate=\i as \previousi using \i-1] in {2,...,8} { 39 | \node [draw, fill=yellow!10, right=of c\previousi] (c\i) {Client}; 40 | } 41 | 42 | \draw [->] (c1) -- (s1); 43 | \draw [->] (c2) -- (s1); 44 | \draw [->] (c3) -- (s2); 45 | \draw [->] (c4) -- (s2); 46 | \draw [->] (c5) -- (s2); 47 | \draw [->] (c6) -- (s4); 48 | \draw [->] (c7) -- (s4); 49 | \draw [->] (c8) -- (s6); 50 | 51 | \end{tikzpicture} 52 | 53 | 54 | %--------------------- 55 | % 2: namespace 56 | 57 | \begin{tikzpicture} 58 | % \graph { \texttt{t} -> {b, c} -> d }; 59 | \graph [grow down, branch right=2cm, nodes={thin, fill=gray!10}] { "/" -> 60 | { 61 | "/app1" -> { 62 | "/app1/n1/", 63 | "/app1/n2/", 64 | "/app1/n3/" 65 | }, 66 | "/app2", 67 | "/serviceA" 68 | } }; 69 | \end{tikzpicture} 70 | 71 | 72 | \end{document} -------------------------------------------------------------------------------- /content/ch_03_RPC_CS/figures/RPCproxy.tex: -------------------------------------------------------------------------------- 1 | 2 | \documentclass[tikz]{standalone} 3 | 4 | 5 | \input{../../templates/tikzFigureHeader} 6 | 7 | \begin{document} 8 | \begin{msc}{Remote procedure call} 9 | \declinst{a}{}{Caller in A} 10 | \declinst{ap}{}{Callee proxy in A} 11 | \declinst{bp}{}{Caller proxy in B} 12 | \declinst{b}{}{Callee in B} 13 | % \regionstart{suspension}{a} 14 | \msccomment[side=left]{Put parameters, return address on stack}{a} 15 | \nextlevel 16 | \mess{Jump}{a}{ap} 17 | \nextlevel 18 | \msccomment[side=left]{Access parameters on stack}{ap} 19 | \nextlevel 20 | % -- 21 | \msccomment[side=left]{Prepare parameters for transport}{ap} 22 | \nextlevel[2] 23 | \mess{Transport parameters, procedure ID}{ap}{bp} 24 | \nextlevel 25 | \msccomment[side=right]{Prepare parameters for use}{bp} 26 | \nextlevel 27 | %--- 28 | \msccomment[side=right]{Put parameters, return address on stack}{bp} 29 | \nextlevel[2] 30 | \mess{Jump}{bp}{b} 31 | \nextlevel 32 | \msccomment[side=right]{Access parameters on stack}{b} 33 | \nextlevel 34 | %-------- 35 | \msccomment[side=right]{Process}{b} 36 | \nextlevel 37 | \msccomment[side=right]{Put result on stack }{b} 38 | \nextlevel[2] 39 | \mess{Jump}{b}{bp} 40 | \nextlevel 41 | \msccomment[side=right]{Retrieve result from stack }{bp} 42 | \nextlevel 43 | %---- 44 | \msccomment[side=right]{Prepare result for transport }{bp} 45 | \nextlevel 46 | % 47 | \mess{Transport result}{bp}{ap} 48 | \nextlevel 49 | \msccomment[side=left]{Retrieve result, prepare for use }{ap} 50 | \nextlevel 51 | \msccomment[side=left]{Put result on stack }{ap} 52 | \nextlevel[2] 53 | \mess{Jump}{ap}{a} 54 | \nextlevel 55 | %--- 56 | \msccomment[side=left]{Retrieve result from stack }{a} 57 | \end{msc} 58 | \end{document} -------------------------------------------------------------------------------- /content/ch_04_improving_CS/figures/failure_detector.tex: -------------------------------------------------------------------------------- 1 | % Created 2016-08-17 Wed 14:38 2 | \documentclass[tikz,12pt]{standalone} 3 | 4 | \input{../../templates/tikzFigureHeader} 5 | \usetikzlibrary{decorations.pathreplacing} 6 | 7 | \usepackage{marvosym} 8 | \usepackage{calc} 9 | 10 | 11 | 12 | \begin{document} 13 | 14 | \begin{tikzpicture} 15 | \Huge 16 | 17 | % grid and coordinates: 18 | \draw [dotted, thin ] (0,0) grid (20, 7); 19 | \draw [thick, ->] (0,0) -- (20.5, 0); 20 | \draw [thick, ->] (0,0) -- (0, 7.5); 21 | \node at (21, -0.25) {$t$}; 22 | \foreach \x in {0,1, ..., 20} \node[anchor=north] at (\x,-0.25) {\x}; 23 | % system and detector states: 24 | \node[anchor=east] (left) at (0, 6) {Believed ok}; 25 | \node[anchor=east] (left) at (0, 5) {Suspect}; 26 | \node[anchor=east] (left) at (0, 4) {Believed failed}; 27 | 28 | \node[anchor=east] (center) at (0, 2) {System ok}; 29 | \node[anchor=east] (right) at (0, 1) {System failed}; 30 | 31 | % time frames of discrepancies: 32 | \foreach \s/\e in {2/3, 4/4.5,6/7,9/10,14/15} { 33 | \draw[fill=gray!10] (\s,0) rectangle (\e,7); 34 | \node at (\s+0.2,7.5) {\Huge\Lightning}; 35 | % This is what I really want: 36 | % \node at (0.5\s+0.5\e,7.5) {\Huge\Lightning}; 37 | } 38 | 39 | % \draw[fill=gray!10] (2,0) rectangle (3,7); \node at (2.5,7.5) {\Huge\Lightning}; 40 | % \draw[fill=gray!10] (4,0) rectangle (4.5,7); \node at (4.25,7.5) {\Huge\Lightning}; 41 | 42 | 43 | % system ground truth: 44 | \draw [very thick, blue] (0,2) -- (2,2) -- (2,1) -- (3, 1) -- (3,2) 45 | -- (6,2) -- (6, 1) -- (9, 1) -- (9, 2) -- (14, 2) -- (14, 1) -- 46 | (20,1); 47 | 48 | % detector: 49 | \draw[very thick, red] (0, 6) -- (4,6) -- (4, 5) -- (4.5, 5) -- 50 | (4.5, 6) -- (7,6) -- (7,5) -- (10,5) -- (10,6) -- (15, 6) -- 51 | (15, 5) -- (18,5) -- (18,4) -- (20, 4); 52 | 53 | \end{tikzpicture} 54 | 55 | \end{document} -------------------------------------------------------------------------------- /content/ch_04_improving_CS/figures/proxy.tex: -------------------------------------------------------------------------------- 1 | % Created 2016-08-17 Wed 14:38 2 | \documentclass[tikz]{standalone} 3 | \usepackage[utf8]{inputenc} 4 | \usepackage[T1]{fontenc} 5 | \usepackage{helvet} 6 | \renewcommand{\familydefault}{\sfdefault} 7 | 8 | \usepackage{tikz} 9 | \author{Holger Karl} 10 | \date{\today} 11 | \title{} 12 | \begin{document} 13 | \begin{tikzpicture}[auto, xscale=3, 14 | block/.style = {rectangle, draw=black, thick, align=left}] 15 | \node[block] at (0,0) (c1) {Client 1}; 16 | \node[block] at (0,2) (c2) {Client 2}; 17 | \node[block] at (1,1) (pr) {Proxy}; 18 | \node[block] at (3,1) (s1) {Server}; 19 | \draw [->] (c1.east) [bend right=45, line width=1.25] to (pr.south); 20 | \draw [->] (c2) [bend left=45, line width=1.25] to (pr.north); 21 | \draw [->] (pr) [bend right=45, line width=1.25] to (c1); 22 | \draw [->] (pr) [bend left=45, line width=1.25] to (c2); 23 | \draw [->] (pr) [bend left=45, line width=2] to (s1); 24 | \draw [->] (s1) [bend left=45, line width=2] to (pr); 25 | % \node [block] at (0,1) (sender) {\textbf{Sender:} \\x = native data;\\px = pack(x); 26 | % \\send(px);}; 27 | % \node [block] at (2,3) (idl) {Data definition file}; 28 | % \node [block] at (2,2) (idlcomp) {IDL compiler}; 29 | % \node [block] at (1,1) (pack) {pack()}; 30 | % \node [block] at (3,1) (unpack) {unpack()}; 31 | % \node [block] at (4,1) (receiver) {\textbf{Receiver:} \\px = receive();\\x = unpack(px); 32 | % \\//use native data in x }; 33 | % % 34 | % \draw [->] (idl) -- (idlcomp); 35 | % \draw [->] (idlcomp) -- (pack); 36 | % \draw [->] (idlcomp) -- (unpack); 37 | % \draw (-1,-1) -- (5,-1); 38 | % \draw [->] (sender) -- (0, -1); 39 | % \draw [->] (4, -1) -- (receiver); 40 | % \draw [->] (sender.east) to [bend left=80] (pack.west) ; 41 | % \draw [->] (pack.west) to [bend left=45] (sender.east) ; 42 | % \draw [->] (receiver.west) to [bend left=45] (unpack.east) ; 43 | % \draw [->] (unpack.east) to [bend left=45] (receiver.west) ; 44 | % \path (sender) edge [bend north ] node [right] {} (pack); 45 | \end{tikzpicture} 46 | \end{document} -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # DistributedSystems 2 | 3 | ## Content 4 | 5 | Lecture material (slides, script) for a distributed systems Bachelor 6 | class. The intention is to update standard material with material on 7 | new developments in cloud systems, big data processing, 8 | etc. Concepts (like vector clocks, distributed algorithms, distributed 9 | transactions) will be introduced using concrete use cases. Heavy 10 | emphasis on case studies. 11 | 12 | The target audience is a third-year Computer Science Bachelor class, 13 | with 6 LP/ECTS. Subsets shold be easily useable for a shorter (e.g., 4 14 | ECTS class). 15 | 16 | ## Material, preparation 17 | 18 | Material will be produced using emacs org mode, from which LaTeX 19 | Beamer files will be generated. These can be turned into slides as 20 | well as handout scripts. 21 | 22 | You need emacs and and org-mode v9 or better. Adapt path name for the 23 | emacs executable in Makefile. 24 | 25 | 26 | ### Files to touch 27 | 28 | - In each chXX subdirectory, you need to update the chapter title in 29 | chXX-slides.org. The actual content - without any header markup - 30 | goes into chXX.org. Slides are at level 3. 31 | 32 | - In book/book.org, include the various files, add \part and \chapter 33 | commands. 34 | 35 | - slidehead.org has formatting setup for the slide decks. Usually, no 36 | need to touch this file. 37 | 38 | - subdirectories need symbolic links to the main Makefile 39 | 40 | ### Produced files 41 | 42 | Produced PDFs end up in subdirectory output. One version of the PDFs 43 | is available in Dropbox: 44 | https://www.dropbox.com/sh/ts47xz5vgiua4l6/AAC-8XZVs3xP0A5--sBslN9na?dl=0 45 | 46 | ### Convenient latexmk replacement 47 | 48 | fswatch -o *.org figures/*.tex | xargs -n1 make slides 49 | 50 | 51 | ## TODO 52 | 53 | ### Continuous intgration 54 | 55 | If somebody feels like setting up a continous integration toolchain on 56 | TravisCI, I'd be oblighed. It would need a fairly new TexLive, emacs, 57 | orgmode9 current version, and dropbox uploader. See here for 58 | inspiration: https://github.com/harshjv/travis-ci-latex-pdf 59 | -------------------------------------------------------------------------------- /content/external_documents.org: -------------------------------------------------------------------------------- 1 | #+LATEX_HEADER: \externaldocument{../book/book} 2 | #+LATEX_HEADER: \externaldocument{../ch_00/ch_00-slides} 3 | #+LATEX_HEADER: \externaldocument{../ch_01_basic_CS/ch_01_basic_CS-slides} 4 | #+LATEX_HEADER: \externaldocument{../ch_02_web_CS/ch_02_web_CS-slides} 5 | #+LATEX_HEADER: \externaldocument{../ch_03_RPC_CS/ch_03_RPC_CS-slides} 6 | #+LATEX_HEADER: \externaldocument{../ch_04_improving_CS/ch_04_improving_CS-slides} 7 | #+LATEX_HEADER: \externaldocument{../ch_05_practical/ch_05_practical-slides} 8 | #+LATEX_HEADER: \externaldocument{../ch_06_p2p_ncs/ch_06_p2p_ncs-slides} 9 | #+LATEX_HEADER: \externaldocument{../ch_07_mcast_ncs/ch_07_mcast_ncs-slides} 10 | #+LATEX_HEADER: \externaldocument{../ch_08_des_pubsub/ch_08_des_pubsub-slides} 11 | #+LATEX_HEADER: \externaldocument{../ch_09_msqQueuing/ch_09_msqQueuing-slides} 12 | #+LATEX_HEADER: \externaldocument{../ch_10_oddsEnds_ncs/ch_10_oddsEnds_ncs-slides} 13 | #+LATEX_HEADER: \externaldocument{../ch_11_distStorage/ch_11_distStorage-slides} 14 | #+LATEX_HEADER: \externaldocument{../ch_12_distTransactions/ch_12_distTransactions-slides} 15 | #+LATEX_HEADER: \externaldocument{../ch_13_nosql/ch_13_nosql-slides} 16 | #+LATEX_HEADER: \externaldocument{../ch_14_failures/ch_14_failures-slides} 17 | #+LATEX_HEADER: \externaldocument{../ch_15_filesystems/ch_15_filesystems-slides} 18 | #+LATEX_HEADER: \externaldocument{../ch_16_gfs/ch_16_gfs-slides} 19 | #+LATEX_HEADER: \externaldocument{../ch_17_websearch/ch_17_websearch-slides} 20 | #+LATEX_HEADER: \externaldocument{../ch_18_elasticStack/ch_18_elasticStack-slides} 21 | #+LATEX_HEADER: \externaldocument{../ch_19_virtualization/ch_19_virtualization-slides} 22 | #+LATEX_HEADER: \externaldocument{../ch_20_clouds/ch_20_clouds-slides} 23 | #+LATEX_HEADER: \externaldocument{../ch_21_bigdata/ch_21_bigdata-slides} 24 | #+LATEX_HEADER: \externaldocument{../ch_22_spark/ch_22_spark-slides} 25 | #+LATEX_HEADER: \externaldocument{../ch_23_streaming/ch_23_streaming-slides} 26 | #+LATEX_HEADER: \externaldocument{../ch_24_ml/ch_24_ml-slides} 27 | #+LATEX_HEADER: \externaldocument{../ch_25_comparisons/ch_25_comparisons-slides} 28 | 29 | -------------------------------------------------------------------------------- /content/ch_04_improving_CS/figures/proxy_2s.tex: -------------------------------------------------------------------------------- 1 | % Created 2016-08-17 Wed 14:38 2 | \documentclass[tikz]{standalone} 3 | \usepackage[utf8]{inputenc} 4 | \usepackage[T1]{fontenc} 5 | \usepackage{helvet} 6 | \renewcommand{\familydefault}{\sfdefault} 7 | \usepackage{tikz} 8 | \author{Holger Karl} 9 | \date{\today} 10 | \title{} 11 | \begin{document} 12 | \begin{tikzpicture}[auto, xscale=3, 13 | block/.style = {rectangle, draw=black, thick, align=left}] 14 | \node[block] at (0,0) (c1) {Client 1}; 15 | \node[block] at (0,2) (c2) {Client 2}; 16 | \node[block] at (1,1) (pr) {Proxy}; 17 | \node[block] at (3,0) (s1) {Server 1}; 18 | \node[block] at (3,2) (s2) {Server 2}; 19 | \draw [->] (c1) [line width=1.25] -- (pr); 20 | \draw [->] (c2) [bend left=45, line width=1.25] -- (pr); 21 | \draw [->] (pr) [line width=1.25] -- (c1); 22 | \draw [->] (pr) [line width=1.25] -- (c2); 23 | \draw [->] (pr) [line width=1.25] -- (s1.west); 24 | \draw [->] (s1.west) [line width=1.25] -- (pr); 25 | \draw [->] (pr) [line width=1.25] -- (s2.west); 26 | \draw [->] (s2.west) [line width=1.25] -- (pr); 27 | % \node [block] at (0,1) (sender) {\textbf{Sender:} \\x = native data;\\px = pack(x); 28 | % \\send(px);}; 29 | % \node [block] at (2,3) (idl) {Data definition file}; 30 | % \node [block] at (2,2) (idlcomp) {IDL compiler}; 31 | % \node [block] at (1,1) (pack) {pack()}; 32 | % \node [block] at (3,1) (unpack) {unpack()}; 33 | % \node [block] at (4,1) (receiver) {\textbf{Receiver:} \\px = receive();\\x = unpack(px); 34 | % \\//use native data in x }; 35 | % % 36 | % \draw [->] (idl) -- (idlcomp); 37 | % \draw [->] (idlcomp) -- (pack); 38 | % \draw [->] (idlcomp) -- (unpack); 39 | % \draw (-1,-1) -- (5,-1); 40 | % \draw [->] (sender) -- (0, -1); 41 | % \draw [->] (4, -1) -- (receiver); 42 | % \draw [->] (sender.east) -- [bend left=80] (pack.west) ; 43 | % \draw [->] (pack.west) -- [bend left=45] (sender.east) ; 44 | % \draw [->] (receiver.west) -- [bend left=45] (unpack.east) ; 45 | % \draw [->] (unpack.east) -- [bend left=45] (receiver.west) ; 46 | % \path (sender) edge [bend north ] node [right] {} (pack); 47 | \end{tikzpicture} 48 | \end{document} -------------------------------------------------------------------------------- /content/ch_06_p2p_ncs/figures/plaxton_fc.tex: -------------------------------------------------------------------------------- 1 | % Created 2016-08-17 Wed 14:38 2 | \documentclass[tikz]{standalone} 3 | 4 | \input{../../templates/tikzFigureHeader} 5 | \usetikzlibrary{arrows.meta, 6 | calc, chains, 7 | quotes, 8 | positioning, 9 | shapes.geometric} 10 | 11 | \begin{document} 12 | 13 | \begin{tikzpicture}[ 14 | node distance = 8mm and 16mm, 15 | start chain = A going below, 16 | base/.style = {draw, minimum width=32mm, minimum height=8mm, 17 | align=center, on chain=A}, 18 | startstop/.style = {base, rectangle, rounded corners, fill=red!10}, 19 | process/.style = {base, rectangle, fill=orange!30}, 20 | io/.style = {base, trapezium, 21 | trapezium left angle=70, trapezium right angle=110, 22 | fill=blue!30}, 23 | decision/.style = {base, diamond, fill=green!30, aspect=4}, 24 | every edge quotes/.style = {auto=right}] 25 | ] 26 | \node [startstop] {Find GUID $n$}; % <-- A-1 27 | \node [decision] { Is $v$ in charge?}; 28 | \node [startstop, right=of A-2] {Done}; 29 | \node [decision, below=of A-2] { Is a neighbor of $v$ in charge?}; 30 | \node [startstop, right=of A-4] {Forward}; 31 | \node [process, below=of A-4] {Find largest $r$ where $v_1\ldots v_r = n_1\ldots n_r$ \\ but $v_{r+1} \not = n_{r+1}$ }; 32 | % 33 | \node [process] {Find largest $c$ where \\ routing entry $r, c$ not empty}; 34 | \node [decision] {Found?}; 35 | \node [startstop, right=of A-8] {Forward}; 36 | \node [process, below=of A-8] {Reduce $r$}; 37 | %% 38 | \draw [arrows=-Stealth,thick] 39 | (A-1) edge["init"] (A-2) 40 | (A-2) edge["Yes"] (A-3) 41 | (A-2) edge["No"] (A-4) 42 | (A-4) edge["Yes"] (A-5) 43 | (A-4) edge["No"] (A-6) 44 | (A-6) edge (A-7) 45 | (A-7) edge (A-8) 46 | (A-8) edge["Yes"] (A-9) 47 | (A-8) edge["No"] (A-10) 48 | (A-10.west) -| ([xshift=-0.5cm]A-6.west) -- (A-6.west); 49 | \end{tikzpicture} 50 | 51 | 52 | 53 | \end{document} -------------------------------------------------------------------------------- /content/ch_14_nosql/figures/tmp.tex: -------------------------------------------------------------------------------- 1 | % Created 2016-08-17 Wed 14:38 2 | \documentclass[tikz]{standalone} 3 | 4 | \input{../../templates/tikzFigureHeader} 5 | \usetikzlibrary{backgrounds,fit,matrix,shapes.callouts} 6 | \usepackage{forest} 7 | \usepackage{tikzpeople} 8 | 9 | 10 | \begin{document} 11 | 12 | 13 | \begin{forest} 14 | for tree={ font=\ttfamily, grow'=0, child anchor=west, parent 15 | anchor=south, anchor=west, calign=first, edge path={ 16 | \noexpand\path [draw, \forestoption{edge}] (!u.south west) 17 | +(7.5pt,0) |- node[fill,inner sep=1.25pt] {} (.child 18 | anchor)\forestoption{edge label}; }, before typesetting 19 | nodes={ if n=1 {insert before={[,phantom]}} {} }, fit=band, 20 | before computing xy={l=15pt}, } [,name=root 21 | [.int,name=int] [.com [.google] [.apple] ] 22 | [.edu, draw, rounded corners, fill=blue!10, 23 | [.yale, name=yale 24 | [.chemistry, name=yalechem ] 25 | [.cs, name=yalecs 26 | [.ai, name=yaleai ] 27 | [.robotics, name=yalerob] 28 | ] 29 | ] 30 | [.stanford] ] 31 | % [.de,name=de, draw, circle 32 | % [.paderborn,name=pb] 33 | % [.uni-paderborn,name=upb 34 | % [.eim,name=eim] ] 35 | % ] 36 | ] 37 | % background 38 | \begin{scope}[on background layer] 39 | % % \draw [fill=green!10] (int.north west) rectangle (pb.east |- 40 | % % de.north); 41 | % % \draw [fill=blue!10] (de.north west) rectangle (pb.east |- 42 | % % eim.south); 43 | % \node [fill=green!10, fit= {(int.north west) (upb.east) 44 | % (de.north)}] (g) {}; 45 | % \node [fill=blue!10, fit= {(de.north 46 | % west) (upb.east) (eim.south)}] (s) {}; 47 | % \node [anchor=north east] at (g.north east) {Generic}; 48 | % \node [anchor=north east] at (s.north east) {Specific}; 49 | % DNS servers 50 | \node [draw, rounded corners, fit=(yale) (yalechem) , 51 | inner sep =0, fill=green!10] {}; 52 | \node [draw, rounded corners, fit=(yalecs) (yaleai) (yalerob), 53 | inner sep =0, fill=yellow!10] {}; 54 | \end{scope} 55 | \end{forest} 56 | 57 | \end{document} 58 | -------------------------------------------------------------------------------- /content/ch_12_distTransactions/figures/cuts.tex: -------------------------------------------------------------------------------- 1 | % Created 2016-08-17 Wed 14:38 2 | \documentclass[tikz]{standalone} 3 | 4 | \input{../../templates/tikzFigureHeader} 5 | \usetikzlibrary{positioning, calc} 6 | 7 | \usetikzlibrary{intersections} 8 | 9 | 10 | \newcommand{\timeline}[1]{ 11 | \draw [-> ] (0,0) -- (#1,0) node [below, auto] {time} ; 12 | \draw [-> ] (0,0) -- (0, 4) node [left=0.75cm, auto, rotate=90] {processes}; 13 | 14 | \foreach \i in {1,2,3} { 15 | \draw [thin , name path=p\i] (0,\i) -- (#1,\i); 16 | \node [left] at (0, \i) {$P_\i$}; 17 | } 18 | } 19 | 20 | \newcommand{\basicpic}{ 21 | \timeline{8} 22 | 23 | \foreach \x/\y/\l [count=\i]in { 1/2/1, 3/3/2, 5/1/3, 7/2/4} { 24 | \node [circle, draw, fill=white] (\i) at (\x, \y) {\l}; 25 | } 26 | \draw [->] (1) to node [auto, near start] {$m_1$} (2); 27 | \draw [->] (3) to node [auto, near end, auto ] {$m_3$} (4); 28 | } 29 | 30 | \newcommand{\intersectcut}{ 31 | \foreach \i in {1,2,3} { 32 | \path [name intersections={of=cut and p\i, by={tmp}}]; 33 | \node [circle, draw, fill=red!10, inner sep=1pt ] at (tmp) {\small $S_\i$}; 34 | } 35 | } 36 | 37 | \begin{document} 38 | 39 | 40 | \begin{tikzpicture} 41 | 42 | % events 43 | \basicpic 44 | 45 | \draw [very thick, red, name path=cut] (3.75, 0) -- (6,4); 46 | 47 | \intersectcut 48 | 49 | \end{tikzpicture} 50 | 51 | 52 | \begin{tikzpicture} 53 | \basicpic 54 | 55 | \draw [->, thick, green, near start] (2) to node [black, auto] {$m_2$} (3) ; 56 | 57 | \draw [very thick, red, name path=cut] (3.75, 0) -- (6,4); 58 | \intersectcut 59 | 60 | \end{tikzpicture} 61 | 62 | 63 | \begin{tikzpicture} 64 | \basicpic 65 | 66 | \draw [->, thick, green, , near start, name path=mess] (2) to node [black, auto]{$m_2$} (3) ; 67 | 68 | % \draw [very thick, red] (2, 4) -- (2.25, 2.75) -- (3.5, 2) -- (6, 1.5) -- (7,0); 69 | \draw [very thick, red, name path=cut] plot [smooth] coordinates 70 | {(2, 4) (2.25, 2.75) (3.25, 2) (6, 1.5) (7,0)}; 71 | 72 | % \path [name intersections={of=mess and cut, by={XX}}]; 73 | % \node [above] at (XX) {??}; 74 | 75 | \intersectcut 76 | 77 | 78 | \end{tikzpicture} 79 | 80 | 81 | \end{document} 82 | 83 | -------------------------------------------------------------------------------- /content/ch_04_improving_CS/figures/strawman.tex: -------------------------------------------------------------------------------- 1 | % Created 2016-08-17 Wed 14:38 2 | \documentclass[tikz]{standalone} 3 | 4 | \input{../../templates/tikzFigureHeader} 5 | 6 | \begin{document} 7 | \begin{tikzpicture}[auto, 8 | block/.style = {rectangle, draw=black, thick, align=left}] 9 | 10 | \draw (0,0) circle (2cm); 11 | \node at ({0}:2.2cm) {0}; 12 | % \node at ({30/64*360}:2.3cm) {a=30}; 13 | % \node at ({48/64*360}:2.3cm) {b=48}; 14 | \draw ({30/64*360}:1.8cm) -- node [left] {a=30} ({30/64*360}:2.2cm); 15 | \draw ({48/64*360}:1.8cm) -- node [below] {b=48} ({48/64*360}:2.2cm); 16 | \draw [->, thick]({30/64*360}:1.5cm) arc [start angle= {30/64*360}, end angle={48/64*360}, radius=1.5cm]; 17 | \end{tikzpicture} 18 | \begin{tikzpicture}[auto, 19 | block/.style = {rectangle, draw=black, thick, align=left}] 20 | 21 | \draw (0,0) circle (2cm); 22 | \node at ({0}:2.2cm) {0}; 23 | % \node at ({30/64*360}:2.3cm) {a=30}; 24 | % \node at ({48/64*360}:2.3cm) {b=48}; 25 | \draw ({30/64*360}:1.8cm) -- node [left] {a=30} ({30/64*360}:2.2cm); 26 | \draw ({48/64*360}:1.8cm) -- node [below] {b=48} ({48/64*360}:2.2cm); 27 | \draw [->, thick]({48/64*360}:1.5cm) arc [start angle= {48/64*360}, end angle={30/64*360+360}, radius=1.5cm]; 28 | \end{tikzpicture} 29 | 30 | 31 | % \begin{tikzpicture} 32 | % \draw (0,0) circle (2cm); 33 | % \draw[red] (330:1.5cm) arc (330:60+360:1.5cm); 34 | % \draw[blue] (60:1.2cm) arc (60:330:1.2cm); 35 | % \end{tikzpicture} 36 | 37 | \begin{tikzpicture}[auto, 38 | block/.style = {rectangle, draw=black, thick, align=left}] 39 | 40 | 41 | \draw [blue, fill=blue!10] ({30/64*360}:1.8cm) arc ({30/64*360}:{48/64*360}:1.8cm) 42 | --++ ({48/64*360}:0.4cm) arc ({48/64*360}:{30/64*360}:2.2cm) -- cycle; 43 | \draw [red, fill=red!10] ({48/64*360}:1.8cm) 44 | arc ({48/64*360}:{30/64*360+360}:1.8cm) 45 | --++ ({30/64*360}:0.4cm) 46 | arc ({30/64*360+360}:{48/64*360}:2.2cm) -- cycle; 47 | 48 | 49 | \draw (0,0) circle (2cm); 50 | \node at ({0}:2.4cm) {0}; 51 | % \node at ({30/64*360}:2.3cm) {a=30}; 52 | % \node at ({48/64*360}:2.3cm) {b=48}; 53 | 54 | \draw ({30/64*360}:1.8cm) -- node [left, blue] {Server 1} ({30/64*360}:2.4cm); 55 | \draw ({48/64*360}:1.8cm) -- node [below, red] {Server 2} ({48/64*360}:2.4cm); 56 | 57 | \end{tikzpicture} 58 | 59 | 60 | \end{document} -------------------------------------------------------------------------------- /content/ch_10_oddsEnds_ncs/ch_10_oddsEnds_ncs.org: -------------------------------------------------------------------------------- 1 | #+BIBLIOGRAPHY: ../bib plain 2 | 3 | \begin{frame}[title={bg=Hauptgebaeude_Tag}] 4 | \maketitle 5 | \end{frame} 6 | 7 | * Odds and ends 8 | 9 | *** Overview 10 | Peer-to-peer networking 11 | - Group communication 12 | - Distributed event systems & publish/subscribe 13 | - Message queuing 14 | - Odds & ends 15 | 16 | *** Tuple spaces 17 | Idea: use an associative memory of “tuples” 18 | - Access possible via atomic operations: Put & Get 19 | - Sometimes: read, notify 20 | - Possibly with wildcards for partial matches 21 | - Get REMOVES tuple from the tuple space, new ones have to be reinserted again 22 | - Tuples are not bound in any fashion to a process (no sender or destination, like in a message queue) 23 | - Tuples have no notion of a “location” where they are stored → (logically) shared memory 24 | - Closely related to the Linda programming language 25 | - See http://cocasoft.cs.tamu.edu/~lidu/courses/mccp02s/papers/GenerativeCommLinda-gelernter85toplas.pdf 26 | - Currently popular examples: JavaSpaces, SlackSpaces, blitz project 27 | 28 | *** Content-centric networking 29 | 30 | V. Jacobson, D.K. Smetters, J.D. Thornton, M.F. Plass, N.H. Briggs, 31 | - and R.L. Braynard, "Networking named content," in Proc. 5th intl. 32 | - conf. Emerging networking experiments and technologies – 33 | - CoNEXT, 2009, p. 1. 34 | 35 | *** Mobile code 36 | Client/server: data transmitted to where the code is 37 | - Alternative: move code to where the data is → Mobile code 38 | - Big security problems obvious 39 | - Popular examples: Postscript, Javascript, Java applets 40 | - 41 | - More sophisticated: Mobile agents 42 | - Pieces of code & data that can “travel” from one computer to another, performing some sort of operation 43 | - Example: A search agent, traveling from one traveling agency computer to another, trying to find a good offer 44 | - Agents can spawn offspring, merge with other agents, … 45 | 46 | *** Conclusion 47 | 48 | - Besides client/server systems, there are many alternative possibilities how interaction patterns could look like 49 | 50 | - Wide range of topics and emphasis 51 | - Search of objects – P2P 52 | - Delivery semantics – group communication 53 | - Decoupling – publish/subscribe systems 54 | 55 | -------------------------------------------------------------------------------- /content/ch_14_nosql/figures/cap.tex: -------------------------------------------------------------------------------- 1 | % Created 2016-08-17 Wed 14:38 2 | \documentclass[tikz]{standalone} 3 | 4 | \input{../../templates/tikzFigureHeader} 5 | \usetikzlibrary{decorations.pathmorphing} 6 | \usetikzlibrary{calc} 7 | 8 | 9 | 10 | 11 | \author{Holger Karl} 12 | \date{\today} 13 | \title{} 14 | 15 | \author{Holger Karl} 16 | \date{\today} 17 | \title{} 18 | 19 | \newcommand{\basescenario}{ 20 | \node[database] (db1) {S1}; 21 | \node[database] (db2) at (2,4) {S2}; 22 | \node[database] (db3) at (3,1) {S3}; 23 | \node[draw, dotted, inner sep=10pt, fit= (db1) (db2) (db3)] {}; 24 | \draw[dashed] (db1) -- (db2) -- (db3) -- (db1); 25 | 26 | \node[below=1.5cm of db1] (w) {Writer}; 27 | \node[bob, above=0cm of w] (wpic) {}; 28 | \node[above left=of db2] (r1) {Reader 1}; 29 | \node[alice, above=0cm of r1] {}; 30 | \node[right=of db3] (r2) {Reader 2}; 31 | \node[alice, above=0cm of r2] {}; 32 | } 33 | 34 | \newcommand{\basemessages}{ 35 | \draw [->] (wpic) to node [near start, right] {x=42!} (db1); 36 | \draw [->] (r1) to node [near start, auto] {x=?} (db2); 37 | \draw [->] (r2) to node [near start, auto] {x=?} (db3); 38 | } 39 | 40 | \begin{document} 41 | 42 | 43 | \begin{tikzpicture} 44 | \basescenario \basemessages 45 | \end{tikzpicture} 46 | 47 | \begin{tikzpicture} 48 | \basescenario \basemessages 49 | 50 | % partition 51 | \coordinate (tmp1) at ([shift={(0.75cm,1.5cm)}]db3); \coordinate 52 | (tmp2) at ([shift={(-1cm,1.cm)}]db3); \coordinate (tmp3) at 53 | ([shift={(-1.25cm,-1.2cm)}]db3); \coordinate (tmp4) at 54 | ([shift={(0.75cm,-1.4cm)}]db3); 55 | 56 | \draw [red, decorate, decoration={snake}] (tmp1) -- (tmp2) -- (tmp3) 57 | -- (tmp4); 58 | \end{tikzpicture} 59 | 60 | 61 | \begin{tikzpicture} 62 | % CAP landscape 63 | \node at (-4, 0) (C) {\Huge C}; 64 | \node at (+4, 0) (P) {\Huge P}; 65 | \node at (0, 4*1.76) (A) {\Huge A}; 66 | 67 | \draw [fill=gray!10] (C.north east) -- (A.south) -- (P.north west) -- cycle; 68 | 69 | \node [rotate=60,anchor=south,align=center] at ($ (C.north)!0.5!(A.west)$) {Conventional DBs\\MySQL, PostgreSQL}; 70 | 71 | \node [align=center,anchor=south,rotate=-60] at ($ (P.north)!0.5!(A.east)$) {Cassandra, CouchDB\\Voldemort, Riak\\\ldots}; 72 | 73 | \node [align=center,anchor=north] at ($ (P.south)!0.5!(C.south)$) {MongoDB, Redis\\HBase, Memcache, BigTable-style\\\ldots}; 74 | 75 | \end{tikzpicture} 76 | 77 | \end{document} -------------------------------------------------------------------------------- /content/templates/emacs_init.el: -------------------------------------------------------------------------------- 1 | (custom-set-variables 2 | ;; custom-set-variables was added by Custom. 3 | ;; If you edit it by hand, you could mess it up, so be careful. 4 | ;; Your init file should contain only one such instance. 5 | ;; If there is more than one, they won't work right. 6 | '(current-language-environment "UTF-8") 7 | '(org-latex-default-packages-alist 8 | '(("AUTO" "inputenc" t 9 | ("pdflatex")) 10 | ("T1" "fontenc" t 11 | ("pdflatex")) 12 | ("" "graphicx" t nil) 13 | ("" "grffile" t nil) 14 | ("" "longtable" nil nil) 15 | ("" "wrapfig" nil nil) 16 | ("" "rotating" nil nil) 17 | ("normalem" "ulem" t nil) 18 | ("" "amsmath" t nil) 19 | ("" "textcomp" t nil) 20 | ("" "amssymb" t nil) 21 | ("" "minted" t nil) 22 | ("" "capt-of" nil nil) 23 | ("" "xr-hyper" nil nil) 24 | ("" "hyperref" nil nil))) 25 | '(org-latex-hyperref-template nil) 26 | '(org-latex-prefer-user-labels t) 27 | '(org-latex-listings 'minted) 28 | '(org-beamer-environments-extra 29 | '( 30 | ("textbook" "T" "\\begin{textbook}" "\\end{textbook}") 31 | ("idea" "I" "\\begin{idea}" "\\end{idea}") 32 | ("requirement" "R" "\\begin{requirement}" "\\end{requirement}") 33 | ("observation" "O" "\\begin{observation}" "\\end{observation}") 34 | ("furtherreading" "L" "\\begin{furtherreading}" "\\end{furtherreading}") 35 | )) 36 | ) 37 | 38 | (with-eval-after-load 'ox-latex 39 | (add-to-list 40 | 'org-latex-classes 41 | '("beamerhpi" "\\documentclass{beamerhpi}" 42 | ("\\section{%s}" . "\\section*{%s}") 43 | ("\\subsection{%s}" . "\\subsection*{%s}") 44 | ("\\subsubsection{%s}" . "\\subsubsection*{%s}") 45 | ("\\paragraph{%s}" . "\\paragraph*{%s}") 46 | ("\\subparagraph{%s}" . "\\subparagraph*{%s}") 47 | ))) 48 | 49 | ;; (add-to-list 'load-path (expand-file-name "~/.emacs.d/elpa/org-ref-20210506.1518")) 50 | ;; (add-to-list 'load-path (expand-file-name "~/.emacs.d/elpa/dash-20210210.1449")) 51 | ;; (add-to-list 'load-path (expand-file-name "~/.emacs.d/elpa/f-20191110.1357")) 52 | ;; (add-to-list 'load-path (expand-file-name "~/.emacs.d/elpa/s-20180406.808")) 53 | ;; (add-to-list 'load-path (expand-file-name "~/.emacs.d/elpa/htmlize-20200816.746")) 54 | ;; (add-to-list 'load-path (expand-file-name "~/.emacs.d/elpa/hydra-20201115.1055")) 55 | ;; (add-to-list 'load-path (expand-file-name "~/.emacs.d/elpa/lv-20200507.1518")) 56 | ;; (add-to-list 'load-path (expand-file-name "~/.emacs.d/elpa/parsebib-20210108.1525")) 57 | 58 | (let ((default-directory "~/.emacs.d/elpa/")) 59 | (normal-top-level-add-subdirs-to-load-path)) 60 | 61 | (require 'org-ref) 62 | -------------------------------------------------------------------------------- /content/ch_14_nosql/figures/nosql.tex: -------------------------------------------------------------------------------- 1 | % Created 2016-08-17 Wed 14:38 2 | \documentclass[tikz]{standalone} 3 | 4 | \input{../../templates/tikzFigureHeader} 5 | \usepackage{ifthen} 6 | \tikzset{ 7 | clear_database/.style={ 8 | cylinder, 9 | shape border rotate=90, 10 | aspect=0.25, 11 | draw 12 | }, 13 | pics/site/.style n args={4}{code={ 14 | 15 | \ifthenelse{#2=1}{ 16 | \node [draw, rounded corners, fill=blue!20, minimum width=5ex, minimum height=2ex] (d1) {}; }{ 17 | \node [rounded corners, minimum width=5ex, minimum height=2ex] (d1) {}; 18 | } 19 | \ifthenelse{#3=1}{ 20 | \node [above=0cm of d1, draw, rounded corners, fill=green!20, minimum width=5ex, minimum height=2ex] (d2) {}; }{ 21 | \node [above=0cm of d1, rounded corners, minimum width=5ex, minimum height=2ex] (d2) {}; 22 | } 23 | \ifthenelse{#4=1}{ 24 | \node [above=0cm of d2, draw, rounded corners, fill=red!20, minimum width=5ex, minimum height=2ex] (d3) {}; }{ 25 | \node [above=0cm of d2, rounded corners, minimum width=5ex, minimum height=2ex] (d3) {}; 26 | } 27 | 28 | \node [clear_database, fill=none, fit=(d1) (d2) (d3)] (s1) {}; 29 | \node [below=0cm of s1] {#1}; 30 | }} 31 | } 32 | 33 | % \newcommand{\site}[1]{ 34 | % } 35 | 36 | \begin{document} 37 | 38 | \begin{tikzpicture} 39 | \draw pic {site={S1}{1}{1}{1}} ++(2cm,0) pic {site={S2}{1}{1}{1}} 40 | ++(2cm,0) pic {site={S3}{1}{1}{1}}; 41 | 42 | \end{tikzpicture} 43 | 44 | \begin{tikzpicture} 45 | \draw pic {site={S1}{0}{1}{0}} ++(2cm,0) pic {site={S2}{1}{0}{0}} 46 | ++(2cm,0) pic {site={S3}{0}{0}{1}}; 47 | \end{tikzpicture} 48 | 49 | 50 | \begin{tikzpicture} 51 | \draw pic {site={S1}{1}{1}{0}} ++(2cm,0) pic {site={S2}{0}{0}{0}} 52 | ++(2cm,0) pic {site={S3}{0}{0}{1}}; 53 | \end{tikzpicture} 54 | 55 | \begin{tikzpicture} 56 | \draw pic {site={S1}{1}{1}{0}} ++(2cm,0) pic {site={S2}{0}{1}{1}} 57 | ++(2cm,0) pic {site={S3}{0}{0}{1}}; 58 | \end{tikzpicture} 59 | 60 | 61 | %-------- Dynamo 62 | 63 | 64 | \begin{tikzpicture} 65 | \foreach \a [count=\ai] in {20, 70, 160, 280, 330}{ 66 | \draw (\a:1.8cm) -- (\a:2.2cm); 67 | \node (s\ai) at (\a:2.4cm) {S \ai}; 68 | } 69 | 70 | \draw (0,0) circle (2cm); 71 | 72 | \draw [red] (300:1.8cm) -- (300:2.2cm); 73 | \node [red, anchor=north west] (data) at (300:2.6cm) {New data}; 74 | \draw [blue, ->, thick] (300:1.9cm) arc (300:330:1.9cm); 75 | \draw [green, ->, thick] (300:1.8cm) arc (300:20+360:1.8cm); 76 | \draw [yellow, ->, thick] (300:1.7cm) arc (300:70+360:1.7cm); 77 | 78 | \end{tikzpicture} 79 | 80 | 81 | \end{document} -------------------------------------------------------------------------------- /content/ch_09_msqQueuing/figures/leaderelect_ring.tex: -------------------------------------------------------------------------------- 1 | % Created 2016-08-17 Wed 14:38 2 | \documentclass[tikz]{standalone} 3 | 4 | \input{../../templates/tikzFigureHeader} 5 | 6 | \begin{document} 7 | 8 | \newcommand{\diam}{2} 9 | 10 | \newcommand{\mygraph}{% 11 | 12 | \draw [dotted] (0,0) circle (\diam cm); 13 | 14 | \foreach \angle/\value [count = \i] in {0/17, 45/22, 80/5, 140/12, 170/7, 210/19, 260/9, 300/13} { 15 | \node [circle, draw, fill=white] (p\i) at (\angle:\diam) {\value}; 16 | \ifnum\i=1 17 | \xdef\Lst{\value} 18 | \else 19 | \xdef\Lst{\Lst,\value} 20 | \fi 21 | } 22 | 23 | } 24 | \begin{tikzpicture} 25 | \mygraph{0} 26 | \end{tikzpicture} 27 | 28 | \newcommand{\drawedges}[1]{ 29 | \mygraph 30 | \foreach [evaluate = {\j=int(mod(\i, 8)+1)}] \i in {1,...,8} { 31 | \pgfmathsetmacro{\X}{{#1}[\i-1]} 32 | \draw [->] (p\i) to [bend right=45] node[midway,auto,swap] {\X} 33 | (p\j) ; 34 | } 35 | } 36 | 37 | % jsut the first two steps: 38 | \begin{tikzpicture} 39 | \begin{scope}[xshift=0cm, yshift=0cm] 40 | \node at (-\diam cm -1cm, \diam cm + 1cm) {Step 0:}; 41 | \drawedges{\Lst} 42 | \end{scope} 43 | 44 | \begin{scope}[xshift=3*\diam cm, yshift=0 * \diam cm] 45 | \node at (-\diam cm -1cm, \diam cm + 1cm) {Step 1:}; 46 | \drawedges{17,22,22,12,12,19,19,13} 47 | \end{scope} 48 | \end{tikzpicture} 49 | 50 | % all steps: 51 | 52 | \begin{tikzpicture} 53 | \begin{scope}[xshift=0cm, yshift=0cm] 54 | \node at (-\diam cm -1cm, \diam cm + 1cm) {Step 0:}; 55 | \drawedges{\Lst} 56 | \end{scope} 57 | 58 | \begin{scope}[xshift=3*\diam cm, yshift=0 * \diam cm] 59 | \node at (-\diam cm -1cm, \diam cm + 1cm) {Step 1:}; 60 | \drawedges{17,22,22,12,12,19,19,13} 61 | \end{scope} 62 | 63 | 64 | \begin{scope}[xshift=6*\diam cm, yshift=0 * \diam cm] 65 | \node at (-\diam cm -1cm, \diam cm + 1cm) {Step 2:}; 66 | \drawedges{17,22,22,22,12,19,19,19} 67 | \end{scope} 68 | 69 | \begin{scope}[xshift=9*\diam cm, yshift=0 * \diam cm] 70 | \node at (-\diam cm -1cm, \diam cm + 1cm) {Step 3:}; 71 | \drawedges{19,22,22,22,22,19,19,19} 72 | \end{scope} 73 | 74 | \begin{scope}[xshift=0*\diam cm, yshift=-3 * \diam cm] 75 | \node at (-\diam cm -1cm, \diam cm + 1cm) {Step 4:}; 76 | \drawedges{19,22,22,22,22,22,19,19} 77 | \end{scope} 78 | 79 | \begin{scope}[xshift=3*\diam cm, yshift=-3 * \diam cm] 80 | \node at (-\diam cm -1cm, \diam cm + 1cm) {Step 5:}; 81 | \drawedges{19,22,22,22,22,22,22,19} 82 | \end{scope} 83 | 84 | \begin{scope}[xshift=6*\diam cm, yshift=-3 * \diam cm] 85 | \node at (-\diam cm -1cm, \diam cm + 1cm) {Step 7:}; 86 | \drawedges{19,22,22,22,22,22,22,22} 87 | \end{scope} 88 | 89 | 90 | \begin{scope}[xshift=9*\diam cm, yshift=-3 * \diam cm] 91 | \node at (-\diam cm -1cm, \diam cm + 1cm) {Step 8:}; 92 | \drawedges{22,22,22,22,22,22,22,22} 93 | \end{scope} 94 | \end{tikzpicture} 95 | \end{document} -------------------------------------------------------------------------------- /homework/WireTransfer/Java/WTExample.java: -------------------------------------------------------------------------------- 1 | import java.io.IOException; 2 | import java.io.InputStream; 3 | import java.io.OutputStream; 4 | import java.net.ServerSocket; 5 | import java.net.Socket; 6 | import java.nio.ByteBuffer; 7 | import java.nio.charset.StandardCharsets; 8 | 9 | //Flatbuffers java library package 10 | //Downloaded from GitHub 11 | import com.google.flatbuffers.FlatBufferBuilder; 12 | //Package for wire transfer structure 13 | //Generated with flatc compiler 14 | import VS.wire_transfer.*; 15 | 16 | 17 | public class WTExample { 18 | 19 | public static void main(String[] args) { 20 | 21 | Socket sockToC = null; 22 | try { 23 | ServerSocket ss = new ServerSocket(9999); 24 | sockToC = ss.accept(); 25 | ss.close(); 26 | 27 | System.out.println("Connection established"); 28 | InputStream in = sockToC.getInputStream(); 29 | OutputStream out = sockToC.getOutputStream(); 30 | 31 | // Start flatbuffer object construction 32 | // Create builder object 33 | FlatBufferBuilder builder = new FlatBufferBuilder(0); 34 | 35 | // Create data for Message 36 | String string_message = "Greetings from the Java world."; 37 | int byteVec_message = builder.createByteVector(string_message.getBytes(StandardCharsets.US_ASCII)); 38 | int from = builder.createString("Java"); 39 | //Create MessageHeader 40 | int head = MessageHeader.createMessageHeader(builder, Type.PUSH, 28); 41 | 42 | // Create Message 43 | Message.startMessage(builder); 44 | Message.addHeader(builder, head); 45 | Message.addFrom(builder, from); 46 | Message.addHasContent(builder, true); 47 | Message.addContent(builder, byteVec_message); 48 | int m = Message.endMessage(builder); 49 | 50 | // End flatbuffer object construction 51 | builder.finish(m); 52 | 53 | // Send serialized data over network 54 | byte[] serialized_message = builder.sizedByteArray(); 55 | out.write(serialized_message); 56 | System.out.println("Send bytes: " + serialized_message.length); 57 | 58 | 59 | // Receive serialized data over network 60 | byte[] rbuffer = new byte[1024]; 61 | int size = 0; 62 | size = in.read(rbuffer); 63 | sockToC.close(); 64 | 65 | ByteBuffer rbuf = ByteBuffer.wrap(rbuffer); 66 | System.out.println("Received bytes: " + size); 67 | 68 | // Access structured data 69 | Message response = Message.getRootAsMessage(rbuf); 70 | MessageHeader mHeader = response.header(); 71 | 72 | System.out.println("request: " + Type.name(mHeader.request())); 73 | System.out.println("seq_num: " + mHeader.seqNum()); 74 | 75 | System.out.println("from: " + response.from()); 76 | System.out.println("hasContent: " + response.hasContent()); 77 | System.out.println("content length: " + response.contentLength()); 78 | 79 | // Interpret byte as char for the sake of this example 80 | for(int i=0; i\frametitle{Table of contents}\tableofcontents[currentsection,hideothersubsections]\end{frame} \lattersubsectfalse} 12 | #+LATEX_HEADER: \AtBeginSubsection[]{\iflattersubsect \begin{frame}\frametitle{Table of contents} \tableofcontents[currentsubsection,currentsection,subsectionstyle=show/shaded/hide]\end{frame}\fi\lattersubsecttrue} 13 | 14 | 15 | #+LATEX_HEADER: \usepackage{etoolbox} 16 | #+LATEX_HEADER: \makeatletter \patchcmd{\beamer@sectionintoc}{\vskip1.5em}{\vskip0.25cm}{}{}\makeatother 17 | 18 | 19 | #+LATEX_HEADER: \usepackage{xr-hyper} 20 | #+LATEX_HEADER: \usepackage{tikz} 21 | #+LATEX_HEADER: \usetikzlibrary{tikzmark} 22 | #+LATEX_HEADER: \usepackage{tikzsymbols} 23 | #+LATEX_HEADER: \usepackage{minted} 24 | #+LATEX_HEADER: \setminted{breaklines,autogobble,escapeinside=??,frame=lines,linenos=false,mathescape=true} 25 | #+LATEX_HEADER: \usepackage[export]{adjustbox} 26 | #+LATEX_HEADER: \usepackage{booktabs} 27 | #+LATEX_HEADER: \usepackage[printonlyused]{acronym} 28 | #+LATEX_HEADER: \usepackage[style=numeric,bibstyle=numeric,url=false,natbib=true,backend=biber]{biblatex} 29 | #+LATEX_HEADER: \setbeamertemplate{bibliography item}{\insertbiblabel} 30 | #+LATEX_HEADER: \setbeamertemplate{section in toc}[sections numbered] 31 | #+LATEX_HEADER: \setbeamertemplate{subsection in toc}[subsections numbered] 32 | #+LATEX_HEADER: \setbeamertemplate{caption}[numbered] 33 | #+LATEX_HEADER: \usepackage{../templates/msc} 34 | #+LATEX_HEADER: \graphicspath{{./figures/}} 35 | #+LATEX_HEADER: \usepackage{amsmath,amssymb} 36 | #+LATEX_HEADER: \DeclareMathOperator{\E}{\mathbb{E}} 37 | #+LATEX_HEADER: \addtobeamertemplate{navigation symbols}{}{ \hspace{1em} \usebeamerfont{footline} \insertframenumber / \inserttotalframenumber } 38 | #+LATEX_HEADER: \newcommand{\zrc}{\framezoom<1><2>(0.5\textwidth,0.01cm)(0.5\textwidth,0.01cm)} % zoom right column } 39 | #+BIBLIOGRAPHY: bib plain 40 | #+LATEX_HEADER: \addbibresource{../bib.bib} 41 | #+LATEX_HEADER: \definecolor{links}{HTML}{2A1B81} 42 | #+LATEX_HEADER: \hypersetup{colorlinks,linkcolor=,urlcolor=links} 43 | #+LATEX_HEADER: \usepackage{xparse} 44 | #+LATEX_HEADER: \DeclareDocumentCommand \slideref { m o } {\only
{\ref{#1}}\only{\IfNoValueTF {#2} {\ref{#1}}{\ref{#1}, slide~\ref{#2}}}} 45 | 46 | 47 | 48 | #+Latex_HEADER: \usepackage{chngcntr} 49 | #+LATEX_HEADER: \counterwithin{section}{chapter} 50 | #+LATEX_HEADER: \counterwithin{subsection}{section} 51 | #+LATEX_HEADER: \counterwithin{figure}{chapter} 52 | #+LATEX_HEADER: \counterwithin{table}{chapter} 53 | #+LATEX_HEADER: \counterwithin{equation}{chapter} 54 | 55 | 56 | #+LATEX_HEADER: \def\checkmark{\tikz\fill[scale=0.4](0,.35) -- (.25,0) -- (1,.7) -- (.25,.15) -- cycle;} 57 | 58 | #+LATEX_HEADER: % \renewcommand{\thefigure}{3.\arabic{figure}} 59 | #+LATEX_HEADER: \input{../externaldocuments.tex} 60 | -------------------------------------------------------------------------------- /content/ch_20_clouds/ch_20_clouds.org: -------------------------------------------------------------------------------- 1 | #+BIBLIOGRAPHY: ../bib plain 2 | ** Clouds 3 | 4 | *** Basic models 5 | 6 | - I/P/SaaS 7 | - Function as a service or Framework as a Service 8 | - Example: AWS Lambda ; https://webtask.io; https://www.iron.io 9 | - Serverless architectures 10 | - https://stackify.com/function-as-a-service-serverless-architecture/ 11 | - https://martinfowler.com/articles/serverless.html 12 | - https://medium.com/@MarutiTech/what-is-serverless-architecture-what-are-its-criticisms-and-drawbacks-928659f9899a 13 | - Business models 14 | 15 | **** Cloud computing 16 | 74 17 | **** Cloud computing – “is a service” 18 | 75 19 | **** Taxonomy of cloud computing 20 | 76 21 | Rimal, Choi, Lumb, A Taxonomy and Survey of Cloud Computing Systems, 2009 22 | Licencing model 23 | - Payment systems 24 | - Standardization, in particular to protect against vendor lock-in 25 | - Formal service level agreements (SLA)? 26 | Hoefer, Karagiannis, Taxonomy of cloud computing, 2012 27 | **** IaaS 28 | 29 | **** PaaS, SaaS 30 | 31 | **** Open Source Examples 32 | Important missing example: OpenStack 33 | **** A taxonomy tree (Example: Google Apps) 34 | Hoefer, Karagiannis, Taxonomy of cloud computing, 2012 35 | 36 | 37 | *** Private clouds: OpenStack 38 | 39 | - OpenStack, the whole family 40 | - Neutron 41 | - Heat 42 | - ... ? 43 | 44 | 45 | **** OpenStack: THE cloud stack, currently 46 | 81 47 | https://www.openstack.org/ 48 | **** OpenStack: core and optional projects 49 | 82 50 | **** OpenStack: Conceptual architecture (late 2015 release) 51 | http://docs.openstack.org/liberty/install-guide-obs/common/get_started_conceptual_architecture.html 52 | Non-trivial system to set up! 53 | **** Using OpenStack 54 | 84 55 | 56 | 57 | 58 | 59 | *** Containter-based approach: Kubernetes 60 | 61 | - Basics 62 | - Autoscaling (and service discovery) 63 | 64 | *** Main examples for public clouds , APIs 65 | 66 | - AWS, block storage, etc. 67 | - Google Cloud 68 | - Rackspace 69 | - ??? 70 | 71 | *** Dealing with heterogeneity 72 | 73 | - Terraform 74 | - Libcloud https://libcloud.apache.org 75 | 76 | *** Cluster Management 77 | 78 | - Apache Mesos 79 | - Cluster Apache Helix https://helix.apache.org 80 | - https://stackoverflow.com/questions/42154354/when-to-use-apache-helix-and-when-to-use-apache-mesos 81 | - https://engineering.linkedin.com/blog/2017/02/building-venice-with-apache-helix 82 | - Replciated state management, data partition. Fault tolerance. Probably does not fit in this category??? 83 | 84 | 85 | 86 | **** Mesos: Cluster resource management 87 | 88 | **** Mesos architecture overview 89 | 90 | **** More examples 91 | 87 92 | Warning: marketing hype ahead! 93 | 94 | 95 | 96 | ** Examples 97 | 98 | 99 | *** Example: Amazon EC2 100 | 101 | **** Amazon Elastic Compute Cloud (EC2) 102 | 88 103 | **** Other Amazon services 104 | 89 105 | **** Other Amazon services 106 | 90 107 | 108 | 109 | 110 | *** Conclusions 111 | 112 | **** Cloud standardization 113 | 91 114 | **** Cloud challenges 115 | 92 116 | Zhang, Chen, Boutaba, Cloud computing: state-of-the-art and research challenges, 2010 117 | -------------------------------------------------------------------------------- /content/ch_04_improving_CS/figures/consistentHashing/ch.py: -------------------------------------------------------------------------------- 1 | import uuid 2 | 3 | num_items = 1000 4 | 5 | num_servers = 50 6 | delta_servers = +1 7 | points_per_server = 100 8 | 9 | num_runs = 5 10 | verbose = False 11 | 12 | 13 | def produce_values(num_items=num_items): 14 | """Produce integers to represent actual items""" 15 | items = [uuid.uuid4().int 16 | for i in range(num_items)] 17 | return items 18 | 19 | def naive_hashing(items, num_servers): 20 | """naive_hashing""" 21 | return [i % num_servers for i in items] 22 | 23 | def consistent_hashing(items, num_servers, server_hashes): 24 | """consistent hashing. Terribly inefficient, but good enough for now""" 25 | 26 | def get_server(item, server_hashes): 27 | # print(item) 28 | try: 29 | return next( server for (hash, server) in server_hashes 30 | if hash >= item) 31 | except Exception: 32 | return -1 33 | 34 | return [ get_server(i, server_hashes) 35 | for i in items] 36 | 37 | 38 | def num_rehashes(old, new): 39 | return [not o == n for o, n in zip(old, new)] 40 | 41 | def server_hashes(num_servers, points_per_server=points_per_server): 42 | # tmp = [ 43 | # [(uuid.uuid4().int, s) for n in range(num_servers)] 44 | # for s in range(num_servers)] 45 | 46 | # print ("server_hashes num_servers", num_servers) 47 | tmp = [[(uuid.uuid4().int, s) 48 | for n in range(points_per_server)] 49 | for s in range(num_servers)] 50 | return tmp 51 | 52 | def flatten_hashes(num_servers, server_hashes): 53 | """use only some of the server hashes""" 54 | 55 | tmp = server_hashes[:num_servers] 56 | 57 | # flatten: 58 | tmp = [item for sublist in tmp for item in sublist] 59 | tmp.sort() 60 | # print("flattened:", num_servers, tmp) 61 | 62 | return tmp 63 | 64 | if __name__ == "__main__": 65 | 66 | for i in range(num_runs): 67 | items = produce_values() 68 | if verbose: 69 | print(items) 70 | 71 | # naive hashing: 72 | 73 | before_servers = naive_hashing(items, num_servers) 74 | after_servers = naive_hashing(items, num_servers+delta_servers) 75 | if verbose: 76 | print(before_servers) 77 | print(after_servers) 78 | 79 | naive_rehashes = sum(num_rehashes(before_servers, after_servers)) 80 | print("N", naive_rehashes) 81 | 82 | # consistent hashing: 83 | sh = server_hashes(max(num_servers, num_servers+delta_servers)) 84 | # print("All server hashes: ", sh) 85 | 86 | before_servers = consistent_hashing( 87 | items, num_servers, 88 | flatten_hashes(num_servers, sh)) 89 | 90 | after_servers = consistent_hashing( 91 | items, num_servers+delta_servers, 92 | flatten_hashes(num_servers+delta_servers, sh)) 93 | 94 | if verbose: 95 | print(before_servers) 96 | print(after_servers) 97 | 98 | consistent_rehashes = sum(num_rehashes(before_servers, after_servers)) 99 | print("C", consistent_rehashes) 100 | -------------------------------------------------------------------------------- /content/ch_03_RPC_CS/figures/orch_choreo.tex: -------------------------------------------------------------------------------- 1 | 2 | \documentclass[tikz]{standalone} 3 | 4 | 5 | \input{../../templates/tikzFigureHeader} 6 | 7 | \begin{document} 8 | 9 | \newcommand{\centerbox}[4]{ % 10 | % xstart, ystart, xwidth, text 11 | \draw [thick, fill=gray!5] (#1+0.05, #2+0.05) rectangle (#1+#3-0.05, #2+1-0.05); % 12 | \draw ( #1+#3/2, #2+0.5) node {#4}; 13 | % 14 | } 15 | 16 | \newcommand{\topbox}[4]{ % 17 | % xstart, ystart, xwidth, text 18 | \draw [thick, fill=gray!5] (#1+0.05, #2+0.05) rectangle (#1+#3-0.05, #2+1-0.05); % 19 | \draw ( #1+#3/2, #2+0.5) node {#4}; 20 | % 21 | } 22 | 23 | 24 | % Orchestrator: 25 | \begin{tikzpicture} 26 | 27 | \node [fill=gray!20] (m1) at (0,0) {MS 1}; 28 | \node [fill=gray!20] (m2) at (2,0) {MS 2}; 29 | \node [fill=gray!20] (m3) at (4,0) {MS 3}; 30 | \node [fill=gray!20] (orch) at (2,1) {Orchestrator}; 31 | 32 | \node [below left=0.25 of m1] (x) {}; 33 | \node (innode) at (-1, 1) {}; 34 | \node (outnode) at (5, 1) {}; 35 | 36 | \draw [->] (innode) -- (orch.west); 37 | \draw [->] (orch.east) -- (outnode); 38 | \draw [->] ([xshift=-10pt]orch.south) -- ([xshift=-10pt]m1.north); 39 | \draw [->] ([xshift=-5pt]m1.north) -- ([xshift=-5pt]orch.south); 40 | \draw [->] ([xshift=-2pt]orch.south) -- ([xshift=-2pt]m2.north); 41 | \draw [->] ([xshift=+2pt]m2.north) -- ([xshift=+2pt]orch.south); 42 | \draw [->] ([xshift=+5pt]orch.south) -- ([xshift=+5pt]m3.north); 43 | \draw [->] ([xshift=+10pt]m3.north) -- ([xshift=+10pt]orch.south); 44 | 45 | \draw (-0.75,-0.5) rectangle (4.75,1.5); 46 | \end{tikzpicture} 47 | 48 | 49 | 50 | % Cheoregraphy: 51 | \begin{tikzpicture} 52 | 53 | \node [fill=gray!20] (m1) at (0,0) {MS 1}; 54 | \node [fill=gray!20] (m2) at (2,0) {MS 2}; 55 | \node [fill=gray!20] (m3) at (4,0) {MS 3}; 56 | 57 | \node [below left=0.25 of m1] (x) {}; 58 | \node [left=0.5 of m1] (innode) {}; 59 | \node [above right=0.25 of m3] (y) {}; 60 | \node [right=0.5 of m3] (outnode) {}; 61 | 62 | 63 | \draw [->] (m1.east) -- (m2.west); 64 | \draw [->] (m2.east) -- (m3.west); 65 | \draw [->] (innode) -- (m1.west); 66 | \draw [->] (m3.east) -- (outnode); 67 | 68 | 69 | 70 | \draw (x) rectangle (y); 71 | \end{tikzpicture} 72 | 73 | % Cheoregraphy, multiple instnaces 74 | \begin{tikzpicture} 75 | 76 | \node [fill=gray!20] (m1) at (0,0) {MS 1}; 77 | \node [fill=gray!20] (m2a) at (2,0) {MS 2a}; 78 | \node [fill=gray!20] (m2b) at (2,-1) {MS 2b}; 79 | \node [fill=gray!20] (m2c) at (2,1) {MS 2c}; 80 | \node [fill=gray!20] (m3) at (4,0) {MS 3}; 81 | 82 | \node (x) at (-0.75, -1.5) {}; 83 | \node [left=0.5 of m1] (innode) {}; 84 | \node (y) at (4.75, 1.5) {}; 85 | \node [right=0.5 of m3] (outnode) {}; 86 | 87 | 88 | \draw [->] (m1.east) -- (m2a.west); 89 | \draw [->] (m1.east) -- (m2b.west); 90 | \draw [->] (m1.east) -- (m2c.west); 91 | \draw [->] (m2a.east) -- (m3.west); 92 | \draw [->] (m2b.east) -- (m3.west); 93 | \draw [->] (m2c.east) -- (m3.west); 94 | \draw [->] (innode) -- (m1.west); 95 | \draw [->] (m3.east) -- (outnode); 96 | 97 | \fill [fill=red] (m1.east) circle [radius=0.15] {}; 98 | \fill [fill=red] (m3.west) circle [radius=0.15] {}; 99 | 100 | \draw (x) rectangle (y); 101 | \end{tikzpicture} 102 | 103 | 104 | \end{document} -------------------------------------------------------------------------------- /homework/WireTransfer/C/WTExample.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include "message_C_builder.h" 10 | 11 | #undef ns 12 | #define ns(x) FLATBUFFERS_WRAP_NAMESPACE(VS_wire_transfer, x) 13 | 14 | #define c_vec_len(V) (sizeof(V)/sizeof((V)[0])) 15 | 16 | void build_message(flatcc_builder_t *B){ 17 | int8_t cont[] = {0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x20, 0x66, 0x72, 0x6f, 0x6d, 0x20, 0x6f, 0x6c, 0x64, 0x20, 0x43, 0x2e, 0x0}; 18 | size_t cont_count = c_vec_len(cont); 19 | 20 | ns(Message_start_as_root(B)); 21 | ns(Message_header_create(B, ns(Type_PULL), 29)); 22 | ns(Message_from_create_str(B, "C")); 23 | ns(Message_hasContent_add(B, 1)); 24 | ns(Message_content_create(B, cont, cont_count)); 25 | ns(Message_end_as_root(B)); 26 | } 27 | 28 | void access_message_buffer(const void *buffer){ 29 | ns(Message_table_t) m = ns(Message_as_root(buffer)); 30 | 31 | if(m == 0){ 32 | perror("Message not available\n"); 33 | } 34 | 35 | ns(MessageHeader_struct_t) header = ns(Message_header(m)); 36 | printf("request: %s\n", ns(Type_name(ns(MessageHeader_request(header))))); 37 | printf("seq_num: %d\n", ns(MessageHeader_seq_num(header))); 38 | 39 | flatbuffers_string_t from = ns(Message_from(m)); 40 | size_t from_len = flatbuffers_string_len(from); 41 | printf("from len: %zu\n", from_len); 42 | printf("from: %s\n", from); 43 | 44 | flatbuffers_bool_t hasContent = ns(Message_hasContent(m)); 45 | printf("hasContent: %u\n", hasContent); 46 | 47 | flatbuffers_int8_vec_t content = ns(Message_content(m)); 48 | size_t content_len = flatbuffers_int8_vec_len(content); 49 | printf("content len: %zu\n", content_len); 50 | // Interpret int8_t as char for the sake of this example 51 | printf("content: %s\n", content); 52 | } 53 | 54 | int main(){ 55 | int sockfd; 56 | 57 | sockfd = socket(AF_INET, SOCK_STREAM, 0); 58 | if(sockfd == -1){ 59 | perror("Could not create socket\n"); 60 | exit(1); 61 | } 62 | 63 | struct sockaddr_in server; 64 | memset(&server, 0, sizeof(server)); 65 | server.sin_family = AF_INET; 66 | server.sin_addr.s_addr = inet_addr("127.0.0.1"); 67 | server.sin_port = htons(9999); 68 | 69 | if(connect(sockfd, (struct sockaddr *)&server , sizeof(server)) < 0){ 70 | perror("Could not create socket\n"); 71 | exit(1); 72 | } 73 | 74 | size_t received_size = 0; 75 | char rbuf[1024]; 76 | memset(rbuf, 0, 1024); 77 | received_size = read(sockfd, rbuf, 1024); 78 | printf("Received bytes: %zu\n", received_size); 79 | 80 | access_message_buffer(rbuf); 81 | 82 | 83 | // Create a `FlatBufferBuilder` 84 | flatcc_builder_t builder; 85 | void* wbuf; 86 | size_t size = 0; 87 | 88 | // Initialize the builder object. 89 | flatcc_builder_init(&builder); 90 | 91 | build_message(&builder); 92 | 93 | wbuf = flatcc_builder_finalize_aligned_buffer(&builder, &size); 94 | write(sockfd, wbuf, size); 95 | close(sockfd); 96 | flatcc_builder_aligned_free(wbuf); 97 | printf("Send bytes: %zu\n", size); 98 | 99 | return 0; 100 | } 101 | -------------------------------------------------------------------------------- /content/ch_21_bigdata/figures/mapreduce.tex: -------------------------------------------------------------------------------- 1 | % Created 2016-08-17 Wed 14:38 2 | \documentclass{standalone} 3 | 4 | \input{../../templates/tikzFigureHeader} 5 | \usetikzlibrary{arrows.meta, 6 | calc, chains, 7 | quotes, 8 | positioning, 9 | shapes.geometric} 10 | 11 | \usepackage[most]{tcolorbox} %<---- Added [most] option 12 | \tcbuselibrary{listings} 13 | 14 | 15 | \begin{document} 16 | 17 | \tcbset{colframe=blue!15,coltitle=black,colback=white} 18 | 19 | \begin{tcblisting}{ 20 | title=Raw Data , 21 | enhanced, % <-- added 22 | remember as = rawdata, % <-- added 23 | box align=center, 24 | hbox, 25 | listing only, 26 | listing options={ 27 | language=python, 28 | } 29 | } 30 | [w1, 31 | w2, 32 | w3, 33 | ... 34 | ] 35 | \end{tcblisting} 36 | \hspace{2cm} 37 | 38 | \begin{tcblisting}{ 39 | title=Raw Data as key/value pairs, 40 | enhanced, % <-- added 41 | remember as = rawdataKV, % <-- added 42 | box align=center, 43 | hbox, 44 | listing only, 45 | listing options={ 46 | language=python, 47 | % basicstyle=\ttfamily, 48 | % keywordstyle=\color{blue}\ttfamily, 49 | % stringstyle=\color{red}\ttfamily, 50 | % commentstyle=\color{green}\ttfamily, 51 | % morecomment={[l][\color{magenta}]{\#}}, 52 | } 53 | } 54 | [(k1, v1), 55 | (k2, v2), 56 | (k1, v3), 57 | (k1, v4), 58 | (k3, v1), 59 | ... 60 | ] 61 | \end{tcblisting} 62 | \hspace{2cm} 63 | 64 | \begin{tcblisting}{ 65 | title=List of key/list of value pairs, 66 | enhanced, % <-- added 67 | remember as = listKlistV, % <-- added 68 | box align=center, 69 | hbox, 70 | listing only, 71 | listing options={ 72 | language=python, 73 | % basicstyle=\ttfamily, 74 | % keywordstyle=\color{blue}\ttfamily, 75 | % stringstyle=\color{red}\ttfamily, 76 | % commentstyle=\color{green}\ttfamily, 77 | % morecomment={[l][\color{magenta}]{\#}}, 78 | } 79 | } 80 | [(k1, [v1, v3, v4]), 81 | (k2, [v2]), 82 | (k3, [v1]), 83 | ... 84 | ] 85 | \end{tcblisting} 86 | \hspace{2cm} 87 | 88 | \begin{tcblisting}{ 89 | title=List of key/aggregated value pairs, 90 | enhanced, % <-- added 91 | remember as = listKaggV, % <-- added 92 | box align=center, 93 | hbox, 94 | listing only, 95 | listing options={ 96 | language=python, 97 | % basicstyle=\ttfamily, 98 | % keywordstyle=\color{blue}\ttfamily, 99 | % stringstyle=\color{red}\ttfamily, 100 | % commentstyle=\color{green}\ttfamily, 101 | % morecomment={[l][\color{magenta}]{\#}}, 102 | } 103 | } 104 | [ (k1, u1) 105 | (k2, u2), 106 | (k3, u3), 107 | ... ] 108 | \end{tcblisting} 109 | 110 | \begin{tikzpicture}[overlay,remember picture] 111 | \draw [->] (rawdata) -- (rawdataKV) node [midway, above, fill=yellow] {\Large Map}; 112 | \draw [->] (rawdataKV) -- (listKlistV) node [midway, above, fill=yellow] {\Large Shuffle}; 113 | \draw [->] (listKlistV) -- (listKaggV) node [midway, above, fill=yellow] {\Large Reduce}; 114 | \end{tikzpicture} 115 | 116 | \end{document} -------------------------------------------------------------------------------- /content/ch_13_consensus/figures/byzantine.tex: -------------------------------------------------------------------------------- 1 | % Created 2016-08-17 Wed 14:38 2 | \documentclass[tikz]{standalone} 3 | 4 | \input{../../templates/tikzFigureHeader} 5 | \usetikzlibrary[intersections] 6 | \usepackage{skull} 7 | \begin{document} 8 | 9 | \newcommand{\byzgraph}{ 10 | \node [circle, draw] (a) {A}; 11 | \node [circle, draw] (b) at (2, 2*1.73/2) {B}; 12 | \node [circle, draw] (c) at (4, 0) {C}; 13 | 14 | \coordinate (al) at ([xshift=-0.5cm, yshift=-0.5cm]a.south west); 15 | \coordinate (bl) at ([xshift=+0.5cm, yshift=+0.5cm]b.north east); 16 | \coordinate (cl) at ([xshift=+0.5cm, yshift=-0.5cm]c.south east); 17 | 18 | \draw [-> ] (a) to [bend left] node [midway, auto, outer sep = 5pt] (ab) {} (b); 19 | \draw [->] (b) to [bend left] node [midway, auto, outer sep = 5pt] (bc) {} (c); 20 | \draw [->] (c) to [bend left] node [midway, auto, outer sep = 5pt] (ca) {} (a); 21 | 22 | \draw [-> ] (a) to node [midway, auto, outer sep = 5pt] (ac) {} (c); 23 | \draw [->] (c) to node [midway, auto, outer sep = 5pt] (cb) {} (b); 24 | \draw [->] (b) to node [midway, auto, outer sep = 5pt] (ba) {} (a); 25 | 26 | % test nodes: 27 | % \node at (ac) {XY}; 28 | % \node at (ab) {XY}; 29 | % \node at (bc) {XY}; 30 | % \node at (ba) {XY}; 31 | % \node at (ca) {XY}; 32 | % \node at (cb) {XY}; 33 | % \node at (al) {XY}; 34 | % \node at (bl) {XY}; 35 | % \node at (cl) {XY}; 36 | } 37 | 38 | \newcommand{\nodelabels}[3]{ 39 | \node [draw] at (al) {#1}; 40 | \node [draw] at (bl) {#2}; 41 | \node [draw] at (cl) {#3}; 42 | } 43 | 44 | \newcommand{\edgelabels}[6]{ 45 | \node at (ab) {#1}; 46 | \node at (ac) {#2}; 47 | \node at (ba) {#3}; 48 | \node at (bc) {#4}; 49 | \node at (ca) {#5}; 50 | \node at (cb) {#6}; 51 | } 52 | 53 | \begin{tikzpicture} 54 | \byzgraph 55 | \nodelabels{1}{0}{1} 56 | \end{tikzpicture} 57 | 58 | %------- regular case: 59 | 60 | \begin{tikzpicture} 61 | \byzgraph 62 | \nodelabels{1}{0}{1} 63 | \edgelabels{1}{1}{0}{0}{1}{1} 64 | \end{tikzpicture} 65 | 66 | \begin{tikzpicture} 67 | \byzgraph 68 | \nodelabels{1}{0}{1} 69 | \edgelabels{C: 1}{B: 1}{C: 0}{A: 0}{B: 1}{A: 1} 70 | \end{tikzpicture} 71 | 72 | % ----- C faulty 73 | 74 | \begin{tikzpicture} 75 | \byzgraph 76 | \nodelabels{1}{1}{0} 77 | \edgelabels{1}{1}{1}{1}{0}{0} 78 | \node [red, fill=white, draw] at (cl) {$\skull$}; 79 | \end{tikzpicture} 80 | 81 | \begin{tikzpicture} 82 | \byzgraph 83 | \nodelabels{1}{1}{0} 84 | \edgelabels{C: 0}{B: 1}{C: 1}{A: 1}{\textcolor{red}{B: 0}}{A: 1} 85 | \node [red, fill=white, draw] at (cl) {$\skull$}; 86 | \end{tikzpicture} 87 | 88 | % ----- A is faulty 89 | 90 | \begin{tikzpicture} 91 | \byzgraph 92 | \nodelabels{x}{0}{0} 93 | \edgelabels{1}{1}{0}{0}{0}{0} 94 | \node [red, fill=white, draw] at (al) {$\skull$}; 95 | \end{tikzpicture} 96 | 97 | \begin{tikzpicture} 98 | \byzgraph 99 | \nodelabels{x}{0}{0} 100 | \edgelabels{C: 0}{\textcolor{red}{B: 1}}{C: 0}{A: 1}{B: 0}{A: 1} 101 | \node [red, fill=white, draw] at (al) {$\skull$}; 102 | \end{tikzpicture} 103 | 104 | 105 | % ----- B is faulty 106 | 107 | \begin{tikzpicture} 108 | \byzgraph 109 | \nodelabels{1}{x}{0} 110 | \edgelabels{1}{1}{\textcolor{red}{C: 1}}{\textcolor{red}{A: 0}}{0}{0} 111 | \node [red, fill=white, draw] at (bl) {$\skull$}; 112 | \end{tikzpicture} 113 | 114 | \begin{tikzpicture} 115 | \byzgraph 116 | \nodelabels{1}{x}{0} 117 | \edgelabels{C: 0}{B: 1}{C: 0}{A: 1}{B: 0}{A: 1} 118 | \node [red, fill=white, draw] at (bl) {$\skull$}; 119 | \end{tikzpicture} 120 | 121 | 122 | 123 | \end{document} -------------------------------------------------------------------------------- /content/ch_09_msqQueuing/figures/bully.tex: -------------------------------------------------------------------------------- 1 | % Created 2016-08-17 Wed 14:38 2 | \documentclass[tikz]{standalone} 3 | 4 | \usepackage{xparse} 5 | 6 | \input{../../templates/tikzFigureHeader} 7 | \usepackage{marvosym} 8 | 9 | \begin{document} 10 | 11 | % state machine 12 | 13 | \newcommand{\numnodes}{7} 14 | \newcommand{\diam}{3cm} 15 | \pgfmathsetmacro{\scopesgrid}{2*\diam+1.5cm} 16 | 17 | \newcommand{\leader}[1]{ 18 | \node [star, draw, green, fill=green!60] at (#1*360/\numnodes:0.5cm + \diam) {}; 19 | } 20 | 21 | \newcommand{\fail}[1]{ 22 | \node [text=red] at (#1*360/\numnodes:0.5cm + \diam) {\Huge\Lightning}; 23 | } 24 | 25 | \newcommand{\suspect}[1]{ 26 | \node [text=blue] at (#1*360/\numnodes:0.5cm + \diam) {\Huge \textbf{?}}; 27 | } 28 | 29 | \newcommand{\asknodes}[1]{ 30 | \pgfmathsetmacro{\Start}{#1+1} 31 | \foreach \i in {\Start,...,\numnodes} { 32 | \draw [->, blue] (#1) to [bend left=20] (\i); 33 | } 34 | } 35 | 36 | \newcommand{\answernodes}[1]{ 37 | \pgfmathsetmacro{\End}{#1-1} 38 | \foreach \i in {1,...,\End} { 39 | \draw [->, green] (#1) to [bend left=20] (\i); 40 | } 41 | } 42 | 43 | 44 | % \newcommand{\mygraph}[1]{% 45 | \NewDocumentCommand \mygraph {o} { 46 | \draw [dotted] (0,0) circle (\diam); 47 | 48 | \foreach \i in {1,...,\numnodes} { 49 | \node [circle, draw, fill=white] (\i) at (\i*360/\numnodes:\diam) {\i}; 50 | } 51 | 52 | \IfNoValueF{#1} { 53 | \node at (-\diam, \diam) {Step #1}; 54 | } 55 | } 56 | 57 | \begin{tikzpicture} 58 | \mygraph 59 | \leader{7} 60 | \fail{6} 61 | \suspect{4} 62 | \asknodes{4} 63 | \answernodes{7} 64 | \end{tikzpicture} 65 | 66 | % regular process: 67 | \begin{tikzpicture} 68 | \begin{scope} 69 | \mygraph[1] 70 | \leader{7} 71 | \suspect{4} 72 | \end{scope} 73 | \begin{scope}[xshift=\scopesgrid] 74 | \mygraph[2] 75 | \leader{7} 76 | \suspect{4} 77 | \asknodes{4} 78 | \end{scope} 79 | \begin{scope}[yshift=-\scopesgrid] 80 | \mygraph[3] 81 | \leader{7} 82 | \suspect{4} 83 | \suspect{6} 84 | \asknodes{6} 85 | \answernodes{6} 86 | \end{scope} 87 | \begin{scope}[xshift=\scopesgrid, yshift=-\scopesgrid] 88 | \mygraph[4] 89 | \leader{7} 90 | \answernodes{7} 91 | \end{scope} 92 | \end{tikzpicture} 93 | 94 | % failed intermediate node 95 | \begin{tikzpicture} 96 | \begin{scope} 97 | \mygraph[1] 98 | \leader{7} 99 | \fail{6} 100 | \suspect{4} 101 | \end{scope} 102 | \begin{scope}[xshift=\scopesgrid] 103 | \mygraph[2] 104 | \leader{7} 105 | \fail{6} 106 | \suspect{4} 107 | \asknodes{4} 108 | \end{scope} 109 | \begin{scope}[xshift=0.5*\scopesgrid, yshift=-\scopesgrid] 110 | \mygraph[3] 111 | \leader{7} 112 | \fail{6} 113 | \answernodes{7} 114 | \end{scope} 115 | \end{tikzpicture} 116 | 117 | 118 | % failed leader 119 | \begin{tikzpicture} 120 | \begin{scope} 121 | \mygraph[1] 122 | \leader{7} 123 | \fail{6} 124 | \end{scope} 125 | \begin{scope}[xshift=\scopesgrid] 126 | \mygraph[2] 127 | \leader{7} 128 | \fail{6} 129 | \fail{7} 130 | \end{scope} 131 | \begin{scope}[xshift=2*\scopesgrid] 132 | \mygraph[3] 133 | \leader{7} 134 | \fail{6} 135 | \fail{7} 136 | \suspect{4} 137 | \end{scope} 138 | \begin{scope}[xshift=0*\scopesgrid, yshift=-\scopesgrid] 139 | \mygraph[4] 140 | \leader{7} 141 | \fail{6} 142 | \fail{7} 143 | \suspect{4} 144 | \asknodes{4} 145 | \end{scope} 146 | \begin{scope}[xshift=2/2*\scopesgrid, yshift=-\scopesgrid] 147 | \mygraph[5] 148 | \leader{7} 149 | \fail{6} 150 | \fail{7} 151 | \suspect{5} 152 | \asknodes{5} 153 | \answernodes{5} 154 | \end{scope} 155 | \begin{scope}[xshift=4/2*\scopesgrid, yshift=-\scopesgrid] 156 | \mygraph[6] 157 | \fail{6} 158 | \fail{7} 159 | \leader{5} 160 | \end{scope} 161 | \end{tikzpicture} 162 | 163 | 164 | \end{document} 165 | 166 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Core latex/pdflatex auxiliary files: 2 | *.aux 3 | *.lof 4 | *.log 5 | *.lot 6 | *.fls 7 | *.out 8 | *.toc 9 | *.fmt 10 | *.fot 11 | *.cb 12 | *.cb2 13 | 14 | ## test file: 15 | todos.org 16 | 17 | ## Intermediate documents: 18 | *.dvi 19 | *-converted-to.* 20 | # these rules might exclude image files for figures etc. 21 | # *.ps 22 | # *.eps 23 | # *.pdf 24 | 25 | 26 | ## Generated if empty string is given at "Please type another file name for output:" 27 | .pdf 28 | 29 | ## Actually generated files: 30 | output/*.pdf 31 | output/*/*.pdf 32 | content/book/book.tex 33 | content/book/book.pdf 34 | content/ch*/ch*-slides.pdf 35 | content/ch*/ch*-slides169.pdf 36 | content/ch*/ch*-handout.pdf 37 | content/ch*/figures/*.pdf 38 | content/ch*/figures/*/*.pdf 39 | content/ch*/ch*.tex 40 | content/ch*/ch*.tex~ 41 | content/ch*/*.rel 42 | content/ch*/figures/*.rel 43 | 44 | # weirdo files 45 | content/da_consensus 46 | content/potsdam_transport 47 | 48 | 49 | # Intermediate files, perhaps useful later 50 | content/ch_01_basic_CS/code.org 51 | dir2forest.py 52 | 53 | 54 | 55 | ## Bibliography auxiliary files (bibtex/biblatex/biber): 56 | *.bbl 57 | *.bcf 58 | *.blg 59 | *-blx.aux 60 | *-blx.bib 61 | *.run.xml 62 | 63 | ## Build tool auxiliary files: 64 | *.fdb_latexmk 65 | *.synctex 66 | *.synctex(busy) 67 | *.synctex.gz 68 | *.synctex.gz(busy) 69 | *.pdfsync 70 | 71 | ## Auxiliary and intermediate files from other packages: 72 | # algorithms 73 | *.alg 74 | *.loa 75 | 76 | # achemso 77 | acs-*.bib 78 | 79 | # amsthm 80 | *.thm 81 | 82 | # beamer 83 | *.nav 84 | *.pre 85 | *.snm 86 | *.vrb 87 | 88 | # changes 89 | *.soc 90 | 91 | # cprotect 92 | *.cpt 93 | 94 | # elsarticle (documentclass of Elsevier journals) 95 | *.spl 96 | 97 | # endnotes 98 | *.ent 99 | 100 | # fixme 101 | *.lox 102 | 103 | # feynmf/feynmp 104 | *.mf 105 | *.mp 106 | *.t[1-9] 107 | *.t[1-9][0-9] 108 | *.tfm 109 | 110 | #(r)(e)ledmac/(r)(e)ledpar 111 | *.end 112 | *.?end 113 | *.[1-9] 114 | *.[1-9][0-9] 115 | *.[1-9][0-9][0-9] 116 | *.[1-9]R 117 | *.[1-9][0-9]R 118 | *.[1-9][0-9][0-9]R 119 | *.eledsec[1-9] 120 | *.eledsec[1-9]R 121 | *.eledsec[1-9][0-9] 122 | *.eledsec[1-9][0-9]R 123 | *.eledsec[1-9][0-9][0-9] 124 | *.eledsec[1-9][0-9][0-9]R 125 | 126 | # glossaries 127 | *.acn 128 | *.acr 129 | *.glg 130 | *.glo 131 | *.gls 132 | *.glsdefs 133 | 134 | # gnuplottex 135 | *-gnuplottex-* 136 | 137 | # gregoriotex 138 | *.gaux 139 | *.gtex 140 | 141 | # hyperref 142 | *.brf 143 | 144 | # knitr 145 | *-concordance.tex 146 | # TODO Comment the next line if you want to keep your tikz graphics files 147 | *.tikz 148 | *-tikzDictionary 149 | 150 | # listings 151 | *.lol 152 | 153 | # makeidx 154 | *.idx 155 | *.ilg 156 | *.ind 157 | *.ist 158 | 159 | # minitoc 160 | *.maf 161 | *.mlf 162 | *.mlt 163 | *.mtc[0-9]* 164 | *.slf[0-9]* 165 | *.slt[0-9]* 166 | *.stc[0-9]* 167 | 168 | # minted 169 | _minted* 170 | *.pyg 171 | 172 | # morewrites 173 | *.mw 174 | 175 | # nomencl 176 | *.nlo 177 | 178 | # pax 179 | *.pax 180 | 181 | # pdfpcnotes 182 | *.pdfpc 183 | 184 | # sagetex 185 | *.sagetex.sage 186 | *.sagetex.py 187 | *.sagetex.scmd 188 | 189 | # scrwfile 190 | *.wrt 191 | 192 | # sympy 193 | *.sout 194 | *.sympy 195 | sympy-plots-for-*.tex/ 196 | 197 | # pdfcomment 198 | *.upa 199 | *.upb 200 | 201 | # pythontex 202 | *.pytxcode 203 | pythontex-files-*/ 204 | 205 | # thmtools 206 | *.loe 207 | 208 | # TikZ & PGF 209 | *.dpth 210 | *.md5 211 | *.auxlock 212 | 213 | # todonotes 214 | *.tdo 215 | 216 | # easy-todo 217 | *.lod 218 | 219 | # xindy 220 | *.xdy 221 | 222 | # xypic precompiled matrices 223 | *.xyc 224 | 225 | # endfloat 226 | *.ttt 227 | *.fff 228 | 229 | # Latexian 230 | TSWLatexianTemp* 231 | 232 | ## Editors: 233 | # WinEdt 234 | *.bak 235 | *.sav 236 | 237 | # Texpad 238 | .texpadtmp 239 | 240 | # Kile 241 | *.backup 242 | 243 | # KBibTeX 244 | *~[0-9]* 245 | 246 | # auto folder when using emacs and auctex 247 | /auto/* 248 | */auto/* 249 | */*/auto/* 250 | */*/*/auto/* 251 | 252 | # expex forward references with \gathertags 253 | *-tags.tex 254 | /content/templates/msc.pdf 255 | /content/book/book.tex~ 256 | .DS_Store 257 | /output 258 | -------------------------------------------------------------------------------- /content/acronyms.tex: -------------------------------------------------------------------------------- 1 | \begin{acronym} 2 | \acro{2PC}{Two-phase commit} 3 | \acro{3PC}{Three-phase commit} 4 | \acro{ACID}{Atomicity, Consistency, Isolation, Durability} 5 | \acro{ACK}{Acknowledgement} 6 | \acro{AD}{Active Directory} 7 | \acro{ADSL}{Asymmetric Digital Subscriber Line} 8 | \acro{AI}{Artificial Intelligence} 9 | \acro{AJAX}{Asynchronous JavaScript and XML} 10 | \acro{AMQP}{Active Message Queuing Protocol} 11 | \acro{API}{Application Programming Interface} 12 | \acro{AS}{Authentication Server} 13 | \acro{AWS}{Amazon Web Service} 14 | \acro{BASE}{Basically Available, Soft state, Eventually consistent} 15 | \acro{CAP}{Consistent, Available, and Partition-tolerant} 16 | \acro{CBCAST}{Causal Broadcast} 17 | \acro{CBCB}{Combined Broadcast and Content-Based} 18 | \acro{CDN}{Content Delivery Networks} 19 | \acro{CERN}{Conseil Européen pour la Recherche Nucléaire} 20 | \acro{CI}{Continuous Integration} 21 | \acro{CLI}{Command Line Interface} 22 | \acro{CRUD}{Create, Read, Update, Delete} 23 | \acro{CQRS}{Command Query Responsibility Segregation} 24 | \acro{CSS}{Cascading Style Sheet} 25 | \acro{CWD}{Current Working Directory} 26 | \acro{CWND}{Congestion Window} 27 | \acro{DCTCP}{Data Center TCP} 28 | \acro{DES}{Distributed Event Systems} 29 | \acro{DHT}{Distributed Hash Table} 30 | \acro{DNS}{Domain Name System} 31 | \acro{DOM}{Document Object Model} 32 | \acro{DSM}{Distributed Shared Memory} 33 | \acro{ECN}{Explicit Congestion Notification} 34 | \acro{FAD}{Fake News Detector} 35 | \acro{FLP}{Fischer-Lynch-Paterson} 36 | \acro{FQDN}{Fully Qualified Domain Names} 37 | \acro{GFS}{Google File System} 38 | \acro{GUID}{Globally Unique Identifier} 39 | \acro{HAL}{Heuristically programmed ALgorithmic computer} 40 | \acro{HATEOAS}{Hypermedia as engine of application state} 41 | \acro{HTML}{Hyptertext Markup Language} 42 | \acro{HTTP}{Hyptertext Transfer Protocol} 43 | \acro{IETF}{Internet Engineering Task Force} 44 | \acro{JSON}{Javascript Object Notation} 45 | \acro{KISS}{Keep is simple, stupid!} 46 | \acro{LB}{Load Balancing} 47 | \acro{LCR}{LeLann, Chang, Roberts} 48 | \acro{LDAP}{Lightweight directory access protocol} 49 | \acro{LHC}{Large Hadron Collider} 50 | \acro{MQ}{Message Queuing} 51 | \acro{MQTT}{Message Queuing Telemetry Transport} 52 | \acro{MVC}{Model/View/Controller} 53 | \acro{MS}{Microservice} 54 | \acro{MTBF}{Mean time between 55 | failures} 56 | \acro{MTTF}{Mean time to failure} 57 | \acro{MTTR}{Mean time to repair} 58 | \acro{MutEx}{Mutual Exclusion} 59 | \acro{NoSQL}{Not only SQL} 60 | \acro{OASIS}{Organization for the Advancement of Structured Information Standards} 61 | \acro{ORM}{Object-Relationship Mapping} 62 | \acro{P2P}{Peer to peer} 63 | \acro{P/S}{Publish/Subscribe} 64 | \acro{QoS}{Quality of Service} 65 | \acro{RE}{Regular Expression} 66 | \acro{RDMA}{Remote Direct Memory Access} 67 | \acro{RDMS}{Relational Database Management Systems} 68 | \acro{RFC}{Request for Comment} 69 | \acro{RMI}{Remote Method Invocation} 70 | \acro{RPC}{Remote Procedure Call} 71 | \acro{RTT}{Round Trip Time} 72 | \acro{RV}{Random Variable} 73 | \acro{SCTP}{Stream Control Transmission Protocol} 74 | \acro{SLA}{Service Level Agreement} 75 | \acro{SLO}{Service Level Objective} 76 | \acro{SNS}{Simple Notification Service} 77 | \acro{SOAP}{Simple Object Access Protocol} 78 | \acro{SPoF}{Single Point of Failure} 79 | \acro{SQL}{Structured Query Language} 80 | \acro{TCP}{Transmission Control Protocol} 81 | \acro{TMR}{Triple Modular Redundancy} 82 | \acro{TGS}{Ticket Granting Service} 83 | \acro{UDDI}{Uniform Description, Discovery, and Integration} 84 | \acro{UDP}{User Datagram Protocol} 85 | \acro{UID}{Unique Identifier} 86 | \acro{URI}{Uniform Resource Identifier} 87 | \acro{URL}{Uniform Resource Locator} 88 | \acro{VCS}{Version Control System} 89 | \acro{VM}{Virtual Machine} 90 | \acro{WSDL}{Web Service Description Language} 91 | \acro{WWW}{World-Wide Web} 92 | \acro{XML}{Extensible Markup Language} 93 | \acro{YAGNI}{You ain't gonna need it!} 94 | \acro{YAML}{Yet Another Markup Language} 95 | \acro{ZAB}{ZooKeeper Atomic Broadcast} 96 | \acro{ZK}{ZooKeeper} 97 | \end{acronym} 98 | 99 | % \acro{}{} -------------------------------------------------------------------------------- /content/ch_09_msqQueuing/figures/mq_broker_topologies.tex: -------------------------------------------------------------------------------- 1 | % Created 2016-08-17 Wed 14:38 2 | \documentclass[tikz]{standalone} 3 | 4 | \input{../../templates/tikzFigureHeader} 5 | 6 | \usetikzlibrary{shapes} 7 | 8 | \begin{document} 9 | \begin{tikzpicture}[auto, 10 | block/.style = {rectangle, draw=black, thick, align=left}] 11 | 12 | \node[block] (s) at (0,0) {S}; 13 | \node[block] (r) at (6,0) {R}; 14 | \node[draw, cloud, aspect=3, scale=5] (c) at (3,0) {}; 15 | \draw [red, thick, ->] (s) -- (r); 16 | \end{tikzpicture} 17 | 18 | \begin{tikzpicture}[auto, 19 | block/.style = {rectangle, draw=black, thick, align=left}] 20 | 21 | \node[block] (s) at (0,0) {S}; 22 | \node[block] (r) at (6,0) {R}; 23 | \node[draw, cloud, aspect=3, scale=5] (c) at (3,0) {}; 24 | 25 | \node[draw, rectangle,thick, fill=blue!20] (b) at (3,0) {B}; 26 | 27 | \draw [red, thick, ->] (s) -- (b); 28 | \draw [red, thick, ->] (b) -- (r); 29 | \end{tikzpicture} 30 | 31 | \begin{tikzpicture}[auto, 32 | block/.style = {rectangle, draw=black, thick, align=left}] 33 | 34 | \node[block] (s) at (0,0) {S}; 35 | \node[block] (r) at (6,0) {R}; 36 | \node[draw, cloud, aspect=3, scale=5] (c) at (3,0) {}; 37 | 38 | \node[draw, rectangle,thick, fill=blue!20] (b1) at (2,0) {B$_1$}; 39 | \node[draw, rectangle,thick, fill=blue!20] (b2) at (4,0) {B$_2$}; 40 | 41 | \draw [red, thick, ->] (s) -- (b1); 42 | \draw [red, thick, ->] (b1) -- (b2); 43 | \draw [red, thick, ->] (b2) -- (r); 44 | \end{tikzpicture} 45 | 46 | \begin{tikzpicture}[auto, 47 | block/.style = {rectangle, draw=black, thick, align=left}] 48 | 49 | \node[block] (s) at (0,0) {S}; 50 | \node[block] (r) at (6,0) {R}; 51 | \node[draw, cloud, aspect=3, scale=5] (c) at (3,0) {}; 52 | 53 | \node[draw, rectangle,thick, fill=blue!20] (b1) at (2,0.5) {B$_1$}; 54 | \node[draw, rectangle,thick, fill=blue!20] (b2) at (4,0.5) {B$_2$}; 55 | \node[draw, rectangle,thick, fill=blue!20] (b3) at (2,-0.5) {B$_3$}; 56 | \node[draw, rectangle,thick, fill=blue!20] (b4) at (4,-0.5) {B$_4$}; 57 | 58 | \draw [red, thick, ->] (s) -- (b1); 59 | \draw [red, thick] (b1) -- (b2); 60 | \draw [red, thick] (b1) -- (b3); 61 | \draw [red, thick] (b2) -- (b4); 62 | \draw [red, thick] (b3) -- (b4); 63 | \draw [red, thick, ->] (b4) -- (r); 64 | \end{tikzpicture} 65 | 66 | 67 | \begin{tikzpicture}[auto, 68 | block/.style = {rectangle, draw=black, thick, align=left}] 69 | \begin{scope} 70 | \node[block] (s) at (0,0) {S}; 71 | \node[block] (r) at (6,0) {R}; 72 | \node[draw, cloud, aspect=3, scale=5] (c) at (3,0) {}; 73 | \draw [red, thick, ->] (s) -- (r); 74 | \end{scope} 75 | 76 | \begin{scope}[xshift=8cm] 77 | \node[block] (s) at (0,0) {S}; 78 | \node[block] (r) at (6,0) {R}; 79 | \node[draw, cloud, aspect=3, scale=5] (c) at (3,0) {}; 80 | 81 | \node[draw, rectangle,thick, fill=blue!20] (b) at (3,0) {B}; 82 | 83 | \draw [red, thick, ->] (s) -- (b); 84 | \draw [red, thick, ->] (b) -- (r); 85 | \end{scope} 86 | 87 | 88 | \begin{scope}[yshift=-3.5cm] 89 | \node[block] (s) at (0,0) {S}; 90 | \node[block] (r) at (6,0) {R}; 91 | \node[draw, cloud, aspect=3, scale=5] (c) at (3,0) {}; 92 | 93 | \node[draw, rectangle,thick, fill=blue!20] (b1) at (2,0) {B$_1$}; 94 | \node[draw, rectangle,thick, fill=blue!20] (b2) at (4,0) {B$_2$}; 95 | 96 | \draw [red, thick, ->] (s) -- (b1); 97 | \draw [red, thick, ->] (b1) -- (b2); 98 | \draw [red, thick, ->] (b2) -- (r); 99 | \end{scope} 100 | 101 | \begin{scope}[xshift=8cm, yshift=-3.5cm] 102 | \node[block] (s) at (0,0) {S}; \node[block] (r) at (6,0) {R}; 103 | \node[draw, cloud, aspect=3, scale=5] (c) at (3,0) {}; 104 | 105 | \node[draw, rectangle,thick, fill=blue!20] (b1) at (2,0.5) {B$_1$}; 106 | \node[draw, rectangle,thick, fill=blue!20] (b2) at (4,0.5) {B$_2$}; 107 | \node[draw, rectangle,thick, fill=blue!20] (b3) at (2,-0.5) {B$_3$}; 108 | \node[draw, rectangle,thick, fill=blue!20] (b4) at (4,-0.5) {B$_4$}; 109 | 110 | \draw [red, thick, ->] (s) -- (b1); \draw [red, thick] (b1) -- (b2); 111 | \draw [red, thick] (b1) -- (b3); \draw [red, thick] (b2) -- (b4); 112 | \draw [red, thick] (b3) -- (b4); \draw [red, thick, ->] (b4) -- (r); 113 | \end{scope} 114 | \end{tikzpicture} 115 | 116 | 117 | \end{document} -------------------------------------------------------------------------------- /content/ch_04_improving_CS/figures/LB.tex: -------------------------------------------------------------------------------- 1 | 2 | \documentclass[tikz]{standalone} 3 | 4 | 5 | \input{../../templates/tikzFigureHeader} 6 | \usepackage{varwidth} 7 | 8 | \begin{document} 9 | 10 | % Page 1: naive version of load balancing 11 | 12 | \begin{msc}{Naive, incorrect load balancing} 13 | \declinst{d}{IP 9.10.11.12}{DNS} 14 | \declinst{c}{IP 5.6.7.8}{Client} 15 | \declinst{r}{IP 1.2.3.1}{Router} 16 | \declinst{f}{IP 1.2.3.2}{Front end} 17 | \declinst{w}{IP 1.2.3.101}{Worker} 18 | \mess{www.bla.com?}{c}{d} 19 | \nextlevel 20 | \mess{1.2.3.2}{d}{c} 21 | \nextlevel 22 | \mess{GET from 1.2.3.2}{c}{r} 23 | \nextlevel 24 | \mess{GET from 1.2.3.2}{r}{f} 25 | \nextlevel 26 | \mess{GET from 1.2.3.2}{f}{w} 27 | \nextlevel 28 | \mess{Reply}{w}{c} 29 | \msccomment[side=left]{ 30 | Client confused, gets reply from IP 1.2.3.101 31 | }{c} 32 | \end{msc} 33 | 34 | % Page 2: Return via front end 35 | 36 | \begin{msc}{LB: reply via front end} 37 | \declinst{d}{IP 9.10.11.12}{DNS} 38 | \declinst{c}{IP 5.6.7.8}{Client} 39 | \declinst{r}{IP 1.2.3.1}{Router} 40 | \declinst{f}{IP 1.2.3.2}{Front end} 41 | \declinst{w}{IP 1.2.3.101}{Worker} 42 | \mess{www.bla.com?}{c}{d} 43 | \nextlevel 44 | \mess{1.2.3.2}{d}{c} 45 | \nextlevel 46 | \mess{GET from 1.2.3.2}{c}{r} 47 | \nextlevel 48 | \mess{GET from 1.2.3.2}{r}{f} 49 | \nextlevel 50 | \mess{GET from 1.2.3.2}{f}{w} 51 | \nextlevel 52 | \mess{Reply}{w}{f} 53 | \nextlevel 54 | \mess{Reply}{f}{r} 55 | \nextlevel 56 | \mess{Reply}{r}{c} 57 | \end{msc} 58 | 59 | 60 | % Page 3: Redirect from FE via HTTP 3xx 61 | 62 | \begin{msc}{LB: front end redirects} 63 | \declinst{d}{IP 9.10.11.12}{DNS} 64 | \declinst{c}{IP 5.6.7.8}{Client} 65 | \declinst{r}{IP 1.2.3.1}{Router} 66 | \declinst{f}{IP 1.2.3.2}{Front end} 67 | \declinst{w}{IP 1.2.3.101}{Worker} 68 | \mess{www.bla.com?}{c}{d} 69 | \nextlevel 70 | \mess{1.2.3.2}{d}{c} 71 | \nextlevel 72 | \mess{GET from 1.2.3.2}{c}{r} 73 | \nextlevel 74 | \mess{GET from 1.2.3.2}{r}{f} 75 | \nextlevel 76 | \mess{Redirect to 1.2.3.101}{f}{r} 77 | \nextlevel 78 | \mess{Redirect to 1.2.3.101}{r}{c} 79 | \nextlevel 80 | \mess{GET from 1.2.3.101}{c}{r} 81 | \nextlevel 82 | \mess{GET from 1.2.3.101}{r}{w} 83 | \nextlevel 84 | \mess{Reply}{w}{r} 85 | \nextlevel 86 | \mess{Reply}{r}{c} 87 | \end{msc} 88 | 89 | % Page 4: Rewrite content of pages to point to some work 90 | 91 | \begin{msc}{LB: rewrite HTML to point to worker} 92 | \declinst{d}{IP 9.10.11.12}{DNS} 93 | \declinst{c}{IP 5.6.7.8}{Client} 94 | \declinst{r}{IP 1.2.3.1}{Router} 95 | \declinst{f}{IP 1.2.3.2}{Front end} 96 | \declinst{w}{IP 1.2.3.101}{Worker} 97 | \mess{www.bla.com?}{c}{d} 98 | \nextlevel 99 | \mess{1.2.3.2}{d}{c} 100 | \nextlevel 101 | \mess{GET from 1.2.3.2}{c}{r} 102 | \nextlevel 103 | \mess{GET from 1.2.3.2}{r}{f} 104 | \nextlevel 105 | \msccomment[side=right]{Rewrite home.html: 1.2.3.101 instead 106 | of www.bla.com}{f} 107 | \nextlevel 108 | \mess{Reply}{f}{r} 109 | \nextlevel 110 | \mess{Reply}{r}{c} 111 | \nextlevel 112 | \msccomment[side=left]{Next request}{c} 113 | \nextlevel 114 | \mess{GET from 1.2.3.101}{c}{r} 115 | \nextlevel 116 | \mess{GET from 1.2.3.101}{r}{w} 117 | \nextlevel 118 | \mess{Reply}{w}{r} 119 | \nextlevel 120 | \mess{Reply}{r}{c} 121 | \end{msc} 122 | 123 | % Page 5: DNS-based LB 124 | 125 | \begin{msc}{LB: add workers to DNS} 126 | \declinst{d}{IP 9.10.11.12}{DNS} 127 | \declinst{c}{IP 5.6.7.8}{Client} 128 | \declinst{r}{IP 1.2.3.1}{Router} 129 | \declinst{f}{IP 1.2.3.2}{Front end} 130 | \declinst{w}{IP 1.2.3.101}{Worker} 131 | % Prepare 132 | \mess{Add workers}{f}{d} 133 | \nextlevel[3] 134 | % USe 135 | \mess{www.bla.com?}{c}{d} 136 | \nextlevel 137 | \mess{1.2.3.101}{d}{c} 138 | \nextlevel 139 | \mess{GET from 1.2.3.101}{c}{r} 140 | \nextlevel 141 | \mess{GET from 1.2.3.101}{r}{w} 142 | \nextlevel 143 | \mess{Reply}{w}{r} 144 | \nextlevel 145 | \mess{Reply}{r}{c} 146 | 147 | \end{msc} 148 | 149 | 150 | 151 | \end{document} -------------------------------------------------------------------------------- /content/ch_17_websearch/ch_17_websearch.org: -------------------------------------------------------------------------------- 1 | #+BIBLIOGRAPHY: ../bib plain 2 | 3 | 4 | * Building a web search engine 5 | 6 | *** NOTE: Immature chapter 7 | 8 | - This chapter is still in an immature state 9 | - Probably will not be treated in class 10 | - Serves as "general interest" material 11 | 12 | ** Context 13 | 14 | *** Web search – Google as case study 15 | Overall setup: Several clusters worldwide, each self-sufficient 16 | - Serving a google query 17 | - Via DNS-based load balancing, find IP address of a suitable cluster 18 | - Query arrives at cluster, via hardware load balancing assigned to a Google Web Server (GWS) in charge of a query 19 | - GWS handles HTML processing, coordinates search 20 | - GWS triggers index servers, which use an inverted index, mapping each query word to a list of documents (hit list) 21 | - Inverted index: Several terabytes 22 | - Individual hit lists are intersected and scored, determining ranked list of relevant documents, identified by docids 23 | - GWS takes docids list, uses document servers to extract, for each element in docids list, title, keyword in context, … from document 24 | - Raw documents: > Tens of terabytes 25 | - GWS produces final HTML result page, returns to client 26 | - 27 | L.Barroso, J. Dean, and U. Hoelzle, Web Search for a Planet: The Google Cluster Architecture, IEEE Micro, 2003. 28 | *** Google search overview 29 | 30 | *** How to handle load in index/document servers? 31 | Work can be easily parallelized 32 | - 33 | - For index servers 34 | - Divide entire index into pieces – index shards 35 | - Each shard: randomly chosen subset of documents from full index 36 | - Each shard served by a pool of machines; one pool per shard 37 | - Each request mapped to one specific machine per shard pool 38 | - Via intermediate load balancer 39 | - 40 | - For document servers: similar 41 | *** Some design principles 42 | Handle failures in software, not hardware 43 | - With an MTBF of 1000 days and 10.000 servers, expected number of failures per day is 10 servers 44 | - Use replication for better request throughput and availability 45 | - Price/performance beats peak performance 46 | - Use commodity PC with best price/performance ratio 47 | - Take into account depreciation cost (e.g., expected useful life is max. 3 years) 48 | - Think about power! 49 | - Power supply density limited in data centers 50 | - Cooling is a problem 51 | 52 | ** BigTable 53 | 54 | *** Google BigTable 55 | How to provide a convenient API to store data for search engines? On top of the GFS? 56 | - Answer: BigTable 57 | - Data model: sparse, distributed, persistent, multi-dimensional sorted map 58 | - Index by row key, column key, timestamp 59 | - Entry can be any array of bytes 60 | - (row: string, column: string, time: int64) ! string 61 | - Via timestamp, multiple versions of entry easily distinguishable 62 | - Columns are grouped into column families 63 | - “anchor:…” 64 | F. Chang, J. Dean, S. Ghemawat, W. C. Hsieh, D. A. Wallach, M. Burrows, T. Chandra, A. Fikes, R. E. Gruber, Bigtable: A Distributed Storage System for Structured Data, Proc. OSDI 2006 65 | *** BigTable example: WebTable 66 | 67 | *** Handling BigTables 68 | Rows are dynamically partitioned into tablets 69 | - Based on lexicographic order 70 | - E.g.: if row keys are inverted URLs (de.uni-paderborn.www), then sorting and partitioning keeps related URLs together 71 | - Tablets are unit of distribution and load balancing; tablet stored on one machine (or replicated) 72 | - Building blocks 73 | - Log and data files stored in GFS 74 | - SSTable file format 75 | - Chubby: highly available, persistent, distributed lock service 76 | - Used by BigTable to elect master, to discover clients of a master, to allow clients to find their master, as root of its data structure to store small amount of metadata 77 | *** Some implementation aspects 78 | One master server, many tablet servers 79 | - Master assigns tablets to tablet servers, balances load, splits tablets as they grow, collects garbage, … 80 | - Actual data does not move via the master, but directly between tablet servers and clients 81 | - Most clients never communicate with master at all 82 | - Tablet location: three-level hierarchy 83 | - First level: find ROOT tablet 84 | - Root tablet stores all 85 | - METADATA tablet locations 86 | - METADATA tablet stores 87 | - location of actual tablet, 88 | - using data about tablet as 89 | - row key 90 | - Clients can traverse hierarchy 91 | - bottom-up; initialized via Master 92 | - 93 | *** Some BigTables 94 | -------------------------------------------------------------------------------- /content/ch_11_distStorage/figures/consistency_mscs.tex: -------------------------------------------------------------------------------- 1 | % Created 2016-08-17 Wed 14:38 2 | \documentclass[tikz]{standalone} 3 | 4 | \input{../../templates/tikzFigureHeader} 5 | \usetikzlibrary{backgrounds} 6 | 7 | 8 | \newcommand{\mscread}[2] { 9 | \lost[side=right]{}{#1}{#2} 10 | } 11 | 12 | \newcommand{\mscwrite}[2] { 13 | \found{}{#1}{#2} 14 | } 15 | 16 | 17 | \begin{document} 18 | 19 | \begin{msc}{Problem with strict consistency} 20 | \declinst{A}{}{A} 21 | \declinst{B}{}{B} 22 | 23 | \found{}{r(X)}{A} 24 | \nextlevel 25 | \mess{read(X)}{A}{B}[4] 26 | \nextlevel[2] 27 | 28 | % \mess{write(X, 42)}{envright}{B} 29 | \found[side=right]{}{w(X,42)}{B} 30 | \end{msc} 31 | 32 | %------------------------------ 33 | 34 | 35 | \begin{msc}{Strictly consistent} 36 | \declinst{A}{}{A} 37 | \declinst{B}{}{B} 38 | 39 | \found{}{w(X,42)}{A} 40 | \nextlevel[2] 41 | 42 | \lost[side=right]{}{r(X): 42}{B} 43 | \end{msc} 44 | 45 | 46 | \begin{msc}{Not strictly consistent} 47 | \declinst{A}{}{A} 48 | \declinst{B}{}{B} 49 | 50 | \found{}{w(X,42)}{A} 51 | \nextlevel[2] 52 | 53 | \lost[side=right]{}{r(X): 17}{B} 54 | \nextlevel[2] 55 | \lost[side=right]{}{r(X): 42}{B} 56 | \end{msc} 57 | 58 | %------------------------- 59 | 60 | \begin{msc}{Sequentially consistent} 61 | \declinst{A}{}{A} 62 | \declinst{B}{}{B} 63 | \declinst{C}{}{C} 64 | \declinst{D}{}{D} 65 | 66 | 67 | \found{}{w(X,42)}{A} 68 | \nextlevel[1] 69 | \found{}{w(X,17)}{B} 70 | \nextlevel[1] 71 | 72 | \mscread{r(X): 17}{C} 73 | \nextlevel[1] 74 | \mscread{r(X): 17}{D} 75 | \nextlevel[1] 76 | \mscread{r(X): 42}{C} 77 | \mscread{r(X): 42}{D} 78 | \end{msc} 79 | 80 | \begin{msc}{Not sequentially consistent} 81 | \declinst{A}{}{A} 82 | \declinst{B}{}{B} 83 | \declinst{C}{}{C} 84 | \declinst{D}{}{D} 85 | 86 | 87 | \mscwrite{w(X,42)}{A} 88 | \nextlevel[1] 89 | \mscwrite{w(X,17)}{B} 90 | \nextlevel[1] 91 | 92 | \mscread{r(X): 17 }{C} 93 | \nextlevel[1] 94 | \mscread{r(X): 42}{D} 95 | \nextlevel[1] 96 | \mscread{r(X): 42}{C} 97 | \mscread{r(X): 17}{D} 98 | \end{msc} 99 | 100 | %----------------- 101 | 102 | \begin{msc}{Causally consistent} 103 | \declinst{A}{}{A} 104 | \declinst{B}{}{B} 105 | \declinst{C}{}{C} 106 | \declinst{D}{}{D} 107 | 108 | 109 | \mscwrite{w(X,42)}{A} 110 | \nextlevel[1] 111 | 112 | \mscread{r(X): 42}{B} 113 | \mscread{r(X): 42}{C} 114 | \mscread{r(X): 42}{D} 115 | \nextlevel[1] 116 | 117 | \mscwrite{w(X,17)}{B} 118 | \nextlevel[1] 119 | 120 | \mscwrite{w(X,99)}{A} 121 | \nextlevel[1] 122 | 123 | 124 | \mscread{r(X): 17}{C} 125 | \mscread{r(X): 99}{D} 126 | 127 | \nextlevel[1] 128 | \mscread{r(X): 99}{C} 129 | \mscread{r(X): 17}{D} 130 | \end{msc} 131 | 132 | 133 | \begin{msc}{Not causally consistent} 134 | \declinst{A}{}{A} 135 | \declinst{B}{}{B} 136 | \declinst{C}{}{C} 137 | \declinst{D}{}{D} 138 | 139 | 140 | \mscwrite{w(X,42)}{A} 141 | \nextlevel[1] 142 | 143 | \mscread{r(X): 42}{B} 144 | \nextlevel[1] 145 | 146 | \mscwrite{w(X,17)}{B} 147 | \nextlevel[1] 148 | 149 | \mscread{r(X): 17}{C} 150 | \mscread{r(X): 42}{D} 151 | 152 | \nextlevel[1] 153 | \mscread{r(X): 42}{C} 154 | \mscread{r(X): 17}{D} 155 | \end{msc} 156 | 157 | \begin{msc}{FIFO consistent} 158 | \declinst{A}{}{A} 159 | \declinst{B}{}{B} 160 | \declinst{C}{}{C} 161 | \declinst{D}{}{D} 162 | 163 | 164 | \mscwrite{w(X,42)}{A} 165 | \nextlevel[1] 166 | 167 | \mscread{r(X): 42}{B} 168 | \nextlevel[1] 169 | 170 | \mscwrite{w(X,17)}{B} 171 | \nextlevel[1] 172 | 173 | \mscwrite{w(X,99)}{B} 174 | \nextlevel[1] 175 | 176 | \mscread{r(X): 17}{C} 177 | \mscread{r(X): 42}{D} 178 | \nextlevel[1] 179 | 180 | \mscread{r(X): 42}{C} 181 | \mscread{r(X): 17}{D} 182 | \nextlevel[1] 183 | 184 | \mscread{r(X): 99}{C} 185 | \mscread{r(X): 99}{D} 186 | 187 | \end{msc} 188 | 189 | 190 | \begin{msc}{Weakly consistent} 191 | \declinst{A}{}{A} 192 | \declinst{B}{}{B} 193 | \declinst{C}{}{C} 194 | 195 | 196 | \mscwrite{Acq(L)}{A} 197 | \nextlevel[1] 198 | 199 | \mscwrite{w(X,42)}{A} 200 | \nextlevel[1] 201 | 202 | \mscwrite{w(X,17)}{A} 203 | \nextlevel[1] 204 | 205 | \mscwrite{Rel(L)}{A} 206 | \nextlevel[1] 207 | 208 | \mscwrite{Acq(L)}{B} 209 | \nextlevel[1] 210 | 211 | \mscwrite{r(X): 17)}{B} 212 | \nextlevel[1] 213 | 214 | \mscwrite{Rel(L)}{B} 215 | \nextlevel[1] 216 | 217 | \mscwrite{r(X): 42)}{C} 218 | \nextlevel[1] 219 | 220 | \end{msc} 221 | 222 | 223 | 224 | \end{document} -------------------------------------------------------------------------------- /content/ch_07_mcast_ncs/figures/logicalTime.tex: -------------------------------------------------------------------------------- 1 | 2 | \documentclass[tikz]{standalone} 3 | 4 | 5 | \input{../../templates/tikzFigureHeader} 6 | 7 | \begin{document} 8 | 9 | \begin{msc}{Timestamps cannot express causality} 10 | % example: + 11 | \declinst{a}{}{A} 12 | \declinst{b}{}{B} 13 | \declinst{c}{}{C} 14 | 15 | \mess{$m_A$}{a}[0.4]{b}[4] 16 | \mess{}{a}{c}[3] 17 | \nextlevel[2] 18 | 19 | \mess{$m_C$}{c}[0.2]{a}[1] 20 | \mess{}{c}{b}[1] 21 | \nextlevel[1] 22 | \end{msc} 23 | 24 | \begin{msc}{Imperfect timestamps hide causality} 25 | % example: + 26 | \declinst{a}{}{A} 27 | \declinst{b}{}{B} 28 | \declinst{c}{}{C} 29 | 30 | \mess{$m_A$}{a}[0.4]{b}[4] 31 | \msccomment[l]{$C_A = 17$}{a} 32 | \mess{}{a}{c}[1] 33 | \nextlevel[2] 34 | 35 | \mess{$m_C$}{c}[0.2]{a}[1] 36 | \msccomment[r]{$C_C = 15$}{c} 37 | \mess{}{c}{b}[1] 38 | \nextlevel[1] 39 | \end{msc} 40 | 41 | 42 | 43 | \begin{msc}{Example events} 44 | % example: + 45 | \declinst{a}{}{A} 46 | \declinst{b}{}{B} 47 | \declinst{c}{}{C} 48 | 49 | \action{a}{a} 50 | \nextlevel 51 | 52 | \action{b}{b} 53 | \action{e}{c} 54 | \mess{}{a}{b}[3] 55 | \nextlevel[2] 56 | 57 | \action{c}{b} 58 | \nextlevel[2] 59 | 60 | \action{d}{b} 61 | \nextlevel 62 | \mess{}{b}{c}[3] 63 | 64 | \nextlevel[2] 65 | \action{f}{c} 66 | \nextlevel 67 | \end{msc} 68 | 69 | \begin{msc}{Example events} 70 | % example: + 71 | \declinst{a}{}{A} 72 | \declinst{b}{}{B} 73 | \declinst{c}{}{C} 74 | %----------- 75 | 76 | \action{2}{a} 77 | \nextlevel 78 | \mess{}{a}{b}[2] 79 | \nextlevel[2] 80 | 81 | \action{3}{b} 82 | \action{1}{c} 83 | \nextlevel[1] 84 | \mess{}{c}{b}[4] 85 | \nextlevel[1] 86 | 87 | \action{4}{b} 88 | \nextlevel 89 | \mess{}{b}{c}[5] 90 | \nextlevel[2] 91 | 92 | \action{8}{b} 93 | \nextlevel[3] 94 | 95 | \action{5}{c} 96 | \nextlevel[2] 97 | 98 | \action{9}{b} 99 | \nextlevel[1] 100 | \mess{}{b}{a}[8] 101 | \nextlevel[2] 102 | 103 | \action{6}{c} 104 | \nextlevel[1] 105 | \mess{}{c}{a}[2] 106 | \nextlevel[2] 107 | 108 | \action{7}{a} 109 | \nextlevel[3] 110 | 111 | \action{10}{a} 112 | \nextlevel[2] 113 | 114 | \end{msc} 115 | 116 | \begin{msc}{Example events -- Rubberband} 117 | % example: + 118 | \declinst{a}{}{A} 119 | \declinst{b}{}{B} 120 | \declinst{c}{}{C} 121 | %----------- 122 | \action{1}{c} 123 | \nextlevel[1] 124 | \mess{}{c}{b}[17] 125 | \nextlevel[1] 126 | 127 | \action{2}{a} 128 | \nextlevel 129 | \mess{}{a}{b}[2] 130 | \nextlevel[2] 131 | 132 | \action{3}{b} 133 | \nextlevel[2] 134 | 135 | \action{4}{b} 136 | \nextlevel 137 | \mess{}{b}{c}[2] 138 | \nextlevel[2] 139 | 140 | \action{5}{c} 141 | \nextlevel[2] 142 | 143 | \action{6}{c} 144 | \nextlevel[1] 145 | \mess{}{c}{a}[2] 146 | \nextlevel[2] 147 | 148 | 149 | \action{7}{a} 150 | \nextlevel[3] 151 | 152 | \action{8}{b} 153 | \nextlevel[3] 154 | 155 | 156 | \action{9}{b} 157 | \nextlevel[1] 158 | \mess{}{b}{a}[2] 159 | \nextlevel[2] 160 | 161 | 162 | \action{10}{a} 163 | \nextlevel[2] 164 | 165 | \end{msc} 166 | 167 | 168 | 169 | \begin{msc}{Example events with Lamport times} 170 | % example: + 171 | \declinst{a}{}{A} 172 | \declinst{b}{}{B} 173 | \declinst{c}{}{C} 174 | %----------- 175 | 176 | \action{(1,A)}{a} 177 | \nextlevel 178 | \mess{ 1 }{a}{b}[2] 179 | \nextlevel[2] 180 | 181 | \action{(2,B)}{b} 182 | \action{(1,C)}{c} 183 | \nextlevel[1] 184 | \mess{1}{c}{b}[4] 185 | \nextlevel[1] 186 | 187 | \action{(3,B)}{b} 188 | \nextlevel 189 | \mess{3}{b}{c}[5] 190 | \nextlevel[2] 191 | 192 | \action{(4,B) }{b} 193 | \nextlevel[3] 194 | 195 | \action{(4,C)}{c} 196 | \nextlevel[2] 197 | 198 | \action{(5,B)}{b} 199 | \nextlevel[1] 200 | \mess{5}{b}{a}[8] 201 | \nextlevel[2] 202 | 203 | \action{(5,C)}{c} 204 | \nextlevel[1] 205 | \mess{5}{c}{a}[2] 206 | \nextlevel[2] 207 | 208 | \action{(6,A)}{a} 209 | \nextlevel[3] 210 | 211 | \action{(7,A)}{a} 212 | \nextlevel[2] 213 | 214 | \end{msc} 215 | 216 | \end{document} -------------------------------------------------------------------------------- /content/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: chapters chapter all slides slides169 handout clean book cleanall dirfigures quick 2 | 3 | # Use .SECONDARY with no argument is a little overkill, but using %.tex does not work 4 | # because we need to refer to .tex files in subdirectories. make does not allow %/%.tex. 5 | .SECONDARY: 6 | 7 | 8 | 9 | EMACS=emacs 10 | # typical alternatives can be something like: 11 | # EMACS="/Applications/Emacs.app/Contents/MacOS/Emacs" 12 | 13 | EMACSEXPORTPARAMS= --batch -l ../templates/emacs_init.el -f org-beamer-export-to-latex 14 | 15 | # pdflatex command 16 | PDFLATEX=pdflatex -shell-escape -interaction=nonstopmode 17 | BIBCOMMAND=biber 18 | 19 | 20 | BookSources := $(shell find .. -name "ch*.org") 21 | SOURCE := $(wildcard *-slides.org) 22 | slidesTex := $(patsubst %.org,%.tex,$(SOURCE)) 23 | slidesPdf := $(patsubst %.org,%.pdf,$(SOURCE)) 24 | slides169Pdf := $(patsubst %.org,%169.pdf,$(SOURCE)) 25 | handoutPdf := $(patsubst %-slides.org,%-handout.pdf,$(SOURCE)) 26 | bookTex := $(patsubst %.org,%-chapter.tex,$(wildcard *.org)) 27 | 28 | # Setting environment for HPI slides right 29 | .EXPORT_ALL_VARIABLES: 30 | TEXINPUTS=".:../hpi-slides/src:./hpi-slides/src::" 31 | TFMFONTS=".:../hpi-slides/src:./hpi-slides/src::" 32 | TTFONTS=".:../hpi-slides/src:./hpi-slides/src::" 33 | 34 | 35 | 36 | # build order for all is important; have to make sure that 37 | # book.aux file exists for inter-chapter cross-references 38 | all: 39 | -make chapterfigures 40 | -make book 41 | -make chapters 42 | 43 | chapters: 44 | for d in ch*; do make -C $$d chapter ; done 45 | 46 | chapterfigures: 47 | for d in ch*; do make -C $$d/figures ; done 48 | 49 | ######################### 50 | 51 | book: 52 | make -C book book.pdf 53 | 54 | book.tex: book.org $(BookSources) 55 | echo "making book.tex" 56 | echo "building beamer tex file", $<, $@ 57 | ${EMACS} -Q --batch $< -eval ${EMACSEXPORTPROG} 58 | grep -v "begin{LaTeX}" $@ | grep -v "end{LaTeX}" | sponge $@ 59 | 60 | 61 | book.pdf: book.tex 62 | -${PDFLATEX} book 63 | -${BIBCOMMAND} book 64 | -${PDFLATEX} book 65 | -${PDFLATEX} book 66 | cp $@ ../../output 67 | 68 | ######################### 69 | 70 | chapter: slides handout slides169 71 | 72 | quick: 73 | quick=True make slides 74 | 75 | slides: $(slidesPdf) 76 | -make -C figures 77 | -make $< 78 | 79 | handout: $(handoutPdf) 80 | -make -C figures 81 | -make $< 82 | 83 | slides169: $(slides169Pdf) 84 | -make -C figures 85 | -make $< 86 | 87 | %-slides.tex: %-slides.org %.org ../slidehead.org ../references.org ../acronyms.tex 88 | echo "building beamer tex file", $<, $@ 89 | ${EMACS} $< ${EMACSEXPORTPARAMS} 90 | 91 | 92 | %-slides.pdf: %-slides.tex $(wildcard figures/*.pdf) ../bib.bib ../book/book.aux 93 | -${PDFLATEX} "\\def\\OutputStyle{presentation}\\input{$<}" 94 | ifndef quick 95 | -${BIBCOMMAND} $(basename $<) 96 | -${PDFLATEX} "\\def\\OutputStyle{presentation}\\input{$<}" 97 | -${PDFLATEX} "\\def\\OutputStyle{presentation}\\input{$<}" 98 | cp $@ ../../output/slides/ 99 | endif 100 | 101 | %-handout.pdf: %-slides.tex $(wildcard figures/*.pdf) ../bib.bib ../book/book.aux 102 | -${PDFLATEX} -jobname $(patsubst %-slides.tex,%-handout,$<) "\\def\\OutputStyle{handout}\\input{$<}" 103 | -${BIBCOMMAND} $(patsubst %-slides.tex,%-handout,$<) 104 | -${PDFLATEX} -jobname $(patsubst %-slides.tex,%-handout,$<) "\\def\\OutputStyle{handout}\\input{$<}" 105 | -${PDFLATEX} -jobname $(patsubst %-slides.tex,%-handout,$<) "\\def\\OutputStyle{handout}\\input{$<}" 106 | cp $@ ../../output/handout/ 107 | 108 | %-slides169.pdf: %-slides.tex $(wildcard figures/*.pdf) ../bib.bib ../book/book.aux 109 | -${PDFLATEX} -jobname $(patsubst %-slides.tex,%-slides169,$<) "\\def\\OutputStyle{presentation,aspectratio=169}\\input{$<}" 110 | ifndef quick 111 | ${BIBCOMMAND} $(patsubst %-slides.tex,%-slides169,$<) 112 | #cp $(basename $<).bbl $(basename $<)169.bbl 113 | -${PDFLATEX} -jobname $(patsubst %-slides.tex,%-slides169,$<) "\\def\\OutputStyle{presentation,aspectratio=169}\\input{$<}" 114 | -${PDFLATEX} -jobname $(patsubst %-slides.tex,%-slides169,$<) "\\def\\OutputStyle{presentation,aspectratio=169}\\input{$<}" 115 | cp $@ ../../output/slides169/ 116 | endif 117 | 118 | 119 | 120 | ########################## 121 | 122 | clean: 123 | -rm *.tex *.tex~ tmp.org *.pdf *.bbl *.vrb 124 | -rm -rf _minted* 125 | -rm *.aux *.log *.nav *.out *.snm *.toc *.pyg *.bcf *.blg *.synctex.gz *.fls *.fdb_latexmk *.run.xml *.auxlock 126 | 127 | cleanall: 128 | -cd book ; rm *.pdf *.aux *.log *.bbl *.tex *.tex~ *.toc *.aux *.bbl *.log *.blg *.out *.vrb 129 | for d in ch*; do make -C $$d clean ; done 130 | 131 | 132 | dirfigures: 133 | mkdir figures 134 | cd figures ; ln -s ../../ch_00/figures/Makefile 135 | 136 | -------------------------------------------------------------------------------- /content/ch_12_distTransactions/figures/2pc.tex: -------------------------------------------------------------------------------- 1 | % Created 2016-08-17 Wed 14:38 2 | \documentclass[tikz]{standalone} 3 | 4 | \input{../../templates/tikzFigureHeader} 5 | \usetikzlibrary{arrows,automata} 6 | 7 | 8 | \begin{document} 9 | 10 | 11 | % FSM coordinator: 12 | \begin{tikzpicture}[->,>=stealth',shorten >=1pt,auto,node 13 | distance=2.8cm, semithick, every edge/.append style={every 14 | node/.style={align=left}}, every state/.style={draw, minimum 15 | size = 1.5cm} ] 16 | 17 | \node[initial, state] (init) {Init}; \node[state, below=of init] 18 | (col) {Collect}; \node[state, accepting, below left=of col] (ab) 19 | {Abort}; \node[state, accepting, below right=of col] (com) 20 | {Commit}; 21 | 22 | \path (init) edge node {Request commit:\\\texttt{VOTE\_REQUEST}} 23 | (col) (col) edge node [swap] {\texttt{VOTE\_ABORT} 24 | received:\\\texttt{GLOBAL\_ABORT}} (ab) (col) edge node {All 25 | \texttt{VOTE\_COMMIT} received:\\\texttt{GLOBAL\_COMMIT}} (com); 26 | % 27 | \end{tikzpicture} 28 | 29 | 30 | % FSM participant: 31 | \begin{tikzpicture}[->,>=stealth',shorten >=1pt,auto,node 32 | distance=2.8cm, semithick, every edge/.append style={every 33 | node/.style={align=left}}, every state/.style={draw, minimum 34 | size = 1.5cm} ] 35 | 36 | \node[initial, state] (r) {Ready}; \node[state, below=of r] 37 | (waiting) {Voted}; \node[state, accepting, below left=of col] (ab) 38 | {Abort}; \node[state, accepting, below right=of col] (com) 39 | {Commit}; 40 | 41 | \path (r) edge 42 | node{\texttt{VOTE\_REQUEST}:\\\texttt{VOTE\_COMMIT}} (col) (r) 43 | edge node [swap, auto ] 44 | {\texttt{VOTE\_REQUEST}:\\\texttt{VOTE\_ABORT}} (ab) 45 | % 46 | (waiting) edge node [auto] {\texttt{GLOBAL\_ABORT} \\received} 47 | (ab) 48 | % 49 | (waiting) edge node {\texttt{GLOBAL\_COMMIT} received} (com); 50 | % 51 | \end{tikzpicture} 52 | 53 | 54 | \begin{msc}{2PC regular success} 55 | \declinst{a}{}{A} \declinst{c}{}{Coordinator} \declinst{b}{}{B} 56 | 57 | \nextlevel[1] 58 | 59 | \mess{\texttt{VOTE\_REQUEST}}{c}{a} 60 | \mess{\texttt{VOTE\_REQUEST}}{c}{b} \nextlevel[2] 61 | 62 | \mess{\texttt{VOTE\_COMMIT}}{a}{c} 63 | \mess{\texttt{VOTE\_COMMIT}}{b}{c} \nextlevel[2] 64 | 65 | \mess{\texttt{GLOBAL\_COMMIT}}{c}{a} 66 | \mess{\texttt{GLOBAL\_COMMIT}}{c}{b} 67 | \end{msc} 68 | 69 | \begin{msc}{2PC regular abort} 70 | \declinst{a}{}{A} \declinst{c}{}{Coordinator} \declinst{b}{}{B} 71 | 72 | \nextlevel[1] 73 | 74 | \mess{\texttt{VOTE\_REQUEST}}{c}{a} 75 | \mess{\texttt{VOTE\_REQUEST}}{c}{b} \nextlevel[2] 76 | 77 | \mess{\texttt{VOTE\_COMMIT}}{a}{c} \mess{\texttt{VOTE\_ABORT}}{b}{c} 78 | \nextlevel[2] 79 | 80 | \mess{\texttt{GLOBAL\_ABORT}}{c}{a} 81 | \mess{\texttt{GLOBAL\_ABORT}}{c}{b} 82 | \end{msc} 83 | 84 | 85 | 86 | \begin{msc}{2PC: Participant crashes} 87 | \declinst{a}{}{A} \declinst{c}{}{Coordinator} \declinst{b}{}{B} 88 | 89 | \nextlevel[1] 90 | 91 | \mess{\texttt{VOTE\_REQUEST}}{c}{a} 92 | \mess{\texttt{VOTE\_REQUEST}}{c}{b} \nextlevel[1] \stop{b} 93 | \nextlevel[1] 94 | 95 | \mess{\texttt{VOTE\_COMMIT}}{a}{c} \nextlevel[1] 96 | \msccomment[side=right]{blocks for B}{c} \nextlevel[1] 97 | \msccomment[side=left]{blocks for Coordinator}{a} 98 | 99 | \end{msc} 100 | 101 | % ------------------------------ 102 | 103 | \begin{msc}{2PC coordinator crashes} 104 | \declinst{a}{}{A} \declinst{c}{}{Coordinator} \declinst{b}{}{B} 105 | 106 | \nextlevel[1] 107 | 108 | \mess{\texttt{VOTE\_REQUEST}}{c}{a} 109 | \mess{\texttt{VOTE\_REQUEST}}{c}{b} \nextlevel[2] 110 | 111 | \mess{\texttt{VOTE\_COMMIT}}{a}{c} 112 | \mess{\texttt{VOTE\_COMMIT}}{b}{c} \nextlevel[1] \stop{c} 113 | 114 | \nextlevel[1] \msccomment[side=left]{blocks for Coordinator}{a} 115 | \msccomment[side=right]{blocks for Coordinator}{b} 116 | 117 | \end{msc} 118 | 119 | %------------------------------ 120 | 121 | \begin{msc}{2PC: coordinator and participant fail} 122 | \declinst{a}{}{A} 123 | \declinst{b}{}{B} 124 | \declinst{c}{}{Coordinator} 125 | \declinst{d}{}{D} 126 | 127 | \nextlevel[1] 128 | 129 | \mess{}{c}{a} 130 | \mess{\texttt{VOTE\_REQUEST}}{c}{b} 131 | \mess{\texttt{VOTE\_REQUEST}}{c}{d} 132 | \nextlevel[2] 133 | 134 | \mess{\texttt{VOTE\_COMMIT}}{a}{c} 135 | \nextlevel[1] 136 | \mess{\texttt{VOTE\_COMMIT}}{b}{c} 137 | \mess{\texttt{VOTE\_COMMIT}}{d}{c} 138 | \nextlevel[2] 139 | 140 | \mess{\texttt{GLOBAL\_COMMIT}}{c}{a} 141 | \nextlevel[1] 142 | \msccomment[side=right]{Die before sending anything else}{c} 143 | \stop{c} 144 | 145 | \nextlevel[1] 146 | \msccomment[side=left]{Commit!!}{a} 147 | \stop{a} 148 | 149 | 150 | \nextlevel[2] 151 | \msccomment[side=left]{Unsure!}{b} 152 | \msccomment[side=right]{Unsure!}{d} 153 | 154 | \end{msc} 155 | 156 | 157 | 158 | 159 | 160 | \end{document} -------------------------------------------------------------------------------- /content/ch_06_p2p_ncs/figures/dht.tex: -------------------------------------------------------------------------------- 1 | % Created 2016-08-17 Wed 14:38 2 | \documentclass[tikz]{standalone} 3 | 4 | \input{../../templates/tikzFigureHeader} 5 | 6 | \begin{document} 7 | \begin{tikzpicture}[auto, 8 | block/.style = {rectangle, draw=black, thick, align=left}] 9 | 10 | % server: 20, 70, 160, 280, 330 11 | 12 | \draw [blue, fill=blue!10] (20:1.8cm) arc (20:70:1.8cm) 13 | --++ (70:0.4cm) arc (70:20:2.2cm) -- cycle; 14 | 15 | \draw [red, fill=red!10] (70:1.8cm) 16 | arc (70:160:1.8cm) 17 | --++ (160:0.4cm) 18 | arc (160:70:2.2cm) -- cycle; 19 | 20 | \draw [green, fill=green!10] (160:1.8cm) 21 | arc (160:280:1.8cm) 22 | --++ (280:0.4cm) 23 | arc (280:160:2.2cm) -- cycle; 24 | 25 | \draw [yellow, fill=yellow!10] (280:1.8cm) 26 | arc (280:330:1.8cm) 27 | --++ (330:0.4cm) 28 | arc (330:280:2.2cm) -- cycle; 29 | 30 | \draw [black, fill=black!10] (330:1.8cm) 31 | arc (330:20+360:1.8cm) 32 | --++ (20+360:0.4cm) 33 | arc (20+360:330:2.2cm) -- cycle; 34 | 35 | \draw (0,0) circle (2cm); 36 | 37 | \draw (20:1.8cm) -- node [right, blue] (s1) {Server 1} (20:2.4cm); 38 | \draw (70:1.8cm) -- node [above, red] (s2) {Server 2} (70:2.4cm); 39 | \draw (160:1.8cm) -- node [left, green] (s3) {Server 3} (160:2.4cm); 40 | \draw (280:1.8cm) -- node [below, yellow] (s4) {Server 4} (280:2.4cm); 41 | \draw (330:1.8cm) -- node [right, black] (s5) {Server 5} (330:2.4cm); 42 | 43 | 44 | \draw [blue, ->] (s1) to[out=90, in=70] (s2); 45 | \draw [red, ->] (s2) to[out=110, in=90] (s3); 46 | \draw [green, ->] (s3) to[out=270, in=180] (s4); 47 | \draw [thick,yellow, ->] (s4) to[out=0, in=270] (s5); 48 | \draw [->] (s5) to[out=70, in=290] (s1); 49 | 50 | \end{tikzpicture} 51 | 52 | %----------- 53 | 54 | \begin{tikzpicture} 55 | \foreach \a [count=\ai] in {20, 70, 160, 280, 330}{ 56 | \draw (\a:1.8cm) -- (\a:2.2cm); 57 | \node (s\ai) at (\a:2.4cm) {S \ai}; 58 | } 59 | 60 | \foreach \a/\b/\ai/\bi in {20/70/1/2, 70/160/2/3, 160/280/3/4, 280/330/4/5, 330/380/5/1}{ 61 | \draw [->,dashed] (s\ai) to[out=\a+20, in=\b-20] (s\bi); 62 | } 63 | 64 | \draw (0,0) circle (2cm); 65 | \end{tikzpicture} 66 | 67 | %------------------- 68 | 69 | 70 | \begin{tikzpicture} 71 | % lilsts: 72 | % r1 = [0, 12, 19, 21, 33, 54, 127, 139, 143, 177, 182, 216, 221, 257, 288, 319, 329, 338, 342, 348] 73 | % r2 = r1[1:] + r1[:1] 74 | % rr = list(zip(r1, r2)) 75 | % [ "{}/{}/{}/{}".format(a[0], a[1], i+1, (i+2)%20) for (i, a) in enumerate(rr)] 76 | % ['0/12/1/2', '12/19/2/3', '19/21/3/4', '21/33/4/5', '33/54/5/6', '54/127/6/7', '127/139/7/8', '139/143/8/9', '143/177/9/10', '177/182/10/11', '182/216/11/12', '216/221/12/13', '221/257/13/14', '257/288/14/15', '288/319/15/16', '319/329/16/17', '329/338/17/18', '338/342/18/19', '342/348/19/0', '348/0/20/1'] 77 | 78 | \foreach \a [count=\ai] in {0, 12, 19, 21, 33, 54, 127, 139, 143, 177, 182, 216, 221, 257, 288, 319, 329, 338, 342, 348}{ 79 | \draw (\a:1.8cm) -- (\a:2.2cm); 80 | \node (s\ai) at (\a:2.4cm) {S \ai}; 81 | } 82 | 83 | \foreach \a/\b/\ai/\bi in {0/12/1/2, 12/19/2/3, 19/21/3/4, 21/33/4/5, 33/54/5/6, 54/127/6/7, 127/139/7/8, 139/143/8/9, 143/177/9/10, 177/182/10/11, 182/216/11/12, 216/221/12/13, 221/257/13/14, 257/288/14/15, 288/319/15/16, 319/329/16/17, 329/338/17/18, 338/342/18/19, 342/348/19/20, 348/0/20/1}{ 84 | \draw [->] (s\ai) to[out=\a+20, in=\b-20] (s\bi); 85 | } 86 | 87 | \draw (0,0) circle (2cm); 88 | \end{tikzpicture} 89 | 90 | \begin{tikzpicture} 91 | % lilsts: 92 | % r1 = [0, 12, 19, 21, 33, 54, 127, 139, 143, 177, 182, 216, 221, 257, 288, 319, 329, 338, 342, 348] 93 | % r2 = r1[1:] + r1[:1] 94 | % rr = list(zip(r1, r2)) 95 | % [ "{}/{}/{}/{}".format(a[0], a[1], i+1, (i+2)%20) for (i, a) in enumerate(rr)] 96 | % ['0/12/1/2', '12/19/2/3', '19/21/3/4', '21/33/4/5', '33/54/5/6', '54/127/6/7', '127/139/7/8', '139/143/8/9', '143/177/9/10', '177/182/10/11', '182/216/11/12', '216/221/12/13', '221/257/13/14', '257/288/14/15', '288/319/15/16', '319/329/16/17', '329/338/17/18', '338/342/18/19', '342/348/19/0', '348/0/20/1'] 97 | 98 | \foreach \a [count=\ai] in {0, 12, 19, 21, 33, 54, 127, 139, 143, 177, 182, 216, 221, 257, 288, 319, 329, 338, 342, 348}{ 99 | \draw (\a:1.8cm) -- (\a:2.2cm); 100 | \node (s\ai) at (\a:2.4cm) {S \ai}; 101 | } 102 | 103 | \foreach \a/\b/\ai/\bi in {0/12/1/2, 12/19/2/3, 19/21/3/4, 21/33/4/5, 33/54/5/6, 54/127/6/7, 127/139/7/8, 139/143/8/9, 143/177/9/10, 177/182/10/11, 182/216/11/12, 216/221/12/13, 221/257/13/14, 257/288/14/15, 288/319/15/16, 319/329/16/17, 329/338/17/18, 338/342/18/19, 342/348/19/20, 348/0/20/1}{ 104 | \draw [->] (s\ai) to[out=\a+20, in=\b-20] (s\bi); 105 | } 106 | 107 | % and direct links: 108 | \draw [->, blue, thick] (s1) to[out=180, in=0] (s11); 109 | \draw [->, blue, thick] (s1) to[out=160, in=240] (s6); 110 | 111 | \draw [->, red, thick] (s14) to[out=60, in=330] (s7); 112 | \draw [->, red, thick] (s14) to[out=50, in=180] (s20); 113 | 114 | 115 | \draw (0,0) circle (2cm); 116 | \end{tikzpicture} 117 | 118 | 119 | \end{document} -------------------------------------------------------------------------------- /content/ch_04_improving_CS/figures/consistentHashing/figure.py: -------------------------------------------------------------------------------- 1 | import uuid 2 | import bisect 3 | 4 | num = 15 5 | num_servers = 4 6 | xscale = 10. 7 | points_per_server = 3 8 | colors = ['red', 'green', 'blue', 'yellow', 'black'] 9 | 10 | # simple hashing: 11 | 12 | uuids = [uuid.uuid4().int for i in range(num)] 13 | servers = [ (x, x % num_servers, x % (num_servers +1)) for x in uuids] 14 | # print(servers) 15 | 16 | few_server_x = [s*(xscale/(num_servers-1)) for s in range(num_servers)] 17 | more_server_x = [s*(xscale/(num_servers)) for s in range(num_servers+1)] 18 | 19 | print("\\begin{tikzpicture}") 20 | print ("\\draw [thin] (0,0) -- ({},0);".format(xscale)) 21 | for s in range(num_servers): 22 | print("\\node at ({}, 1) {{S{}}};".format(few_server_x[s], s)) 23 | for s in range(num_servers+1): 24 | print("\\node at ({}, -1) {{S{}}};".format(more_server_x[s], s)) 25 | 26 | for s in servers: 27 | x = (float(s[0]) / 2**128 * xscale) 28 | # print("\\draw [thick] ({},0) -- ({},1);".format(x, x)) 29 | print("\\node at ({},0) {{X}};".format(x, x)) 30 | print("\\draw ({}, 0.2) -- ({}, 0.8);".format(x, few_server_x[s[1]])) 31 | 32 | if s[1] == s[2]: 33 | print("\\draw ({},-0.2) -- ({}, -0.8);".format(x, more_server_x[s[2]])) 34 | else: 35 | print("\\draw[red] ({},-0.2) -- ({}, -0.8);".format(x, more_server_x[s[2]])) 36 | 37 | print("\\end{tikzpicture}") 38 | 39 | 40 | print ("%--------------") 41 | 42 | # consistent hashing 43 | print("\\begin{tikzpicture}") 44 | 45 | 46 | server_points = [[(uuid.uuid4().int, s) 47 | for n in range(points_per_server)] 48 | for s in range(num_servers)] 49 | 50 | # print(server_points) 51 | 52 | all_points = sorted([item for sublist in server_points for item in sublist], 53 | key= lambda x:x[0]) 54 | 55 | # print(all_points) 56 | 57 | def consistent_hashing(items, server_hashes): 58 | def get_server(item, server_hashes): 59 | return bisect.bisect(hashes, item) 60 | 61 | hashes = [x[0] for x in server_hashes] 62 | return [get_server(i, hashes) for i in items] 63 | 64 | 65 | def uuid2angle(uuid): 66 | return int(float(uuid)/float(2**128)*360) 67 | 68 | indexes = consistent_hashing(uuids, all_points) 69 | # print(indexes) 70 | 71 | for a, aprime in zip(all_points[:-1], all_points[1:]) : 72 | start = uuid2angle(a[0]) 73 | end = uuid2angle(aprime[0]) 74 | # print(start, end, colors[a[1]]) 75 | print("\\draw[fill={color}] ({start}:1cm) arc [start angle = {start}, end angle={end}, radius=1cm] --++({end}:1cm) arc [start angle = {end}, end angle={start}, radius=2cm] --++({start}:-1cm)--cycle;".format(color=colors[a[1]], start=start, end=end)) 76 | 77 | # special case for first one: 78 | end = uuid2angle(all_points[-1][0]) -360 79 | start = uuid2angle(all_points[0][0]) 80 | print("\\draw[fill={color}] ({start}:1cm) arc [start angle = {start}, end angle={end}, radius=1cm] --++({end}:1cm) arc [start angle = {end}, end angle={start}, radius=2cm] --++({start}:-1cm)--cycle;".format(color=colors[all_points[-1][1]], start=start, end=end)) 81 | 82 | 83 | # Print the UUIDs 84 | 85 | for u in uuids: 86 | print("\\node at ({{{}}}:1.5cm) {{X}};".format(uuid2angle(u))) 87 | 88 | print("\\end{tikzpicture}") 89 | 90 | 91 | ############# 92 | 93 | num_servers = num_servers + 1 94 | # consistent hashing 95 | print("\\begin{tikzpicture}") 96 | 97 | colors = ['red', 'green', 'blue', 'yellow', 'gray!10'] 98 | 99 | server_points = server_points + [[(uuid.uuid4().int, num_servers-1) 100 | for n in range(points_per_server)]] 101 | 102 | 103 | 104 | 105 | all_points = sorted([item for sublist in server_points for item in sublist], 106 | key= lambda x:x[0]) 107 | 108 | # print(all_points) 109 | 110 | def consistent_hashing(items, server_hashes): 111 | def get_server(item, server_hashes): 112 | return bisect.bisect(hashes, item) 113 | 114 | hashes = [x[0] for x in server_hashes] 115 | return [get_server(i, hashes) for i in items] 116 | 117 | 118 | def uuid2angle(uuid): 119 | return int(float(uuid)/float(2**128)*360) 120 | 121 | indexes = consistent_hashing(uuids, all_points) 122 | # print(indexes) 123 | 124 | for a, aprime in zip(all_points[:-1], all_points[1:]) : 125 | start = uuid2angle(a[0]) 126 | end = uuid2angle(aprime[0]) 127 | # print(start, end, colors[a[1]]) 128 | print("\\draw[fill={color}] ({start}:1cm) arc [start angle = {start}, end angle={end}, radius=1cm] --++({end}:1cm) arc [start angle = {end}, end angle={start}, radius=2cm] --++({start}:-1cm)--cycle;".format(color=colors[a[1]], start=start, end=end)) 129 | 130 | # special case for first one: 131 | end = uuid2angle(all_points[-1][0]) -360 132 | start = uuid2angle(all_points[0][0]) 133 | print("\\draw[fill={color}] ({start}:1cm) arc [start angle = {start}, end angle={end}, radius=1cm] --++({end}:1cm) arc [start angle = {end}, end angle={start}, radius=2cm] --++({start}:-1cm)--cycle;".format(color=colors[all_points[-1][1]], start=start, end=end)) 134 | 135 | 136 | # Print the UUIDs 137 | 138 | for u in uuids: 139 | print("\\node at ({{{}}}:1.5cm) {{X}};".format(uuid2angle(u))) 140 | 141 | print("\\end{tikzpicture}") 142 | -------------------------------------------------------------------------------- /content/ch_03_RPC_CS/figures/rpc_rrp.tex: -------------------------------------------------------------------------------- 1 | % RPC request/reply protocol 2 | 3 | 4 | \documentclass[tikz]{standalone} 5 | 6 | 7 | \input{../../templates/tikzFigureHeader} 8 | 9 | \begin{document} 10 | 11 | \begin{msc}{RPC -- no errors} 12 | \declinst{a}{}{Caller} 13 | \declinst{ap}{}{Stub} 14 | \declinst{bp}{}{Skeleton} 15 | \declinst{b}{}{Callee} 16 | % \regionstart{suspension}{a} 17 | \mess{Call}{a}{ap} 18 | \nextlevel 19 | \settimer{T}{ap} 20 | \mess{Request}{ap}{bp} 21 | \nextlevel 22 | \mess{Call}{bp}{b} 23 | \nextlevel 24 | \msccomment[side=right]{Execute}{b} 25 | \nextlevel 26 | \mess{Result}{b}{bp} 27 | \nextlevel 28 | \mess{Reply}{bp}{ap} 29 | \stoptimer{T}{ap} 30 | \nextlevel[1.5] 31 | \mess{Result}{ap}{a} 32 | \end{msc} 33 | 34 | %----------------------------------- 35 | 36 | 37 | \begin{msc}{RPC -- request lost} 38 | \declinst{a}{}{Caller} 39 | \declinst{ap}{}{Stub} 40 | \declinst{bp}{}{Skeleton} 41 | \declinst{b}{}{Callee} 42 | % \regionstart{suspension}{a} 43 | \mess{Call}{a}{ap} 44 | \nextlevel[1.5] 45 | \settimeout{T}{ap}[6] 46 | \lost[side=right]{Request}{}{ap} 47 | \nextlevel[6] 48 | % Timeout 49 | \nextlevel 50 | \msccomment[side=left]{Retry}{ap} 51 | \nextlevel 52 | \settimer{T}{ap} 53 | \mess{Request}{ap}{bp} 54 | \nextlevel 55 | \mess{Call}{bp}{b} 56 | \nextlevel 57 | \msccomment[side=right]{Execute}{b} 58 | \nextlevel 59 | \mess{Result}{b}{bp} 60 | \nextlevel 61 | \mess{Reply}{bp}{ap} 62 | \stoptimer{T}{ap} 63 | \nextlevel[1.5] 64 | \mess{Result}{ap}{a} 65 | \end{msc} 66 | 67 | %----------------------------------- 68 | 69 | \begin{msc}{RPC -- reply lost, recompute} 70 | \declinst{a}{}{Caller} 71 | \declinst{ap}{}{Stub} 72 | \declinst{bp}{}{Skeleton} 73 | \declinst{b}{}{Callee} 74 | % \regionstart{suspension}{a} 75 | \mess{Call}{a}{ap} 76 | \nextlevel 77 | \settimeout{T}{ap}[6] 78 | \mess{Request}{ap}{bp} 79 | \nextlevel 80 | \mess{Call}{bp}{b} 81 | \nextlevel 82 | \msccomment[side=right]{Execute}{b} 83 | \nextlevel 84 | \mess{Result}{b}{bp} 85 | \nextlevel 86 | \lost{Reply}{}{bp} 87 | \nextlevel[2] 88 | % Timeout 89 | \nextlevel 90 | \settimer{T}{ap} 91 | \mess{Request}{ap}{bp} 92 | \nextlevel 93 | \msccomment[side=right]{Recompute}{bp} 94 | \nextlevel[2] 95 | \mess{Call}{bp}{b} 96 | \nextlevel 97 | \msccomment[side=right]{Execute}{b} 98 | \nextlevel 99 | \mess{Result}{b}{bp} 100 | \nextlevel 101 | \mess{Reply}{bp}{ap} 102 | \stoptimer{T}{ap} 103 | \nextlevel[1.5] 104 | \mess{Result}{ap}{a} 105 | \end{msc} 106 | 107 | %----------------------------------- 108 | 109 | \begin{msc}{RPC -- reply lost, reply cache} 110 | \declinst{a}{}{Caller} 111 | \declinst{ap}{}{Stub} 112 | \declinst{bp}{}{Skeleton} 113 | \declinst{b}{}{Callee} 114 | % \regionstart{suspension}{a} 115 | \mess{Call}{a}{ap} 116 | \nextlevel 117 | \settimeout{T}{ap}[6] 118 | \mess{Request}{ap}{bp} 119 | \nextlevel 120 | \mess{Call}{bp}{b} 121 | \nextlevel 122 | \msccomment[side=right]{Execute}{b} 123 | \nextlevel 124 | \mess{Result}{b}{bp} 125 | \nextlevel 126 | \lost{Reply}{}{bp} 127 | \nextlevel[2] 128 | % Timeout 129 | \nextlevel 130 | \settimer{T}{ap} 131 | \mess{Request}{ap}{bp} 132 | \nextlevel 133 | \msccomment[side=right]{Use reply cache}{bp} 134 | \nextlevel[2] 135 | \mess{Reply}{bp}{ap} 136 | \stoptimer{T}{ap} 137 | \nextlevel[1.5] 138 | \mess{Result}{ap}{a} 139 | \end{msc} 140 | 141 | 142 | %----------------------------------- 143 | 144 | \begin{msc}{RPC -- server crash} 145 | \declinst{a}{}{Caller} 146 | \declinst{ap}{}{Stub} 147 | \declinst{bp}{}{Skeleton} 148 | \declinst{b}{}{Callee} 149 | % \regionstart{suspension}{a} 150 | \mess{Call}{a}{ap} 151 | \nextlevel 152 | \settimeout{T}{ap}[9] 153 | \mess{Request}{ap}{bp} 154 | \nextlevel 155 | \mess{Call}{bp}{b} 156 | \nextlevel 157 | \msccomment[side=right]{Execute}{b} 158 | \nextlevel 159 | \condition{CRASH}{bp,b} 160 | \nextlevel[2] 161 | \stop{bp} 162 | \stop{b} 163 | \nextlevel[2] 164 | \startinst{bp}{}{Restart} 165 | \startinst{b}{}{Restart} 166 | \nextlevel[3] 167 | %--------------- 168 | \msccomment[side=left]{Retry}{ap} 169 | \nextlevel 170 | \settimer{T}{ap} 171 | \mess{Request}{ap}{bp} 172 | \nextlevel 173 | \mess{Call}{bp}{b} 174 | \nextlevel 175 | \msccomment[side=right]{Execute}{b} 176 | \nextlevel 177 | \mess{Result}{b}{bp} 178 | \nextlevel 179 | \mess{Reply}{bp}{ap} 180 | \stoptimer{T}{ap} 181 | \nextlevel[1.5] 182 | \mess{Result}{ap}{a} 183 | 184 | % \condition{Restart}{bp,b} 185 | % \nextlevel 186 | % \mess{Result}{b}{bp} 187 | % \nextlevel 188 | % \lost{Reply}{}{bp} 189 | % \nextlevel[2] 190 | % % Timeout 191 | % \nextlevel 192 | % \settimer{T}{ap} 193 | % \mess{Request}{ap}{bp} 194 | % \nextlevel 195 | % \msccomment[side=right]{Use reply cache}{bp} 196 | % \nextlevel[2] 197 | % \mess{Reply}{bp}{ap} 198 | % \stoptimer{T}{ap} 199 | % \nextlevel[1.5] 200 | % \mess{Result}{ap}{a} 201 | \end{msc} 202 | 203 | 204 | \end{document} -------------------------------------------------------------------------------- /content/ch_09_msqQueuing/figures/kafka.tex: -------------------------------------------------------------------------------- 1 | % Created 2016-08-17 Wed 14:38 2 | \documentclass[tikz]{standalone} 3 | 4 | \input{../../templates/tikzFigureHeader} 5 | 6 | \usetikzlibrary{chains,shapes.multipart} 7 | \usetikzlibrary{shapes,calc} 8 | \usetikzlibrary{automata,positioning} 9 | 10 | \tikzset{ 11 | queue/.pic={ 12 | \node (-open) at (0,0) {}; 13 | \node (-closed) at (3cm,0) {}; 14 | \draw[line width=1pt] 15 | (0,-0.5) -- ++(2.75cm,0) -- ++(0,1cm) -- ++(-2.75cm, 0cm); 16 | \foreach \Val in {1,...,#1} { 17 | \draw [rounded corners, fill=blue!20] (2.75cm-0.5cm*\Val-0.05cm,-0.45cm) rectangle (2.75cm-0.5cm*\Val+0.5cm-0.05cm, 0.45cm) node[pos=0.5] {\Val}; 18 | } 19 | }, 20 | lqueue/.pic={ 21 | \node (-open) at (0,0) {}; 22 | \node (-closed) at (-3cm,0) {}; 23 | \draw[line width=1pt] 24 | (0,-0.5) -- ++(-2.75cm,0) -- ++(0,1cm) -- ++(+2.75cm, 0cm); 25 | \foreach \Val in {1,...,#1} { 26 | \draw [rounded corners, fill=green!20] (-2.75cm+0.5cm*\Val-0.5cm+0.05cm,-0.45cm) rectangle (-2.75cm+0.5cm*\Val+0.05cm, 0.45cm) node[pos=0.5] (-\Val) {\Val}; 27 | } 28 | }, 29 | database/.style={ 30 | cylinder, 31 | cylinder uses custom fill, 32 | cylinder body fill=yellow!50, 33 | cylinder end fill=yellow!50, 34 | shape border rotate=90, 35 | aspect=0.25, 36 | draw 37 | } 38 | } 39 | 40 | \begin{document} 41 | 42 | 43 | 44 | \begin{tikzpicture}% [line width=0.25mm] 45 | 46 | \node [draw, align=center, fill=blue!20] at (0,0) (k) {Kafka\\cluster}; 47 | \node [draw, above=of k] (a1) {App}; 48 | \node [draw, above right =of k, xshift=-1cm] (a2) {App}; 49 | \node [draw, above left =of k, xshift=+1cm] (a3) {App}; 50 | \node [above of= a2, anchor=east] {Producer}; 51 | 52 | \node [draw, below left =of k, xshift=+1cm] (c1) {App}; 53 | \node [draw, below =of k] (c2) {App}; 54 | \node [draw, below right =of k, xshift=-1cm] (c3) {App}; 55 | \node [below = of c2, anchor=north, yshift=0.8cm] {Consumer}; 56 | 57 | 58 | \node [draw, right =of k, yshift=0.5cm] (s1) {App}; 59 | \node [draw, right =of k, yshift=-0.5cm] (s2) {App}; 60 | \node [right = of s1, anchor=north, yshift=-0.4cm, rotate=270] {Stream}; 61 | 62 | \node [database, left =of k, yshift=0.5cm] (db1) {App}; 63 | \node [database, left =of k, yshift=-0.5cm] (db2) {App}; 64 | \node [left = of db1, anchor=north, yshift=-0.2cm, rotate=90] {Connect}; 65 | 66 | 67 | \foreach \x in {a1,a2,a3} \draw [->] (\x) -- (k); 68 | \foreach \x in {c1,c2,c3} \draw [->] (k) -- (\x); 69 | \foreach \x in {s1,s2} \draw [<->] (\x) -- (k); 70 | \draw [->] (k) -- (db1); 71 | \draw [<-] (k) -- (db2); 72 | 73 | 74 | \end{tikzpicture} 75 | 76 | % Kafka queues: 77 | 78 | % \end{document} 79 | 80 | \begin{tikzpicture} 81 | 82 | \pic (q1) at (0,0) {lqueue=5}; 83 | \pic (q2) at (0,2) {lqueue=3}; 84 | \pic (q3) at (0,4) {lqueue=5}; 85 | 86 | \node [left=of q1-closed, xshift=1cm] (p0) {Partition 0}; 87 | \node [left=of q2-closed, xshift=1cm] (p1) {Partition 1}; 88 | \node [left=of q3-closed, xshift=1cm] (p2) {Partition 2}; 89 | 90 | \node (writes) [right= of q2-open] {Writes}; 91 | 92 | \node (old) [below=of q1-1] {Old}; 93 | \node (new) at (q1-5|-old) {New}; 94 | 95 | \draw [->] (writes) -- (q1-open); 96 | \draw [->] (writes) -- (q2-open); 97 | \draw [->] (writes) -- (q3-open); 98 | 99 | \draw [thick, ->] (old) -- (new); 100 | \end{tikzpicture} 101 | 102 | 103 | 104 | \begin{tikzpicture} 105 | \pic (q) at (0,0) {lqueue=5}; 106 | 107 | \node [above=of q-5] (p) {Producers write}; 108 | \node [below=of q-2, xshift=-1cm, align=center] (ca) {Consumer A \\reads, offset =2}; 109 | \node [below=of q-4, xshift=+1cm, align=center] (cb) {Consumer B \\reads, offset =4}; 110 | 111 | \draw [->] (q-2) -- (ca); 112 | \draw [->] (q-4) -- (cb); 113 | 114 | \draw [->] (p) -- ($(q-5) + (0.5, 0)$); 115 | \end{tikzpicture} 116 | 117 | \begin{tikzpicture} 118 | 119 | \node [draw] (p0) {P0}; 120 | \node [draw, right=of p0] (p3) {P3}; 121 | 122 | \node [draw, right=of p3, xshift=0.5cm] (p1) {P1}; 123 | \node [draw, right=of p1] (p2) {P2}; 124 | 125 | \node [fit= (p0) (p3), draw] (s1) {}; 126 | \node [fit= (p1) (p2), draw] (s2) {}; 127 | \node [above = 0cm of s1] (s1l) {Server 1}; 128 | \node [above = 0cm of s2] (s2l) {Server 2}; 129 | \node [fit= (s1) (s2) (s1l) (s2l), draw, dotted, 130 | label=above:{Cluster}] (kc) {}; 131 | 132 | % ----------- 133 | 134 | \node [draw] (c1) at (-1, -2) {C1}; 135 | \node [draw, right=of c1] (c2) {C2}; 136 | \node [draw, right=of c2] (c3) {C3}; 137 | \node [draw, right=of c3] (c4) {C4}; 138 | \node [draw, right=of c4] (c5) {C5}; 139 | \node [draw, right=of c5] (c6) {C6}; 140 | 141 | \node [fit= (c1) (c2), draw, dotted, 142 | label=below:{Group A}] (cga) {}; 143 | 144 | \node [fit= (c3) (c4) (c5) (c6), draw, dotted, 145 | label=below:{Group B}] (cgb) {}; 146 | 147 | %------------- 148 | 149 | \draw [->] (p0.south) -- (c1.north); 150 | \draw [->] (p0.south) -- (c3.north); 151 | \draw [->] (p3.south) -- (c1.north); 152 | \draw [->] (p3.south) -- (c4.north); 153 | 154 | \draw [->] (p1.south) -- (c2.north); 155 | \draw [->] (p1.south) -- (c5.north); 156 | \draw [->] (p2.south) -- (c2.north); 157 | \draw [->] (p2.south) -- (c6.north); 158 | 159 | 160 | \end{tikzpicture} 161 | 162 | 163 | % test picture to get the queues to work out right: 164 | % \begin{tikzpicture} 165 | % \pic (q1) at (0,0) {queue=3} ; 166 | 167 | % \pic (q2) at (0,2) {lqueue=5}; 168 | 169 | % \draw [->, thick] (q2-closed) to[out=180,in=180] (q1-open); 170 | % \draw [->, thick, red] (q1-closed) to[out=0,in=0] (q2-open); 171 | % \end{tikzpicture} 172 | 173 | \end{document} 174 | 175 | --------------------------------------------------------------------------------