O conteudo do presente relatorio e de unica resp onsabilidade dos autores

The contents of this rep ort are the sole resp onsibility of the authors

An Overview of MOLDS A MetaOb ject

Library for Distributed Systems

Alexandre Oliva Luiz Eduardo Buzato

Relatorio Tecnico IC

Abril de

An Overview of MOLDS

A MetaOb ject Library for Distributed Systems

Alexandre Oliva Luiz Eduardo Buzato

olivadccunicampbr buzatodccunicampbr

Lab oratorio de Sistemas Distribudos

Instituto de Computacao

Universidade Estadual de Campinas

April

Abstract

This pap er presents a library of metaob jects suitable for developing distributed systems The reexive

architecture of Guarana makes it p ossible for these metaob jects to b e easily combined in order to form

complex dynamically recongurable metalevel b ehavior We briey describ e the implementation of

Guarana on Java Then we explain how several metalevel services such as p ersistence distribution

replication and atomicity can b e implemented in a transparent and exible way

Resumo

Este artigo apresenta uma biblioteca de metaob jetos adequada para o desenvolvimento de sistemas

distribudos A arquitetura reexiva Guarana torna p ossvel que esses metaob jetos sejam facilmente

combinados a m de desemp enhar comp ortamento de metanvel complexo e reconguravel dinamica

TM

mente Descrevese sucintamente a implementacao de Guarana em Java Em seguida explicase

como varios servicos de metanvel como p ersistencia distribuicao replicacao e atomicidade p o dem ser

implementados de forma transparente e exvel

Keywords Reection Distributed Ob jects Persistence Replication Atomic Actions

Java is a trademark of Sun Microsystems Inc

Intro duction A metaob ject may reply with a result for the

op eration an alternate op eration to b e p erformed

Computational reection henceforth just re

instead of the one requested by the baselevel or a

ection has proven to b e a useful feature for build

request for the original op eration to b e p erformed

ing distributed systems in a transparent way

Unless it provides a result itself it may ask to b e

presented the result of the op eration after it is p er

Guarana is a reexive architecture that aims

formed or even to b e able to mo dify this result

at reuse of reexive solutions It provides sim

Any metaob ject is an instance of the class

ple mechanisms for combining multiple metaob jects

MetaObject that is a Java class just like any other

into the metalevel conguration of a single ob ject

Hence its instances may b e made reexive to o by as

These metaob jects may implement metalevel re

so ciating them with other metaob jects which leads

quirements such as distribution p ersistence repli

to the socalled p otentially innite tower of meta

cation atomicity etc

ob jects This class may b e sp ecialized sub

This pap er is organized as follows In Section

classed which leads to one of the key concepts intro

we briey describ e our implementation of the re

duced by Guarana a sub class of MetaObject called

exive architecture of Guarana on top of a mo di

Comp oser

ed freelyavailable Java Virtual Machine Then we

A comp oser is a metaob ject that delegates op er

intro duce MOLDS a library of metaob jects that

ations and results to other metaob jects Comp osers

provide essential features for developing reliable dis

may delegate to metaob jects sequentially or concur

tributed systems Finally in Section we summarize

rently or following whatever p olicy ts the needs of

the b enets of designing a library such as MOLDS in

a develop er A sample comp oser is provided that

a reexive architecture like Guarana and describ e

delegates op erations to the elements of an array of

the current state of development of b oth Guarana

metaob jects and delegates results to the same meta

and MOLDS

ob jects in the reverse order

Some of the delegatee metaob jects of a com

p oser can b e comp osers themselves which leads to

The Javabased implementa

a hierarchical organization of the metaob jects di

rectly or indirectly asso ciated with a baselevel ob

tion of Guarana

ject This organization called the ob jects meta

conguration is orthogonal to the tower of meta

Java is a simple yet p owerful ob jectoriented

ob jects each metaob ject may have its own indep en

language Java classes are compiled into highlevel

dent metaconguration Furthermore a metaob ject

ob jectoriented crossplatform byteco des that can b e

may b elong to the metaconguration of more than

executed on Java Virtual Machines JVM Since the

one ob ject

sp ecication of the JVM is op en anyone can im

Asso ciating an ob ject with its primary meta

