61
ICWE’19 FEDER Una manera de hacer Europa. Architectural Styles for the Development of WoT Applications Jose Garcia-Alonso @jmgaralo Javier Berrocal @jberolm

Architectural Styles for the Development of WoT Applicationsweb.geni-pco.com/icwe2019/tutorial4.pdf · 2019. 6. 12. · Javier Berrocal, José García-Alonso, Cristina Vicente - Chicote,

  • Upload
    others

  • View
    0

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Architectural Styles for the Development of WoT Applicationsweb.geni-pco.com/icwe2019/tutorial4.pdf · 2019. 6. 12. · Javier Berrocal, José García-Alonso, Cristina Vicente - Chicote,

ICWE’19 FEDERUna manera de hacer Europa.

Architectural Styles for the Development of

WoT Applications

Jose Garcia-Alonso@jmgaralo

Javier Berrocal@jberolm

Page 2: Architectural Styles for the Development of WoT Applicationsweb.geni-pco.com/icwe2019/tutorial4.pdf · 2019. 6. 12. · Javier Berrocal, José García-Alonso, Cristina Vicente - Chicote,

ICWE’19

Before we start• https://forms.gle/YvTJscVQGXuRsoU76

Page 3: Architectural Styles for the Development of WoT Applicationsweb.geni-pco.com/icwe2019/tutorial4.pdf · 2019. 6. 12. · Javier Berrocal, José García-Alonso, Cristina Vicente - Chicote,

ICWE’19

Context• Mobile apps

Page 4: Architectural Styles for the Development of WoT Applicationsweb.geni-pco.com/icwe2019/tutorial4.pdf · 2019. 6. 12. · Javier Berrocal, José García-Alonso, Cristina Vicente - Chicote,

ICWE’19

Index

• Server-Centric vs Mobile-Centric

• Consumption estimations

• Generating Mobile-Centric APPs

Page 5: Architectural Styles for the Development of WoT Applicationsweb.geni-pco.com/icwe2019/tutorial4.pdf · 2019. 6. 12. · Javier Berrocal, José García-Alonso, Cristina Vicente - Chicote,

ICWE’19

SC vs MC• Server-Centric

Page 6: Architectural Styles for the Development of WoT Applicationsweb.geni-pco.com/icwe2019/tutorial4.pdf · 2019. 6. 12. · Javier Berrocal, José García-Alonso, Cristina Vicente - Chicote,

ICWE’19

SC vs MC• Mobile-Centric

Page 7: Architectural Styles for the Development of WoT Applicationsweb.geni-pco.com/icwe2019/tutorial4.pdf · 2019. 6. 12. · Javier Berrocal, José García-Alonso, Cristina Vicente - Chicote,

ICWE’19

SC vs MC• Mobile-Centric

Page 8: Architectural Styles for the Development of WoT Applicationsweb.geni-pco.com/icwe2019/tutorial4.pdf · 2019. 6. 12. · Javier Berrocal, José García-Alonso, Cristina Vicente - Chicote,

ICWE’19

SC vs MC

Page 9: Architectural Styles for the Development of WoT Applicationsweb.geni-pco.com/icwe2019/tutorial4.pdf · 2019. 6. 12. · Javier Berrocal, José García-Alonso, Cristina Vicente - Chicote,

ICWE’19

SC vs MC

Javier Berrocal, José García-Alonso, Cristina Vicente-Chicote, Juan Hernández Núñez, Tommi Mikkonen, Carlos Canal, Juan Manuel Murillo:Early analysis of resource consumption patterns in mobile applications. Pervasive and Mobile Computing 35: 32-50 (2017)

Page 10: Architectural Styles for the Development of WoT Applicationsweb.geni-pco.com/icwe2019/tutorial4.pdf · 2019. 6. 12. · Javier Berrocal, José García-Alonso, Cristina Vicente - Chicote,

ICWE’19

HeatMap

