Lab Exercise 2 (Lab Sessions 2, 3, and 4)

Slides:



Advertisements
Similar presentations
Reinventing using REST. Anything addressable by a URI is called a resource GET, PUT, POST, DELETE WebDAV (MOVE, LOCK)
Advertisements

Interprocess Communication CH4. HW: Reading messages: User Agent (the user’s mail reading program) is either a client of the local file server or a client.
Implementing A Simple Storage Case Consider a simple case for distributed storage – I want to back up files from machine A on machine B Avoids many tricky.
Lab Exercise 2 (Sessions 2, 3, and 4) The Joy of Programming on the Web.
The Basic Authentication Scheme of HTTP. Access Restriction Sometimes, we want to restrict access to certain Web pages to certain users A user is identified.
Distributed Object & Remote Invocation Vidya Satyanarayanan.
Copyright 2004 Monash University IMS5401 Web-based Systems Development Topic 2: Elements of the Web (g) Interactivity.
CS 582 / CMPE 481 Distributed Systems Fault Tolerance.
A CHAT CLIENT-SERVER MODULE IN JAVA BY MAHTAB M HUSSAIN MAYANK MOHAN ISE 582 FALL 2003 PROJECT.
Erlang concurrency. Where were we? Finished talking about sequential Erlang Left with two questions  retry – not an issue; I mis-read the statement in.
Distributed Systems Fall 2009 Replication Fall 20095DV0203 Outline Group communication Fault-tolerant services –Passive and active replication Highly.
Implementing Application Protocols. Overview An application protocol facilitates communication between applications. For example, an client uses.
Service Broker Lesson 11. Skills Matrix Service Broker Service Broker, provides a solution to common problems with message delivery and consistency that.
Asynchronous Web Services Approach Enrique de Andrés Saiz.
Web Security Programming I Building Security in from the Start Except where otherwise noted all portions of this work are Copyright (c) 2007 Google and.
Rensselaer Polytechnic Institute Shivkumar Kalvanaraman, Biplab Sikdar 1 The Web: the http protocol http: hypertext transfer protocol Web’s application.
Extending Vista The PowerLinks WebServices SDK John Hallett Senior Product Manager WebCT, Inc
Data Synchronization Dani Beaubien
Dodick Zulaimi Sudirman Lecture 14 Introduction to Web Service Pengantar Teknologi Internet Introduction to Internet Technology.
Lab Exercise 2 (Sessions 2, 3, and 4) The Joy of Programming on the Web.
Google App Engine MemCache ae-09-session
V1.7Fault Tolerance1. V1.7Fault Tolerance2 A characteristic of Distributed Systems is that they are tolerant of partial failures within the distributed.
Building Dependable Distributed Systems, Copyright Wenbing Zhao
Lecture 4 Mechanisms & Kernel for NOSs. Mechanisms for Network Operating Systems  Network operating systems provide three basic mechanisms that support.
Highly available, Fault tolerant Co-scheduling System With working implementation.
Mutual Exclusion Algorithms. Topics r Defining mutual exclusion r A centralized approach r A distributed approach r An approach assuming an organization.
COMP2322 Lab 4 Socket Programming Toby Lam March 2, 2016.
27.1 Chapter 27 WWW and HTTP Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Distributed Computing & Embedded Systems Chapter 4: Remote Method Invocation Dr. Umair Ali Khan.
WELCOME COACHES to the PARK VALLEY UNITED FUTBOL CLUB.
Object Interaction: RMI and RPC 1. Overview 2 Distributed applications programming - distributed objects model - RMI, invocation semantics - RPC Products.
EEC 688/788 Secure and Dependable Computing Lecture 10 Wenbing Zhao Department of Electrical and Computer Engineering Cleveland State University
The Echo Server Problem. Contents  Basic Networking Concepts  The Echo Server Problem.
COMP2322 Lab 4 Socket Programming
SE-1021 Software Engineering II
Cloud Computing Web Services.
WWW and HTTP King Fahd University of Petroleum & Minerals
03 – Remote invoaction Request-reply RPC RMI Coulouris 5
Computing with C# and the .NET Framework
Cross-Site Forgery
Client / Session Identification Cookies
Chapter 6: Transport Layer (Part I)
Web Caching? Web Caching:.
Introduction to Networking
Whether you decide to use hidden frames or XMLHttp, there are several things you'll need to consider when building an Ajax application. Expanding the role.
Internet Networking recitation #12
CGS 2100 Lab sections 0029, 0031, 0035, 0045, /9/18.
Client-Server Interaction
Fault Tolerance - Transactions
WEB API.
Distributed Systems - Comp 655
Fault Tolerance - Transactions
AJAX Robin Burke ECT 360.
Outline Announcements Fault Tolerance.
Process-to-Process Delivery:
Fault Tolerance - Transactions
Architecture Competency Group
EEC 688/788 Secure and Dependable Computing
HyperText Transfer Protocol
Chinese wall model in the internet Environment
Fault Tolerance - Transactions
An Introduction to Internetworking
NETWORK PROGRAMMING CNET 441
EEC 688/788 Secure and Dependable Computing
EEC 688/788 Secure and Dependable Computing
Lecture 7: RPC (exercises/questions)
PHP-II.
Error Checking continued
Exceptions and networking
Fault Tolerance - Transactions
Presentation transcript:

Lab Exercise 2 (Lab Sessions 2, 3, and 4) The Joy of Programming on the Web

Objective Slot Reserved By 1 Free 2 Dean 3 ... Slot Reserved By 1 Free Write a client that reserves the earliest matching slots for the band and the hotel You will compete for slots with your fellow students Provides a reservation service on the Web Hotel Band Slot Reserved By 1 Free 2 Dean 3 ... Slot Reserved By 1 Free 2 Dean 3 ...

