104
Κατανεμημένα Συστήματα Βασικές Έννοιες, Αρχιτεκτονικά Μοντέλα, Σχεδιαστικές Προκλήσεις Χρήστος Γκουμόπουλος Πανεπιστήμιο Αιγαίου Τμήμα Μηχανικών Πληροφοριακών και Επικοινωνιακών Συστημάτων Σχεδιαστικές Προκλήσεις

02 Distsyst Basic Concepts

Embed Size (px)

DESCRIPTION

distributed systems

Citation preview

  • , ,

  • 2

  • .

    (

    ()

    (

    )

    3

  • (resource sharing)

    .

    ,

    : :

    ,

    ,

    ,

    Lost,

    iTunes,

    4

  • (CPU): ,

    thin client,

    SETI@home

    : ,

    (typesetters), drum scanners, , ..(typesetters), drum scanners, , ..

    : (proxy server), (file/DB

    server)

    : -11 (

    )

    :

    5

  • , (.. ),

    (.. web-banking)

    , ..

    , ..

    , iTunes, , iTunes,

    Lost

    , file server

    6

  • :

    7

  • :

    8

  • Internet

    :

    9

    Laptop

    Mobile

    PrinterCamera

    Host intranet Home intranetWAP Wireless LAN

    phone

    gateway

    Host site

  • .

    .

    ;

    ;

    ;

    10

  • RFID reader

    RFID tag

    :

    (

    .

    11

  • (context)

    :

    , , , , ,

    , ,

    , ,

    (context-aware

    application):

    /

    12

  • ..

    ( )

    :

    ( )

    13

  • (..

    :

    T

    ( )

    14

  • = (

    )

    15

  • .

    ,

    , , , ,

    .

    .

    16

  • ,

    . .

    ,

    .

    17

  • .

    ,

    .

    18

  • : e-mail

    19

  • (, ,

    )

    .

    ,

    , ,

    20

  • (omission failure),

    (arbitrary failure)

    (timing failure).

    21

  • .

    ()

    .

    (buffer)

    .

    .

    22

  • .

    23

  • ,

    .

    :

    .

    .

    , ,

    .

    24

  • 25

  • .

    .

    :

    ,

    ,

    ,

    26

  • :

    /

    .

    27

  • client/server

    To :

    service: server

    server: /

    client: / client: /

    28

    Directory server Print server File server

    client client

  • client/server

    (client)

    (server)

  • Client/Server

    (proxy servers)

    (caching)

    (mobile code)

    (mobile agents)

    (network computers)

    () (thin clients)

    (fat clients)

    30

  • 31

  • -

    .

    ,

    ,

    .

    :

    ,

    .

    32

  • (proxy servers)

    (caching)

    33

  • (proxy servers)

    (caching)

    -

    (.. )

    (..

    ) .

    (.. cache ).

    .

    34

  • (proxy servers)

    (caching)

    .

    , ,

    .

    ,

    ,

    ,

    , .

    ,

    ,

    (..

    HTML WAP). 35

  • (mobile code)

    .

    Java applets

    . .

    ,

    .

    36

  • (mobile code)

    applet

    37

    O applet

  • (mobile code)

    ,

    .

    (push model)

    , , .

    ,

    .

    38

  • (mobile agents)

    ( )

    ,

    , ,

    .

    ,

    ,

    .

    39

  • (mobile agents)

    , (

    )

    ,

    , .

    .

    40

  • (network computers)

    ()

    ,

    (.. )

    RAM.

    ,

    ,

    .

    Java,

    .

    .

    Sun Oracle

    .41

  • (thin clients)

    H

    ,

    .

    ,

    ,

    ,

    .

    42

  • (thin clients)

    ,

    ,

    , .

    ,

    ,

    ,

    ,

    (compute server).

    43

  • 44

  • ,

    PDAs

    GSM, 3G,

    WiFi Bluetooth.

    -

    .

    ,

    .

    45

  • ()

    .

    (service discovery)

    .

    46

  • 47

  • 3-

    client/server 2-

    (2-tier architecture).

    2-

    , ,

    DNS Internet DNS Internet

    Domain Names .

    , :

    (web crawlers)

    :

    ( )

    ()

  • 3-

    client-server 3-

    , ,

    .

    ( )

    ( )

    ( )

    Web ,

    Web Server

    DB Server.49

  • 3-

    50

  • 3-

  • ()

    -

    :

  • ,

    : Google: web

    : URL, : URL,

    : HTML,

    : ,

    ,

    : ,

    , ..

    .. Wikipedia

    OpenOffice

  • :

    ..

    ( ...)

  • 3-

    legacy

    (

    )

    55

  • 3-

    56

  • -tier

    multi-tiered

    client

    w

    e

    b

    s

    e

    r

    v

    e

    r

    J

    a

    v

    a

    a

    p

    p

    l

    i

    c

    a

    t

    i

    o

    n

    s

    e

    r

    v

    e

    r

    l

    o

    a

    d

    b

    a

    l

    a

    n

    c

    e

    r

    f

    i

    r

    e

    w

    a

    l

    l

    f

    i

    r

    e

    w

    a

    l

    l

    database

    client

    w

    e

    b

    s

    e

    r

    v

    e

    r

    J

    a

    v

    a

    a

    p

    p

    l

    i

    c

    a

    t

    i

    o

    n

    s

    e

    r

    v

    e

    r

    l

    o

    a

    d

    b

    a

    l

    a

    n

    c

    e

    r

    f

    i

    r

    e

    w

    a

    l

    l

    f

    i

    r

    e

    w

    a

    l

    l

    ObjectStore

  • Gartner Group

    -

    58

  • thin client .

    H

    ,

    .

    ,

    GUI

    . .

    -11

    Window System Unix , Virtual Network Computer

    & Labs, Remote Desktop Protocol Microsoft, ..

    screen-

    scraping (emulation-based)

    (legacy systems) text-

    based windows-based .

    (dumb

    terminals).59

  • .

    thin client .

    , , , ,

    .

    on-line

    transaction , (ftp, telnet,

    ..) Web Web

    browsers.

    60

  • (application logic) .

    (.. ).

    .

    Web

    ( ) ,

    , Java applet.

    61

  • fat-client

    PC.

    .

    (DB2, Oracle, Informix, ..)

    client/server

    . .

    (Network File Systems)

    .

    (Decision Support System)

    ,

    .

    62

  • .

    fat-client

    (cache) (cache)

    .

    (.. NFS)

    .

    63

  • (Peer-to-Peer)

    (, )

    : Napster,

    Gnutella, FastTrack, Kontiki,

    Osiris, Skype)

    64

  • ,

    ( ).

    (.. )

    , ,

    .

    ,

    , ,

    .

    ,

    .

    ,

    , ,

    .

    65

  • CLIENT/SERVER

    66

  • header.h

    header.h

    /* definitions needed by clients and servers.*/

    #define MAX_PATH 255 /* maximum length of a file name */

    #define BUF_SIZE 1024 /* how much data to transfer at once */

    #define FILE_SERVER 243 /* file servers network address */

    /* definitions of the allowed operations. */

    #define CREATE 1 /* create a new file */

    #define READ 2 /* read a piece of a file and return it */

    #define WRITE 3 /* write a piece of a file */

    #define DELETE 4 /* delete an existing file */

  • header.h

    /* Error codes. */

    #define OK 0 /* operation performed correctly */

    #define E_BAD_OPCODE 1 /* unknown operation requested */

    #define E_BAD_PARAM 2 /* error in a parameter */

    #define E_IO 3 /* disk error or other I/O error */

  • header.h

    /* Definition of the message format. */

    struct message {

    long source; /* senders identity */

    long dest; /* receivers identity */

    long opcode; /* which operation: CREATE, READ, etc. */

    long count; /* how many bytes to transfer */

    long offset; /* where in file to start reading or writing */

    long extra1; /* extra field */long extra1; /* extra field */

    long extra2; /* extra field */

    long result; /* result of the operation reported here */

    char name[MAX_PATH]; /* name of the file being operated on */

    char data[BUF_SIZE]; /* data to be read or written */

    };

  • server

    #include

    void main(void)

    {

    struct message m1, m2; /* incoming and outgoing messages */

    int r; /* result code */

    while (1) { /* server runs forever */

    receive(ANY, &m1); /* block waiting for a message */

    switch(m1.opcode) { /* dispatch on type of request */switch(m1.opcode) { /* dispatch on type of request */

    case CREATE: r = do_create(&m1, &m2); break;

    case READ: r = do_read(&m1, &m2); break;

    case WRITE: r = do_write(&m1, &m2); break;

    case DELETE: r = do_delete(&m1, &m2); break;

    default: r = E_BAD_OPCODE;

    }

    m2.result = r; /* return result to client */

    send(m1.source, &m2); /* send reply */

    }

    }

  • client

    #include

    int copy (char *src, char *dst) { /* procedure to copy file using the server */

    struct message m1; /* message buffer */

    long position; /* current file position */

    long client = 110; /* clients address */

    initialize(); /* prepare for execution */

    position = 0;

  • client

    do { /* get a block of data from the source file. */

    m1.opcode = READ; /* operation is a read */

    m1.offset = position; /* current position in the file */

    strcpy(&m1.name, src); /* copy name of file to be read to message */

    send(FILE_SERVER, &m1); /* send the message to the file server */

    receive(FILE_SERVER, &m1); /* block waiting for the reply */

    /* write the data just received to the destination file. */

    m1.opcode = WRITE; /* operation is a write */m1.opcode = WRITE; /* operation is a write */

    m1.offset = position; /* current position in the file */

    m1.count = m1.result; /* how many bytes to write */

    strcpy(&m1.name, dst); /* copy name of file to be written to buf */

    send(FILE_SERVER, &m1); /* send the message to the file server */

    receive(FILE_SERVER, &m1); /* block waiting for the reply */

    position += m1.result; /* m1.result is number of bytes written */

    } while (m1.result > 0); /* iterate until done */

    return (m1.result >=0 > OK: m1.result); /* return OK or error code */

    } /* copy */

  • 73

  • :

    ,

    ,

    , ,

    ,

    ()

    ,

    ,

    .

    74

  • ,

    ,

    .

    , :

    (.., Ethernet, Token Ring, FDDI)

    (.., Big Endian, Little Endian)

    (.., Unix, MAC OS, MS Windows)

    (.., Java,

    C++, Python)

    75

  • TCP/IP (

    )

    .

    (middleware)

    .

    ,

    ,

    .

    ,

    76

  • :

    ,

    ,

    , ,

    ,

    ()

    ,

    ,

    .

    77

  • .

    (..

    )

    ,

    .

    . .

    .

    (.. )

    .

    ,

    , .

    78

  • ,

    :

    ,

    :

  • + +

    +

    :

    ,

    : :

    :

    ,

    ,

  • :

    ,

    ,

    , ,

    ,

    ()

    ,

    ,

    .

    81

  • ,

    .

    , ,

    .

    .

    .

    .

    82

  • ,

    .

    (access rights)

    .

    .

    (secure channel)

    .

    Virtual Private Networks Secure Sockets Layer

    .

    83

  • :

    ,

    ,

    , ,

    ,

    ()

    ,

    ,

    .

    84

  • .

    ,

    ,

    .

    . .

    .

    ,

    ,

    .

    . 85

  • :

    :

    :

    : , : ,

    ,

  • ..

    ,

    .

    () :

    (.. )

    (.. 12:00 )

  • --

    / /

    :

  • ; ,

    ..

    ...

    , , ...

    ...

    ... ;

    ..

    ,

    , applets,

    ... !

  • , ,

    :

    :

  • :

    , ..

    , /

  • : DNS , ()

    server

    web ()

  • ,

    , (

    )

    : , , /

    ,

    , (.. )

    /

  • :

    ,

    ,

    , ,

    ,

    ()

    ,

    ,

    .

    94

  • .

    .

    , .

    . 95

  • , .

    ,

    .

    ,

    .

    .

    (redundancy)

    . 96

  • .

    .

    (omission failure),

    (arbitrary failure),

    (arbitrary failure),

    (timing failure).

    ;

    .

    97

  • :

    ,

    ,

    , ,

    ,

    ()

    ,

    ,

    .

    98

  • .

    . .

    ,

    , .. ,

    .99

  • ( ).

    .

    (amount)

    ( PIN myPIN)

    (thread) .

    .

    1. case CMD_WITHDRAW:

    2. Account sessionAcc = getSessionAccount(myPIN); // Account

    3. String result = sessionAcc.withdraw(amount); //

    4. saveSessionAccount(sessionAcc); //

    5. break;

    100

  • To : (1 2)

    ()

    , 5000,

    3000 4000

    .

    .

    (race condition) (race condition)

    ,

    .

    To

    .

    101

  • :

    ,

    ,

    , ,

    ,

    ()

    ,

    ,

    .

    102

  • ,

    .

    :

    (

    , IP )

    , 103

  • ,

    ,

    , ,

    104