Page 11: Architectural Styles for the Development of WoT Applicationsweb.geni-pco.com/icwe2019/tutorial4.pdf · 2019. 6. 12. · Javier Berrocal, José García-Alonso, Cristina Vicente - Chicote,

ICWE’19

HeatMap- Funcionality

• Two main funcionalities

– Gather users’ positioning

– Generate heatmap

Page 12: Architectural Styles for the Development of WoT Applicationsweb.geni-pco.com/icwe2019/tutorial4.pdf · 2019. 6. 12. · Javier Berrocal, José García-Alonso, Cristina Vicente - Chicote,

ICWE’19

HeatMap- Implementation

• Three architectures

– Server-Centric

– Mobile-Centric

– Hybrid

Page 13: Architectural Styles for the Development of WoT Applicationsweb.geni-pco.com/icwe2019/tutorial4.pdf · 2019. 6. 12. · Javier Berrocal, José García-Alonso, Cristina Vicente - Chicote,

ICWE’19

HeatMap- SC

Page 14: Architectural Styles for the Development of WoT Applicationsweb.geni-pco.com/icwe2019/tutorial4.pdf · 2019. 6. 12. · Javier Berrocal, José García-Alonso, Cristina Vicente - Chicote,

ICWE’19

HeatMap- MC

Page 15: Architectural Styles for the Development of WoT Applicationsweb.geni-pco.com/icwe2019/tutorial4.pdf · 2019. 6. 12. · Javier Berrocal, José García-Alonso, Cristina Vicente - Chicote,

ICWE’19

HeatMap- Hybrid

Page 16: Architectural Styles for the Development of WoT Applicationsweb.geni-pco.com/icwe2019/tutorial4.pdf · 2019. 6. 12. · Javier Berrocal, José García-Alonso, Cristina Vicente - Chicote,

ICWE’19

HeatMap - Implementation

https://goo.gl/Bnvhno

Page 17: Architectural Styles for the Development of WoT Applicationsweb.geni-pco.com/icwe2019/tutorial4.pdf · 2019. 6. 12. · Javier Berrocal, José García-Alonso, Cristina Vicente - Chicote,

ICWE’19 FEDERUna manera de hacer Europa.

Consumption estimations

Page 18: Architectural Styles for the Development of WoT Applicationsweb.geni-pco.com/icwe2019/tutorial4.pdf · 2019. 6. 12. · Javier Berrocal, José García-Alonso, Cristina Vicente - Chicote,

ICWE’19

Consumption estimation• If we analyze mobile apps, we find lots of

funcionalities created by composing the sameprimitive operations

Page 19: Architectural Styles for the Development of WoT Applicationsweb.geni-pco.com/icwe2019/tutorial4.pdf · 2019. 6. 12. · Javier Berrocal, José García-Alonso, Cristina Vicente - Chicote,

ICWE’19

Consumption estimation• If we analyze mobile apps, we find lots of

funcionalities created by composing the sameprimitive operations

Primitive

store(content_size)

post(content_size)

get(content_size)

receivePush()

getGPS()

Page 20: Architectural Styles for the Development of WoT Applicationsweb.geni-pco.com/icwe2019/tutorial4.pdf · 2019. 6. 12. · Javier Berrocal, José García-Alonso, Cristina Vicente - Chicote,

ICWE’19

Consumption estimation• If we analyze mobile apps, we find lots of

funcionalities created by composing the sameprimitive operations

• The used operations and its order depend on thespecific funcionality and the architecture

Primitive

store(content_size)

post(content_size)

get(content_size)

receivePush()

getGPS()

Page 21: Architectural Styles for the Development of WoT Applicationsweb.geni-pco.com/icwe2019/tutorial4.pdf · 2019. 6. 12. · Javier Berrocal, José García-Alonso, Cristina Vicente - Chicote,

ICWE’19

Consumption estimation• Conceptual Framework

– Primitive operations

– Different architectures

– Several use cases

– Use cases are composed by primitive operations