plement it so Java has b ecome available on several

ob ject is an op eration provided by the kernel of

dierent hardware platforms and freelymo diable

Guarana In fact this op eration is so general that

and redistributable source co de for some of these im

it allows any metaob ject in a metaconguration to

plementations is available at no cost The reexive

b e replaced with another Any reconguration must

architecture of Guarana was implemented on top of

b e approved by the previous metaconguration if

one of these platforms

the baselevel ob ject was not reexive its class is in

In Guarana every Java ob ject may b e directly

formed ab out the reconguration request and may

asso ciated with zero or one metaob ject called the

prevent it

ob jects primary metaob ject An ob ject that is as

so ciated with a metaob ject will b e called a reex Ob jects created by reexive ob jects have their

2

ive ob ject Every op eration targeted to a reexive metacongurations determined by their creators

ob ject is intercepted reied represented as a meta metaconguration Furthermore the meta

level ob ject and presented to the ob jects primary conguration of the class of the new ob ject is notied

metaob ject b efore the ob jects constructor is invoked so that it

By op eration we mean metho ds and constructors invo cations monitor synchronized enter and exit op erations eld reads

and writes Since Java arrays are ob jects to o array elements reads and writes as well as array length reads are considered

op erations to o

may try to mo dify the metaconguration of its new Persistence

instance The kernel of Guarana makes it p ossi

ble to create pseudoob jects that are uninitialized in

A p ersistent ob ject is one whose lifetime spans

stances of a given class These ob jects may b e turned

the application that created it The state of p er

into real ob jects by invoking a constructor or initial

sistent ob jects can b e stored in les databases or

izing its elds but it may remain a pseudoob ject

longrunning pro cesses An ob ject can b e made p er

and b e used for example as a proxy of an ob ject

sistent by simply adding a p ersistence metaob ject to

in a separate address spaces The metaconguration

its metaconguration

of the class the pseudoob ject b elongs to is also no

A p ersistence metaob ject may b e implemented

tied so it may mo dify the pseudoob jects meta

using two dierent approaches i it may intercept

conguration or even prevent the creation of the

all eld up date op erations and up date the p ersis

pseudoob ject

tent storage accordingly p ossibly in background or

This notication is done by using another op er

ii it may up date the p ersistent storage only when the

ation provided by the kernel of Guarana any in

p ersistent ob ject is no longer used by the running ap

stance of a class that implements the interface Mes

plication

sage can b e broadcasted to p ossibly all comp onent

Whatever the choice every ob ject must b e given

metaob jects of a metaconguration of an ob ject

a unique identier that can b e used for maintain

Such an op eration is necessary b ecause for security

ing references from one p ersistent ob ject to another

reasons we made it is imp ossible to obtain a refer

as well as for reincarnating an ob ject from p ersistent

ence to the primary metaob ject of an ob ject Fur

storage into a running application This unique iden

thermore we b elieve this helps maintaining a clear

tier might b e maintained by the p ersistence meta

separation of concerns b etween the base and the meta

ob ject itself however a unique identier may b e use

level just like encapsulation encourages go o d ob ject

ful for other purp oses so we recommend the creation

oriented design

of a separate identication metaob ject

Guarana provides an interface that allows arbi

Whenever an ob jecttyp e eld of a p ersistent ob

trary Op eration ob jects to b e created in the meta

ject is assigned to the referredto ob ject must also

level even op erations that would violate encapsu

b e made p ersistent otherwise it will not b e p ossible

lation can b e created and p erformed by using this

to recreate the complete state of the referring ob ject

interface However for the sake of security such

afterwards This can b e accomplished by probing the

op erations must b e created using Op erationFactory

metaconguration of this ob ject with a broadcast

ob jects that are given to metaob jects whenever

message If no p ersistence nor identication meta

they are asso ciated with an ob ject This ensures

ob ject exists in the ob jects metaconguration the

that only comp onent metaob jects of an ob jects

ob ject must recongured so as to b ecome p ersistent

metaconguration and metalevel ob jects trusted by

or the eld assignment must b e denied by throwing

them can obtain priviledged access to this ob ject

an exception

Comp osers may distribute restricted op eration facto

In order to reincarnate a p ersistent ob ject there

ries to metaob jects they delegate to

