COPYRIGHT © 2012 ALCATEL-LUCENT. ALL RIGHTS RESERVED. Jose Javier Garcia Aranda

Slides:



Advertisements
Presentaciones similares
El mecanismo básico de interacción entre el usuario y un sitio web esta dado por el uso de formularios html. El server envía un formulario que el browser.
Advertisements

El uso de Internet con software libre y fuentes abiertas para colaborar en la toma de decisiones espaciales: la herramienta MapChat G. Brent Hall Michael.
Comunicación con el servidor, RPC GWT Google Web Toolkit Prof. Ing
ACCESO A BASES DE DATOS ORACLE CON PHP
GWT Designer, Organización del proyecto GWT Google Web Toolkit Prof
Ejercicios con listas.
Editing Slides With Polaris Office, you can create new .ppt and .pptx presentations or edit your presentation with ease.
1 1.Prepare and Install 1.1 You have to know before installation 1.2 Hardware Installation 2. How to use Bluetooth Printer Adapter’s Services 2.1 Connect.
saquen la tarea en la página 57, ejercicio 1 ejemplos 4 y 5
Taller 5: Trabajo con Plantillas y uso de tecnología Ajax.
PL/SQL Francisco Moreno Universidad Nacional.
JavaScript Programación Web. Java Script es un lenguaje de escripts que se usa en páginas web (ligero) Java es un lenguaje de programación orientada a.
©2014 by Vista Higher Learning, Inc. All rights reserved  Para hablar de actividades necesitamos usar verbos.  Los Verbos expresan: Acciones, o.
English Lesson 5.
Unidad 3 Lección 1 – El Futuro.  You have already learned how to refer to future events by using the formula – IR + a + infinitive Example Yo voy a reutilizarlo.
Node.JS Proyecto Redes de Computadores Sem
Future. Before learning to form the future it in English: I will speak. The future tense in English ALWAYS has the word “will” (or “shall”). It can be.
-go Verbs There is a small but very important group of verbs that we call the “-go” verbs. These verbs are: Hacer: to make/do Poner: to put Salir: to.
Srta. Forgue El 6 de mayo de  Elige la palabra que completa correctamente cada una de las oraciones. (Usa págs ) 1.__ representa al acusado.
Por y para You’ve probably noticed that there are two ways to express “ for ” in Spanish: Por Para In this slide show, we’ll look at how these two prepositions.
Los complementos directos Direct Object Pronouns.
IRREGULAR VERBS. Remember how regular verbs are formed? You drop the –ar, -er, or –ir and add the appropriate ending.
Department of Modern Languages. Gramática nueva El verbo ir = to go Its conjugation The verb ir is irregular not only in its yo form, but in all other.
Notes #18 Numbers 31 and higher Standard 1.2
Copyright © 2008 Vista Higher Learning. All rights reserved  In Spanish, the command forms are used to give orders or advice. You use tú commands.
The Present Subjunctive The Subjunctive l Up to now you have been using verbs in the indicative mood, which is used to talk about facts or actual events.
Informatic Topics M. Sc. Juan Carlos Olivares Rojas February, 2009.
Sistemas de Información Agosto-Diciembre 2007 Sesión # 3.
What has to be done today? It can be done in any order. Make a new ALC form Do the ALC Get two popsicle sticks Get 16 feet of yarn. That is 4 arms width.
Eng. Ivan E. Juárez. Preliminary Activity The different kind of tools that we will use during this course require to use a gmail account, even if you.
Desarrollo de aplicaciones empresariales con Web Services
Servlets Servlets son módulos que extienden a servidores orientados a request/response, como por ejemplo Servidores Web “java-enabled”. Un servlet puede.
First Grade – High Frequency Word Reading Competition Classroom Competition Created by: Malene Golding School Improvement Officer: Kimberly Fonteno.
Nombre de equipo: abaddon Camilo ramos rojas Grupo :6 Pista # 2 Traductor y motor de búsqueda : google Miércoles 1 de septiembre 2010 Pagina de respuesta.
Mi dormitorio My bedroom
Los infinitivos (Infinitives) ¿Qué es un infinitivo? What is an infinitive?
Digital Photography: Selfie Slides Your Name Date Class Period.
Digital Photography: Selfie Slides By: Essence L. Thomas.
¿Qué haces en la escuela? Question words, objects, yo-go’s.
Indirect Object Pronouns
Formal Commands! Telling people what to do…… You speak, or you are speaking……Hablas, estás hablando This is different from telling (commanding) someone.
Tecnología y Estructura de Costos. Technologies u A technology is a process by which inputs are converted to an output. u E.g. labor, a computer, a projector,
Digital Photography: Selfie Slides Your Name Date Class Period.
IR, Professions, Question Words. VoyVamos VasVais VaVan.
Digital Photography: Selfie Slides Anaiyah holiday 10/23/2014 6th.
Formal Commands! Ten-Hut! In this presentation, you will learn about making commands in Spanish.
BARTERING. What is Bartering? Bartering is negotiating a lower price between a buyer and a seller of a good or service Bartering is negotiating a lower.
Copyright © 2008 Vista Higher Learning. All rights reserved  The conditional tense in Spanish expresses what you would do or what would happen under.
Expresiones Lección 1 Presentaciones con el verbo “llamarse”
Objetivo: to identify phrases that express someone must do something. Ahora: List 3 adverbs and where are they placed in a sentence.
JUEVES, EL 10 DE SEPTIEMBRE LT: I WILL RECOGNIZE SOME NEW VOCABULARY WORDS. Go over tests & retake procedures Interpretive Assessment: numbers & alphabet.
-go Verbs There is a small but very important group of verbs that we call the “-go” verbs. These verbs are: Conocer : to know (people) Hacer: to make/do.
Hacer Ahora. Usa saber o conocer para completar las oraciones.
USE OF SUBJUNCTIVE & INDICATIVE IN ADVERBIAL CLAUSES.
Essential ?: How do I use these irregular verbs? How are they different than the verbs I already know?
Indirect Object Pronouns Original PowerPoint was by Ms. Martin of Tri-Center Community Schools.
ECOM-6030 PASOS PARA LA INSTALACIÓN DE EASYPHP Prof. Nelliud D. Torres © - Derechos Reservados.
©2014 by Vista Higher Learning, Inc. All rights reserved You have learned that reflexive verbs indicate that the subject of a sentence does the action.
Un juego de adivinanzas: ¿Dónde está el tesoro? A1B1C1D1E1F1 A4B4C4D4E4F4 A2B2C2D2E2F2 A5B5C5D5E5F5 A3B3C3D3E3F3 A6B6C6D6E6F6 Inténtalo de nuevo Inténtalo.
¿New media? Lev Manovich It is responsible for one of the works of reference for the interpretation of the new media. “The language of new media (2001)”
Antes de empezar – ¿Cómo se llaman estos quehaceres? (Necesito la tarea.)
Essential question: How do I say what I like and what interests/bores me?
LOS VERBOS REFLEXIVOS. WRITE: What is a reflexive verb? A reflexive verb describes when a person doing an action is also receiving the action.
Forming Questions ¡Aprenda! Forming Questions By Patricia Carl October 2013.
Hoy es miércoles el dieciseis de septiembre. HAGAN AHORA: Contesta las preguntas 1.¿Cómo te llamas? 2.¿Cuántos años tienes? 3.¿Cuándo es tu cumpleaños?
Verbs like Gustar Notes/ Examples.
A + el = al de + el = del Capítulo 1A. To be pleasing to or To please Gustar I like your shoes! Your shoes are pleasing to me! I like to watch TV. To.
UNIVERSIDAD AUTÓNOMA DEL ESTADO DE HIDALGO ESCUELA SUPERIOR DE ZIMAPÁN Licenciatura en Derecho Logros y experiencias. Lengua extranjera. L.E.L.I. Paulina.
Fundamentals of Web Development - 2 nd Ed.Randy Connolly and Ricardo Hoar Fundamentals of Web DevelopmentRandy Connolly and Ricardo Hoar © 2017 Pearson.
Transcripción de la presentación:

