52
Chair of Software Engineering P. Eugster Concurrent Object-Oriented Programming

Concurrent Object-Oriented Programmingse.inf.ethz.ch/old/teaching/ss2005/0268/lectures/Lect4.pdf · Illustration: Java import java.rmi.*; public interface HelloInterface extends Remote

  • Upload
    others

  • View
    16

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Concurrent Object-Oriented Programmingse.inf.ethz.ch/old/teaching/ss2005/0268/lectures/Lect4.pdf · Illustration: Java import java.rmi.*; public interface HelloInterface extends Remote

Chair of Software Engineering P. Eugster

Concurrent Object-Oriented Programming

Page 2: Concurrent Object-Oriented Programmingse.inf.ethz.ch/old/teaching/ss2005/0268/lectures/Lect4.pdf · Illustration: Java import java.rmi.*; public interface HelloInterface extends Remote

2

Chair of Software Engineering P. Eugster

Lectures Overview

Lecture 1: Introduction and Motivation

Lecture 2: Classic Approaches to Concurrent Programming

Lecture 3: Objects and Concurrency

Lecture 4: From Concurrent to Distributed Programming

Page 3: Concurrent Object-Oriented Programmingse.inf.ethz.ch/old/teaching/ss2005/0268/lectures/Lect4.pdf · Illustration: Java import java.rmi.*; public interface HelloInterface extends Remote

3

Chair of Software Engineering P. Eugster

Distributed Programming

Tasks can interfere through the networkTransmitted data is copied to/from the OS memoryNo global clock“Loosely coupled” systemsVery different networks can be used

Page 4: Concurrent Object-Oriented Programmingse.inf.ethz.ch/old/teaching/ss2005/0268/lectures/Lect4.pdf · Illustration: Java import java.rmi.*; public interface HelloInterface extends Remote

4

Chair of Software Engineering P. Eugster

Note

Parallel computing can be done on distributed system

“Emulate” parallel hardwareSpecial case of distributed computing with strong assumptions

Is distributed computing vs concurrent computing just a matter of granularity?

Cf. threads vs tasks?

Page 5: Concurrent Object-Oriented Programmingse.inf.ethz.ch/old/teaching/ss2005/0268/lectures/Lect4.pdf · Illustration: Java import java.rmi.*; public interface HelloInterface extends Remote

5

Chair of Software Engineering P. Eugster

Lecture 4: From Concurrent to Distributed Programming

Page 6: Concurrent Object-Oriented Programmingse.inf.ethz.ch/old/teaching/ss2005/0268/lectures/Lect4.pdf · Illustration: Java import java.rmi.*; public interface HelloInterface extends Remote

6

Chair of Software Engineering P. Eugster

Outline

Classic Approach

Failure and system models

Fundamental results

Approaches to distributed (object-oriented) programming

Page 7: Concurrent Object-Oriented Programmingse.inf.ethz.ch/old/teaching/ss2005/0268/lectures/Lect4.pdf · Illustration: Java import java.rmi.*; public interface HelloInterface extends Remote

7

Chair of Software Engineering P. Eugster

“Classic” Approach

Proxy/marshalling approach Remote objects are invoked through proxies

Two kinds of objects involved in (remote) interaction1. “Data objects” (small, likely primitive types)

Can be passed by value if arguments/return values to invocations

2. “Bound objects” (larger, logically bound to host)

Are passed by reference, i.e., proxies are created on receiver site

Page 8: Concurrent Object-Oriented Programmingse.inf.ethz.ch/old/teaching/ss2005/0268/lectures/Lect4.pdf · Illustration: Java import java.rmi.*; public interface HelloInterface extends Remote

8

Chair of Software Engineering P. Eugster

Value Passing

Proxy / Stub SkeletonInvoker Invokee

I00II….I0I

Value Argument Argument Copy

Page 9: Concurrent Object-Oriented Programmingse.inf.ethz.ch/old/teaching/ss2005/0268/lectures/Lect4.pdf · Illustration: Java import java.rmi.*; public interface HelloInterface extends Remote

9

Chair of Software Engineering P. Eugster

Reference Passing

Proxy / Stub SkeletonInvoker Invokee

I00II….I0I

Reference Argument Argument Proxy

Page 10: Concurrent Object-Oriented Programmingse.inf.ethz.ch/old/teaching/ss2005/0268/lectures/Lect4.pdf · Illustration: Java import java.rmi.*; public interface HelloInterface extends Remote

10

Chair of Software Engineering P. Eugster

