Q: What arbitrators are provided in the habanero framework?
A:
There are a few arbitrators provided in the habanero framework. They include the CentralArbitrator, the DynamicArbitrator,
the LimitArbitrator, and the TurnTakerArbitrator.
CentralArbitrator is an arbitrator on the server machine that sends all the actions that it receives to all the collaborative objects. This arbitrator does not grant any keys, since none are needed to complete an action.
DynamicArbitrator is an arbitrator on the client's machine which forwards all action and key requests to the arbitrator on the server machine.
LimitArbitrator is an arbitrator on the server machine which grants keys and sends along actions. This arbitrator grants a key as long as they don't conflict with keys granted previously. And only actions that are accompanied by valid keys are sent on to the other collaborative objects.
TurnTakerArbitrator is an arbitrator that forces participants to first identify themselves by getting a PlayerLock, and then use TurnLocks to take turns. This forces the participants to act in order.
Q: How do you select an arbitrator?
A: When creating the request for the new collaborative object inside the client program, you can specify the name of the tool and arbitrator in the habanero.rsc/toolsDir file. Below is an example of the Whiteboard's toolsDir file.
tool.name= WhiteBoard
tool.picture=WhiteBoard.gif
tool.classname=WhiteBoard.WhiteBoard
tool.arbitrator=ncsa.habanero.LimitArbitrator
tool.version=v1.0
tool.help=http://www.ncsa.uiuc.edu/SDG/Software/Habanero/Tools/
tool.useOwnStream=true
The tool.arbitrator property specifies which arbitrator the tool should use. The default arbitrator is the CentralArbitrator and puts
no restrictions on the types of objects that can be sent to all collaborative objects.
In this example, we use the LimitArbitrator, but you can specify the name of any arbitrator that you have created.
Q: What do you need to do to limit an action?
A: The first step is to direct the server to use a different arbitrator. The default arbitrator is the CentralArbitrator, which allows any action to be performed. Instead, you need to use the LimitArbitrator or an arbitrator of your own design. Defining an arbitrator for your application is discussed in the How do you select an arbitrator for your program? FAQ.
The second step is to request a key to a lock. Locks are a limitation on the types of actions that can be performed. To get a lock, you determine what type of limitation you will need, and request the arbitrator give you permission to do these types of actions. The arbitrator returns the key. To learn more about locks, look at:
A: To get a key, you first must create a lock that describes what you will do. Then you need to ask the arbitrator for a key. The tricky part then is getting the arbitrator. The arbitrator can be retrieved from the frame. The frame is input to the procedure startInFrame.
For this example, let's assume that you have saved the frame from startInFrame in the variable frame. Then you can get a key to a MyLock object using the following code:
Arbitrator arbitrator = (frame.getCollobject()).arbitrator();
kyNewKey = arbitrator.getLock (new MyLock (), Key.NoKey);
This lock doesn't require any previous permissions, so the Key that is passed to getLock is Key.NoKey.
A: There are seven procedures that you must write to create a lock. These are:
allows routine. The lock can then check to see if the action that is about to occur matches with the actions that it allows.
blocks. The LimitArbitrator forces almost every action that is performed to have a Key. We have considered the possibility that you may not always want this to be true. So when an action arrives at a LimitArbitrator without a key, two things happen. First, only certain actions may operate without a key. Actions without a key are checked to see if the arbitrator will allow it to run at all. It proforms this check in the keylessAction method. If the action is permitted, then arbitrator checks the action against all the locks. The routine it uses to check the action is blocks. Each lock has its blocks method called with the possible action.
If you don't override this method, it is assumed that the action is OK.
consistent procedure is called.
keyWorksWith procedure is called.
releaseAfterUsing returns true. Otherwise it returns false.
If you return false from releaseAfterUsing you are responsible for releasing the lock when you are finished using the releaseLock method of the LimitArbitrator.
Q: What locks are provided with the Habanero framework?
A: The Habanero provides four locks are designed to be used with the TurnTakerArbitrator. These locks are:
PlayerLock
To play a game or to participate in a system where people need to take turns, you first need to identify yourself to the arbitrator. A PlayerLock is taken to identify the user.
TurnLock
Once a player or a participant has been identified by taking a PlayerLock, the person can then take their turn with a TurnLock.
LimitPlayerLock
Some games have a limited number of players that are allowed to participate. The user who creates a session gets to decide how many others will be allowed to take turns in the actions. The LimitPlayerLock allows a participant to set this limit.
Habanero® is a registered trademark owned by The Board of Trustees of the University of Illinois. Copyright 1996-1998. All rights reserved. Java(TM) is a proprietary trademark owned by Sun Microsystems, Inc.