COPYRIGHT © 2012 ALCATEL-LUCENT. ALL RIGHTS RESERVED. Jose Javier Garcia Aranda Marzo 2015 Desarrollo de aplicaciones big-data en la nube Deploying….please wait

COPYRIGHT © 2012 ALCATEL-LUCENT. ALL RIGHTS RESERVED. Agenda 1| Introduction to cloud and Big Data 2| S3 and SimpleDB 3| Users and Roles 4| programming languages 5| python on aws 6| javascript client on aws 7| nodejs on aws 8| JSON and simpleDB 9| debugging Logs & CORS 1| Introduction to AWS

COPYRIGHT © 2012 ALCATEL-LUCENT. ALL RIGHTS RESERVED. Tipos de nubes : IAAS y PAAS Voy a crear las maquinas, instalar el sistema operativo, instalaré y configuraré una base de datos, un servidor web, un motor de paginas JSP, un balanceador de carga, conectaré discos a mis maquinas, vigilaré la carga para crear nuevas maquinas….y subiré mis programas Voy a subir mi programa Hello world My name is PaaS IAAS =cloud for freaks? PAAS= cloud for doomies?

COPYRIGHT © 2012 ALCATEL-LUCENT. ALL RIGHTS RESERVED. Tipos de nubes IaaS vs PaaS IaaS: "The cloud" is based on the concept of "virtualization". This concept means many small computers can run within a larger computer and these small computers are called virtual machines. The program which manages this and makes it indistinguishable for us a virtual one physical computer is what is called hypervisor. This model is often called "IaaS" (infrastructure as a service. Such is the case of "Amazon Elastic Compute Cloud" known by its acronym EC2). Today Amazon also offers a PaaS model called “elastic Beanstalk”. PaaS: There is a form of virtualization that is just the opposite: many computers “appear” as a single, more powerful. In this case we speak of PaaS (Examples of PaaS are amazon beanstalk, Microsoft "Azure" or Google "Engine").

