2 GlobalStore Module Application Programming Interface

The interface functions to use the GlobalStore module are the following:

2.1 Initialise a new global store (GS) and connect to GS

GlobalStore.newStore

{GlobalStore.newStore ?BootLocalStore}

newLocal

{BootLocalStore newLocal(Module UserName ?NewObj ?LocalStore ?MoveHere)}

{LocalStore newLocal(Module UserName1 ?NewObj1 ?LocalStore1 ?MoveHere1)}

Creates a new global store together with a procedure BootLocalStore which can be used to create local stores on different sites. A local store is a single site's reference into the global store.

  • the BootLocalStore and LocalStore calls can be executed on any site.

  • A LocalStore created by one of these calls can itself create more LocalStores, and so forth recursively. That is, the creation of LocalStores is fully distributed.

  • LocalStore is sited except for the newLocal method , which can be executed on any site.

  • NewObj is a sited reference; it can be executed only on the site on which it was created.

  • MoveHere is a non-sited reference; it can be executed on any site

  • The call newStore throws a gs(failed_globalstore_creation) exception when no global store is created.

  • The call newLocal throws a gs(connectionfailed) exception if it fails to connect to the global store.

  • UserName is an atom or a string identifying a user and Module is the ressource Module Manager in the system.

2.2 Create new objects in the GS

NewObj

O={NewObj Class Init}

Add a new object O to the store. The call NewObj is synchronous. O is an object reference in the global store.The new object is immediately broadcast to the other clients. If there is a failure, then the new object will survive if at least one surviving client contains the new object. Class is any Oz class with the following restrictions:

  • no reference to ressources.

  • no references to external states i.e. logic variables, cells, objects including global store object references. In the next release of Mozart, global store object can have references to other global store objects.

2.3 Initialise new transactions

The user interacts with the global store by using transactions:

trans

{LocalStore trans(Trans ?OutPut ?Transid)}

Initialises a transaction Trans which is a procedure of one argument. The argument Output is a computed return value in Trans. A gs(ill_formed_transaction) is raised when Trans is not a one argument procedure. The procedure must have the following properties:

  • Transactions have no external references to: objects, cells, variables and global store objects.

  • At a single user, execution of transactions are serialized.

2.3.1 Calls inside transactions

These functions are only used inside a transaction. If one of this function is called outside a transaction the exception gs(invalidcall) is raised.

apply a method on an object

{O Meth}

O is a reference to an object in the store.

waitlocks

{LocalStore waitlocks(Objects)}

Wait for locks on Objects: If the locks are not obtained the transaction is aborted.

newthread

{LocalStore newthread(Proc)}

The call newthread inside a transaction procedure executes Proc of 0 arguments in a separate thread.

retrans

{LocalStore retrans(Proc  ?Output ?ReTransid)}

The call retrans confirms all updates of the transaction Transid that have already committed without waiting its end. The initial transaction Transid is mapped to a new transaction ReTransid. Initially, the new transaction has the set of Transid objects.

2.4 Check transactions

The user checks the states of transaction by the following call

checktrans

{LocalStore checktrans(Transid ?Res ?Nb)}

Checks if a transaction was committed or aborted. Res is a commit, abort atom or is a free variable that will be bound as soon as the transaction receives abort or commit. Since the computation of a transaction is speculative, it is useful to know the number of time Nb that the Transid is recomputed.

2.5 Delete Object from GlobalStore

The user delete an object from GolbalStore by the following call

deleteobj

{LocalStore deleteobj(ObjRef ?Res)}

This call will successfully delete an object from the store if it can obtain the lock.Res is a commit, abort atom or is a free variable that will be bound as soon as the transaction receives abort or commit.

2.6 Disconnect from GlobalStore

The user can disconnect normally from GolbalStore by the following call

disconnect

{LocalStore disconnect}

This call will successfully disconnect the caller from Globalstore. This call will change the current membership, and every member in GS will be notified about the latest membership.

2.7 Global Store migration

we can migrate the global store by calling the MoveHere procedure. The MoveHere procedure is returned by the newLocal call.

MoveHere

{MoveHere Module LocalStore Proc}

The call migrates the global store to the site where the one argument MoveHere procedure is executed. LocalStore is a returned sited reference to the store in the site where the call MoveHere is executed. Module is the ressource Module Manager in the system. Proc is a user defined zero argument procedure. Proc is executed in the site where the call MoveHere is executed.

2.8 Notification methods

To communicate with user applications, the global store offers notify procedures are of three kinds: Creation, Update, and Delete procedures. Creation procedures are called upon creation of a GlobalStore object. Update procedures are called whenever the state of a GlobalStore object is changed coherently. Delete procedures are called whenever a GlobalStore object is deleted. One Creation, Update, or Delete procedure can be installed per client and per object. A Notify procedure installed by a client will be executed only by that client on that client's site. functions to notify a user for a creation of a new object and for object update in the GS. Notify procedures must respect the following rules:

setnotifycreation

{LocalStore setnotifycreation(Proc)}

Proc is a user defined one argument procedure executed when another user creates a new object in the global store. Proc is executed on all remote local stores. The argument of Proc is a reference to the new object in the store.

setnotifyupdate

{LocalStore setnotifyupdate(Proc)}

Proc is a user defined one argument procedure executed when an object in the global store is updated by other users. Proc is executed on all remote local stores. The argument of Proc is a reference to the updated GS object.

setnotifydelete

{LocalStore setnotifydelete(Proc)}

Proc is a user defined one argument procedure executed when an object in the global store is deleted by other users. Proc is executed on all remote local stores. The argument of Proc is a reference to the deleted GS object.

setnotifyabort

{LocalStore setnotifyabort(Proc)}

Proc is a user defined one argument procedure executed when restoring the state of a GS object after a transaction abort. Proc is executed on the current local store only. The argument of Proc is a reference to a GS object of the aborted transaction. setactionmyacount(P)

setnotifymembership

{LocalStore setnotifymembership(Proc)}

Proc is a user defined one argument procedure executed when there is a change in the memership (user connected, or disconnected). the argument of this Proc will be the list of current membership (username1#id1,...usernmaen#idn).

setnotifymyacount

{LocalStore setnotifymyacount(Proc)}

Proc is a user defined one argument procedure executed when the user is connected to GlobalStore. the argument of this Proc will be the user's account (username#id)

setnotifyrecovery

{LocalStore setnotifyrecovery(Proc)}

Proc is a user defined zero argument procedure executed when there is a recovery after server's failure and this will only executed at the leader site. Every user must set this setnotifyrecovery.

2.9 Export/Import GS object references

Currently, global store object references are exported and imported using saveobj and getobj functions. In the next release, those references will have the distribution transparency property i.e. GS references like classic Oz objects references will be non-sited references.

saveobj

{LocalStore  saveobj(Obj ?N)}

N is a name (constant) that can be passed external to the global store.

loadobj

{LocalStore  loadobj(N ?Obj)}

N is the name that contains the global object reference already created at another user. Obj is a the reference to the N at the store LocalStore. if the imported object is lost, a gs(objectlost) exception is raised. All transactional calls on N objects from other users give a gs(invalidcall) exception.


Mostafa AL-Metwally, Ilies Alouini
Version 1.2.0 (20010319)