2 GlobalStore Module Application Programming Interface

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

2.1 Create a new global store (GS) and connect to it

GlobalStore.new

{GlobalStore.new ?GS}

Creates a new global store GS where GS can be executed at any site using the following call:

newLocal

{GS newLocal(Module UserName ?UserId ?NewObj ?LocalStore ?MoveHere)}

Creates a new LocalStore i.e. connect to Global Store. Each LocalStore can be used again by another site to connect to GlobalStore.

  • A local store is a single site's reference into the global store.

  • the GS and newLocal calls can be executed on any site.

  • Module is the ressource Module Manager in the system.

  • UserName is an atom or a string identifying a user.

  • UserId is a unique identifier given to a user.

  • NewObj is a sited reference; it can be executed only on the site on which it was created. Used to add a new object to the store.

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

  • MoveHere is a non-sited reference; it can be executed on any site to move the server to that site.

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

  • 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 decenralized.

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

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 that is uniquely identified. The new object is immediately broadcasted to the other clients. Object can refrence to other object in the store. Class is any Oz class with the following restrictions:

  • getuniqueobjectid($) method is defined by GlobalStore for any object from any class. This call returns Oz name. Example:

    X={O getuniqueobjectid($)}

  • no reference to resources e.g. file system, graphics interfece, objects that are not in GS, cells, variables, ports, etc.

2.3 Query single object

object_query

{O Method}

At any time without a transaction one can apply a read only method on O (a method that will not change object state). Applying a method that will change O's state should be called inside a transaction. However, if rhe method invocation will change the object state, this does not change the object itself but affects its copy.

2.4 Initiate a new transaction

The user interacts with the global store by using transactions:

trans

{LocalStore trans(Trans ?Out ?Result)}

Initiates a transaction Trans which is a procedure of one argument.This call is asynchronous. The argument Output is a computed return value in Trans. The argument Result is initially unbound. It is bound to the atoms commit or abort. This argument will be bound as soon as global store determine the transaction state. A gs(ill_formed_transaction) exception is raised when Trans is not a one argument procedure. At a single user, execution of transactions are serialized. The procedure must have the following property:

  • Transactions have no external references to statful entities, such as objects that are not in GS, cells, variables and ports.

2.4.1 Calls inside transaction

These functions can be called inside a transaction.

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.

retrans

{LocalStore retrans(Proc  ?Output ?TranRes)}

The call retrans confirms all updates of the original (father) transaction that have already committed without waiting its end. The initial transaction result Res is mapped to a new transaction's result TransRes. Initially, the new transaction has the set of objects that its father has.

2.5 Delete Object from GS

The user can delete an object from GlobalStore by the following call

deleteobj

{LocalStore deleteobj(ObjRef ?Res)}

This call will successfully delete an object from the store if it can obtain its lock. Res is initially unbound. It is bound to the atomes commit, abort. This call is synchronous.

2.6 Disconnect from GS

The user can disconnect normally from GolbalStore by the following call

disconnect

{LocalStore disconnect(R)}

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

2.7 Global Store migration

GS can migrates 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 at the site where the call MoveHere is executed.

2.8 Notification procedures

In order to communicate with user applications, the Golbal Store offers notify procedures of three kinds:

A Notify procedure installed by a client is executed only by that client on its site. 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 the local store. The argument of Proc is a reference to the new object in the store. a method that not change the object state could be called inside the notification to read the most recent state for the object.

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 the local store. The argument of Proc is a reference to the updated GS object. This reference can be called with a method that will not change its state.

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 the local store. The argument of Proc is a reference to the deleted GS object. The object only be used temporarily inside the notification.

setnotifymembership

{LocalStore setnotifymembership(Proc)}

Proc is a user defined one argument procedure executed when there is a change in the membership (user connected, or disconnected). The argument of this Proc will be the list of current membership (username1#Id1,...username#Idn). Where Username1 is an atom or string issued by the user and Id is globally unique and neverchanges for a user.

setnotifyrecovery

{LocalStore setnotifyrecovery(Proc)}

Proc is a user defined zero argument procedure executed when there is a recovery after server's failure and this is only executed at the new server site. To guarantee its execution upon recovery, every user must set this setnotify recovery.


Ilies Alouini, Mostafa AL-Metwally, Peter Van Roy
Version 1.3.0 (20030218)