COPYRIGHT © 2012 ALCATEL-LUCENT. ALL RIGHTS RESERVED. Qué es Big Data y cuales son las nubes Las aplicaciones que se enfrentan con un gran volumen de datos tienen que hacer frente a diferentes capas para abordar el problema Google EngineAmazon Web Services Azure NoSQLBigTablesimpleDB, dynamoDB “tables” service ficherosDocumentDBS3Blob Service MapReduce ElasticMapRed uce HDinsight La BBDD ya no hay que instalarla. Es un “servicio”. Lo usamos y nos cobran por las transacciones o el espacio usado. Eliminamos complejidad

COPYRIGHT © 2012 ALCATEL-LUCENT. ALL RIGHTS RESERVED.NO-SQL No join ( join inviable por RAM) veces mas rápido escalable

COPYRIGHT © 2012 ALCATEL-LUCENT. ALL RIGHTS RESERVED. Map Reduce Cuando necesitamos hacer join y no podemos Hay que programar “mappers” y “reducers” Por ejemplo, en un caso de contar todas las palabras de una colección de documentos, cada nodo map recibiría un paquete de documentos, y daría como salida la lista de palabras encontradas y la frecuencia de las mismas. Reduce: El nodo maestro colecciona todas las respuestas recibidas y las combina para generar la salida, es decir, la respuesta al problema que originalmente se trata de resolver. En el ejemplo del recuento de palabras, las palabras y sus frecuencias son enviadas a nodos reduce que realizan el recuento. Una misma palabra puede venir de varios nodos map y debe ir al mismo nodo reduce.

COPYRIGHT © 2012 ALCATEL-LUCENT. ALL RIGHTS RESERVED. Clustering en big data: EVALUATED METHODS DBSCANDensity (not suitable)Nlogn (scales) BIRCH, ROCK, CURE, CHAMELEON Hierarquical (suitable) N (not scales) KMEANSPartitions (suitable)N (scales) Creation of “clusters” of users based on their preferences ( used keywords on their inventory of files and services) 2

COPYRIGHT © 2012 ALCATEL-LUCENT. ALL RIGHTS RESERVED. 9

Agenda 1| Introduction to cloud and Big Data 2| S3 and SimpleDB 3| Users and Roles 4| programming languages 5| python on aws 6| javascript client on aws 7| nodejs on aws 8| JSON and simpleDB 9| debugging Logs & CORS 1| Introduction to AWS

COPYRIGHT © 2012 ALCATEL-LUCENT. ALL RIGHTS RESERVED. overview of main tools STS (security token service) Nodeclipse plugin

