<< Prev | - Up - | Next >> |
GlobalStore
Module Application Programming Interface The interface functions to use the GlobalStore
module are the following:
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.
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. 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.
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.
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.
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.
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.
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:
A Notify procedure can use in any way any language entity outside of the GlobalStore, e.g., resources, ports, cells, or objects that are not part of the GlobalStore. There are no restrictions.
A Notify procedure is given a coherent view of the GlobalStore, and it may call GlobalStore objects in any way. However, any changes done by these calls will be canceled after the Notify procedure exits.
The execution of a Notify procedure is serialized with transaction executions at a client. Therefore, the Notify procedure should not be too time-consuming, as this will delay the execution of transactions at that client.
A Notify procedure may initiate transactions, but it should not wait until a transaction completes. Otherwise, deadlock will occur.
A Notify procedure must use {LocalStore newThread(P)} to create new threads. The system considers then that the Notify procedure completes when all these threads complete.
A Notify procedure *may* use thread S end, but only if S refers to no GlobalStore objects and does no transactions. This ability should be used with extreme care: in most cases, newThread(P) should be used.
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.
setnotifycommit
{LocalStore setnotifycommit(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.
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.
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 FNexportedObj)}
FNexportedObj
is a Filename that stores a global reference to Obj
. The call enables to notify other users for new object references in the store.
getobj
{LocalStore getobj(FNexportedObj ?Obj)}
FNexportedObj
is a Filename that contains the global object reference already created at another user. Obj
is a the reference to the FNexportedObj
at the store LocalStore
. if the imported object is lost, a gs(objectlost)
exception is raised. All transactional calls on FNexportedObj
objects from other users give a gs(invalidcall)
exception.
<< Prev | - Up - | Next >> |