Skip to content

Services in web context, concurrent, (a)synchronous, transactions

Notifications You must be signed in to change notification settings

Dnomyar/IMT-Service-Java

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

62 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Services

The objective of this lesson is to study services in the context of the web.

Is studied :

  • concurrent and parallel programming
  • synchronous/asynchronous programs
  • handling transactions

This repo gather the exercises (tp) of the lesson.

TP1 - Automaton as a service

The case study of this TP is to handle stateful and stateless services through the example of an automaton.

TP2 - Register as service

The case study of this TP is to optimist concurrency control through the example of an automaton.

Server without concurrency control

Server

- get(rep) & Ressource(x) -> rep(x) & Ressource(x)
- set(rep, y) & Ressource(x) -> rep(y) & Ressource(y)

Client

- get(lecture) // Etat initial
- lecture(x) -> set(ecriture, x + 1)
- ecriture(x) -> Affichage(x)

Server with concurrency control

- get(rep) & Ressource(x) & Version(n)
    -> rep(x, n) & Ressource(x) & Version(n)
// Ecriture réussie
- set(rep, y, n) & Ressource(x) & Version(n)
    -> rep(OK, y, n + 1) & Ressource(y) & Version(n + 1)
// Ecriture annulée
- set(rep, y, m) & Ressource(x) & Version(n) & (n != m)
    -> rep(KO, x, n) & Ressource(x) & Version(n)

Server with client cache

// Lecture à réaliser en cache
- get(rep, n) & Version(n)
    -> rep(CACHE, n) & Version(n)
// Lecture de la ressource
- get(rep, m) & Ressource(x) & Version(n) & (n != m)
    -> rep(x, n) & Ressource(x) & Version(n)
// Ecriture réussie
- set(rep, y, n) & Ressource(x) & Version(n)
    -> rep(OK, y, n + 1) & Ressource(y) & Version(n + 1)
// Ecriture annulée
- set(rep, y, m) & Ressource(x) & Version(n) & (n != m)
  -> rep(KO, x, n) & Ressource(x) & Version(n)

Client with cache

Client

// Etat initial
- getI(lecture)

// Incrémentation
- lecture(x) -> setI(ecriture, x + 1)
// Echec avec reprise
- ecriture(KO, x) -> setI(ecriture, x + 1)
// Succès
- ecriture(OK, x) -> Affichage(x)

Interceptor

// Etat initial
- Cache(NON_DEFINI, NON_DEFINI)

// Interception d'une requête en lecture
- getI(k) & Cache(x, n) -> get(lectureI, n) & Cache(x, n)
// Réponse demandant la lecture en cache
- lectureI(CACHE, n) & Cache(x, n) -> k(x) & Cache(x, n)
// Réponse transmettant le résultat et mise en cache
- lectureI(y, m) & Cache(x, n) -> k(y) & Cache(y, m)

// Interception d'une requête en écriture
- setI(k, y) & Cache(x, n) -> set(ecritureI, y, n) & Cache(x, n)
// Ecriture réussie avec mise à jour du cache
- ecritureI(OK, y, m) & Cache(x, n) -> k(OK, y) & Cache(y, m)
// Ecriture annulée avec mise à jour du cache
- ecritureI(KO, y, m) & Cache(x, n) -> k(KO, y) & Cache(y, m)

Client version management

Client GET request

The request needs contain the header if-none-match=[clientVersion].

Then there is 2 cases :

  • either the client and the server version are the same, then return
    • code 200 with
    • header ETag=[currentVersion]
  • either version are different, then return
    • code 304 (Not-Modified) with
    • header ETag=[clientVersion] and
    • header Content-Length=[0]

Client SET request

The request needs contain the header if-match=[clientVersion].

Then there is 3 cases :

  • either request header if-match is missing, then return
    • code 428 (Precondition Required) with
    • header ETag=[clientVersion]
  • either the client and the server version are the same, then return
    • code 200 with
    • header ETag=[newVersion]
  • otherwise return
    • code 412 (Precondition Failed) with
    • header ETag=[currentVersion]

Server filters

Priority : 1 ----------------------------------------------------------------------> 5

|--> CompterRequetes --> InteragirAtomiquement --> Cacher --> RealiserEcritureOptimiste  -->|
|                                                                                           | Business
|                                                                                           | code
|<-- CompterReponse  <-- InteragirAtomiquement <-- AjouterVersionAuxReponses             <--|

Priority : 1 <---------------------------------------------------------------------- 5

Releases

No releases published

Packages

No packages published

Languages