COPYRIGHT © 2012 ALCATEL-LUCENT. ALL RIGHTS RESERVED. 12 Environment and aplication( I)

COPYRIGHT © 2012 ALCATEL-LUCENT. ALL RIGHTS RESERVED. 13 Environment and aplication( II) 1 aplicación = N environments 1 environment = 1 programming language= 1 virtual instance type Environments don’t share machines python nodejs one application

COPYRIGHT © 2012 ALCATEL-LUCENT. ALL RIGHTS RESERVED. 14 Environment platforms: language and instance type Nodejs & python are the best in terms of performance An smaller type of instance is cheaper but this strategy force to instance more machines if incoming traffic grows. So, if there is success, perhaps it is not the cheapest strategy

COPYRIGHT © 2012 ALCATEL-LUCENT. ALL RIGHTS RESERVED. 15 EBS: elastic block store SSD (estado solido) 1TB de almacenamiento 3000 IOPS (si necesitas mas debes pagar por usar “volúmenes de IOPS” Tipos de instancias disponibles

COPYRIGHT © 2012 ALCATEL-LUCENT. ALL RIGHTS RESERVED. 16instances Click on EC2 pto see all your instances Instances of the same application. Ordered by environment. For each environment we can have N instances One instance can not belong to more than one environment

COPYRIGHT © 2012 ALCATEL-LUCENT. ALL RIGHTS RESERVED. 17 Uploading software: version control ZIP with sources

COPYRIGHT © 2012 ALCATEL-LUCENT. ALL RIGHTS RESERVED. 18costs 750 hours free per month ( it means one machine). The rest of machines are paid per hours. The same for load balancers. Load balancers looks expensive but there are only one per environment Factura mes de marzo 2014

COPYRIGHT © 2012 ALCATEL-LUCENT. ALL RIGHTS RESERVED. 19 Costs (II): designing applications Incoming traffic to S3 from internet is free Outgoing traffic from Services to S3 is not free (free only first 15GB) Server processing is not free (only 750h) therefore is a good option to move processing to client side Design is constrained by costs. A more efficient design usually is also cheaper EXAMPLE: 5 instances, 5 load balancers, 10 GB/month incoming traffic and 10GB outgoing traffic. Almost all cost are related to instances, but only around 150€

COPYRIGHT © 2012 ALCATEL-LUCENT. ALL RIGHTS RESERVED. 20 Elasticity triggers At the end of development you will determine your thresholds by means of load tests. Depends on type of requests, type of processing, languages, database read/writes, etc And of course: INSTANCE TYPE

COPYRIGHT © 2012 ALCATEL-LUCENT. ALL RIGHTS RESERVED. 21 Load Tests: elasticity triggers Evita el “pagging”: cuando empiece, la latencia subirá dramáticamente Ojo con las 3000 IOPS del default EBS!!!! Si las alcanzas puede que provoques el límite Es mala práctica escribir a disco ( no es lo mismo que escribir en bbdd)

COPYRIGHT © 2012 ALCATEL-LUCENT. ALL RIGHTS RESERVED. 22 Agenda 1| Introduction to cloud and Big Data 2| S3 and SimpleDB 3| Users and Roles 4| programming languages 5| python on aws 6| javascript client on aws 7| nodejs on aws 8| JSON and simpleDB 9| debugging Logs & CORS 1| Introduction to AWS

COPYRIGHT © 2012 ALCATEL-LUCENT. ALL RIGHTS RESERVED. 23 S3: almacenamiento masivo Massive storage, extremely cheap Organized in “buckets”. A directory is a “bucket” inside other “bucket” You can create infinite buckets Click on S3 to see all your buckets and edit permissions, etc

COPYRIGHT © 2012 ALCATEL-LUCENT. ALL RIGHTS RESERVED. 24 To upload a file or object to S3 you must use an HTTP interface amazon libraries simplifies the process, then you use functions instead HTTP requests to use it from a program you must have user’s credentials or role’s credentials S3: almacenamiento masivo

COPYRIGHT © 2012 ALCATEL-LUCENT. ALL RIGHTS RESERVED. 25 SimpleDB: base de datos NoSQL noSQL database for massive estorage. Extremely cheap Schema less: create domain without fields, then at object insertion, specifies the fields Tables are called “domains” No human interface. But SimpleDB plugin for firefox. You can create domains using : Manually using a python window or a server side program created by yourself

COPYRIGHT © 2012 ALCATEL-LUCENT. ALL RIGHTS RESERVED. 26 SimpleDB: SDBTool plugin results

COPYRIGHT © 2012 ALCATEL-LUCENT. ALL RIGHTS RESERVED. 27 Import boto Import boto.sdb sdb=boto.sdb.connect_to_region('eu-west-1', aws_access_key_id='AKIAJDXPT5WBCIN6IRJQ', aws_secret_access_key='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') my_domain=sdb.create_domain("hola") domains = sdb.get_all_domains() domains My_domain = sdb.get_domain('hola') item_name = 'un_item' item_attrs = {'Artist': 'The Jackson 5', 'Genera':'Pop'} my_domain.put_attributes(item_name, item_attrs) item_name = 'otro_item' item_attrs = {'Artist': 'julio iglesias', 'Genera':'Pop'} my_domain.put_attributes(item_name, item_attrs) my_domain.get_item('un_item') sdb.get_attributes(my_domain,'un_item',attribute_names='Artist') query = 'select * from hola where Genera="Pop"' rs = my_domain.select(query) for j in rs: print j.name + "tiene como autor:" + j['Artist'] sdb.delete_domain("hola") SimpleDB: py example Conecta y lista los dominios Inserta dos items Lee un item individual usando dos formas diferentes Hace una query basada en un campo e imprime los resultados Borra el dominio Usar linea de comando python, desde nuestro PC en una ventana command Importa la librería boto de amazon para python

COPYRIGHT © 2012 ALCATEL-LUCENT. ALL RIGHTS RESERVED. 28 Agenda 1| Introduction to cloud and Big Data 2| S3 and SimpleDB 3| Users and Roles 4| programming languages 5| python on aws 6| javascript client on aws 7| nodejs on aws 8| JSON and simpleDB 9| debugging Logs & CORS 1| Introduction to AWS

COPYRIGHT © 2012 ALCATEL-LUCENT. ALL RIGHTS RESERVED. 29 Users and Roles amazon’s account credentials User’s credentials Role’s credentials STS (security token service)

COPYRIGHT © 2012 ALCATEL-LUCENT. ALL RIGHTS RESERVED. 30 Creating amazon account credentials Secret Key id : it is like a login Secret Access key: it is like a password Users and Roles

COPYRIGHT © 2012 ALCATEL-LUCENT. ALL RIGHTS RESERVED. 31 Users and roles are created separately A user can asume a role And then, user can generate temporal credentials of certain role, using STS (Security Token Service) of AWS Users and Roles

COPYRIGHT © 2012 ALCATEL-LUCENT. ALL RIGHTS RESERVED. 32 Temporal credentials are useful to access amazon resources (like S3 ) directly from a browser instead from a server-side Without valid credentials, S3 reject requests Creating temporal credentials in node.js import boto from boto.sts import STSConnection def pedirToken(): sts_connection = boto.sts.connect_to_region('eu-west- 1',aws_access_key_id='AKIAJMSM5FKHYGHQOHDQ',aws_secre t_access_key='jvh9AMEsOuSpa3RQzCLb8QFBzlBsfbFQWOmpc 3i6') assumedRoleObject = sts_connection.assume_role(role_arn="arn:aws:iam:: :role/mmsclient",role_session_name="AssumeRoleSes sion1",duration_seconds=900) return assumedRoleObject Creating temporal credentials in python Role’s credencials MUST include: AccessKey, SecretAccessKey and SessionToken. Without sessionToken you can not connect Users and Roles

COPYRIGHT © 2012 ALCATEL-LUCENT. ALL RIGHTS RESERVED. 33 Agenda 1| Introduction to cloud and Big Data 2| S3 and SimpleDB 3| Users and Roles 4| programming languages 5| python on aws 6| javascript client on aws 7| nodejs on aws 8| JSON and simpleDB 9| debugging Logs & CORS 1| Introduction to AWS

COPYRIGHT © 2012 ALCATEL-LUCENT. ALL RIGHTS RESERVED. 34 Node has a monothread execution model, which allow more concurrency that nother lenguages because ( among other reasons) a lower use of RAM Python and node offers a similar performance. Python is multithread but is comparable with node Jetty and Resin are java engines, with similar performance than node or python but amazon uses tomcatlanguages

COPYRIGHT © 2012 ALCATEL-LUCENT. ALL RIGHTS RESERVED. 35languages Requirements.txt Package.json Declare dependencies And at client side you can use javascript Root file import aws library

COPYRIGHT © 2012 ALCATEL-LUCENT. ALL RIGHTS RESERVED. 36languages Service X Logic in Python, nodejs, java, etc Service X Logic in Python, nodejs, java, etc Respnses in JSON format Request from browser Request from javascript light client HTML+JS and/or Jquery Service X hello Service X hello Good practices: do not mix HTML neither javascript in server responses. Templates engine is only useful for initial client aplication download

COPYRIGHT © 2012 ALCATEL-LUCENT. ALL RIGHTS RESERVED. 37 Agenda 1| Introduction to cloud and Big Data 2| S3 and SimpleDB 3| Users and Roles 4| programming languages 5| python on aws 6| javascript client on aws 7| nodejs on aws 8| JSON and simpleDB 9| debugging Logs & CORS 1| Introduction to AWS

COPYRIGHT © 2012 ALCATEL-LUCENT. ALL RIGHTS RESERVED Python on aws

COPYRIGHT © 2012 ALCATEL-LUCENT. ALL RIGHTS RESERVED. 39 Python on aws Install python (it has editor) Install boto library Install a framework : Django o Flask ( both compatible with aws) Develop locally. If you are behind firewall in intranet, perhaps you must upload services before test ( otherwise S3 or simpleDB connections could fail) Application.py DIR A DIR B fichero1.py fichero2.py __init__.py To upload software to amazon you must build a ZIP file with the complete application Requirements.txt URL (URL routing) fichero3.py __init__.py

COPYRIGHT © 2012 ALCATEL-LUCENT. ALL RIGHTS RESERVED. 40 Server code Client code Server code YOUR COMPUTER deploy Express server Listening on :3000 Testing locally, and then deploy

COPYRIGHT © 2012 ALCATEL-LUCENT. ALL RIGHTS RESERVED. 41 Python on aws Application.py otrofile.py Hello world! 2 routes

COPYRIGHT © 2012 ALCATEL-LUCENT. ALL RIGHTS RESERVED. 42 Python on aws This example uses boto to access simpleDB and all is included in one file (application.py) Conectar siempre usando región europa Credenciales de cuenta amazon o bien credenciales de un usuario creado desde la cuenta amazon Inicializa variables o error 500

COPYRIGHT © 2012 ALCATEL-LUCENT. ALL RIGHTS RESERVED. 43 Python on aws Ejecutado en local. Si no hay cortafuegos, python se conectará a simpledb desde nuestro PC Ejecutado en amazon. Siempre va a funcionar y no hay conexión a simpledb desde nuestro PC flask escucha en el 5000 por defecto

COPYRIGHT © 2012 ALCATEL-LUCENT. ALL RIGHTS RESERVED. 44 Python on aws This example create a temporal credentials using STS (Security Token Service) Credenciales de un usuario creado desde la cuenta amazon. La credenciales de cuenta amazon en este caso no valen, solo un usuario puede asumir un rol Asumes the role “mmsclient” Le pasa las credenciales al motor de templates

COPYRIGHT © 2012 ALCATEL-LUCENT. ALL RIGHTS RESERVED. 45 Agenda 1| Introduction to cloud and Big Data 2| S3 and SimpleDB 3| Users and Roles 4| programming languages 5| python on aws 6| javascript client on aws 7| nodejs on aws 8| JSON and simpleDB 9| debugging Logs & CORS 1| Introduction to AWS

COPYRIGHT © 2012 ALCATEL-LUCENT. ALL RIGHTS RESERVED. 46 Javascript on aws Esta es la continuación del ejemplo anterior. Ahora vemos el lado cliente javascript

COPYRIGHT © 2012 ALCATEL-LUCENT. ALL RIGHTS RESERVED. 47 Javascript con aws Usa las tres componentes de las credenciales temporales. El token es necesario Instanciamos un objeto bucket usando la librería AWS que nos conecta a S3 Cargamos la librería aws-sdk These symbols “{{“ is interpreted by template engine and replace these variables by their values

COPYRIGHT © 2012 ALCATEL-LUCENT. ALL RIGHTS RESERVED. 48 Agenda 1| Introduction to cloud and Big Data 2| S3 and SimpleDB 3| Users and Roles 4| programming languages 5| python on aws 6| javascript client on aws 7| nodejs on aws 8| JSON and simpleDB 9| debugging Logs & CORS 1| Introduction to AWS

COPYRIGHT © 2012 ALCATEL-LUCENT. ALL RIGHTS RESERVED Nodejs on aws Es la misma documentacion tanto en javascript cliente como en nodejs. Solo cambia la forma de instalar

COPYRIGHT © 2012 ALCATEL-LUCENT. ALL RIGHTS RESERVED. 50 Nodejs on aws Install node Install a framework : express (includes templates engine “jade”) Install editor: nodeclipse. Develop and test locally (executing app.js). If you are behind intranet firewall perhaps you must upload to amazon before test URL App.js DIR A DIR B fichero1.js fichero2.js Package.json (URL routing) fichero3.js Install aws-sdk using npm. 3 execute package json to Install aws-sdk. and express 3 To upload to amazon you must create a ZIP including all files

COPYRIGHT © 2012 ALCATEL-LUCENT. ALL RIGHTS RESERVED. 51 Package.json Same functionality as requirements.txt of python Nodejs on aws Do not execute before adding this line Usando nodeclipse App.js: includes the mapping between URLs and functions included in other files.js

COPYRIGHT © 2012 ALCATEL-LUCENT. ALL RIGHTS RESERVED. 52 Express escucha en el puerto 3000 Nodejs on aws

COPYRIGHT © 2012 ALCATEL-LUCENT. ALL RIGHTS RESERVED. 53 Nodejs on aws Variables son referencias a ficheros Mapeo de Urls a funciones de esos ficheros Fichero App.js

COPYRIGHT © 2012 ALCATEL-LUCENT. ALL RIGHTS RESERVED. 54 Fichero PruebaS3.js Nodejs on aws In this case you can use amazon account’s credentials instead temporal credentials because this credentials are not sent to browser. This is server-side Blocking function! Client awaits for callback invocation

COPYRIGHT © 2012 ALCATEL-LUCENT. ALL RIGHTS RESERVED. 55 Fichero token.js Nodejs con aws

COPYRIGHT © 2012 ALCATEL-LUCENT. ALL RIGHTS RESERVED. 56 Node js y simpledb Variables POST This example insert a new item into table “playlist and then list by console all stored elements User_id url keywords No blocking function. Client does not wait for callback invocation Nombre del campovalor del campo

COPYRIGHT © 2012 ALCATEL-LUCENT. ALL RIGHTS RESERVED. 57 blocking. Esta vez el cliente espera a que la función callback sea invocada Hemos comentado la respuesta y ahora contestamos desde dentro Nodejs con aws

COPYRIGHT © 2012 ALCATEL-LUCENT. ALL RIGHTS RESERVED. 58 BLOQUEANTE vs no bloqueante Tío, no bloqueante te da mas concurrencia, pero haz lo que quieras

COPYRIGHT © 2012 ALCATEL-LUCENT. ALL RIGHTS RESERVED. 59 Agenda 1| Introduction to cloud and Big Data 2| S3 and SimpleDB 3| Users and Roles 4| programming languages 5| python on aws 6| javascript client on aws 7| nodejs on aws 8| JSON and simpleDB 9| debugging Logs & CORS 1| Introduction to AWS

COPYRIGHT © 2012 ALCATEL-LUCENT. ALL RIGHTS RESERVED. 60 JSON y simpleDB Concepto JSON JSON son strings, siempre. Y a partir de estos strings se pueden construir objetos javascript y viceversa. Pero NO son lo mismo. Un objeto no es un string simpleDB y JSON JSON son strings y por tanto podemos hacer queries de tipo “select campo1 from tabla where campo2 like ‘valor%’ de este modo podemos encontrar tuplas bajo el criterio de que un atributo de un objeto que se almacena en campo1 tenga cierto valor Supongamos que recibimos unos campos por POST y queremos unirlos en un objeto que almacenaremos en base de datos. Recogemos los datos que llegan por post usando req.body. var input_keywords=req.body.keywords; input_keywords=input_keywords.toUpperCase(); var split_keywords= input_keywords.split(","); var keywords=JSON.stringify(split_keywords); Ahora keywords es : ["MUSICA"," CINE"," OCIO"] lo cual está en formato JSON, listo para ser almacenado. Al leerlo invocaremos a JSON.parse( cadena) y asi podremos acceder los 3 valores en forma de objeto array Mi objeto[0] tomará el valor “MUSICA”

COPYRIGHT © 2012 ALCATEL-LUCENT. ALL RIGHTS RESERVED. 61 JSON y simpleDB Creamos una tupla en la que el valor del campo keywords es un string en formato JSON, convertible a objeto Ahora consultamos la tabla e imprimimos Insertamos la tupla

COPYRIGHT © 2012 ALCATEL-LUCENT. ALL RIGHTS RESERVED. 62 JSON y simpleDB usamos JSON.parse para convertir la cadena en objeto

COPYRIGHT © 2012 ALCATEL-LUCENT. ALL RIGHTS RESERVED. 63 Supongamos que queremos almacenar un perfil de usuario como una lista de palabras con pesos. El formato JSON es Keywords = [ { “key”: “música”, “peso”: 5}, {“key”: “deportes”, “peso”: 7} ] Para acceder, construiremos un objeto asi: var keywords=JSON.parse(keywords);. Y luego accedemos a keywords[0].key, o a keywords[0].peso Si lo que tenemos es una lista de palabras sin pesos: Keywords = [ { “key”: “música” }, {“key”: “deportes” } ] como solo hay un campo, pues podemos eliminar dicho campo y asi queda: Keywords = [ “música”, “deportes” ] Y asi accedermos a los valores como elementos de un array Claves= JSON.parse(keywords) Claves[0] es musica Otros ejemplos sencillos de uso de JSON JSON y simpleDB

COPYRIGHT © 2012 ALCATEL-LUCENT. ALL RIGHTS RESERVED. 64 Agenda 1| Introduction to cloud and Big Data 2| S3 and SimpleDB 3| Users and Roles 4| programming languages 5| python on aws 6| javascript client on aws 7| nodejs on aws 8| JSON and simpleDB 9| debugging Logs & CORS 1| Introduction to AWS

COPYRIGHT © 2012 ALCATEL-LUCENT. ALL RIGHTS RESERVED. 65logs

COPYRIGHT © 2012 ALCATEL-LUCENT. ALL RIGHTS RESERVED. 66logs Console.log (“ this is a message readable only checking logs”)

COPYRIGHT © 2012 ALCATEL-LUCENT. ALL RIGHTS RESERVED. 67 CORS: Cross Origin Resource Sharing

COPYRIGHT © 2012 ALCATEL-LUCENT. ALL RIGHTS RESERVED. 68 CORS: Cross Origin Resource Sharing Cuando desarrollamos con amazon, si queremos hacer pruebas en local sin subir nuestro código a amazon, puede que hagamos una pagina web en html+javascript que invoque a amazon y dicha pagina la estamos tomando de nuestro disco duro. Su origen es nuestro disco duro. Si dicha pagina de forma autónoma (AJAX) hace peticiones a amazon, estas fallarán, porque el browser detectará que la pagina está haciendo peticiones fuera de su dominio origen sin nuestro consentimiento explicito.

COPYRIGHT © 2012 ALCATEL-LUCENT. ALL RIGHTS RESERVED. 69 CORS: solution while developing

COPYRIGHT © 2012 ALCATEL-LUCENT. ALL RIGHTS RESERVED. 70 Para permitir que se pueda acceder a S3 desde otro origen que los servicios que corren en amazon, debemos tocar el fichero CORS CORS: más autorizaciones

All Rights Reserved © Alcatel-Lucent 2010 Ya he terminado!!! Despertad!

All Rights Reserved © Alcatel-Lucent | Open API Enriched Communication | September diferencias entre IAAS y PAAS 2.que permisos darías a una aplicacion cliente? rol o usuario? por que? 3.que ventaja tiene usar llamadas no bloqueantes a los servicios? 4.describe el problema que genera CORS al programador 5.que trigger de elasticidad es el más importante? por que?