Reservation Service Provides you with a simple service: Check availability Reserve a slot Cancel a reservation Check your bookings However, we are going to make your life interesting Appreciate the “fun” in building distributed applications

Couple 1 Availability request identifier: 1 username: couple_1 password: couple_1_password

Couple 2 Availability request identifier: 1 username: couple_2 password: couple_2_password

Couple 3 Availability request identifier: 1 username: couple_3 password: couple_3_password

Couple 3 Availability msg id: msg_id_100

Couple 2 Service Unavailable The network and the server are un-reliable

Couple 1 Availability msg id: msg_id_104

It is your responsibility to generate unique message IDs Messages can be delivered in any order Service may be unavailable when messages arrive

Couple 3 Get Message message_id: msg_id_100 username: couple_3 password: couple_3_password

Couple 1 Get Message message_id: msg_id_104 username: couple_1 password: couple_1_password

Couple 1 Message: msg_id_104 Slots: 1, 3, 5, ...

Or Service unavailable Couple 3 Get Message Message not available Or Service unavailable

Couple 3 Retries Get Message: msg_id_100 Slots: 1, 3, 5, ...

Requests may not be ready when you retrieve your messages Server introduces arbitrary delays when processing messages

Couple 3 Reserve request_id = 2 ........... Slot_id: 3 Reserve msg_id:

Couple 1 Reserve request_id = 2 ........... Slot_id: 3 Reserve msg_id:

Easy to achieve at most once semantic Requests with the same <request_id, username, password> will get the same message identifier Easy to achieve at most once semantic Keep on sending until you get a message id back.

Couple 3 Get Message msg_id: msg_id_203 ......... Reserve Reserved slot 3

Couple 1 Get Message msg_id: msg_id_403 ......... Reserve Reservation failed

Data is ALWAYS potentially out-of-date Couple 1 thought slot 3 was available but .... Same as trying to organise a meeting via SMS

More Fun and Games User sends “reserve slot 3”, “cancel slot 3” and “reserve slot 1” One possible outcome Slot 3 is reserved; Reservation for slot 3 is cancelled; Slot 1 is reserved Another possibility Cancel of slot 3 fails; Slot 3 is reserved; Reservation for slot 1 fails as you have exceeded the max number of reservations

Messages from the same client can be processed in any order To enforce sequential execution Send a request, get the result of the request before sending the next But this is inefficient especially if the network and server are slow

Request to Service Reserve Cancel Availability List of slots “free” when the message was processed Bookings List of slots reserved by you when the message was processed

Response from a Request Either Message identifier Use it to fetch the result from the request Or Service unavailable

Get Response Possible responses depend on the request Reserve OK or failed and reason Cancel Bookings and Availability List of slots

Summary Service randomly rejects some incoming messages Requests are then delayed for an arbitrary amount of time before they are processed Messages are processed in any order Availability information is potentially out of date

Implementation You are going to use HTTP and XML messages Write your client in the language of your choice Java, C#, C++, ... Set HTTP Header 'Content-Type' => 'application/xml' 'Accept' => 'application/xml'

For Java users We provide quite a lot of (legacy) code – see $COMP28112/ex2/java-client (but you don’t have to use it – you can write your own if you wish!) Read README.txt Look for code in package uk.ac.manchester.cs.comp28112.lab2 grep for TODO in code given!

XML to Reserve a Slot <reserve> <request_id> 1 </request_id> <username> dean </username> <password> deanpwd </password> <slot_id> 1 </slot_id> </reserve>

Response Http response code: 200 <msg_uri> http://jewel.cs.man.ac.uk:3010/queue/msg/15 </msg_uri> Http response code: 503 Service unavailable

HTTP Get http://jewel.cs.man.ac.uk:3010/queue/msg/3 1?username=dean&password=deanpwd Use of HTTP response codes 200 success retrieval of message 404 Message is not available 503 Service unavailable 401 Unauthorized

Reserve Responses Body <code> … </code> Use HTTP codes - see documentation <body> … </body> Provides additional information

Browser Interface http://jewel.cs.man.ac.uk:3010/queue http://jewel.cs.man.ac.uk:3010/booking http://jewel.cs.man.ac.uk:3010/queue/msg/31?usern ame=dean&password=deanpwd

Avoid Denial of Service! If your program loops making requests (without pausing) it becomes a denial of service attack – don’t do it! Everyone suffers You will lose marks! At least 1 second waiting time between anything sent to the server!

Session I (week commencing 19/2) Write a client to make a reservation, cancel a reservation, check for availability, check your reservations Deal with the possible “failures” that can occur

Session I - deadline assessment If programming in Java: 5 marks for showing that it works on time Other languages: also 5 marks and perhaps more slack but you need to ask and obtain it explicitly!

Session II Reserve Hotel & Band You need to reserve the matching slots for both the hotel and the band Hotel - http://jewel.cs.man.ac.uk:3010/queue Band - http://jewel.cs.man.ac.uk:3020/queue Maximum number of reservations you are allowed to hold Hotel and Band – 2 (no deadline/assessment)

Session III - deadline Reserve the Earliest Possible Time Slot (week commencing 19/3) I may block some slots and then release them during the lab sessions Important: your code should always assume that slot availability changes frequently and messages may be delayed and lost (the fact that your client works once doesn’t mean you should get full marks!)

Enjoy! Experience the difficulties (and the fun) in building distributed applications using the language of your choice There is no perfect solution Possible improvements (no marks) Make your client fault-tolerant (survive crashes) Use of threads Important (you may lose marks) Avoid denial of service attacks No code anywhere on the web Keep your username/password safe and do not publicize it