are two p ossible approaches i the p ersistence meta

library may provide a metho d that can b e called from

the base level that reincarnates an ob ject given its

unique identication or ii a baselevel reexive con

Reusable MetaOb jects for

tainer that represents the p ersistent storage may b e

Distributed Systems

used to reincarnate p ersistent ob jects transparently

An ob ject is reincarnated by creating a pseudo

The metalevel proto col of Guarana was designed ob ject whose elds are lled in from the p ersistent

in a way that makes it p ossible to create meta storage Reincarnation of referred ob jects can b e

ob jects that implement sp ecic metalevel b ehav done on demand as they are accessed from the base

iors and to easily comp ose them into complex meta level Even elds might b e reincarnated individu

congurations In this section we delineate how some ally The implementation of such metaob ject would

metalevel services for distributed computing can b e b e much more complicated but it may pay o if the

implemented in Guarana ob jects state is large enough

Replication ies to remote replicas metaob jects in every address

space so that they can communicate This is not an

Ob ject replication may b e used in order to in

overkill since group communication proto cols usu

crease availability and faulttolerance of an ob ject If

ally require every memb er of the group to know every

one replica fails others may keep the ob ject running

other memb er

There is a very simple way of implementing repli

cation with Guarana Every replica executes meth

Caching

o ds and reads elds without exchanging information

with other replicas Field mo dications however are

Having to send every single op eration targeted to a

broadcasted to all replicas in a totallyordered

remote ob ject through the network may cause seri

way so that all replicas p erform eld writes in the

ous negative impact on the p erformance of an appli

same sequence Synchronization op erations must b e

cation On the other hand replicating an ob ject may

sub ject to the same total order

intro duce to o much overhead for an ob ject that is

Other replication mechanisms may broadcast

frequently up dated

metho d invo cations and even eld read op erations to

An intermediate solution may b e achieved by

multiple replicas then run an election algorithm to

caching the contents of elds of an ob ject in proxy

select a result However this intro duces some prob

ob jects These elds could b e up dated p erio dically

lems that are hard to solve For example when one

or when synchronization op erations take place Up

replicated ob ject interacts with another the interac

date op erations in the proxy ob ject might not need

tion must o ccur as if the ob jects were not replicated

to b e immediately forwarded to the actual ob ject or

at all So when one replicated ob ject invokes an

replicas This is somewhat dep endent on the

other all the individual invo cations must b e identi

requirements of the application but it may prove to

ed as replicas of a single invo cation and the op era

b e very useful in certain situations

tion must b e p erformed only once on each replica of

A caching metaob ject can b e easily implemented

the invoked ob ject

as a comp oser that selectively delegates op erations to

a distribution metaob ject

Distribution

Implementing transparent interaction b etween ob

Migration

jects lo cated in separate virtual machines was made

Ob jects such as mobile agents may have to move

easy by the intro duction of pseudoob jects An ap

from one address space to another This may b e

proach similar to that taken for p ersistence may b e

achieved by creating a replica of the moving ob ject in

used to lo cate remote ob jects There are dierences

the target address space then removing the replica

i instead of lo cating ob jects in a database they will

from the source address space

b e searched for in a distributed name server which

However this may b e to o costly a way to migrate

might b e viewed as a database after all and ii

an ob ject Another p otentially faster approach is to

instead of reincarnating the ob ject a proxy of the

have a metaob ject that stops delivering op erations

remote ob ject is created as a pseudoob ject

to the ob ject as so on as it decides the ob ject must mi

Whenever an op eration is requested to the proxy

grate Then it marshalls the complete internal state

its distribution metaob ject marshalls the op eration

of the ob ject and sends it to a remote metaob ject

and sends a message through a network channel to

that is going to b ecome a memb er of the migrated ob

a metaob ject lo cated in the actual target ob jects

jects metaconguration It creates a pseudoob ject

address space This metaob ject just creates an op

and lls in its elds with the marshalled image of the

eration equivalent to the requested one and delivers it

ob ject At this p oint the original ob ject will have b e

for metalevel interception As so on as a result for the

come a proxy ob ject that simply forwards op erations

op eration is available it is marshalled and returned

to the migrated ob ject until the proxy is garbage col