Passing Semantics

1. Pass-by-value (copy semantics)Increases network trafficNo support for consistency/synchronization issuesExplicit distribution

2. Pass-by-referenceIncreases dependency (“shared objects”)

Failure-wiseLatency-wise

Might require heavy synchronizationHidden distribution

Page 11: Concurrent Object-Oriented Programmingse.inf.ethz.ch/old/teaching/ss2005/0268/lectures/Lect4.pdf · Illustration: Java import java.rmi.*; public interface HelloInterface extends Remote

11

Chair of Software Engineering P. Eugster

Illustration: Java

import java.rmi.*;

public interface HelloInterface extends Remote {

/* return the message of the remote object, such as "Hello, world!". exception RemoteException if the remote invocation fails. */

public String say() throws RemoteException;}

Objects can/must be Remote

Serializable

Above, String is serializable

Page 12: Concurrent Object-Oriented Programmingse.inf.ethz.ch/old/teaching/ss2005/0268/lectures/Lect4.pdf · Illustration: Java import java.rmi.*; public interface HelloInterface extends Remote

12

Chair of Software Engineering P. Eugster

Interference in Distribution

As long as no failures are consideredNo additional ones“Proxies” handled on behalf of remote objects

But nothing is perfectFailures can occur

HostsTasks: usually unit of failure, but 1 per hostCommunication

LatencyA failed task (process) can not be distinguished from a very slow oneFLP-Impossibility result [Fischer,Lynch,Patterson’85]

Page 13: Concurrent Object-Oriented Programmingse.inf.ethz.ch/old/teaching/ss2005/0268/lectures/Lect4.pdf · Illustration: Java import java.rmi.*; public interface HelloInterface extends Remote

13

Chair of Software Engineering P. Eugster

Failures Exceptions?

RemoteException is thrown in case of trouble

But interpretation is often left to applicationHas object received invocation?

Sent back return value?Has object crashed?

In between request/return

Resend requestWhat if received (in the meantime, return value lost)?

Page 14: Concurrent Object-Oriented Programmingse.inf.ethz.ch/old/teaching/ss2005/0268/lectures/Lect4.pdf · Illustration: Java import java.rmi.*; public interface HelloInterface extends Remote

14

Chair of Software Engineering P. Eugster

Proxy Proliferation

Remote objects passed as arguments are transparently “replaced” by proxies

Spiderweb of remote references is createdIncreases dependencies between processesA single failure/exception can bring down entire system

Page 15: Concurrent Object-Oriented Programmingse.inf.ethz.ch/old/teaching/ss2005/0268/lectures/Lect4.pdf · Illustration: Java import java.rmi.*; public interface HelloInterface extends Remote

15

Chair of Software Engineering P. Eugster

Sophistry?

Imagine you are standing at an ATM withdrawing money

…public static void main(String[] args) {

String name = args[0];int amount = Integer.parseInt(args[1]);

Bank myBank = …; // connect to Bank

BankAccount myAccount = myBank.getAccount(name);

myAccount.withdraw(amount);CardReader.releaseCard();MoneyOutput.returnAmount(amount);…

}…

Page 16: Concurrent Object-Oriented Programmingse.inf.ethz.ch/old/teaching/ss2005/0268/lectures/Lect4.pdf · Illustration: Java import java.rmi.*; public interface HelloInterface extends Remote

16

Chair of Software Engineering P. Eugster

Process View

Bank/Account

ATM

withdraw(x) [ok]

account := account – x;

Page 17: Concurrent Object-Oriented Programmingse.inf.ethz.ch/old/teaching/ss2005/0268/lectures/Lect4.pdf · Illustration: Java import java.rmi.*; public interface HelloInterface extends Remote

17

Chair of Software Engineering P. Eugster

Latency Asynchronous Invocations?

Different variants“Oneway”, i.e., no return value

Cf. actorsLazy synchronization

A.k.a. wait-by-necessity (cf. SCOOP)Object invoked, return value not “populated”Implicit vs explicit future

IssueAsynchronously dealing with failures?

Page 18: Concurrent Object-Oriented Programmingse.inf.ethz.ch/old/teaching/ss2005/0268/lectures/Lect4.pdf · Illustration: Java import java.rmi.*; public interface HelloInterface extends Remote

18

Chair of Software Engineering P. Eugster

Unfortunately

Latency and (partial) failures are reality!Must cope with message passing latency, contention, …Failures of hosts/processes, transmission

See [Gaertner’99] for a good overview

