JavaBased Distributed Models - PowerPoint PPT Presentation

About This Presentation
Title:

JavaBased Distributed Models

Description:

Last Updated 29 Nov. 1999. 2. Common DS Paradigms. Channels ... Proxy awaits and relays prices to you. a.read ?airline, you, home, to, leave, return, price ... – PowerPoint PPT presentation

Number of Views:39
Avg rating:3.0/5.0
Slides: 27
Provided by: Charles6
Learn more at: http://www.cs.ucf.edu
Category:

less

Transcript and Presenter's Notes

Title: JavaBased Distributed Models


1
Java-Based Distributed Models
Charles E. Hughes ceh_at_cs.ucf.edu http//www.cs.ucf
.edu/ceh Professor, School of Computer
Science University of Central Florida
2
Common DS Paradigms
  • Channels send / receive
  • Messages to single or collection of recipients
  • Distributed Objects invoke services on remote
    objects
  • Requires object serialization and
    un-serialization
  • Tuple space write, read, take
  • A space for reliable communication and
    coordination

3
IP Network Communication
  • Each node has an address (IP address)
  • Each node has many mailboxes (ports)
  • Messages (packets) are received at and sent
    through ports

4
UDP Simplest Communication
  • Like regular mail
  • I send messages with a return address and mailbox
  • Theres no guarantee of delivery or order of
    receipt
  • If all goes well you receive my mail at your
    mailbox
  • You can respond using my address and mailbox
    number

5
Sample UDP Service
  • CLIENT (sender)socket new DatagramSocket()
    packet new DatagramPacket(sendBuf,256,host,5500
    ) socket.send(packet)
  • SERVER (receiver)socket new DatagramSocket(5500
    )packet new DatagramPacket(buf, 256)
    socket.receive(packet)address
    packet.getAddress()port packet.getPort()s
    new String(packet.getData(),packet.getlength())

6
TCP/IP Common Protocol
  • Like a phone call
  • I place a call your address and ask for you
    (port)
  • You pick up and automatically have my address and
    port
  • We have a two-way channel (stream) over which we
    communicate
  • We need to be sure our messages are arriving
    reliably and in order

7
Sample TCP/IP Service
  • CLIENT (sender, then just participant)connection
    new Socket( host, 5000 ) in
    connection.getInputStream()out
    connection.getOutputStream()
  • SERVER (receiver, then just participant) server
    new ServerSocket( 5000, 2 )connection
    server.accept()in connection.getInputStream()
    out connection.getOutputStream()

8
Remote Messages
  • Personalized at the object level
  • Messages are at a high-level of abstraction
  • Interpretation of messages is at receiver end

9
Sketch of Sample RMI Service
  • INTERFACEpublic interface Hughes extends Remote
    ResType service() throws RemoteException
  • CLIENTobj (Hughes)Naming.lookup(//host/Charles
    Server)result obj.service()
  • SERVER obj new HughesImpl()Naming.rebind("//h
    ost/CharlesServer", obj)

10
Tuple Space
  • Tuples are like entries in a database
  • lt Mexico City, Querétaro, 180 gtmeans it
    takes 180 min. to travel from Mexico City to
    Querétaro
  • We can match this with many templates
  • lt Mexico City, Querétaro, Integer gt
  • lt String, Querétaro , 180 gt

11
Tuple Match
  • Template is of a chosen class
  • Template fields can have values or null
  • Template can match only tuples of class or
    subclass
  • Values are exact matches nulls are type matches

12
Sketch of JavaSpace Service
  • TEMPLATEpublic class Atlas implements Entry
    public String startCity public String
    endCity public Integer travelTime
  • PRODUCERJavaSpace space SpaceAccessor.getSpace(
    )Atlas msg new Atlas(Mexico City",
    Querétaro, 180)space.write(msg, null,
    Lease.FOREVER)
  • CONSUMER JavaSpace space SpaceAccessor.getSpace
    ()Atlas template new Message() endCity
    QuerétaroAtlas msg space.take(template,
    null, Long.MAX_VALUE)

13
Tuple Space Bid for Airline Ticket
  • Customer write bid to proxys tuple space
  • p.writeltme, home, to, leave, return, bidgt
  • Customer takes bids from tuple space
  • p.takelt?airline, me, home, to, ?leave, ?return,
    ?pricegt
  • Customer accepts some bid
  • p. writeltairline,me,home,to,leave,return,price,cre
    ditgt

14
Proxy to Airlines
  • Proxy takes bid from tuple space
  • p.takelt?you, ?home, ?to, ?leave, ?return, ?bidgt
  • Proxy replicates (writes) bid to each airline (a)
  • a.writeltairline, you, home, to, leave, return,
    bidgt
  • Proxy awaits and relays prices to you
  • a.readlt?airline, you, home, to, leave, return,
    pricegt
  • p.writeltairline, you, home, to, leave, return,
    pricegt

15
Completing the Purchase
  • Proxy passes your acceptance on
  • Airline sends confirmation which is relayed to
    you
  • Uses multiple tuple spaces
  • Uses class (type) of template as part of match

16
Atomic Operations
  • Want to treat group of actions as atomic
  • At some point we either
  • Commit and roll all changes into visible state
    or
  • Abort and roll back state to condition before
    group

17
Transactions
  • Some client starts a transaction
  • Others join the transaction
  • Client asks for a vote from participants
  • Each responds prepared, nochanges, or abort

18
Leases
  • Crashes could be real bad with deserted tuples
  • Each tuple leases space
  • You must renew lease or tuple is deleted
    automatically

19
Completing Transactions
  • All participants keep state at start
  • All prepared participants save prepared state
  • Client reports roll back if anyone voted abort
  • Client reports roll forward if no aborts
  • Nochanges do not participate, but should pause

20
Jini Architecture
  • Discovery
  • Find Jini lookup service (acts as broker)
  • Join (if providing new service)
  • Lookup services (if required)

21
Discovery Parameters
  • Protocol version number ( 1 )
  • Response port
  • Groups to discover (or empty for all)
  • Set of lookup services that already responded
  • All packed into at most 512 bytes for single UDP
    packet

22
Discovery Process
Multicast request client
Multicast request server
Multicast response server
Multicast response client
Discovering Entity
Lookup Service
23
Discovery Protocol
  • Use multicast to request local lookup service
  • Use unicast to request specific lookup service

24
Join Parameters
  • Service ID assigned when service is new
  • Attributes that describe service
  • Groups in which service participates
  • Lookup services at which this is (to be)
    registered

25
Avoiding a Packet Storm
  • Wait a random time (up to 15 seconds)
  • Then register service at lookup sites
  • Random wait is useful after a crash
  • If didnt do this, then all servers would start
    simultaneously
  • Technique similar to that used after Ethernet
    collision

26
Lookup
  • Use lookup service to get desired service
  • Can choose by group and attributes
  • Print service that prints in color at 1440 dpi
  • Three-D rendering object that imports VRML
  • Service object can be remote or a local proxy
Write a Comment
User Comments (0)
About PowerShow.com