– Architectures are composed of use cases

21

Page 22: Architectural Styles for the Development of WoT Applicationsweb.geni-pco.com/icwe2019/tutorial4.pdf · 2019. 6. 12. · Javier Berrocal, José García-Alonso, Cristina Vicente - Chicote,

ICWE’19

Consumption estimation• Emergency Alerts

22

Page 23: Architectural Styles for the Development of WoT Applicationsweb.geni-pco.com/icwe2019/tutorial4.pdf · 2019. 6. 12. · Javier Berrocal, José García-Alonso, Cristina Vicente - Chicote,

ICWE’19

Consumption estimation• Emergency Alerts

23

UC – 1 Send GPS positionUC – 2 Receive alert message

Page 24: Architectural Styles for the Development of WoT Applicationsweb.geni-pco.com/icwe2019/tutorial4.pdf · 2019. 6. 12. · Javier Berrocal, José García-Alonso, Cristina Vicente - Chicote,

ICWE’19

Consumption estimation• Emergency Alerts

24

UC1 UC1

UC2 UC2

UC2 UC2 UC2 UC2

UC – 1 Send GPS positionUC – 2 Receive alert message

Server-Centric Mobile-Centric

Page 25: Architectural Styles for the Development of WoT Applicationsweb.geni-pco.com/icwe2019/tutorial4.pdf · 2019. 6. 12. · Javier Berrocal, José García-Alonso, Cristina Vicente - Chicote,

ICWE’19

Consumption estimation• Emergency Alerts

25

getGPS getGPS getGPS getGPS

Server-Centric Mobile-Centric

Page 26: Architectural Styles for the Development of WoT Applicationsweb.geni-pco.com/icwe2019/tutorial4.pdf · 2019. 6. 12. · Javier Berrocal, José García-Alonso, Cristina Vicente - Chicote,

ICWE’19

Consumption estimation• Emergency Alerts

26

Server-Centric Mobile-Centric

Page 27: Architectural Styles for the Development of WoT Applicationsweb.geni-pco.com/icwe2019/tutorial4.pdf · 2019. 6. 12. · Javier Berrocal, José García-Alonso, Cristina Vicente - Chicote,

ICWE’19

Consumption estimation• Emergency Alerts

27

push push

Server-Centric Mobile-Centric

Page 28: Architectural Styles for the Development of WoT Applicationsweb.geni-pco.com/icwe2019/tutorial4.pdf · 2019. 6. 12. · Javier Berrocal, José García-Alonso, Cristina Vicente - Chicote,

ICWE’19

Estimación Consumo• Emergency Alerts

28

CU1 CU1

CU2 CU2

Server-Centric

UC1 = ( getGPS() + post (16b) ) x GPSFreq

UC2 = receivePush() x PUSHFreq

SC = UC1 +UC2

Page 29: Architectural Styles for the Development of WoT Applicationsweb.geni-pco.com/icwe2019/tutorial4.pdf · 2019. 6. 12. · Javier Berrocal, José García-Alonso, Cristina Vicente - Chicote,

ICWE’19

Consumption estimation• Emergency Alerts

29

Server-Centric Mobile-Centric

push push

Page 30: Architectural Styles for the Development of WoT Applicationsweb.geni-pco.com/icwe2019/tutorial4.pdf · 2019. 6. 12. · Javier Berrocal, José García-Alonso, Cristina Vicente - Chicote,

ICWE’19

Consumption estimation• Emergency Alerts

30

push push

Server-Centric Mobile-Centric

push push pushpush

getG

PS

getG

PS

getG

PS

getG

PS

Page 31: Architectural Styles for the Development of WoT Applicationsweb.geni-pco.com/icwe2019/tutorial4.pdf · 2019. 6. 12. · Javier Berrocal, José García-Alonso, Cristina Vicente - Chicote,

ICWE’19

Consumption estimation• Emergency Alerts

31

UC2 UC2 UC2 UC2

Mobile-Centric