Distributed systems are Heterogenous (without mentioning languages)Not static…Basically just a set of processes {p1, p2, … } communicating by message passing

Page 19: Concurrent Object-Oriented Programmingse.inf.ethz.ch/old/teaching/ss2005/0268/lectures/Lect4.pdf · Illustration: Java import java.rmi.*; public interface HelloInterface extends Remote

19

Chair of Software Engineering P. Eugster

Processes

One assumes processes Have unique identifiersAre connected pair-wise through links which enable message passing

At a tick of its local clock, a processExecutes a computation (local event) and exchanges messages with others (global event)Note: one message sent/delivered per tick

For a given algorithm run, a process is correct or faulty

Page 20: Concurrent Object-Oriented Programmingse.inf.ethz.ch/old/teaching/ss2005/0268/lectures/Lect4.pdf · Illustration: Java import java.rmi.*; public interface HelloInterface extends Remote

20

Chair of Software Engineering P. Eugster

Failure Models

OmissionCertain actions can be omitted, e.g., message reception or send (e.g., due to buffer limitations)Crash

(Usually) processes, e.g., crash-stop, crash-recovery

TimingCertain action takes place too late (usually based on assumption that this can be detected, i.e., bound)

Byzantine (arbitrary)Malicious behavior

Page 21: Concurrent Object-Oriented Programmingse.inf.ethz.ch/old/teaching/ss2005/0268/lectures/Lect4.pdf · Illustration: Java import java.rmi.*; public interface HelloInterface extends Remote

21

Chair of Software Engineering P. Eugster

(Message Passing) System Models

Synchronous: known upper bounds ondelays for message transferprocessing speeddrifts between individual local host clocks and global real time

Asynchronous: none of the aboveYet typical of Internet

IntermediatePartially synchronous (e.g., “failure detector”)Eventually synchronous

Page 22: Concurrent Object-Oriented Programmingse.inf.ethz.ch/old/teaching/ss2005/0268/lectures/Lect4.pdf · Illustration: Java import java.rmi.*; public interface HelloInterface extends Remote

22

Chair of Software Engineering P. Eugster

Communication Channels

Latency is one thingIf at least a message is “eventually” received

Unreliable channels (“at-most-once”)No duplication: a message is received at most onceNo creation: a message received has been sent

Fair-lossy channels Fairness: a repeatedly sent message is only lost a finite number of times (processes are correct)Sufficient to build reliable channels: message is eventually received (processes are correct)

Page 23: Concurrent Object-Oriented Programmingse.inf.ethz.ch/old/teaching/ss2005/0268/lectures/Lect4.pdf · Illustration: Java import java.rmi.*; public interface HelloInterface extends Remote

23

Chair of Software Engineering P. Eugster

In Practice?

UDP: unreliable channel

TCP: reliable, and FIFO, assumingUnlimited buffersUnique identifiers for

MessagesProcesses

“Eventually”, and hence latency, are usually defined in terms of an algorithm run

Inversely run is bound by actions happening “eventually”..

Page 24: Concurrent Object-Oriented Programmingse.inf.ethz.ch/old/teaching/ss2005/0268/lectures/Lect4.pdf · Illustration: Java import java.rmi.*; public interface HelloInterface extends Remote

24

Chair of Software Engineering P. Eugster

Further

Consensus impossible in asynchronous system [Fischer,Lynch,Patterson’85]

With a single process failureEven with reliable channels

Etc.Mutual exclusion among n processes can not be implemented in asynchronous system with process failures(Non-blocking) atomic commitLeader election…

Page 25: Concurrent Object-Oriented Programmingse.inf.ethz.ch/old/teaching/ss2005/0268/lectures/Lect4.pdf · Illustration: Java import java.rmi.*; public interface HelloInterface extends Remote

25

Chair of Software Engineering P. Eugster

Intuition (Mutual Exclusion)

Imagine a process p entering a critical sectionProcess p crashes before exitingProcess p’s failure must be detected such that someone else can enter the critical sectionTo that end, every process must periodically “hear” from every process (failure detector)When can a process which does not hear from pdecide that p is dead?

No bound on communication latency: p could still be alive (false suspicion)Also, other processes might still have heard from p

Page 26: Concurrent Object-Oriented Programmingse.inf.ethz.ch/old/teaching/ss2005/0268/lectures/Lect4.pdf · Illustration: Java import java.rmi.*; public interface HelloInterface extends Remote

26

Chair of Software Engineering P. Eugster

In other Terms

For reasoning about programsWe need to reason about (certain) operationsYet, operations are usually divisible

