A RMI protocol for Aglets

A RMI protocol for Aglets
of 5
All materials on our website are shared by users. If you have any questions about copyright issues, please report us to resolve them. We are always happy to assist you.
Related Documents
  A RMI Protocol for Aglets Feng Lu Kris Bubendorfer School of Mathematical and Computing SciencesVictoria University of Wellington,P. O. Box 600 Wellington, New Zealand,Email:, Abstract Aglets is a mobile agent system that allows an agentto move with its code and execution state across thenetwork to interact with other entities. Aglets utilizesJava RMI to support client-server inter-agent com-munication. However, Java RMI requires static stubsand skeletons to be precompiled and deployed at boththe client and server before communication can takeplace. There are also issues of interoperability, wherethe single communication protocol is embedded in theJava RMI stubs and skeletons at compile time. Run-time connection to non Java RMI entities is thereforedifficult if not impossible. In Aglets, the use of JavaRMI runs counter to modern trends for late-bindingand highly nomadic code in heterogeneous environ-ments. To address these shortcomings, we have de-signed and implemented an alternative RMI architec-ture that is easily retrofitted into the existing Agletsdistribution. We have adopted lightweight stubs gen-erated dynamically by the client’s supporting runtimeenvironment, and a single generic skeleton deployedon the server’s host machine. In addition, we use theSOAP protocol in our prototype to encode remotecalls in XML documents to maximize interoperabil-ity, albeit at the expense of performance. These areincorporated into a component based communicationstack that permits runtime configuration and selec-tion of the protocols transparently to the agents in-volved. With our RMI architecture we have overcomeconsiderable usability limitations in Aglets, extendingAglets by providing full access and relocation trans-parencies. Keywords:  Mobile Agents, Aglets, RMI 1 Introduction A mobile agent is a program that is not bound to thesystem on which it began execution, but rather travelsamongst the hosts in the network with its code andcurrent execution state (Milojicic et al. 2001). Theuse of this technology represents a modern program-ming paradigm for the development of distributed ap-plications. Benefits include a reduction in networkload, reduced latency, encapsulation of protocols,asynchronous and autonomous operation (particu-larly disconnected operation in wireless networks),and their ability to adapt dynamically to changesin the environment (Lange et al. 1999). The mobileagent paradigm is not likely to replace traditional non Copyright (c)2004, Australian Computer Society, Inc. This pa-per appeared at the 27th Australasian Computer Science Con-ference, The University of Otago, Dunedin, New Zealand. Con-ferences in Research and Practice in Information Technology,Vol. 26. V. Estivill-Castro, Ed. Reproduction for academic,not-for profit purposes permitted provided this text is included. mobile distributed programming technologies, ratherwe see it as a complementary technology.Aglets (Wong et al. 1999, Osshima 1998) was oneof the first Java-based mobile agent systems. Agletsprovides two mechanisms for inter-agent communi-cation. A message passing mechanism supports thepeer-to-peer communications, and Java RMI is pro-vided to support client-server communication. JavaRMI (remote method invocation) (RMI 1999, Pittet al. 2001) is an object oriented RPC (remote pro-cedure calls) (Birrell et al. 1984) protocol that allowsthe user to invoke methods on a remote object as if it were a local object.Amongst the goals of middleware are interoper-ability despite heterogeneity and interaction despitedistribution (RM-ODP 1995). Aglets falls short of these ideals, with regard to supporting mobile agents,due to the use of Java RMI for client-server commu-nication. Specifically, Java RMI requires static stubsand skeletons to be precompiled and deployed at boththe client and server before communication can takeplace. This is counter to modern trends for late-binding and highly nomadic code in heterogeneousenvironments. Although Java RMI allows an agentto dynamically load stubs and skeletons from a re-mote class repository via a URL, this is not a suf-ficiently flexible mechanism. For instance, runtimerequirements for interoperability may demand a dif-ferent object representation or protocol. One solu-tion to this dilemma is to separate the stub interfacespecification from the stub protocol and dynamicallygenerate the stub component at runtime.From these arguments above, it is clear that tofully support nomadic agents, Aglets needs bettermechanisms that provide a greater degree of ac-cess and relocation transparencies (RM-ODP 1995).Transparencies hide common complexities, such asheterogeneity and physical distribution, from appli-cation programmers and transfer the burden to theinfrastructure developer.In this paper, we present a new RMI architec-ture for Aglets. Our protocol utilizes an architecturebased on the component based framework from RM-ODP (RM-ODP 1995) plus dynamic stub generationand generic skeletons from FlexiNet (Hayton 1999)to retrofit access and relocation transparencies (forboth the clients, and servers) into Aglets. The dy-namic stubs are generated on demand by the client’ssupporting runtime environment, and forward remoteinvocations via a communication stack to the appro-priate server. On the server, the generic skeleton de-multiplexes all incoming remote invocations to thecorrect target methods using Java reflection.We support full relocation transparency. When anexisting binding fails, the generated stub automati-cally contacts a location service (Bubendorfer 2001)to obtain the server’s current location. The samefunctionality is provided by the generic skeleton, to 249  hide client mobility from the server on return fromthe target server invoked method.Full access transparency is provided by separat-ing the stub interface specification from the proto-col, and utilizing a component based communicationstack. Different protocols can be used with the samedynamic stub - depending on the current runtime in-teroperability requirements. 2 Remote Object Model A Java RMI stub is a very heavyweight object. It notonly acts as a local representative or proxy for the re-mote object, but also takes on the responsibilities of communication with the server. A method invocationon the stub is marshaled into a request message andtransferred to the server. The server skeleton unmar-shals the request, invokes the method on the targetobject and then marshals and sends the result backto the client stub. Finally the client stub unmarshalsand returns the result to the client.Our RMI architecture adopts a different remoteobject model to Java RMI, taking an approach basedon a combination of RM-ODP and FlexiNet. Theclient stub is a very lightweight object that is not re-sponsible for the ’on the wire’ representation of theinvocation (Hayton 1999). Each stub is associatedwith a protocol stack which provides the communi-cation mechanisms. An invocation on the stub istransferred to the client protocol stack, as shown inFigure 1. It is the protocol stack that marshals themethod invocation and communicates with the server.On the server side, the protocol stack unmarshals therequest, and then forwards the request to the genericskeleton, which invokes the appropriate method onthe target object. Client ServerObjectInterfaceServermethodProtocolStackGenericSkeletonClienta methodinvokes InvokesApp Code StubInterfaceProtocol Stackthe target Figure 1:  RMI call to a remote object  3 RMI Architecture As discussed in section 2, the stub interface is sepa-rated from the protocol stack. This lightweight stub isgenerated dynamically to represent the remote objectwithin the client application name space and providesa dynamic rebinding mechanism to automatically re-bind itself to mobile server object. The protocol stackis a multi-tier set of components, as shown in Figure 2.The layer components of the client side implement theinterface  CallDown   to pass client side calls down thestack, and the layer components of the server side im-plement the interface  Callup  to pass server side callsup the stack. A call object contains the reference tothe remote target object, the required method sig-nature and the arguments of the method. The callobject is created by the stub and transferred to thetop of the client’s protocol stack. Each layer performsoperations on the call object, and by the bottom of the client side stack, the object reference has beenresolved and the call object has been serialized. Thefollowing sections 3.1 through 3.5 detail the function-ality of each layer. CallDownCallUp SerialLayer CallDownCallUp NameLayer CallDownCallUp TransportLayerGeneric SkeletonClient ServerStub Target Object   Protocol Stack Figure 2:  The RMI Architecture  3.1 The Stub The bytecode generator from FlexiNet is used to con-struct bytecode for stubs on demand. To simplify thegeneration of the stub bytecode, a template is used toabstract the parts common to all stubs. For example,each stub requires the name of the remote target anda reference to the top of the protocol stack. Sincethe stub is the proxy for a remote object, it mustalso provide the appropriate methods as specified bythe remote object’s interface. These are added to thestub instance using Java reflection to analyze eachmethod signature from the remote object’s interface.The stub is generated directly in the client’s namespace. Generating a lightweight stub from a locallyheld interface can take less time than downloading aheavyweight stub across the network.When a stub’s method is invoked, the parametersof the method are passed as an array of object. If a parameter is of primitive type, it is converted intothe corresponding Wrapper Object type. Then a  call object is created and associated with the name andsignature of the corresponding method as well as thearguments. The  call  object represents an invocationand each method is associated with a different  call object. When the method  invoke  of the  call  objectis called, the  call  object is transferred to the top of the communication stack. The result from the serveris stored in the  call  object after the invocation com-pletes.Remote Invocation introduces two additional ex-ceptions that may be raised during invocation.The first is an exception caused by failure of thenetwork or target machine. The second is an ObjectNotFoundException  exception that indicatesthe server Agent was not found on the target machine.We do not know if the remote object was destroyedor simply moved to another location. Thus, the stubtries to rebind to the remote object. This rebindingprocess is described in Section 4. 3.2 SerialLayer Serialization is the process of converting an objectinto a serial, or byte array, form. We serialize an ob- ject into a byte stream before sending it to anotherhost and reconstruct the new instance from the bytestream at the destination. Rather than utilizing thebuilt-in Java Serialization technology for the proto-type, we use the Apache implementation of the SimpleObject Access Protocol (SOAP) (SOAP1.1 2000) toprovide a high degree of interoperability and access 250  transparency. The Apache SOAP implementationsupports the encoding of most Java primitive typesand their corresponding Wrapper classes, plus someother standard classes, such as String, HashTable,Map and JavaBean object in textual XML docu-ments. There is no general purpose object encoderin Apache SOAP. If users want to transfer their own(non bean) objects as parameters, they have to createspecial encoders. 3.3 NameLayer A server object has two identities. A published ex-ternal name string describes the service provided bythe object. An internal reference is used to iden-tify the location and interface of the service Agent.The resolution of an external name provides a clientwith an internal reference for the service. The ref-erence consists of three parts:  protocol  ,  address   and id  . The  protocol   states which application protocol isused. The  address   represents the last known addressof the server Agent, including IP address and portnumber. The  id   is a globally unique number usedto identify the server object. It will never change af-ter it is generated. The reference can be represented,parsed and stored, in stringified format. 3.4 TransportLayer The TransportLayer is used to send the client messageto the server and receive the server’s response. Onthe server, the TransportLayer receives the requestmessage, constructs a call object, and forwards it upto the NameLayer. As the prototype utilizes SOAPfor object serialization, we also utilize HTTP as thematching TransportLayer protocol. 3.5 Generic Skeleton The Generic Skeleton performs the local method in-vocation on the targeted object. Reflection is usedto identify the correct target object and method fromthe signature encoded by the client stub. The re-sulting returned value or exception from the targetmethod is then stored in the call object, which ispassed back down the stack. 3.6 Client Side Call Processing In this section, we will detail the process of a callbeing made down the stack. •  A method is invoked on a client stub. A callobject is created, consisting of, the internal ref-erence to the remote object, the signature of themethod and any method arguments. •  The call object is passed to the top of the proto-col stack, the SerialLayer. The SerialLayer seri-alizes the contents of the call object into a XMLdocument. When the invocation returns, it willalso deserialize the result. The modified call ob- ject is then passed to the NameLayer. •  The NameLayer resolves the reference of the tar-get object and extracts the target machine ad-dress. •  The TransportLayer wraps the XML documentinto a HTTP Request message, opens a TCPconnection to the target and then sends theHTTP Request message. The TransportLayerthen waits for the response 1 . On receipt of the 1 Any call to migrate the Agent at this point must wait for thecall to complete or timeout. server response, the TransportLayer extracts theXML document from the HTTP Response Mes-sage and stores it in the srcinal call object. Thecall object is then passed back up through thestack. If the connection timeouts, then the callobject is passed back up with the appropriateexception. 3.7 Server Side Call Processing A call up the stack is somewhat more interesting, aswe now must deal with the fact that the server mayhave moved, invalidating the reference held by theclient. In this section, we will go through the processof an incomming call up the stack. •  The TransportLayer initializes the listening portand then waits for requests. When it receives theHTTP Request Message, it creates a call objectcontaining the entire message. •  The NameLayer extracts the target id from therequest message header. Then, it checks if thetarget Agent exists on this host. This is impor-tant, as the mobile agent may have since movedto a different host, or ceased execution. Eachhost runs an extended Aglets Tahiti server thatautomatically maintains a register of all MobileAgents executing within it. If the target Agentis not in the register, the call up the stack ter-minates, and an  ObjectNotFound   exception is re-turned to the client. The client stub will then at-tempt to relocate the Agent on a different host,as described in section 4. •  The SerialLayer extracts the XML documentfrom the HTTP Request message, and thenparses the XML document to get the method’ssignature and any objects passed in as argu-ments. When the invocation returns, it serializesthe result into the returning XML document. •  Finally the Generic Skeleton uses Java reflectionto find and invoke the required method on thetarget object. The result is then stored in thecall object which is passed back down the stack.If the result is an exception, then the exceptionis stored in the call object and the exception flagin the call object is set. 4 Dynamic Rebinding Aglets needs to have relocation transparency to hidethe mobility of Agents within the network. Whena server object moves to another host, all referencesheld on this object by its clients become out-of-date.From this point, all subsequent invocations on this ob- ject will result in an  ObjectNotFound   exeption gener-ated by the host encoded in the out-of-date reference.Relocation transparency requires that resolvingthe new object location and rebinding occur trans-parently to the client. This duty falls to the stub,which contains a reference to a  Whitepages   locationrepository (relocator in RM-ODP terminology). Thisservice is then queried by the client stub to resolve thenew location. The whitepages service is automaticallymaintained on object migration by extensions to theTahiti Aglet Server. This location service is a sim-plified version (less scalable) of the NOMAD globallocation service (Bubendorfer et al. 2003), which issufficient for our purposes in the prototype. The newreference is then used by the stub to rebind to theobject, and the invocation is then reissued. 251  5 Interoperability CORBA (OMG 1999), DCOM (Horstmann et al.1997) and Java RMI, use the remote object modelto allow objects in one machine to access objects inother machines. However, these protocols have lim-ited interoperability, although some protocol bridgeshave been developed. Also, the standard implementa-tions of these protocols use randomly generated portto communicate. This means that they are extremelydifficult to pass through firewalls, which typicallyblock all ports except for several well known ports,such as 80 and 25. Tunneling has been suggested toenable the firewalls to be sidestepped, but the config-uration is complex. However, the fundamental prob-lem is that it is difficult to design a universal RMIprotocol — SOAP is one possibility. However, SOAPis recognized as providing considerably worse perfor-mance than other RMI protocols (Govindaraju 2000). 5.1 SOAP SOAP provides a simple and lightweight mecha-nism for exchanging structured and typed informa-tion between peers in a decentralized, distributedenvironment using XML(Extensible Markup Lan-guage) (SOAP1.1 2000). SOAP utilizes XML to de-fine a set of platform independent encoding rules torepresent data that are easy to generate and parse.SOAP is a text-based protocol, in contrast to cur-rent RMI protocols, which are binary-based proto-cols. Text-based protocols such as SOAP are espe-cially easy to debug because all of the data transferredis in a human readable format. In addition, SOAP canuse a variety of existing Internet Protocols, such asHTTP, SMTP. This makes it very easy for distributedapplications to communicate with each other in a net-work environment with firewalls. The most importantthing is that SOAP is widely supported by the mainindustry consortiums, such as Microsoft and IBM. 5.2 SOAP & Serialization SOAP defines a set of encoding rules that describehow to represent the different types of object in anXML document. A set of XML schemas are usedto define the different types and describe their struc-tures. With the XML schema and the correspondingdata values, an XML document can be constructed.On the other end, an XML document may be destruc-ted to a set of data values and corresponding XMLschema. 5.3 SOAP & RPC An RPC may be represented as an object consisting of the address of the target, a method signature and thearguments of the method. Therefore, any RPC callcan be encapsulated into a SOAP XML message. Us-ing HTTP as the carrier for SOAP messages providesthe advantage of being able to use the formalism anddecentralized flexibility of SOAP with the rich featureset of HTTP (SOAP1.1 2000).Consider the following example. The  EchoImp class implements the interface  Echo  and acts asa server object. It is located in the server   on prot  9000  . The global id 12345687   is assigned to this object. public class EchoImp implements Echo {public String echo(String message, int id)throws IncorrectIDException{return message + " " + id;}} When the client tries to invoke the method on theserver object  EchoImp , a HTTP Request message isgenerated as a wrapper of the SOAP message. TheSOAP Action field indicates the target object globalID  12345687  . The SOAP Envelope specifies the over-all structure of the message. A method call is mod-eled as a compound data type with a sequence of pa-rameters. The parameters of this method call are:arg0(message)  This is a test   and arg1(id)  123  . POST / HTTP/1.0Host: text/xml; charset=utf-8Content-Length: 469SOAPAction: "12345687"<?xml version=’1.0’ encoding=’UTF-8’?><SOAP-ENV:Envelopexmlns:SOAP-ENV=""xmlns:xsi=""xmlns:xsd=""><SOAP-ENV:Body><ns1:echo xmlns:ns1="12345687"SOAP-ENV:encodingStyle=""><arg0 xsi:type="xsd:string">This is a test</arg0><arg1 xsi:type="xsd:int">123</arg1></ns1:echo></SOAP-ENV:Body></SOAP-ENV:Envelope> The server wraps the result into a HTTP ResponseMessage. It is similar to the usual HTTP Responseexcept the fact that there is a suffix ”Response” addedto the element name representing the method name. Content-Type: text/xml; charset=utf-8Content-Length: 482<?xml version=’1.0’ encoding=’UTF-8’?><SOAP-ENV:Envelopexmlns:SOAP-ENV=""xmlns:xsi=""xmlns:xsd=""><SOAP-ENV:Body><ns1:echoResponse xmlns:ns1="12345687"SOAP-ENV:encodingStyle=""><return xsi:type="xsd:string">Your message = This is a test and id = 123</return></ns1:echoResponse></SOAP-ENV:Body></SOAP-ENV:Envelope> If the result is an exception, the content of thebody is a SOAP:Fault structure which describes theexception. Content-Type: text/xml; charset=utf-8Content-Length: 480<?xml version=’1.0’ encoding=’UTF-8’?><SOAP-ENV:Envelopexmlns:SOAP-ENV=""xmlns:xsi=""xmlns:xsd=""><SOAP-ENV:Body><SOAP-ENV:Fault><faultcode></faultcode><faultstring></faultstring><faultactor>17345687</faultactor></SOAP-ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envelope> 252  6 Implementation in Aglets The implementation of the RMI protocol in Agletsrequired alterations to two standard Aglet compo-nents. Firstly, the Tahiti server, that creates andmaintains the Aglet’s runtime environment, was mod-ified to initialise the RMI protocol stack. Secondly,the  Aglet  class, that defines the methods for con-trolling an Aglet’s life cycle and behavior, was ex-tended by the subclass  RmiAglet . The new  RmiAglet class permits Aglets to utilise the new RMI commu-nications stack. The default Aglet Dispatch methodwas modified to add migration failure recovery byreestablishing the srcinal  Whitepages   entry. In ad-dition three new methods were required to interactwith the  Whitepages  . The method  lookup  queries the Whitepages   to find a service. The method  export is used to export a service name into  Whitepages  when a server object wants to advertise its service.The method  unexport  removes a service from the Whitepages   when a server object is disposed of ormigrates 2 to another host. 7 Performance Analysis We conducted experiments to compare our perfor-mance to that of Java RMI. In these experiments, weimplemented four pairs of client/server programs thatcommunicated using our RMI (using SOAP compo-nents), Java RMI, Java TCP Sockets and Native TCPSockets. All applications are written in Java, exceptfor the application using Native TCP socket whichuses the Java Native Interface (JNI). All programswere run on the same two machines, a NetBSD clientand a Sun Solaris server, on a 100 Mb/s switchedEthernet network. We recorded the interval from thetime when a client sent the package to the time whena client received the response. Size(byte) RMI(ms) Java RMI Java TCP Native TCP10 265.05 0.70 0.40 0.22100 266.63 0.78 0.52 0.251000 277.97 1.56 1.66 0.472000 279.78 2.62 2.85 0.613000 388.96 2.94 3.77 0.864000 278.56 3.7 4.78 1.025000 280.37 4.01 6.64 0.926000 386.18 4.06 7.32 1.037000 386.66 4.78 8.43 1.088000 379.76 5.28 9.32 1.329000 300.2 6.02 8 9.87 1.4310000 388.15 6.54 10.75 1.36 Table 1: PerformanceAs shown in Table 1, the performance of our RMIis significantly worse than Java RMI, between 60-100times slower in fact. This is result is consistent withprevious research (Govindaraju 2000) utilizing SOAPunderneath an RMI mechanism. From this it is clearthat the performance is a SOAP issue. Clearly, forSOAP to have any credibility as a protocol for inter-operability, vast improvements must be made to theimplementations currently available.However, these results should not be taken outof context. They provide a proof-of-concept thatthe RMI architecture presented in this paper can beretrofitted into Aglets. Indeed, one of the points of our architecture is that it is component based, andtherefore we can substitute alternative protocol com-ponents both at compile and runtime. Alternativecomponents should be able to achieve better perfor-mance, albeit at the cost of interoperability. 2 Once on the new host, the server Aglet automatically re-exports its service name. 8 Conclusions We have presented a RMI protocol that can beretrofitted into Aglets via a combination of dynamicstub generation, and server side extensions to theAglets Tahiti server. The stub supports a dynamicrebinding to automatically relocate and bind itself to a mobile server Agent providing relocation trans-parency. The protocol stack is designed as a multiple-tier set of interchangable components. SOAP is in-tegrated into the protocol stack as the SerialLayerbecause SOAP’s interoperability makes it valuablein heterogeneous environment. Though our proto-type’s performance is considerably worse than JavaRMI, this is a result of selecting SOAP as a serial-ization component in the prototype’s protocol stack.This none-the-less provides a proof-of-concept thatthe RMI architecture presented in this paper can beretrofitted into Aglets with clear advantages in accessand relocation transparency. In this we overcome aconsiderable usability limitation in Aglets. References A. D. Birrell & B. J. Nelson (1984), ImplementingRemote Procedure Calls, ACM Transactions onComputer Systems.Danny B. Lange & Mitsuru Oshima (1999), SevenGood Reasons for Mobile Agents, Communica-tion of ACM, volume 42.Dejan Milojicic, Frederick Douglis & Richard Wheeler(2001), Mobility - Processes, Computers andAgents, Addition Longman.D. Wong, N. Paciorek & D. Moore (1999), Java-basedMobile Agents, Communication of ACM, volume42.Esmond Pitt & Kathleen McNiff (2001), The RemoteMethod Invocation Guide, Pearson Education.International Standards Organisation (1995), OpenDistributed Processing Reference Model - Part3: Architecture.Kris Bubendorfer (2001), NOMAD: Towards anArchitecture for Mobility in Large Scale Dis-tributed Systems, Ph.D. Thesis, Victoria Uni-versity of Wellington.Kris Bubendorfer & John Hine (2003), NOMAD: Ap-plication Participation in a Global Location Ser-vice, Lecture Notes in Computer Science, num-ber 2574, pages 294-306.Madhusudhan Govindaraju (2000), Requirements forand Evaluation of RMI Protocols for ScientificComputing, IEEE.Markus Horstmann & Mary Kirtland (1997), DCOMArchitecture, Technical Report, Microsoft.Mitsuru Osshima (1998), Aglets Specification 1.1Draft, IBM Japan.Object Management Group (1999), The CommonObject Request Broker:Architecture and Spec-ification, 2.3.1 edition.Richard Hayton (1999), FlexiNet Architecture, Tech-nical Report, ANSA.SOAP 1.1 Specification (2000), World Wide WebConsortium, Microsystems (1999), Java Remote Method In-vocation Specification. 253
Related Search
We Need Your Support
Thank you for visiting our website and your interest in our free products and services. We are nonprofit website to share and download documents. To the running of this website, we need your help to support us.

Thanks to everyone for your continued support.

No, Thanks