UC1 = ∅

UC2 = ( receivePush() + getGPS()+post (16b) ) x PUSHFreq

MC = UC1 + UC2

Page 32: Architectural Styles for the Development of WoT Applicationsweb.geni-pco.com/icwe2019/tutorial4.pdf · 2019. 6. 12. · Javier Berrocal, José García-Alonso, Cristina Vicente - Chicote,

ICWE’19

Consumption estimation• Knowing the consumption of each primitive, we

could estimate the consumption of mobileapplications. Even for different architectures

32

Page 33: Architectural Styles for the Development of WoT Applicationsweb.geni-pco.com/icwe2019/tutorial4.pdf · 2019. 6. 12. · Javier Berrocal, José García-Alonso, Cristina Vicente - Chicote,

ICWE’19

Consumption estimation• Knowing the consumption of each primitive, we

could estimate the consumption of mobileapplications. Even for different architectures

33

On early stages and without implementing the apps

Page 34: Architectural Styles for the Development of WoT Applicationsweb.geni-pco.com/icwe2019/tutorial4.pdf · 2019. 6. 12. · Javier Berrocal, José García-Alonso, Cristina Vicente - Chicote,

ICWE’19

Consumption estimation• Knowing the consumption of each primitive, we

could estimate the consumption of mobileapplications. Even for different architectures

34

Primitive Size (Bytes) Battery (μAh) Data (Bytes)

store 16 0,44 0

post 16 16,83 1067

get 16 16,29 657

receivePush 140 18,36 407

getGPS n/a 7,20 0

On early stages and without implementing the apps

Page 35: Architectural Styles for the Development of WoT Applicationsweb.geni-pco.com/icwe2019/tutorial4.pdf · 2019. 6. 12. · Javier Berrocal, José García-Alonso, Cristina Vicente - Chicote,

ICWE’19

Consumption estimation• Simple apps simple estimation

• Complex apps not so direct estimation

• If we want to follow the app evolution underdifferent circumstances, estimation gets even more complex

35

https://api-consumptions.herokuapp.com/

Page 36: Architectural Styles for the Development of WoT Applicationsweb.geni-pco.com/icwe2019/tutorial4.pdf · 2019. 6. 12. · Javier Berrocal, José García-Alonso, Cristina Vicente - Chicote,

ICWE’19

Consumption estimation• The API takes a JSON describing the app and

calculate its consumption

36

Page 37: Architectural Styles for the Development of WoT Applicationsweb.geni-pco.com/icwe2019/tutorial4.pdf · 2019. 6. 12. · Javier Berrocal, José García-Alonso, Cristina Vicente - Chicote,

ICWE’19

Consumption estimation• We can see an example

Repository:

API:

37

https://api-consumptions.herokuapp.com/

https://github.com/jberolm/ICWE19

Page 38: Architectural Styles for the Development of WoT Applicationsweb.geni-pco.com/icwe2019/tutorial4.pdf · 2019. 6. 12. · Javier Berrocal, José García-Alonso, Cristina Vicente - Chicote,

ICWE’19

Consumption estimation• The API generates a CSV result following this

format:

38

Architecture_“arName1”_Battery(μAh)

Var1 Var2 … VarN Result

-- -- -- -- --

-- -- -- -- --

Architecture_“arName1”_Data(Byte)

Var1 Var2 … VarN Result

-- -- -- -- --

-- -- -- -- --

CU_“cuName”_Battery(μAh)

Var1 Var2 … VarN Result

-- -- -- -- --

-- -- -- -- --

Page 39: Architectural Styles for the Development of WoT Applicationsweb.geni-pco.com/icwe2019/tutorial4.pdf · 2019. 6. 12. · Javier Berrocal, José García-Alonso, Cristina Vicente - Chicote,

ICWE’19

Coffee Break!

Page 40: Architectural Styles for the Development of WoT Applicationsweb.geni-pco.com/icwe2019/tutorial4.pdf · 2019. 6. 12. · Javier Berrocal, José García-Alonso, Cristina Vicente - Chicote,