In the face of concurrencyCan introduce indivisible operations, e.g., masking interruptions in lock() and unlock()

In the face of failuresBy making sure that an action takes full effect or noneBut how? Failures are not controlled by us..

Page 27: Concurrent Object-Oriented Programmingse.inf.ethz.ch/old/teaching/ss2005/0268/lectures/Lect4.pdf · Illustration: Java import java.rmi.*; public interface HelloInterface extends Remote

27

Chair of Software Engineering P. Eugster

Example: Reliable Broadcast

Integrity: a message is rdelivered at most once, and only if it was previously rbroadcastValidity: if a correct process p rbroadcasts a message m, it eventually rdelivers mAgreement: every message relivered by a correct process p is relivered by every correct process q

With reliable channels (rsend / rreceive):broadcast(m): rsend(m) to every process p

upon rreceive(m) for the first time:rsend(m) to every process pdeliver(m)

Page 28: Concurrent Object-Oriented Programmingse.inf.ethz.ch/old/teaching/ss2005/0268/lectures/Lect4.pdf · Illustration: Java import java.rmi.*; public interface HelloInterface extends Remote

28

Chair of Software Engineering P. Eugster

Attitudes towards Failures

NoteAssumptions are necessary given impossibility results

AgnosticismSafety is mainly issue of software, i.e., data (type) safetyStrong assumptions, e.g.,

Reliable channels, no process failuresStatic analysis based on static system, e.g., set of processes, set of exchanged data/messages

Page 29: Concurrent Object-Oriented Programmingse.inf.ethz.ch/old/teaching/ss2005/0268/lectures/Lect4.pdf · Illustration: Java import java.rmi.*; public interface HelloInterface extends Remote

29

Chair of Software Engineering P. Eugster

Attitudes (cont’d)

AwarenessFailure handling

Make failures explicit, e.g., exceptionsForce programmer to deal with them

Failure maskingEmploy specific protocols (based of course on additional assumptions on system)Typically obtained by replication

GoalMaximize simplicity for programmer (abstraction)Minimize assumptions and complexities of mechanisms

Page 30: Concurrent Object-Oriented Programmingse.inf.ethz.ch/old/teaching/ss2005/0268/lectures/Lect4.pdf · Illustration: Java import java.rmi.*; public interface HelloInterface extends Remote

30

Chair of Software Engineering P. Eugster

Typical Assumptions/Workarounds

Often, reliable FIFO channels

Oracles, e.g., Failure detectors

Accuracy: measure of false suspicionsCompleteness: measure of righteous suspicions

Randomization

Majority of correct processes

Page 31: Concurrent Object-Oriented Programmingse.inf.ethz.ch/old/teaching/ss2005/0268/lectures/Lect4.pdf · Illustration: Java import java.rmi.*; public interface HelloInterface extends Remote

31

Chair of Software Engineering P. Eugster

Flavors of Awareness

Failure handling+ Usually rather lightweight mechanisms- Sometimes huge burden for programmer+ Sometimes desired

Failure masking- Usually rather heavyweight mechanisms+ Relieves programmer from any burden+ Sometimes necessary

Page 32: Concurrent Object-Oriented Programmingse.inf.ethz.ch/old/teaching/ss2005/0268/lectures/Lect4.pdf · Illustration: Java import java.rmi.*; public interface HelloInterface extends Remote

32

Chair of Software Engineering P. Eugster

Classic Mechanisms

Replication (masking)High-availability (crash only decreases performance slightly)Heavyweight

Transactions (handling)Make reasoning in case of partial failures easierSupports (heroic) efforts of application in such cases

PersistenceLow-availability (crash affects performance widely)Lightweight

Page 33: Concurrent Object-Oriented Programmingse.inf.ethz.ch/old/teaching/ss2005/0268/lectures/Lect4.pdf · Illustration: Java import java.rmi.*; public interface HelloInterface extends Remote

33

Chair of Software Engineering P. Eugster

(Software) Replication

I00II….I0I

Replica 1

Replica 2

Replica 3

myAccount

myAccount.withdraw()

Page 34: Concurrent Object-Oriented Programmingse.inf.ethz.ch/old/teaching/ss2005/0268/lectures/Lect4.pdf · Illustration: Java import java.rmi.*; public interface HelloInterface extends Remote

34

Chair of Software Engineering P. Eugster

Issues

ConsistencyAll replicas must see commands/queries in same order

Total Order Broadcast et al.Nesting