to the proxys metaob ject which unmarshalls the

lected

result and returns it as the result of the op eration

This facility may b e used as a basis for having If an ob ject migrates many times an op eration

distributed replicas Instead of implementing inter may have to ow through several proxies b efore it

metaob ject communication in the replication meta reaches the actual ob ject In this case it may b e

ob jects themselves now we just have to keep prox useful to have an algorithm that notices whether an

Atomicity ob ject migrated any further and sets up a shortcut

to the most recently known lo cation of the ob ject

Atomic actions involve three prop erties i seri

from then on

alizability that ensures that the execution of concur

We should note that there is some overlap of the

rent atomic actions is equivalent to at least one serial

migration and the p ersistence functionalities Af

execution ii atomicity that is either all its eects

ter all a p ersistent ob ject may b e implemented by

b ecome visible or none do and iii p ermanence of

migrating it to and from a longrunning server pro

eect

cess On the other hand migration could b e easily

The last prop erty requires ob jects involved in an

implemented by storing the mobile ob ject in p ersis

atomic action to b e kept in stable storage so that

tent storage then reincarnating it in another address

even if one of the hosts running a distributed atomic

space

action fails its eects are p ermanent

Instead of implementing one mechanism on top

of another we b elieve the correct approach is to fac

The atomicity prop erty requires a global co ordi

tor out the common functionality required by b oth

nation of all ob jects involved in an atomic action If

mechanisms and implement the dierences as sp e

the atomic action is committed all ob jects involved

cializations Caching metaob jects may also share

must have its states made p ersistent if it ab orts all

functionality with these two mechanisms

ob jects must b e reverted to the states previous to the

b eginning of the atomic action

The serializability prop erty requires some kind of

Accounting

concurrency control on op erations There are op

Metaob jects for accounting can b e easily asso ciated

timistic and p essimistic p olicies Pessimistic algo

with arbitrary ob jects One may count the invo ca

rithms rely on lo cking for ensuring serializable exe

tions of a particular metho d or up dates of a eld

cutions optimistic ones let separate atomic actions

or even complex multiob ject patterns of interaction

op erate on separate copies of ob jects and check for

Classes can b e congured so that all instances are

serializability at commit time

given appropriate accounting metaob jects

Monitoring

Atomic actions may b e totally controlled at the

base level for example by providig a class Atomi

In addition to the ability of maintaining information

cAction that takes an instance of the Java standard

ab out baselevel ob jects it may b e useful for meta

class Runnable as its constructor argument The

ob jects to interact with baselevel ob jects from the

metho d run of this argument is then executed inside

meta level

the atomic action If it terminates successfully the

It is p ossible to interconnect otherwise indep en

transaction is committed if it throws an exception

dent ob jects through metaob jects This can b e used

the atomic action may ab ort

to implement the MVC pattern connecting a

Concurrency control may take place transpar

mo del ob ject with its views transparently the con

ently at the meta level using whatever selected p ol

trol can b e totally implemented in the metalevel

icy However if it is a p essimistic one it should b e

We might also use metaob jects that implement

p ossible to predeclare lo cks for example from b oth

Statecharts to mo del and control the b ehavior

the base and the meta level

of baselevel ob jects Transitions in the Statechart

could b e triggered by the interception of op erations

Instead of explicitly creating and managing

or results there may b e additional conditions for

atomic actions in the base level certain ob jects may

the transition to take place involving the state of

b e congured as atomic ones so that every op

the baselevel ob ject as well as internal metaob ject

eration on that ob ject is p erformed inside an inde

state

p endent atomic action It may b e useful for meta

Monitoring multiple distributed ob jects may re level control of atomic actions to b e able to sp ecify

quire the construction of consistent global snap that a particular op eration should b e p erformed in

shots Algorithms for obtaining consis side a given atomic action as a nested atomic action

tent global snapshots can b e implemented completely or sharing data with other threads running the same

in the metalevel transaction

Conclusion References

Gul Agha Svend Frlund Ra jendra Panwar

The design of Guarana was largely inuenced by

and Danield Sturman A Linguistic Framework

detected needs of a library like MOLDS In fact we

for Dynamic Comp osition of Dep endability Pro

have only started Guarana b ecause no other reex