ICWE’19 FEDERUna manera de hacer Europa.

Generating Mobile-Centric APPs

Javier Berrocal@jberolm

Page 41: Architectural Styles for the Development of WoT Applicationsweb.geni-pco.com/icwe2019/tutorial4.pdf · 2019. 6. 12. · Javier Berrocal, José García-Alonso, Cristina Vicente - Chicote,

ICWE’19

OpenAPI• Almost any application make use of APIs to connect

with other applications or with other parts of that application.

Page 42: Architectural Styles for the Development of WoT Applicationsweb.geni-pco.com/icwe2019/tutorial4.pdf · 2019. 6. 12. · Javier Berrocal, José García-Alonso, Cristina Vicente - Chicote,

ICWE’19

OpenAPI

Server-Centric APPs

Page 43: Architectural Styles for the Development of WoT Applicationsweb.geni-pco.com/icwe2019/tutorial4.pdf · 2019. 6. 12. · Javier Berrocal, José García-Alonso, Cristina Vicente - Chicote,

ICWE’19

OpenAPI

Server-Centric APPs

Page 44: Architectural Styles for the Development of WoT Applicationsweb.geni-pco.com/icwe2019/tutorial4.pdf · 2019. 6. 12. · Javier Berrocal, José García-Alonso, Cristina Vicente - Chicote,

ICWE’19

OpenAPI

Server-Centric APPs

Page 45: Architectural Styles for the Development of WoT Applicationsweb.geni-pco.com/icwe2019/tutorial4.pdf · 2019. 6. 12. · Javier Berrocal, José García-Alonso, Cristina Vicente - Chicote,

ICWE’19

Generating MC APPs

6

Mobile-Centric APPs

Page 46: Architectural Styles for the Development of WoT Applicationsweb.geni-pco.com/icwe2019/tutorial4.pdf · 2019. 6. 12. · Javier Berrocal, José García-Alonso, Cristina Vicente - Chicote,

ICWE’19

Generating MC APPs

7

Mobile-Centric APPs

Page 47: Architectural Styles for the Development of WoT Applicationsweb.geni-pco.com/icwe2019/tutorial4.pdf · 2019. 6. 12. · Javier Berrocal, José García-Alonso, Cristina Vicente - Chicote,

ICWE’19

Generating MC APPs• Steps:

– Create the APP’s specification with OpenAPI.• An example can be seen in the following URL

https://github.com/jberolm/ICWE19

Page 48: Architectural Styles for the Development of WoT Applicationsweb.geni-pco.com/icwe2019/tutorial4.pdf · 2019. 6. 12. · Javier Berrocal, José García-Alonso, Cristina Vicente - Chicote,

ICWE’19

Generating MC APPs• Steps:

– Generate the mobile-centric app following the spec.

https://openapi-generator-spilab.herokuapp.com/

Page 49: Architectural Styles for the Development of WoT Applicationsweb.geni-pco.com/icwe2019/tutorial4.pdf · 2019. 6. 12. · Javier Berrocal, José García-Alonso, Cristina Vicente - Chicote,

ICWE’19

Generating MC APPs• Steps:

– Download the generated APP.

Page 50: Architectural Styles for the Development of WoT Applicationsweb.geni-pco.com/icwe2019/tutorial4.pdf · 2019. 6. 12. · Javier Berrocal, José García-Alonso, Cristina Vicente - Chicote,

ICWE’19

Generating MC APPs• Steps:

– Create a Firebase project

https://console.firebase.google.com

1 2

Page 51: Architectural Styles for the Development of WoT Applicationsweb.geni-pco.com/icwe2019/tutorial4.pdf · 2019. 6. 12. · Javier Berrocal, José García-Alonso, Cristina Vicente - Chicote,

ICWE’19

Generating MC APPs• Steps:

– Register app and download the file google-services.json