What if replicas invoke further (replicated objects)

N-to-M invocationsTransparency

What to do with multiple return valuesHow to implement state transfers?

Page 35: Concurrent Object-Oriented Programmingse.inf.ethz.ch/old/teaching/ss2005/0268/lectures/Lect4.pdf · Illustration: Java import java.rmi.*; public interface HelloInterface extends Remote

35

Chair of Software Engineering P. Eugster

(Total) Order

Page 36: Concurrent Object-Oriented Programmingse.inf.ethz.ch/old/teaching/ss2005/0268/lectures/Lect4.pdf · Illustration: Java import java.rmi.*; public interface HelloInterface extends Remote

36

Chair of Software Engineering P. Eugster

Nesting

Page 37: Concurrent Object-Oriented Programmingse.inf.ethz.ch/old/teaching/ss2005/0268/lectures/Lect4.pdf · Illustration: Java import java.rmi.*; public interface HelloInterface extends Remote

37

Chair of Software Engineering P. Eugster

State Transfer

Page 38: Concurrent Object-Oriented Programmingse.inf.ethz.ch/old/teaching/ss2005/0268/lectures/Lect4.pdf · Illustration: Java import java.rmi.*; public interface HelloInterface extends Remote

38

Chair of Software Engineering P. Eugster

Transactionspublic void transfer(BankAccount account1,

BankAccount account2) {Transaction t = new Transaction();try {

t.start();my1stAccount.withdraw(amount);my2ndAccount.deposit(amount);

} catch(…) { … t.abort();… }} finally { t.commit; }

}

public void transfer(BankAccount account1, BankAccount account2) {

atomic {my1stAccount.withdraw(amount);my2ndAccount.deposit(amount);

} catch(…) { … }}

or

Page 39: Concurrent Object-Oriented Programmingse.inf.ethz.ch/old/teaching/ss2005/0268/lectures/Lect4.pdf · Illustration: Java import java.rmi.*; public interface HelloInterface extends Remote

39

Chair of Software Engineering P. Eugster

Issues

ConsistencySerialization of operationsReducing locking (optimisitic)

Nesting Dealing with long transactions

TransparencyPropagating transactional contextsExpressing transactions in language

Inheritance et al.Rollbacks/compensation (optimistic transactions)

Page 40: Concurrent Object-Oriented Programmingse.inf.ethz.ch/old/teaching/ss2005/0268/lectures/Lect4.pdf · Illustration: Java import java.rmi.*; public interface HelloInterface extends Remote

40

Chair of Software Engineering P. Eugster

Serialization Order

T1

T2

myAccount.close()

myAccount.withdraw()

myAccount.withdraw()

myAccount.balance()

Page 41: Concurrent Object-Oriented Programmingse.inf.ethz.ch/old/teaching/ss2005/0268/lectures/Lect4.pdf · Illustration: Java import java.rmi.*; public interface HelloInterface extends Remote

41

Chair of Software Engineering P. Eugster

Context Propagation

Page 42: Concurrent Object-Oriented Programmingse.inf.ethz.ch/old/teaching/ss2005/0268/lectures/Lect4.pdf · Illustration: Java import java.rmi.*; public interface HelloInterface extends Remote

42

Chair of Software Engineering P. Eugster

Approaches to and

Possibilities [Briot et al.‘98]1. The library approach2. The reflection approach3. The integration approach

Page 43: Concurrent Object-Oriented Programmingse.inf.ethz.ch/old/teaching/ss2005/0268/lectures/Lect4.pdf · Illustration: Java import java.rmi.*; public interface HelloInterface extends Remote

43

Chair of Software Engineering P. Eugster

Library Approach

Group communication toolkitsIsis [Birman et al.], …In Java JGroups etc.

Explicit way of going about replicationProgrammer deals with

Plurality (multiple replies)State transfer: implement get-/setState()

Joining, leavingRequired guarantees: reliable, total order, causal order, …

Page 44: Concurrent Object-Oriented Programmingse.inf.ethz.ch/old/teaching/ss2005/0268/lectures/Lect4.pdf · Illustration: Java import java.rmi.*; public interface HelloInterface extends Remote

44

Chair of Software Engineering P. Eugster

Example

public class MyClient {…public static void main(String[] args) {

Group g = Group.lookup(“/myGroup”);g.setProtocol(“tobcast”);Object[] rets = g.broadcast(…);…

}…

}

public class MyServer extends Skeleton implements Replica {

public Object getState() { … }public void setState(Object state) { … }

public MyServer() { super(); join(“/myGroup”); }

public Object receive(Object[] args) { … }…

}

