network objects

24
Network Objects Marco F. Duarte COMP 520: Distributed Systems September 14, 2004

Upload: wayne-norman

Post on 04-Jan-2016

49 views

Category:

Documents


0 download

DESCRIPTION

Network Objects. Marco F. Duarte COMP 520: Distributed Systems September 14, 2004. Introduction. Distributed systems require data, process sharing among nodes Object oriented programming appropriate for distributed systems A. Birrell, G. Nelson, S. Owicki, E. Wobber (1993) - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Network Objects

Network Objects

Marco F. Duarte

COMP 520: Distributed Systems

September 14, 2004

Page 2: Network Objects

Introduction

Distributed systems require data, process sharing among nodes

Object oriented programming appropriate for distributed systems

A. Birrell, G. Nelson, S. Owicki, E. Wobber (1993) How to share objects in distributed systems?

Methods provide sharing interface – share methods?

Network Objects: Objects whose methods can be accessed by other programs

Page 3: Network Objects

Pickles

Solution to marshaling complex data types Simple variable types marshaled in-line Complex types (i.e. objects) marshaled by pickle

package – which can be customized for each object type

Network objects are passed by reference Non-network objects are copied to destination Marshalling support for inter-process streams

Page 4: Network Objects

Network Object Sharing

Network object T, subtypes TImpl, TSrg

Surrogates are created by the unmarshaling code

Clients select a transport shared by client and owner

Clients select TSrg corresponding to TImpl

Page 5: Network Objects

Object Sharing

How to choose best surrogate for a network object? Narrowest Surrogate: Choose TSrg which is the most

specific and consistent with TImpl, and with stubs available both in client and owner.

Third Party Transfers: Obtaining a reference to a network object from another client

Page 6: Network Objects

Object Sharing: Example

MODULE Server EXPORTS Main;

IMPORT NetObj, FS, Time;

TYPE File = FS.File OBJECT <buffers, etc.> OVERRIDES getChar := GetChar; eof := Eof END; Svr = FS.Server OBJECT <directory cache, etc.> OVERRIDES open := Open; END;

< Code for GetChar, Eof, and Open >

BEGIN NetObj.Export(NEW(Srv), “FS1”); < Pause Indefinitely >END Server.

MODULE Client EXPORTS Main; IMPORT NetObj, FS, IO;

VAR s: FS.Server := NetObj.import(“FS1”, NetObj.LocateHost(“server”));

f:= s.open(“/usr/dict/words”);

BEGIN WHILE NOT f.eof() DO IO.PutChar(f.getChar()) END

END Client

TYPE NewFS.File OBJECT METHODS close() END;

Page 7: Network Objects

Typecodes

Unique object identifier in a machine

Used for allocation Typecodes are

matched with supertypecodes (parent)

Page 8: Network Objects

Typecodes: Problem

Page 9: Network Objects

Fingerprints: Solution

64 kilobit checksum dependent on object structure

Page 10: Network Objects

Network Object Marshaling

Networks Objects are marshaled through their wire representation: (SpaceID, ObjID)

If object is not known at client, a surrogate is found for it using the narrowest surrogate rule.

Page 11: Network Objects

Remote Invocation

Stubs registered in table with srgType, disp. Obtain and release connections

Dispatcher: obj.disp(c, obj) – written by stub generator – unmarshals arguments and calls appropriate method Methods identified by integers

Page 12: Network Objects

Garbage Collection

Page 13: Network Objects

Garbage Collection

Dirty Set: List of clients containing surrogates for the objects

Page 14: Network Objects

Garbage Collection

When surrogate is collected, RPC removes it from dirty set

If there are no local references, TImpl can be collected

Page 15: Network Objects

Garbage Collection

Third party transfers as results require Ack message to protect both copies

Page 16: Network Objects

Explicit Import/Export

MODULE Server EXPORTS Main;

IMPORT NetObj, FS, Time;

TYPE File = FS.File OBJECT <buffers, etc.> OVERRIDES getChar := GetChar; eof := Eof END; Svr = FS.Server OBJECT <directory cache, etc.> OVERRIDES open := Open; END;

< Code for GetChar, Eof, and Open >

BEGIN NetObj.Export(NEW(Srv), “FS1”); < Pause Indefinitely >END Server.

MODULE Client EXPORTS Main; IMPORT NetObj, FS, IO;

VAR s: FS.Server := NetObj.import(“FS1”, NetObj.LocateHost(“server”));

f:= s.open(“/usr/dict/words”);

BEGIN WHILE NOT f.eof() DO IO.PutChar(F.getChar()) END

END Client

TYPE NewFS.File OBJECT METHODS close() END;

Page 17: Network Objects

Bootstrapping

Objects passed as results to method calls How to share an “original” object?

Forge original surrogate Location, Object ID, Surrogate Type

Special Object w/ID = 0 Methods implement network object runtime

operations (Import, Export, Locate, etc.) get, put operations Specific TCP port assigned for location

Page 18: Network Objects

Performance doesn’t matter

Network penalty 1600 usecs

Null Call 3310 usecs/call

Ten integer call 3435 usecs/call

Same object argument 3895 usecs/call

Same object return 4290 usecs/call (ack)

New object argument 9148 usecs/call (dirty)

New object return 10253 usecs/call (dirty)

TCP throughput 3400 Kbytes/sec

Reader test 2824 Kbytes/sec

Writer test 2830 Kbytes/sec

Page 19: Network Objects

Linda: Basic Concepts

N. Carriero and D. Gelernter Simpler, more powerful and more elegant

than alternatives Tuple: Unconstrained data structureA tuple is a series of typed fields

(“a string”, 15.01, 17. “another string”)

Page 20: Network Objects

Tuple Operations

Four basic operations: eval,out create new data objects in, rd remove and read data objects

Operation syntax: out(“a string”, 15.01, 17, “another string”) in(“a string”, ? f, ? i, “another string”) rd(“a string”, ? f, ? i, “another string”)

Page 21: Network Objects

Using Tuples

Live Tuple: Tuple whose data is to be determined by a running process.

Tuple space: Collection of tuples available to all programs

Implementing data structures as a collection of tuples: n-vector V (“V”, 1, FirstElt), (“V”, 2, SecondElt) …

(“V”, n, NthElt)

To read the jth element: rd(“V”, j, ? x);

To modify the ith element: in(“V”, j, ? OldVal); … out(“V”, j, NewVal);

Page 22: Network Objects

Advantages of Linda over Concurrent Objects

Communication, synchronization and process creation are two facets of the same operation

Tuples are persistent Asynchronous communication between

processes Data structures can be expressed as a collection

of tuples. Live data structures are a collection of live

tuples Fine grained live data structure programs

Page 23: Network Objects

Linda and Objects

Can be used with object oriented programming Generate passive objects using out Generate active objects using eval Communication with active object goes

through tuple space Parallelism-oriented, unlike other methods

Page 24: Network Objects

Conclusions

Network object simplifies communication in distributed systems, but introduces new complexities Identifying objects consistently across computers Network-based garbage collection

Communication between objects can be implemented in several ways RPC conveniently implements remote method access

Object-oriented programming itself doesn’t implement parallelism