distributed objects

31
Designing Distributed Objects 1 Distributed Objects Objective Understand the difference between local and distributed objects and how to correctly use them Outline Object Model Local versus Distributed Objects

Upload: klaus

Post on 14-Jan-2016

22 views

Category:

Documents


0 download

DESCRIPTION

Distributed Objects. Objective Understand the difference between local and distributed objects and how to correctly use them Outline Object Model Local versus Distributed Objects. Object Types. Object types specify the common characteristic of similar objects - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Distributed Objects

Designing Distributed Objects 1

Distributed Objects

Objective Understand the difference between local and distributed objects and how to

correctly use them

Outline Object Model Local versus Distributed Objects

Page 2: Distributed Objects

Designing Distributed Objects 2

Object Types

Object types specify the common characteristic of similar objects

Object types define a contract that binds the interaction between client and server objects

Object types are specified through interfaces that determine the operations that clients can request. Operation visibility: public, private, etc. Signature of an operation: name, list of formal parameters, and the result with

type information

Non-Object Types Atomic types: boolean, char, int, etc, Values No identity Cannot be referenced

Page 3: Distributed Objects

Designing Distributed Objects 3

Objects

Object Unique identifier Multiple references Attributes

public Private Name and a type Class or static variables (not for distributed objects)

Operations

Object Identity vs Equality Identical equal Equal ! identical

Page 4: Distributed Objects

Designing Distributed Objects 4

Requests

An object request is made by a client object in order to request execution of an operation from a server object. Object reference Operation List of actual parameters

Request vs method invocation Resolve data heterogeneity Synchronization between client and server objects Communication through network …

Page 5: Distributed Objects

Designing Distributed Objects 5

Exceptions

Exceptions are a mechanism for notifying clients about failures that occur during the execution of an object request. Data structures carrying details about failures Part of the contract between client and sever objects Raised by a server object Raised by middleware (system exception) Transferred via network from server to client

Page 6: Distributed Objects

Designing Distributed Objects 6

Types and Distributed Objects

Attributes, operations and exceptions are properties objects may export to other objects.

Multiple objects may export the same properties. Only define the properties once! Attributes and operations, and exceptions are defined in object

types.

Page 7: Distributed Objects

Designing Distributed Objects 7

Attributes Attributes have a name and a type. Type can be an object type or a non-object type. Attributes are readable by other components. Attributes may or may not be modifiable by other components. Attributes correspond to one or two operations (set/get).

Page 8: Distributed Objects

Designing Distributed Objects 8

Exceptions Service requests in a distributed system may not be properly

executed. Exceptions are used to explain reason of failure to requester of

operation execution. Operation execution failures may be

generic or specific.

Specific failures may be explained in specific exceptions.

Page 9: Distributed Objects

Designing Distributed Objects 9

Operations Operations have a signature that consists of

a name, a list of in, out, or inout parameters, a return value type, and a list of exceptions that the operation can raise.

Page 10: Distributed Objects

Designing Distributed Objects 10

Object Type Example

<<interface>>Player

-name:string;-role:Position;-Number:int;+void book(in Date d) raises (AlreadyBooked);

Page 11: Distributed Objects

Designing Distributed Objects 11

Operation Execution Requests A client object can request an operation execution from a server

object. Operation request is expressed by sending a message (operation

name) to server object. Server objects are identified by object references. Clients have to react to exceptions that the operation may raise.

Page 12: Distributed Objects

Designing Distributed Objects 12

Subtyping

Properties shared by several types should be defined only once. Object types are organised in a type hierarchy. Subtypes inherit attributes, exceptions and operations from

their supertypes. Subtypes can add more specific properties. Subtypes can redefine inherited properties.

Page 13: Distributed Objects

Designing Distributed Objects 13

Multiple Inheritance Means that one object type can be subtype of more than one

super type Not supported by all middleware May lead to ambiguities

Page 14: Distributed Objects

Designing Distributed Objects 14

Multiple Inheritance Example

<<interface>>Player

-name:string;-role:Position;-Number:int;+void book(in Date d) raises (AlreadyBooked);+next_game():Date

<<interface>>Trainer

-salary:int;

+next_game():Date

<<interface>>PlayerTrainer

Page 15: Distributed Objects

Designing Distributed Objects 15

Polymorphism

Object models may be statically typed. Static type of a variable restricts the dynamic type of objects

that can be assigned to it. Polymorphism denotes the possibility of assignments of objects

that are instances of the static type and all its subtypes.

Page 16: Distributed Objects

Designing Distributed Objects 16

Polymorphism Example

chelsea:Team

name = “Chelsea”

