------------------------------------------------------------------------- Using Jgroup/ARM with JINI ------------------------------------------------------------------------- 1. INTRODUCTION This document contains additional instructions of using JINI with the Jgroup/ARM toolkit. See README.txt for instructions on installing and using Jgroup/ARM. 2. THE JINI-BASED APPLICATIONS 2.1 GROUP-ENHANCED REGGIE The Jgroup distribution also contains some Jini compliant applications used to test various Jini related parts of Jgroup. As of Jgroup version 1.1, it is possible to register server groups on a Jini-compliant lookup service besides on the dependable registry service. Jgroup includes a modified version of Reggie, the Jini lookup service. This service is code-named "greg", which stands for "Group-enhanced REGgie". When greg is running, servers belonging to a group may register themselves on it and have a group proxy built from their registration. This release also includes a group-based exporter, which lets the user create a group exporter with the use of Jini 2.0 compliant configuration files. 2.2 GROUP-ENHANCED MAHALO Mahalo is the code-name of the distributed transaction manager included in Jini. Jgroup includes a modified version of Mahalo, which is enhanced with some group communication aspects. It uses the various Jgroup services, to make it possible to perform replicated transactions. 2.3 BUILDING THE JINI RELATED APPLICATIONS Before running the Jini related applications, some preparations must be done in the build environment. Included in the distribution is a build-local.jini.xml. This file contains an example of how to include custom configuration files on top of the default jgroup ones. In this case, configuration of the jgroup-jini applications and services. Rename this file to build-local.xml and everything should be good. Also, you need to run: ant jgroup-jini-dist which will build the jars for all the examples. 2.4 RUNNING THE VARIOUS JINI RELATED APPLICATIONS 2.4.1 RUNNING THE REGGIE HELLO APPLICATION This application is just a simple one used to test Reggie. It has no group functionality, and is only included in the distribution to test that Reggie is installed in a correct manner. As with all Jini related applications, an instance of a webserver and greg has to be started first. The ant target provided in the build file to start the web-server: ant httpd Greg can then be started with the following command: ant greg -Dgreg.codebase='http:///jsk-dl.jar \ http://:8081/greg-dl.jar' where you replace with the host you are running the webserver on. The reggie hello application consist of two small ant targets; a server and a client. The first only creates a proxy and registers it in greg. To start it, type: ant reggiehelloserver -Dreggiehello.codebase=http://:8081/reggiehello-dl.jar The server is then ready for lookup by a client. The reggie hello client can then be started with: ant reggiehelloclient -Djava.rmi.server.codebase=http://:8081/reggiehello-dl.jar The client should then do a lookup in greg to get the proxy, and simply write a hello message from the machine running the reggie hello server. 2.4.2 RUNNING THE JHELLO APPLICATION The jhello application is almost equal to the reggiehello application. The only difference is that many servers can be started together in a group, and the client can then do a lookup on the group. After starting a webserver and greg as in the previous section, the jhello server can be started with: ant jhelloserver -Djhello.codebase=http://:8081/jhello-dl.jar To see the group functionality of this application, it is best to start several servers on different machines. The client will then do a lookup on the servers as a group. Simply start the client with: ant jhelloclient -Djava.rmi.server.codebase=http://:8081/jhello-dl.jar If several servers are running, the client will write a hello message from a random server running in the server group. 2.4.3 RUNNING THE BANK TRANSACTION APPLICATION The bank transaction example is a bit more complicated. As in a classical transaction example, this application uses two bank services to transfer money from one account to another. Each bank service uses an object-oriented database to save account numbers, and the balance of the accounts. A client creates a transaction, asks the two bank services to join the transaction, and then joins in ourselves. After that, the client tells the transaction manager to start the voting process, which uses a 2-PC protocol to decide if the money should be transferred or not. The bank transaction application can be run in different modes of operation; replicated transactions or non-replicated transactions. 2.4.3.1 RUNNING THE NON-REPLICATED BANK TRANSACTION APPLICATION To run this application, first a webserver and an instance of greg have to be started, as in the previous sections. When these two applications are running, a transaction service (mahalo) can be started with: ant mahalo -Dmahalo.codebase='http:///jsk-dl.jar \ http://:8081/gahalo-dl.jar' The non-replicated bank services can then be started with: ant nonreplicatedbank -Dnonreplicatedbank.codebase=http://:8081/bank-dl.jar ant nonreplicatedbank2 -Dnonreplicatedbank2.codebase=http://:8081/bank-dl.jar After this, a client transferring money from one account to another can be started with: ant txnclient -Djava.rmi.server.codebase=http://:8081/bank-dl.jar 2.4.3.2 RUNNING THE REPLICATED BANK TRANSACTION APPLICATION USING ACTIVE REPLICATION The replicated bank application is like the non-replicated one, dependent of a running web server and an instance of greg. Instead of starting mahalo, a Jini transaction service which allows replication can be started with: ant gahalo -Dmahalo.codebase='http:///jsk-dl.jar \ http://:8081/gahalo-dl.jar' The bank services with support for replication can then be started with the following ant targets on two different hosts: ant replicatedbank -Dreplicatedbank.codebase=http://:8081/bank-dl.jar ant replicatedbank2 -Dreplicatedbank2.codebase=http://:8081/bank-dl.jar The client can then be started on a new host with: ant txnclient -Djava.rmi.server.codebase=http://:8081/bank-dl.jar \ -Dtm.replication=true To test that replication really works, several instances of the transaction service and the bank services can be started on different hosts. 2.4.3.3 RUNNING THE REPLICATED BANK TRANSACTION APPLICATION USING PASSIVE REPLICATION The process is exactly the same as when using active replication. The tasks you need to run are: (in the given order) ant gahalo -Dmahalo.codebase='http:///jsk-dl.jar \ http://:8081/gahalo-dl.jar' ant preplicatedbank -Dreplicatedbank.codebase=http://:8081/bank-dl.jar ant preplicatedbank2 -Dreplicatedbank2.codebase=http://:8081/bank-dl.jar ant txnclient -Dtm.replication=true -Dbanks.passive=true -Dtm.passive=true \ -Djava.rmi.server.codebase=http://:8081/bank-dl.jar 2.4.4 RUNNING THE SERVICE BROWSER An ant target for a service browser is also included in the distribution. A service browser can be used to debug services or to lookup information about a service. To start it, type: ant sb Note that the service browser will do a lookup on all services running in the network. It will try to get a proxy for each one of them, and for this to work, every machine containing a service must have a codebase pointing to a host with a running web server containing the dynamic jar files for the services.