Package name Thisinfo is in the file build.gradle of the downloaded app. Label applicationId

1 2

Google-services.json shouldbe stored in the rootdirectory

Page 52: Architectural Styles for the Development of WoT Applicationsweb.geni-pco.com/icwe2019/tutorial4.pdf · 2019. 6. 12. · Javier Berrocal, José García-Alonso, Cristina Vicente - Chicote,

ICWE’19

Generating MC APPs• Steps:

– The file local.properties should be created in the APP’s root directory

– This file should include information about the directory of the Android SDK

Page 53: Architectural Styles for the Development of WoT Applicationsweb.geni-pco.com/icwe2019/tutorial4.pdf · 2019. 6. 12. · Javier Berrocal, José García-Alonso, Cristina Vicente - Chicote,

ICWE’19

Generating MC APPs• Steps:

– Build and generate the APK.

• The APK should be located in the filder “build\outputs\apk\debug\”

.\gradlew assembleDebug

Page 54: Architectural Styles for the Development of WoT Applicationsweb.geni-pco.com/icwe2019/tutorial4.pdf · 2019. 6. 12. · Javier Berrocal, José García-Alonso, Cristina Vicente - Chicote,

ICWE’19 15

https://github.com/jberolm/ICWE19

Page 55: Architectural Styles for the Development of WoT Applicationsweb.geni-pco.com/icwe2019/tutorial4.pdf · 2019. 6. 12. · Javier Berrocal, José García-Alonso, Cristina Vicente - Chicote,

ICWE’19

Calling a MC endpoint

16

Page 56: Architectural Styles for the Development of WoT Applicationsweb.geni-pco.com/icwe2019/tutorial4.pdf · 2019. 6. 12. · Javier Berrocal, José García-Alonso, Cristina Vicente - Chicote,

ICWE’19

Calling a MC endpoint• Steps:

– Before calling the endpoint, we need two important data.• Token: provided by the installed app• Authorization: obtained from the Firebase Console

Page 57: Architectural Styles for the Development of WoT Applicationsweb.geni-pco.com/icwe2019/tutorial4.pdf · 2019. 6. 12. · Javier Berrocal, José García-Alonso, Cristina Vicente - Chicote,

ICWE’19

Calling a MC endpoint• Steps:

– (Option 1) using Postman:• Url: https://fcm.googleapis.com/fcm/send• Headers:

– Content-Type: application/json– Authorization: key=<obtained in the previous slide>

• Body:

Page 58: Architectural Styles for the Development of WoT Applicationsweb.geni-pco.com/icwe2019/tutorial4.pdf · 2019. 6. 12. · Javier Berrocal, José García-Alonso, Cristina Vicente - Chicote,

ICWE’19

Calling a MC endpoint• Steps:

– (Option 2) Generate a HTML client to call the MC API’sendpoints:https://openapi-generator-spilab.herokuapp.com/swagger-ui.html

Page 59: Architectural Styles for the Development of WoT Applicationsweb.geni-pco.com/icwe2019/tutorial4.pdf · 2019. 6. 12. · Javier Berrocal, José García-Alonso, Cristina Vicente - Chicote,

ICWE’19

Calling a MC endpoint• Steps:

– (Option 2) Use the generated client :• Provide the toke, Authorization key and the endpoint parameteres.

Page 60: Architectural Styles for the Development of WoT Applicationsweb.geni-pco.com/icwe2019/tutorial4.pdf · 2019. 6. 12. · Javier Berrocal, José García-Alonso, Cristina Vicente - Chicote,

ICWE’19

A favor

21

https://forms.gle/Ko8DH8grZNhL9eU49

Page 61: Architectural Styles for the Development of WoT Applicationsweb.geni-pco.com/icwe2019/tutorial4.pdf · 2019. 6. 12. · Javier Berrocal, José García-Alonso, Cristina Vicente - Chicote,

ICWE’19 22

¡Muchas gracias a todos!

THANK YOU!