Page 45: Concurrent Object-Oriented Programmingse.inf.ethz.ch/old/teaching/ss2005/0268/lectures/Lect4.pdf · Illustration: Java import java.rmi.*; public interface HelloInterface extends Remote

45

Chair of Software Engineering P. Eugster

Transactions

Transactions can be similarly dealt with

And even

public class MyTransactionalServer … implements Transactional {

public boolean vote() { … }public void commit(…) { … }public void abort(…) { … }…

}

public class MyTransactionalServer … implements Transactional {

public void myMethod1(myArg1 arg1, …, TransactionContext ctxt) {…}

}

Page 46: Concurrent Object-Oriented Programmingse.inf.ethz.ch/old/teaching/ss2005/0268/lectures/Lect4.pdf · Illustration: Java import java.rmi.*; public interface HelloInterface extends Remote

46

Chair of Software Engineering P. Eugster

Evaluation

No surprises

Servers/replicas must implement APIFor state transfer, commit etc.

Common approach: application serverComponents are replicatedRun under the control of containerEvery in-/outgoing invocation is intercepted

Page 47: Concurrent Object-Oriented Programmingse.inf.ethz.ch/old/teaching/ss2005/0268/lectures/Lect4.pdf · Illustration: Java import java.rmi.*; public interface HelloInterface extends Remote

47

Chair of Software Engineering P. Eugster

Reflection Approach

Initial idea based on InterceptorsFilters for in-/outgoing invocations

Flown into Aspect-Oriented ProgrammingReplication aspectTransaction aspect…

Page 48: Concurrent Object-Oriented Programmingse.inf.ethz.ch/old/teaching/ss2005/0268/lectures/Lect4.pdf · Illustration: Java import java.rmi.*; public interface HelloInterface extends Remote

48

Chair of Software Engineering P. Eugster

Example

aspect Transactionizer {pointcut transfer() :

calls(void Teller.transfer(BankAccount, BankAccount));around() : transfer() {

boolean aborted = false;Transaction t = new Transaction();try { proceed(); } catch(TransactionalException e) {

aborted = true;t.abort();throw e;

} finally { if (!aborted) t.commit(); }}

}

public class Teller {public void transfer(BankAccount account1,

BankAccount account2) {my1stAccount.withdraw(amount);my2ndAccount.deposit(amount);

}}

Page 49: Concurrent Object-Oriented Programmingse.inf.ethz.ch/old/teaching/ss2005/0268/lectures/Lect4.pdf · Illustration: Java import java.rmi.*; public interface HelloInterface extends Remote

49

Chair of Software Engineering P. Eugster

Evaluation

Known benefits of AOP/reflection approachSeparation of concerns

Divide efforts and expertise among programmers

Known disadvantagesTransparency in main code misleading

Falsely promotes orthogonality

Page 50: Concurrent Object-Oriented Programmingse.inf.ethz.ch/old/teaching/ss2005/0268/lectures/Lect4.pdf · Illustration: Java import java.rmi.*; public interface HelloInterface extends Remote

50

Chair of Software Engineering P. Eugster

Integration Approach

TransactionsNeed to denote “atomic” sections (e.g., methods)What to do in case of abort?

Client-side: retry automatically or exceptionServer-side: automatic rollback?

ReplicationReplicated objects are invoked as usual through proxiesMultiple replies and policies handled through libraries

Page 51: Concurrent Object-Oriented Programmingse.inf.ethz.ch/old/teaching/ss2005/0268/lectures/Lect4.pdf · Illustration: Java import java.rmi.*; public interface HelloInterface extends Remote

51

Chair of Software Engineering P. Eugster

Example…transfer (a1, a2: separate ACCOUNT; amount: INTEGER) isrequire

a1.balance => amountatomic

a1.withdraw(amount)a2.deposit(amount)

ensurea1.balance = old a1.balance – amounta2.balance = old a2.balance + amount

end

keep_trying isdo

transfer(bill_gates_account, my_account, 1000000)rescue

retryend…

Page 52: Concurrent Object-Oriented Programmingse.inf.ethz.ch/old/teaching/ss2005/0268/lectures/Lect4.pdf · Illustration: Java import java.rmi.*; public interface HelloInterface extends Remote

52

Chair of Software Engineering P. Eugster

Evaluation

Clearly cleanest approachDivision of responsibility

without false promises

Drawback: interoperabilityNot all languages support it

Somebody has to lead the path…