org.objectweb.perseus.distribution.api

Interface DistResUserService

Known Implementing Classes:
JGroupsUserService

public interface DistResUserService

This is the user side interface of a distributed resource service. It permit resource users to communicate with their respective resource coordinators. Tipically, the user side of a sharing protocol will use this interface to communicate with the corresponding coordinator side, while the coordinator will use the DistResCoordinatorService interface. The newLocalNode of the DistResServiceManager interface should be used to retrieve this interface.

See Also:
DistResServiceManager, DistResUser, DistResCoordinator

Method Summary

Serializable
getNodeId()
Returns the id of the local node.
DistResUser
getUser(Object resId)
Gets the user interface associated with a given resource identifier.
boolean
joinUsers(Object resId, DistResUser dru)
Request the coordinator(s) to join the users of a resource.
void
sendToCoordinator(Object resId, Serializable message)
Asynchronously sends a message to the coordinator(s).

Method Details

getNodeId

public Serializable getNodeId()
Returns the id of the local node. The identifier can be sent in messages as it is serializable.

Returns:
the id of the local node


getUser

public DistResUser getUser(Object resId)
Gets the user interface associated with a given resource identifier.

Parameters:
resId - the id of the coresponding resource

Returns:
the user interface associated with the resource identifier, null if there is no correspondance.


joinUsers

public boolean joinUsers(Object resId,
                         DistResUser dru)
            throws UseNotGrantedException,
                   InterruptedException
Request the coordinator(s) to join the users of a resource. This is a synchronous operation which is accepted only if all coordinators have accepted the node as a new user member.

Parameters:
resId - the id of the related resource
dru - the user to which messages must be delivered

Returns:
true if the user is the first (and only one) user of the resource

Throws:
UseNotGrantedException - if the joining has not been accepted


sendToCoordinator

public void sendToCoordinator(Object resId,
                              Serializable message)
            throws NotUserException
Asynchronously sends a message to the coordinator(s). A FIFO delivery is guaranteed for each resource, that is, the receive method of the coordinator will be called in the same order that the call to this method with the same resource id. Also, either the coordinator will receive the message once and only once, or the user will be excluded from the users

Parameters:
resId - the id of the resource
message - the message to send

Throws:
NotUserException - if the not is not registered has a user of this resource


Copyright © 2000-2002 France Telecom S.A., INRIA, IMAG-LSR All Rights Reserved.