to cols In DCCA Third IFIP Working Con

ive platform we knew could provide the mo dulariza

ference on Dependable Computing for Critical

tion comp osition reconguration and security fea

Applications pages Septemb er

tures demanded by such a library The choice of Java

as the programming language has just made things

M Ancona G Do dero V Gianuzzi A Clema

easier b ecause of the existing basic reection capa

tis and M L Lisb oa Reective Architectures

bilities and of the libraries for developing networked

for Reusable FaultTolerant Software In PAN

applications

EL XXI Conferencia LatinoAmericana

We b elieve MOLDS will b ecome a very p ower

de Informatica March

ful and sound framework for developing distributed

Ken Arnold and James Gosling The Java Pro

applications but its comp onents still have to b e de

gramming Language AddisonWeslley

tailed further and implemented

M P Atkinson P J Bailey K J Chisholm

This library is a basic part of a larger pro ject

W P Co ckshott and Morrison An approach

The only similar pro ject we have known to date is

to p ersistent programming Computer Journal

Ap ertos a reexive op erating system We

Decemb er

should note however that it is based on a slightly

more limited reexive mo del sp ecically targeted at

Y Berb ers B De Decker and W Jo osen

op erating system development

Infrastructure for mobile agents In Seventh

ACM SIGOPS European Workshop System

Support for Worldwide Applications pages

A Obtaining Guarana and

Philip A Bernstein Vassos Hadzilacos and

MOLDS

Nathan Go o dman Concurrency Control and

Recovery in Database Systems AddisonWesley

Additional information ab out Guarana can b e

found at the Guarana Home Page http

wwwdccunicampbr olivaguarana The com

Stijn Bijnens Wouter Jo osen and Pierre Ver

plete Java API of Guarana the source co de for its

baeten A reective invo cation scheme to realise

implementation and full pap ers can b e downloaded

advanced ob ject management In ObjectBased

from there MOLDS is currently in early design

Distributed Programming ECOOP Work

stage but when you read this pap er there may b e

shop July

up dated information in the home page of Guarana

Kenneth P Birman and Thomas A Joseph Re

Both Guarana and MOLDS are re

liable communication in the presence of fail

leased under the GNU General Public License but its

ures ACM Transactions on Computer Systems

sp ecications are op en so anyone can provide non

Feb

free cleanro om implementations

L E Buzato Management of ObjectOriented

ActionBased Distributed Programs PhD The

sis University of Newcastle up on Tyne Depart

B Acknowledgments

ment of Computer Science Decemb er

This work is partially supp orted by FAPESP LE Buzato HK Liesenb erg CMF Rubira

Fundacao de Amparo a Pesquisa do Estado de R Anido and MBF de Toledo Uma ar

Sao Paulo grant for Alexandre Oliva quitetura de software para o desenvolvimento

and for LSDICUNICAMP Lab oratorio de aplicacoes distribudas conaveis In First

de Sistemas Distribudos Instituto de Computacao Workshop on Distributed Systems WoSid

Universidade Estadual de Campinas Salvador BA Brasil May

Luiz E Buzato and Alcides Calsavara Stabilis Islene Calciolari Garcia and Luiz Eduardo

A Case study in Writing FaultTolerant Dis Buzato Asynchronous Construction of Consis

tributed Applications Using Persistent Ob jects tent Global Snapshots in the Ob ject and Action

In A Albano and R Morrison editors Proceed Mo del In Proceedings of the th International

ings of the Fifth International Workshop on Per Conference on Congurable Distributed Systems

sistent Object Systems Workshops in Comput Annap olis Maryland EUA May IEEE

ing pages San Miniato Italy Septem Available as Technical Rep ort IC

b er SpringerVerlag

Islene Calciolari Garcia and Luiz Eduardo

Buzato Cortes consistentes em aplicacoes dis

Roy H Campb ell Nayeem Islam David Raila

tribuidas Technical Rep ort IC Insti

and Peter Madany Designing and Implementing

tuto de Computacao Universidade Estadual de

Choices An Ob jectOriented system in C

Campinas April

Communications of the ACM

Septemb er

Adele Goldb erg and David Robson Smal ltalk

The Language and Its Implementation

M Chandy and L Lamp ort Distributed Snap