v:PlayerTrainername = “Gianluca Vialli”role = ForwardNumber = 10salary=1000000

z:Player

name = “Gianfranco Zola”role=ForwardNumber=3

d:Player

name = “Marcel Desailly”role=DefenderNumber=5

Page 17: Distributed Objects

Designing Distributed Objects 17

Motivation Many will have experience with designing local objects that

reside in the run-time environment of an OO programming lang.

Designing distributed objects is different! Explain the differences. Avoid some serious pitfalls

Page 18: Distributed Objects

Designing Distributed Objects 18

Local vs. distributed Objects References Activation/Deactivation Migration Persistence Latency of Requests Concurrency Communication Security Several Pitfalls are lurking here

Page 19: Distributed Objects

Designing Distributed Objects 19

Object Lifecycle OOPL objects reside in one virtual machine. Distributed objects might be created on a different machine. Distributed objects might be copied or moved (migrated) from

one machine to another. Deletion by garbage collection does not work in a distributed

setting. Lifecycle needs attention during the design of distributed

objects.

Page 20: Distributed Objects

Designing Distributed Objects 20

Object References References to objects in OOPL are usually pointers to memory

addresses sometimes pointers can be turned into references (C++) sometimes they cannot (Smalltalk,Java)

References to distributed objects are more complex Location information Security information References to object types

References to distributed objects are bigger (e.g 40 bytes with Orbix).

Page 21: Distributed Objects

Designing Distributed Objects 21

Latency of Requests Performing a local method call requires a couple of hundred

nanoseconds. An object request requires between 0.1 and 10 milliseconds. Interfaces of distributed objects need to be designed in a way

that operations perform coarse-grained tasks do not have to be requested frequently

Page 22: Distributed Objects

Designing Distributed Objects 22

Example: Iteration over a Sequence Java

Vector

+size():int+elementAt(i:int):Object...

Distributed Objects

List

+long list (in how_many:long, out l:sequence<object>, out bi:Iterator i)

Iterator

+next_one(out o:Object): boolean +next_n(in how_many:long, out l:sequence<object>):boolean

Page 23: Distributed Objects

Designing Distributed Objects 23

Activation/Deactivation Objects in OOPL are in virtual memory between creation and

destruction. This might be inappropriate for distributed objects

sheer number of objects objects might not be used for a long time some hosts might have to be shut down without stopping all applications

Distributed object implementations are brought into main memory (activation) discarded from main memory (deactivation)

Page 24: Distributed Objects

Designing Distributed Objects 24

Activation/Deactivation (cont’d)

BvB:TeamBvB:Team

bookGoaliesbookGoalies

Tony:TrainerTony:Trainer

objectactivatedobjectactivated

objectdeactivationobjectdeactivation

Page 25: Distributed Objects

Designing Distributed Objects 25

Activation/Deactivation (cont’d) Several questions arise

Repository for implementations Association between objects and processes Explicit vs. implicit activation When to deactivate objects How to treat concurrent requests

Who decides answers to these questions? Designer Programmer Administrator

How to document decisions?

Page 26: Distributed Objects

Designing Distributed Objects 26

Persistence Stateless vs. statefull objects Statefull objects have to save their state between

object deactivation and object activation

onto persistent storage Can be achieved by

externalization into file system mapping to relational database object database

To be considered during object design

Page 27: Distributed Objects

Designing Distributed Objects 27

Parallelism Execution of OOPL objects is often

sequential concurrent (with multi-threading)

Distributed objects execute in parallel Can be used to accelerate computations

Page 28: Distributed Objects

Designing Distributed Objects 28

Communication Method invocations of OOPL objects are synchronous Alternatives for distributed objects:

synchronous requests oneway requests deferred synchronous requests asynchronous requests

Who decides on request Designer of server? Designer of client?

How documented?

Page 29: Distributed Objects

Designing Distributed Objects 29

Failures Distributed object requests are more likely to fail than local

method calls Different request reliabilities are available for distributed

objects Clients have an obligation to validate that servers have executed

request

Page 30: Distributed Objects

Designing Distributed Objects 30

Security Security in OO applications can be dealt with at session level. OOPL Objects do not have to be written in a particular way. For distributed objects:

Who is requesting an operation execution? How can we know that subject is who it claims to be? How do we decide whether or not to grant that subject the right to execute the

service? How can we prove that we have delivered a service so as to make the requester

pay

Page 31: Distributed Objects

Designing Distributed Objects 31

Key Points Distributed objects evolved from research and development in

object-oriented programming languages and distribution middleware

The Unified Modeling Language can be used to design distributed objects

Meta object models determine the characteristics of distributed objects

Designers need to be aware of differences between local and distributed objects