AddisonWesley rst edition

shots Determining Global States of Distributed

Systems ACM Transactions on Computing Sys

James Gosling Bill Joy and Guy L Steele

tems February

The Java Language Specication Java Series

AddisonWesley Septemb er Version

Shigeru Chiba and Takashi Masuda Designing

David Harel Statecharts A visual formalism

an extensible distributed language with a meta

for complex systems Science of Computer Pro

level architecture In NM Nierstrasz editor

gramming pages August

ECOOP pages

Jurgen Kleinoder and Michael Golm Trans

Marlia Gabriela Co elho Ceclia Mary Fischer

parent and adaptable ob ject replication using

Rubira and Luiz Eduardo Buzato Uma ab or

a reective Java Technical Rep ort TRI

dagem reexiva para a construcao de frame

Universitat ErlangenNurn b erg IMMD IV

works para interfaces homemcomputador In

Septemb er

XI Simposio Brasileiro de Engenharia de Soft

ware SBES pages Fortaleza CE

Rivka Ladin Barbara Liskov and Liuba Shrira

Octob er

Lazy replication Exploiting the semantics of

distributed services In Proceedings of the th

Rob ert Co op er and K Marzullo Consistent De

ACM Symposium on Principles of Distributed

tection of Global Predicates SIGPLAN Notices

Computing pages Queb ec City Queb ec

Decemb er

Canada Aug

Tim Lindholm and Frank Yellin The Java

Marc Shapiro et al SSP chains In Symposium

Virtual Machine Specication Java Series

on Principles of Distributed Computing acm

AddisonWesley January

Peter W Madany Nayeem Islam Panos Kou

J C Fabre T Perennou and L Blain Meta

giouris and Roy H Campb ell Reication and

ob ject Proto cols for Implementing Reliable and

reection in C An op erating system p er

Secure Distributed Applications Technical

sp ective Technical rep ort University of Illinois

Rep ort LASS Centre National de la

at UrbanaChampaign March

Recherche Scientique February

Pattie Maes Concepts and exp eriments in com

JeanCharles Fabre Vincent Nicomette Tanguy

putation reection ACM SIGPLAN Notices

Perennou and Zhixue Wu Implementing Fault

Decemb er

Tolerant Applications using Reective Ob ject

Oriented Programming In th Simposium on Kideaki Okamura and Yutaka Ishikawa Ob

FaultTolerant Computing Systems pages ject Lo cation Control Using Metalevel Pro

Pasadena CA June gramming In ECOOP pages

Alexandre Oliva Islene Calciolari Garcia and ECOOP th European Conference pages

Luiz Eduardo Buzato The reexive architec August

ture of Guarana Technical Rep ort IC In

Rob ert Stroud Transparency and reection

stituto de Computacao Universidade Estadual

in distributed systems In th European

de Campinas April

SIGOPS Workshop on Models and Paradigms

for Distributed Systems Structuring Mont Saint

Andreas Paep cke PCLOS A exible imple

Michel France Septemb er ACM SIGOPS

mentation of CLOS Persistence In ECOOP

IRISA INRIARennes

pages August

Rob ert J Stroud and Zhixue Wu Using metaob

Fred B Schneider Implementing faulttolerant

ject proto cols to satisfy nonfunctional require

services using the state machine approach A tu

ments In Chris Zimmermann editor Advances

torial ACM Computing Surveys

in ObjectOriented Metalevel Architectures and

Decemb er

Reection chapter pages CRC Press

Brian C Smith Prologue to Reection and Se

mantics in a Pro cedural Language PhD Thesis

Yasuhiko Yokote The Ap ertos reective op er

Prologue

ating system The concept and its implementa

R J Stroud and Z Wu Using metaob jects to

tion In Proceedings OOPSLA ACM SIG

adapt a p ersistent ob ject system to meet applica

PLAN Notices volume pages Oc

tions needs In th SIGOPS European Workshop

tob er

on Matching Operating Systems to Applications

Yosuhiko Yokote Fimio Teraoka and Mario

Needs

Tokoro A reective architecture for an ob ject

oriented distributed op erating system In R J Stroud and Z Wu Using Metaob ject Pro

ECOOP to cols to Implement Atomic Data Typ es In