EP1021766A1 - Itinerary based agent mobility including mobility of executable code - Google Patents

Itinerary based agent mobility including mobility of executable code

Info

Publication number
EP1021766A1
EP1021766A1 EP97948189A EP97948189A EP1021766A1 EP 1021766 A1 EP1021766 A1 EP 1021766A1 EP 97948189 A EP97948189 A EP 97948189A EP 97948189 A EP97948189 A EP 97948189A EP 1021766 A1 EP1021766 A1 EP 1021766A1
Authority
EP
European Patent Office
Prior art keywords
agent
computer
mobile agent
mobile
class
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Withdrawn
Application number
EP97948189A
Other languages
German (de)
French (fr)
Other versions
EP1021766A4 (en
Inventor
Thomas C. Walsh
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Mitsubishi Electric Information Technology Corp
Mitsubishi Electric Research Laboratories Inc
Original Assignee
Mitsubishi Electric Information Technology Corp
Mitsubishi Electric Research Laboratories Inc
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Mitsubishi Electric Information Technology Corp, Mitsubishi Electric Research Laboratories Inc filed Critical Mitsubishi Electric Information Technology Corp
Publication of EP1021766A1 publication Critical patent/EP1021766A1/en
Publication of EP1021766A4 publication Critical patent/EP1021766A4/en
Withdrawn legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/48Program initiating; Program switching, e.g. by interrupt
    • G06F9/4806Task transfer initiation or dispatching
    • G06F9/4843Task transfer initiation or dispatching by program, e.g. task dispatcher, supervisor, operating system
    • G06F9/485Task life-cycle, e.g. stopping, restarting, resuming execution
    • G06F9/4856Task life-cycle, e.g. stopping, restarting, resuming execution resumption being on a different machine, e.g. task migration, virtual machine migration
    • G06F9/4862Task life-cycle, e.g. stopping, restarting, resuming execution resumption being on a different machine, e.g. task migration, virtual machine migration the task being a mobile agent, i.e. specifically designed to migrate
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/465Distributed object oriented systems
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/52Program synchronisation; Mutual exclusion, e.g. by means of semaphores
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network

Definitions

  • the present invention is generally related to network computing, and more particularly to mobile objects.
  • Mobile objects that are transmitted across a computer network are known.
  • Mobile objects are comprised of code and data, both of which are transmitted across the computer network.
  • Technologies such as client-server protocols, remote procedure call protocols, and distributed object technologies are employed to transmit mobile objects across the computer network. These technologies implement either a "push” model or a "pull” model, both of which have drawbacks.
  • a "pull" model the code for an executing object i ⁇ downloaded from a network source such as a web server.
  • a network source such as a web server.
  • that portion of code is first sought on the local filesystem. If the local filesystem does not include that portion, of the code, a network request is sent to another computer in the network in order to prompt transmission of that portion of code to the local computer.
  • a separate network request must be sent to retrieve code for each class .
  • HTTP Hyper-Text Transfer Protocol
  • TCP/IP Transmission Control Protocol/Internet Protocol
  • Another drawback associated with the pull model is that as an object travels, the code which enables the object to operate must be re-downloaded at each computer. More particularly, when the object arrives at each a destination computer, the object downloads any code which is required but not present on the local filesystem, even if that code was downloaded at the previous destination computer. Previously downloaded code is not cached. Network overhead is incurred as a consequence.
  • a "push" model the code for an executing object is carried with the mobile object. Prior to launching the mobile object, all of the code that will be needed by the object is identified. The code is packaged with the agent and pushed around the network to each destination computer. While the push model reduces network requests in comparison with the pull model, network overhead is still incurred because of the relatively large amount of code that is pushed to every destination computer. In some cases the object will push code for classes that are no longer needed. For example, an agent may create an instance of a particular class of object only in very exceptional circumstances. In such a case it is inefficient for the object to push the code for this class.
  • Known mobile objects initiate travel by performing a subroutine call. The method is sometimes given a name such as "go" or "moveTo,” and the caller is responsible for specifying a name or Uniform Resource Locator ("URL") indicating the destination computer for the mobile object.
  • URL Uniform Resource Locator
  • the travel method is called, the execution of the mobile object is halted and the mobile object is converted into a network transmittable form. On the destination computer the mobile object is restored from the network form and restarted. This restart can either occur on the instruction directly following the call to the travel method, or at the beginning of some known method.
  • a "mobile codebase” object is constructed.
  • the mobile codebase travels with the agent and serves as a repository of code for classes that facilitate agent operation.
  • the launcher specifies a list of related classes. These classes are retained in the mobile codebase.
  • the launcher also specifies a Uniform Resource Locator ("URL") that points to a network source (“home codebase”) from which code can be downloaded.
  • URL Uniform Resource Locator
  • the combination of the mobile codebase and home codebase improve agent operation and reduce network overhead.
  • an agent is launched with a mobile codebase that is preloaded with classes which are certain to be needed. Classes that are unlikely to be needed are stored in the home codebase.
  • the agent with mobile codebase and home codebase provide the desirable features of the push and pull models without the undesirable network overhead incurred by transmitting unneeded classes around the network or re-downloading code.
  • Agent travels are defined by an itinerary data structure.
  • the itinerary is composed of a list of destinations, each of which includes: (1) the hostname of a destination computer on the network to which the agent should travel, and (2) the name of a method that the agent should execute when the agent arrives at the destination computer.
  • An agent is allowed to modify its itinerary. When an agent modifies its itinerary, the agent owner is automatically notified, thus allowing the owner to "follow" the agent wherever it may travel .
  • the itinerary provides advantages related to agent and network management. Inspection of the agent itinerary reveals where the agent has travelled and where the agent may travel in the future. Since the itinerary is a standard data structure, an observer can depend on it to be present. Further, since the itinerary is a separate data structure from the agent, the observer does not need special knowledge of the internal structure of the agent in order to examine the itinerary.
  • Fig. 1 is a block diagram which illustrates agent migration
  • Fig. 2 is a block diagram which illustrates agent execution in conjunction with agent migration
  • Fig. 3 is a block diagram of an agent
  • Fig. 4 is a block diagram of agent interaction with agent managers on multiple computers in a network
  • Fig. 5 is a flow chart which illustrates agent mobility
  • Fig. 6 is a block diagram which illustrates agent operation according to an itinerary
  • Fig. 7 is a block diagram which illustrates the agent runtime environment.
  • Fig. 8 is a flow chart which illustrates agent deserialization.
  • an agent 10 comprises a mobile object which can travel from a first computer 12 to a second computer 14 in a computer network 16.
  • the agent is generated and stored in memory on the first computer for a specific purpose, and includes both data and executable code.
  • the agent executes on the first computer and then migrates to the second computer by being transmitted across the network. The agent then resumes execution on the second computer.
  • the agent acts in accordance with an agent itinerary. For example, the agent will migrate to another computer if the itinerary so indicates.
  • the agent executes a sequence of instructions during operation.
  • a first method 18 is executed on the first computer 12 and a second method 20 is executed on the second computer 14.
  • migration between computers is transparent from the perspective of the agent .
  • agent mobility is preferably facilitated through use of JAVA agent manager Objects 32 and an Object Serialization facility (a product of Sun Microsystems which is known in the art) .
  • Object Serialization operates to serialize objects such that a representative stream of bytes, i.e., data, is generated therefrom.
  • Object Serialization facilitates transmission of an agent across the network by serializing the agent 10 into a format that is suitable for network transmission.
  • Serialization of the agent may also include serialization of sub-objects which are contained within member variables of the agent.
  • the serialization process involves the serialization of executable code, data, and an itinerary as hereinafter discussed in greater detail.
  • the serialized agent is regenerated in the second computer 14 upon arrival.
  • the stream of bytes transmitted along the socket is deserialized in the second computer.
  • Deserialization regenerates the agent in the form in which the agent existed prior to migration, i.e., an object.
  • the agent executes a predetermined method specified by its itinerary. The predetermined method may prompt interaction with another object 34 located on the second computer.
  • the agent is serialized and transmitted to yet another computer, or possibly back to the first computer.
  • the agent is therein deserialized upon arrival and proceeds to execute another predetermined method and interact with that computer. In the case of the agent migrating back to the first computer, such interaction could be with a host application 36 through which an information query was entered.
  • the agent continues migrating across the network in this manner as execution requires. Eventually, the agent is terminated when execution of the itinerary is complete. It should be noted that the agent need not necessarily migrate to the initial host (first) computer after executing on a remote (second) computer. The agent could travel to multiple computers, and may not return to the initial host computer.
  • each agent may include data 22, code 24, sub-objects 26 and an itinerary 28.
  • the data portion 22 includes internal state information associated with the agent.
  • the code portion 24 includes executable code associated with operation of the agent.
  • the itinerary portion 28 specifies destinations for the agent.
  • Sub-objects 26 include code of distinct objects contained within the agent.
  • the agent carries the code for these sub-objects.
  • the code 24 portion of the agent 10 includes a mobile codebase and a reference pointer to a home codebase.
  • the mobile codebase comprises executable code which is retained as part of the agent. When the agent migrates, the mobile codebase is transmitted along with the data, sub-objects and itinerary to the destination.
  • the home codebase is executable code which resides on the computer which originally created and launched the agent or a suitable network server (such as a web server) .
  • the reference pointer to the home codebase is a Uniform Resource Locator ("URL") that allows remote access to the home codebase from other computers in the network. If the agent requires code that is not present in the mobile codebase during execution, the agent retrieves the required code from the home codebase and retains such retrieved code in the mobile codebase.
  • URL Uniform Resource Locator
  • the itinerary 28 is a data structure which defines agent migration parameters.
  • the itinerary is composed of a list of destinations and the name of a method associated with each such destination.
  • each destination entry contains the Transmission Control Protocol/Internet Protocol ("TCP/IP") host name of a computer on the network to which the agent is designated to migrate.
  • TCP/IP Transmission Control Protocol/Internet Protocol
  • the method associated with the respective destination is invoked upon arrival at that destination.
  • each destination represents a location and a task to be performed at the location.
  • Figs. 4 and 5 illustrate agent mobility.
  • the agent manager 30 examines the itinerary 28 to ascertain the next destination to which the agent 10 is designated to migrate.
  • the agent manager 30 establishes a network connection to the agent manager 32 at the destination computer 14.
  • the agent manager 30 passes the agent and related travel information to the destination agent manager
  • the agent manager 30 then deletes the local copy of the agent, terminates any execution threads which were being used by the agent, and performs other appropriate clean up activities .
  • the agent arrives at the destination computer as illustrated in step 38.
  • the agent arrives in the form of data which includes the code, sub-objects, itinerary and other data.
  • Java/Object Serialization assists the de- serialization and reconstruction of the agent as depicted in step 40.
  • the server then spawns a new thread in which the agent will execute as shown in step 42.
  • a persistent local copy of the agent is then made as illustrated in step 44.
  • the agent manager invokes the proper method of the agent for execution in the spawned thread at this node.
  • the itinerary contains information indicating which method should be invoked at each designated destination computer.
  • the agent then executes as illustrated in step 50.
  • another persistent copy of the agent is stored on the local disk as depicted in step 52 in order to prevent redundant execution in the event that the computer malfunctions before the agent migrates.
  • the agent manager then examines the agent itinerary as illustrated in decision step 54. If the itinerary does not indicate any further destinations then agent execution is deemed complete as shown in step 56. However, if the itinerary indicates further destinations, then the agent manager determines whether the next destination is associated with another computer in decision step 58. If the next destination is not another computer, flow returns to step 44, thereby bypassing network traffic.
  • next destination is associated with a different agent manager then a network connection to the indicated agent manager is established as depicted in step 60.
  • the destination contains a string which indicates where to travel.
  • the string contains either the name (host name) of a computer or a URL to a distributed object.
  • the agent is then serialized as illustrated in Step 62 and subsequently transmitted to the next agent manager as depicted in Step 64.
  • the itinerary includes a listing including identification of each agent manager 66 to which the agent is configured to migrate and identification of a method 68 to execute at each respective agent manager.
  • the agent migrates through the agent managers listed in the itinerary sequentially in the order in which the servers are listed, invoking each respective method upon arrival. Such method could be, for example, querying or updating a database on the destination computer.
  • Fig. 7 illustrates the agent runtime environment.
  • Each computer 70 on the network includes a Java Virtual Machine 72 running therein.
  • a agent manager 74 runs on each respective Virtual Machine 72.
  • the agent manager includes a plurality of threads 76, each thread having an agent 78 associated therewith.
  • a new thread is formed when a new agent arrives at the server, and the agent executes on that thread.
  • Security mechanisms prevent each agent from operating outside the scope of the associated thread.
  • agent execution completes the agent migrates to the next destination identified in the itinerary.
  • the agent manager modifies the mechanism by which Java loads classes.
  • the Java standard library provides an object called a "ClassLoader" which can be subclassed by a programmer to modify the rules that Java follows to load classes.
  • the ClassLoader class allows web browsers to download "applets” from a web server.
  • the agent manager provides a specialized ClassLoader which allows the executable code for mobile agents to travel with the agent.
  • a Java interpreter loads classes as needed for execution from a logical file system on the local computer.
  • agents become separated from the home computer and the home codebase during migration, i.e., agents are separated from the directory or directories on the filesystem of the home computer where the code is stored.
  • sub-objects sometimes need to be created as the agent executes, either as member variables or as temporary variables within the methods. These sub-objects could be instances of classes which are part of the standard Java packages or they could be instances of new classes written by the programmer of the agent.
  • the Java virtual machine may not be able to directly retrieve the code for the particular sub-object.
  • a special ClassLoader is employed by the agent manager whenever an agent attempts to construct an object.
  • the ClassLoader object first attempts to locate a class on the local file system of the computer. If the class is not on the local file system, the ClassLoader searches the mobile codebase. If such attempt fails, the ClassLoader sends a request back to the home machine of the agent.
  • the agent's travel information contains a reference such as a URL which refers back to the home codebase on the home computer, and by accessing the URL the ClassLoader can retrieve classes from the home computer.
  • Agent deserialization is illustrated in Fig. 8. As depicted in step 80 the serialized agent arrives as a stream of data. Java Development Kit Object Serialization classes then call an agent manager related method to perform deserialization as shown in step 82. The method reads agent related objects from the object stream as depicted in step
  • the mobile codebase, itinerary and codebase URL are read by the method.
  • a custom Classloader and ObjectInputStream are constructed as shown in step 86.
  • Object Serialization then reads the agent and other objects from the input stream as depicted in step 88 and step 90, respectively.
  • the ClassLoader retrieves the classes which comprise the agent as illustrated in step 92.
  • the new object's class is loaded once the classes are retrieved. As depicted in step 94, if the class is determined to have been previously loaded then the previously loaded class instance is employed (step 96) and the object is instantiated using the loaded class object as shown in step 98. However, if the class has not been previously loaded as determined in inquiry step 94, then inquiry is made as to whether the class is on the local class path of the destination computer as illustrated in decision step 100. If the class is present on the local machine then the class is loaded therefrom as shown in step 102 and the object is instantiated using the loaded class object as depicted in step 98.
  • step 104 an inquiry is made as to whether the class is in the mobile codebase as shown in step 104. If the class is located in the mobile codebase then the class is loaded therefrom as shown in step 106 and the object is instantiated using the loaded class object as shown in step 98. However, if the class is not located in the mobile codebase in decision step 104 then the class is loaded by accessing the home codebase as shown in step 108.
  • the codebase pointer is an Internet type pointer such as a Hyper- Text Transfer Protocol ("HTTP") URL, as determined in inquiry step 110, then an HTTP request is sent to the local web server as shown in step 112 and the retrieved class is added to the Mobile CodeBase as depicted in step 114.
  • HTTP Hyper- Text Transfer Protocol
  • a remote method request is sent to a RemoteClassLoader object as shown in step 116 and the class is added to the mobile codebase as shown in step 114.
  • the object is instantiated using the loaded class object as shown in step 98. If more objects exist in the stream to be retrieved, as determined in decision step 118, then another object is read from the input stream as illustrated in step 90. If there are no more objects to be retrieved, flow terminates.
  • agents should be derived from the class Agent.
  • agentID host + "/agent” + nextAgentNum( ) ;
  • AgentID is a unique String
  • Agents can override this method to perform any final processing
  • AgentCodebase java_l Tue Nov 12 08:01:22 1996 1
  • AgentCodebase class provides accessability to the "home
  • the agent may have
  • AgentCodebase provides an mechanism through
  • AgentCodebase . j va_l Tue Nov 12 98:01:22 1996
  • AgentCodebase 63 * AgentCodebase
  • server (such as ⁇ b>rmi : //host/RemoteClassLoader/directory ⁇
  • AgentCodebase java_l Tue Nov 12 08:01:22 1996
  • RemoteClassLoaderlmpl retrieveRemoteClass (itsURL, classname);
  • AgentCodebase Java_l Tue Nov 12 38:01:22 1996 4
  • MeteredStream stream (MeteredStream) classUrl . getConten () ;
  • MeteredStream stream (MeteredStream) classUrl . getConten () ;
  • Static Intializer is jsed to initialize some of the CONSTANTS */
  • 40 * represent the system CLASSPATH, or a custom ClassPath specified by the
  • InputStream stream file .getInputStream( ) ;
  • This parameter can have the value ⁇ b>JASProperties .USER ⁇ /b>
  • AgentClassInfoGatherer class peeks ⁇ i:o an agents class file to
  • AgentClassInfoGatherer verifies that the class file indicated
  • AgentClassIn oGatherer (String agentDir, String agentFilename)
  • Class agent ClassLoader . loadAgentClassFromFile (agentFilename, true) ; 110

Abstract

In accordance with the present invention, a mobile agent object (10) executes a first method (18) on a first computer (12), migrates from the first computer (12) to a second computer (14), and executes a second method (20) on the second computer (14). The first and second methods and first and second computers are designated in an itinerary (28). The agent includes both data (22) and executable code (24, 26) which are serialized for transmission from the first computer to the second computer as data. The data containing the agent is then deserialized in the second computer to regenerate the agent in the form of an object. The executable code portion of the agent can be supplemented with code from a home codebase located on another computer.

Description

TITLE OF THE INVENTION ITINERARY BASED AGENT MOBILITY INCLUDING MOBILITY OF EXECUTABLE CODE
CROSS REFERENCE TO RELATED APPLICATIONS A claim of priority is made to U.S. provisional patent application Serial Number 60/030,906, entitled USE AND COLLABORATION OF MOBILE AGENTS IN A COMPUTER NETWORK, filed
November 14, 1996.
STATEMENT REGARDING FEDERALLY SPONSORED RESEARCH OR DEVELOPMENT
Not applicable
BACKGROUND OF THE INVENTION The present invention is generally related to network computing, and more particularly to mobile objects.
Mobile objects that are transmitted across a computer network are known. Mobile objects are comprised of code and data, both of which are transmitted across the computer network. Technologies such as client-server protocols, remote procedure call protocols, and distributed object technologies are employed to transmit mobile objects across the computer network. These technologies implement either a "push" model or a "pull" model, both of which have drawbacks.
In a "pull" model the code for an executing object iε downloaded from a network source such as a web server. When a particular portion of code becomes necessary for operation, that portion of code is first sought on the local filesystem. If the local filesystem does not include that portion, of the code, a network request is sent to another computer in the network in order to prompt transmission of that portion of code to the local computer. However, as different classes of sub-objects are created, a separate network request must be sent to retrieve code for each class . In the case of a Hyper-Text Transfer Protocol ("HTTP") request, each request must re-establish a Transmission Control Protocol/Internet Protocol ("TCP/IP") socket connection to the web server. Thus, when downloading a large number of classes, a large number of connections must be established and a large amount of network overhead is incurred.
Another drawback associated with the pull model is that as an object travels, the code which enables the object to operate must be re-downloaded at each computer. More particularly, when the object arrives at each a destination computer, the object downloads any code which is required but not present on the local filesystem, even if that code was downloaded at the previous destination computer. Previously downloaded code is not cached. Network overhead is incurred as a consequence.
In a "push" model the code for an executing object is carried with the mobile object. Prior to launching the mobile object, all of the code that will be needed by the object is identified. The code is packaged with the agent and pushed around the network to each destination computer. While the push model reduces network requests in comparison with the pull model, network overhead is still incurred because of the relatively large amount of code that is pushed to every destination computer. In some cases the object will push code for classes that are no longer needed. For example, an agent may create an instance of a particular class of object only in very exceptional circumstances. In such a case it is inefficient for the object to push the code for this class.
Another limitation of known mobile objects is difficulty in examining and predicting destination information. Known mobile objects initiate travel by performing a subroutine call. The method is sometimes given a name such as "go" or "moveTo," and the caller is responsible for specifying a name or Uniform Resource Locator ("URL") indicating the destination computer for the mobile object. When the travel method is called, the execution of the mobile object is halted and the mobile object is converted into a network transmittable form. On the destination computer the mobile object is restored from the network form and restarted. This restart can either occur on the instruction directly following the call to the travel method, or at the beginning of some known method.
BRIEF SUMMARY OF THE INVENTION In order to provide efficient mobility of code for a mobile agent object ("agent"), a "mobile codebase" object is constructed. The mobile codebase travels with the agent and serves as a repository of code for classes that facilitate agent operation. When the agent is launched, the launcher specifies a list of related classes. These classes are retained in the mobile codebase. The launcher also specifies a Uniform Resource Locator ("URL") that points to a network source ("home codebase") from which code can be downloaded.
If the agent is required to instantiate an object comprising code that is not in the mobile codebase, a network request is sent to the home codebase to retrieve that code. Code that is downloaded in this manner is retained in the mobile codebase .
The combination of the mobile codebase and home codebase improve agent operation and reduce network overhead. In a preferred embodiment an agent is launched with a mobile codebase that is preloaded with classes which are certain to be needed. Classes that are unlikely to be needed are stored in the home codebase. Thus the agent with mobile codebase and home codebase provide the desirable features of the push and pull models without the undesirable network overhead incurred by transmitting unneeded classes around the network or re-downloading code.
Agent travels are defined by an itinerary data structure. The itinerary is composed of a list of destinations, each of which includes: (1) the hostname of a destination computer on the network to which the agent should travel, and (2) the name of a method that the agent should execute when the agent arrives at the destination computer. An agent is allowed to modify its itinerary. When an agent modifies its itinerary, the agent owner is automatically notified, thus allowing the owner to "follow" the agent wherever it may travel .
The itinerary provides advantages related to agent and network management. Inspection of the agent itinerary reveals where the agent has travelled and where the agent may travel in the future. Since the itinerary is a standard data structure, an observer can depend on it to be present. Further, since the itinerary is a separate data structure from the agent, the observer does not need special knowledge of the internal structure of the agent in order to examine the itinerary.
BRIEF DESCRIPTION OF THE DRAWING The invention will be more fully understood from the following Detailed Description of the Invention, in conjunction with the Drawing, of which:
Fig. 1 is a block diagram which illustrates agent migration;
Fig. 2 is a block diagram which illustrates agent execution in conjunction with agent migration; Fig. 3 is a block diagram of an agent;
Fig. 4 is a block diagram of agent interaction with agent managers on multiple computers in a network;
Fig. 5 is a flow chart which illustrates agent mobility; Fig. 6 is a block diagram which illustrates agent operation according to an itinerary;
Fig. 7 is a block diagram which illustrates the agent runtime environment; and
Fig. 8 is a flow chart which illustrates agent deserialization.
DETAILED DESCRIPTION OF THE INVENTION Referring to Fig. 1, an agent 10 comprises a mobile object which can travel from a first computer 12 to a second computer 14 in a computer network 16. The agent is generated and stored in memory on the first computer for a specific purpose, and includes both data and executable code. The agent executes on the first computer and then migrates to the second computer by being transmitted across the network. The agent then resumes execution on the second computer. When the agent completes execution on the second computer, the agent acts in accordance with an agent itinerary. For example, the agent will migrate to another computer if the itinerary so indicates.
Referring now to Figs. 1 and 2, the agent executes a sequence of instructions during operation. In particular, a first method 18 is executed on the first computer 12 and a second method 20 is executed on the second computer 14. As a result, migration between computers is transparent from the perspective of the agent .
Referring to Fig. 4, agent mobility is preferably facilitated through use of JAVA agent manager Objects 32 and an Object Serialization facility (a product of Sun Microsystems which is known in the art) . Object Serialization operates to serialize objects such that a representative stream of bytes, i.e., data, is generated therefrom. Object Serialization facilitates transmission of an agent across the network by serializing the agent 10 into a format that is suitable for network transmission. Serialization of the agent may also include serialization of sub-objects which are contained within member variables of the agent. In accordance with the present invention, the serialization process involves the serialization of executable code, data, and an itinerary as hereinafter discussed in greater detail. Once the agent has been serialized, a communication socket to the second computer is opened and the resulting stream of bytes is transmitted to the second computer along the socket.
The serialized agent is regenerated in the second computer 14 upon arrival. In particular, the stream of bytes transmitted along the socket is deserialized in the second computer. Deserialization regenerates the agent in the form in which the agent existed prior to migration, i.e., an object. Following deserialization, the agent executes a predetermined method specified by its itinerary. The predetermined method may prompt interaction with another object 34 located on the second computer. When the method has been executed, the agent is serialized and transmitted to yet another computer, or possibly back to the first computer. The agent is therein deserialized upon arrival and proceeds to execute another predetermined method and interact with that computer. In the case of the agent migrating back to the first computer, such interaction could be with a host application 36 through which an information query was entered. The agent continues migrating across the network in this manner as execution requires. Eventually, the agent is terminated when execution of the itinerary is complete. It should be noted that the agent need not necessarily migrate to the initial host (first) computer after executing on a remote (second) computer. The agent could travel to multiple computers, and may not return to the initial host computer.
Referring to Fig. 3, each agent may include data 22, code 24, sub-objects 26 and an itinerary 28. The data portion 22 includes internal state information associated with the agent. The code portion 24 includes executable code associated with operation of the agent. The itinerary portion 28 specifies destinations for the agent. Sub-objects 26 include code of distinct objects contained within the agent. The agent carries the code for these sub-objects. The code 24 portion of the agent 10 includes a mobile codebase and a reference pointer to a home codebase. The mobile codebase comprises executable code which is retained as part of the agent. When the agent migrates, the mobile codebase is transmitted along with the data, sub-objects and itinerary to the destination. The home codebase is executable code which resides on the computer which originally created and launched the agent or a suitable network server (such as a web server) . The reference pointer to the home codebase is a Uniform Resource Locator ("URL") that allows remote access to the home codebase from other computers in the network. If the agent requires code that is not present in the mobile codebase during execution, the agent retrieves the required code from the home codebase and retains such retrieved code in the mobile codebase.
Referring to Figs. 3 and 6, the itinerary 28 is a data structure which defines agent migration parameters. The itinerary is composed of a list of destinations and the name of a method associated with each such destination. In a preferred embodiment, each destination entry contains the Transmission Control Protocol/Internet Protocol ("TCP/IP") host name of a computer on the network to which the agent is designated to migrate. The method associated with the respective destination is invoked upon arrival at that destination. Hence, each destination represents a location and a task to be performed at the location.
Figs. 4 and 5 illustrate agent mobility. When the determination is made that the agent should migrate, the agent manager 30 examines the itinerary 28 to ascertain the next destination to which the agent 10 is designated to migrate. The agent manager 30 establishes a network connection to the agent manager 32 at the destination computer 14. The agent manager 30 passes the agent and related travel information to the destination agent manager
32. The agent manager 30 then deletes the local copy of the agent, terminates any execution threads which were being used by the agent, and performs other appropriate clean up activities . From the perspective of the destination computer, the agent arrives at the destination computer as illustrated in step 38. As previously described, the agent arrives in the form of data which includes the code, sub-objects, itinerary and other data. Java/Object Serialization assists the de- serialization and reconstruction of the agent as depicted in step 40. The server then spawns a new thread in which the agent will execute as shown in step 42. A persistent local copy of the agent is then made as illustrated in step 44. As depicted in step 46 the agent manager invokes the proper method of the agent for execution in the spawned thread at this node. The itinerary contains information indicating which method should be invoked at each designated destination computer. The agent then executes as illustrated in step 50. When the agent has completed execution of the indicated method, another persistent copy of the agent is stored on the local disk as depicted in step 52 in order to prevent redundant execution in the event that the computer malfunctions before the agent migrates. The agent manager then examines the agent itinerary as illustrated in decision step 54. If the itinerary does not indicate any further destinations then agent execution is deemed complete as shown in step 56. However, if the itinerary indicates further destinations, then the agent manager determines whether the next destination is associated with another computer in decision step 58. If the next destination is not another computer, flow returns to step 44, thereby bypassing network traffic. However, if the next destination is associated with a different agent manager then a network connection to the indicated agent manager is established as depicted in step 60. The destination contains a string which indicates where to travel. The string contains either the name (host name) of a computer or a URL to a distributed object. The agent is then serialized as illustrated in Step 62 and subsequently transmitted to the next agent manager as depicted in Step 64.
Migration in accordance with the itinerary 28 is further illustrated in Fig. 6. The itinerary includes a listing including identification of each agent manager 66 to which the agent is configured to migrate and identification of a method 68 to execute at each respective agent manager. The agent migrates through the agent managers listed in the itinerary sequentially in the order in which the servers are listed, invoking each respective method upon arrival. Such method could be, for example, querying or updating a database on the destination computer.
Fig. 7 illustrates the agent runtime environment. Each computer 70 on the network includes a Java Virtual Machine 72 running therein. A agent manager 74 runs on each respective Virtual Machine 72. The agent manager includes a plurality of threads 76, each thread having an agent 78 associated therewith. In particular, a new thread is formed when a new agent arrives at the server, and the agent executes on that thread. Security mechanisms prevent each agent from operating outside the scope of the associated thread. When agent execution completes, the agent migrates to the next destination identified in the itinerary.
In order for migration and execution to function properly, the agent manager modifies the mechanism by which Java loads classes. The Java standard library provides an object called a "ClassLoader" which can be subclassed by a programmer to modify the rules that Java follows to load classes. The ClassLoader class allows web browsers to download "applets" from a web server. The agent manager provides a specialized ClassLoader which allows the executable code for mobile agents to travel with the agent. During a typical execution of a Java program, a Java interpreter loads classes as needed for execution from a logical file system on the local computer. However, agents become separated from the home computer and the home codebase during migration, i.e., agents are separated from the directory or directories on the filesystem of the home computer where the code is stored. Further, sub-objects sometimes need to be created as the agent executes, either as member variables or as temporary variables within the methods. These sub-objects could be instances of classes which are part of the standard Java packages or they could be instances of new classes written by the programmer of the agent. However, since the agent is executing on a different computer than the home computer following migration, the Java virtual machine may not be able to directly retrieve the code for the particular sub-object. To allow agents to properly load classes and construct objects when remote from the home computer, a special ClassLoader is employed by the agent manager whenever an agent attempts to construct an object. The ClassLoader object first attempts to locate a class on the local file system of the computer. If the class is not on the local file system, the ClassLoader searches the mobile codebase. If such attempt fails, the ClassLoader sends a request back to the home machine of the agent. The agent's travel information contains a reference such as a URL which refers back to the home codebase on the home computer, and by accessing the URL the ClassLoader can retrieve classes from the home computer. Agent deserialization is illustrated in Fig. 8. As depicted in step 80 the serialized agent arrives as a stream of data. Java Development Kit Object Serialization classes then call an agent manager related method to perform deserialization as shown in step 82. The method reads agent related objects from the object stream as depicted in step
84. In particular, the mobile codebase, itinerary and codebase URL are read by the method. A custom Classloader and ObjectInputStream are constructed as shown in step 86. Object Serialization then reads the agent and other objects from the input stream as depicted in step 88 and step 90, respectively. When the related objects are read, the ClassLoader retrieves the classes which comprise the agent as illustrated in step 92.
The new object's class is loaded once the classes are retrieved. As depicted in step 94, if the class is determined to have been previously loaded then the previously loaded class instance is employed (step 96) and the object is instantiated using the loaded class object as shown in step 98. However, if the class has not been previously loaded as determined in inquiry step 94, then inquiry is made as to whether the class is on the local class path of the destination computer as illustrated in decision step 100. If the class is present on the local machine then the class is loaded therefrom as shown in step 102 and the object is instantiated using the loaded class object as depicted in step 98. However, if the class is not found on a local class path as shown in step 100 then an inquiry is made as to whether the class is in the mobile codebase as shown in step 104. If the class is located in the mobile codebase then the class is loaded therefrom as shown in step 106 and the object is instantiated using the loaded class object as shown in step 98. However, if the class is not located in the mobile codebase in decision step 104 then the class is loaded by accessing the home codebase as shown in step 108. If the codebase pointer is an Internet type pointer such as a Hyper- Text Transfer Protocol ("HTTP") URL, as determined in inquiry step 110, then an HTTP request is sent to the local web server as shown in step 112 and the retrieved class is added to the Mobile CodeBase as depicted in step 114. However, if the codebase URL is not a HTTP URL then a remote method request is sent to a RemoteClassLoader object as shown in step 116 and the class is added to the mobile codebase as shown in step 114. In either case, the object is instantiated using the loaded class object as shown in step 98. If more objects exist in the stream to be retrieved, as determined in decision step 118, then another object is read from the input stream as illustrated in step 90. If there are no more objects to be retrieved, flow terminates.
Having described the preferred embodiments of the invention, other embodiments which incorporate concepts of the invention will now become apparent to one of skill in the art. Therefore, the invention should not be viewed as limited to the disclosed embodiments but rather should be viewed as limited only by the spirit and scope of the appended claims .
Λ program listing follows in the attached APPENDIX. Agent. java_l Tue Nov 12 08:01:22 1996 1
1 /* $Header: /com/mei ca/hsl/zones j gents /shared/Agent . Java 13 9/30/9
2
3 * Copyright 1996 Horizon Systems Laboratory, Mitsubishi Electric
4 * Information Technology America.
5 * All rights reserved. 6
7 * CONFIDENTIAL AND PROPRIETARY PROPERTY OF MITSUBISHI ELECTRIC ITA.
8 *
9 * DESCRIPTION
10 * Base class for mobile Agent
11 *
12 * $Log : /com/meitca/hsl/zonesjagents/shared/Agent . Java $
13 *
14 * 13 9/30/96 6:23Ό Walsh
15 * clean up javadoc comments
16 * . 17 * 12 9/29/96 4:09p Walsh
18 * Give Agent access to Agen Package information 19
20 * 11 9/28/96 6:Ξ7p Walsh
21 * Comment out debug println
22
23 * 10 9/09/96 4 : 53p Walsh
24 * Add prepareForTransporc , completedTransport methods 25
26 * 9 9/04/96 3:18p Noemi
27 * Added static initializer. Moved functionality related to collaborat
28 * to new CollaboratorAgent subclass. 29
30 * 8 8/30/96 4:30p Noemi
31 * Changed constructors and_ finalizer to operate on AgentGroup referenc
32 * (rather than AgentGroupIm 1 references) .
33 *
34 * 7 8/28/96 2:45p Noemi 35 * Removed SourceSafe conflict garbage.
36
37 * 6 8/28/96 2:20p Noemi
38 * Added support for AgentGroups .
39 *
40 * 5 8/23/96 3:52p Walsh
41 * Remove live method (superceded by ad-hoc invocation)
42 *
43 * 4 8/22/96 6 : 36p Walsh
44 * Remove parameter to live method
45 *
46 * 3 8/13/96 2:23p Walsh
47 * Add some comments & documentation
Agent. ava_l Tue Nov 12 08:01:22 1996 2
48 *
49 * 2 8/09/96 4:49p Walsh
50 */
51 package com. meitca. hsl . zonesjagents . shared;
53 import Jav .util . *;
54 import Java .net . InetAddress ; 55
56 import com. meitca .hsl . zones;agents . conduit . * ;
57
58
59 /**
60 * A base class representing a traveling agent program. All user defined
61 * agents should be derived from the class Agent. An agent
62 * travels from machine to machine as dictated by its Itinerary. At each stop,
63 * a specified method will be invoked. After the method completes, the Agent
64 * will be sent tc the next host on the itinerary. To develop an agent, a
65 * programmer should derive a class from Agent.
66 * @see ConcuitServer
67 * Ssee AgentGroup
68 * Sauthor Noemi Paciorek 69 * ©author Thoiras Walsh
70 */
71 public abstract class Agent { 72
73 // Class variables
74 /** A counter used to generate the Agent's ID /
75 protected static ir.t agentNu = 0; // counter for agents started on a system 76
77 /** A unique ID representing the host the agent was initiated from*/
78 protected static String host; // unique host ID 79
80 // Instance variables
81 /** A un_gue ID representing the Agent */
82 protected String agent ID; // unique agent ID
83
84 // A reference to the Agent's AgentPackage. This reference will only be
85 // valid when the Agent is actually tavelling. Prior to travel, this
86 // will be a null reference (for example the reference will be null
87 // when the Agents constructor is executing) .
88 private AcentPackage itsPackage;
89
90 // Static initializer
91 static {
92 /*
93 * Try to obtain the host's name and IP address. If this fails,
94 * construct a pseudo-random name and hope for the best! (Of course,
Agent. java_l Tue Nov 12 08:01:22 1996 3
95 * this should never happen.)
96 */
97 try {
98 host = Iπet÷Address .getLocalHost () .toString () ;
99 } catch (Exception e) {
100 hose = " FOSTID " + new Random( ) .nextLong ( ) ;
101 }
102 } * 103
104 // Constructors
105 /** Constructs an Agent */
106 public Agent () {
107 /*
108 * Assign a unique agent ID.
109 */
110 try {
111 agentID = host + "/agent" + nextAgentNum( ) ;
112 //System. out. rintln( "Agent ID = " + agentID) ;
113 } catch (Exception e) {
114 System. out .println ( "Agent constructor error: " + e .getMessage ( )
115 e .printStackTrac ( ) ; 116
117 }
118
119 itsPackage = null;
120 } V 121
122 // Class methods
123 private final synchronized int nextAgentNum( ) {
124 return ++agentNum;
125 } 126
127 // Instance methods
128 /**
129 * Retrieves the Agents ' s ID. An AgentID is a unique String
130 * which identifies a particular instance of an Agent.
131 * δreturπ The Agent's ID.
132 */
133 public final String getAgentlDO {
134 return agentID;
135 }
136
137 / **
138 * Converts an Agent to a String. Implementation simply
139 * returns the AgentID.
140 * Sreturn A String representation of the Agent.
Agent. java_l Tue Nov 12 08:01:22 1996
142 public final String toStringO {
143 return geύAgentID( ) ;
144 } 145
146 /**
147 * This is called by the ConduitServer immediatley prior to
148 * the agent being transported to its next destination. Derived
149 * Agents can override this method to perform any final processing
150 * needed before transport
151 */
152 public void prepareForTransport ( ) {
153 } 154
155 /**
156 * This is called by the ConduitServer when the Agent arrives at
157 * its new destination. Derived Agents can override this method
158 * to perform any processing needed on arrival
159 */
160 publ ic void completedTransport ( ) {
161 }
162
163 /**
164 * Returns a reference to the Agents Itinerary. The Itinerary
165 * iε only available when the Agent is traveling. It is not
166 * available during -he Agent's constructor. If the Itinerary
167 * is not available, this method returns null.
168 * øreturr. The Agents Itinerary or null if the itinerary is
169 * not available
170 */
171 public Itinerary getltinerary ( ) {
172 if (izsPackage != null) {
173 return itsPackage .getltinerary () ;
174 } else {
175 return null;
176 }
177 }
178 179
180 * Returns a URL pointing to the Agent's codebase on it home machine.
181 * This URL is used in conjunction with the AgentCodebase class to
182 * retrieve the byteccdes of the Agent and it related classes.
183 * The URL available v;hen the Agent is traveling. It is not
184 * available during the Agent's constructor. If the URL
185 * is not available, this method returns null.
186 * ©return The URL of the Agents codebase or null if the URL is
187 * not available
188 */
Agent. java_l ue Nov 12 08:01:22 1996 5
189 public String getHomeCodebaseURL ( ) {
190 if (itsPackage != null) {
191 return itsPackage .getHomeCodebaseURL) ) ;
192 } else {
193 return null;
194 }
195 } 196
197 /**
198 * This Method is called internally by the ConduitServer to
199 * provide the Agencs with a reference to its package.
200 */
201 public void setPackage (AgentPackage agentPackage) {
202 itsPackage = agentPackage;
203 } 204
205 }
AgentCodebase. java_l Tue Nov 12 08:01:22 1996 1
1 /* $Header: /com/meitca/hsl/zonesjagents/εhared/AgentCodebase . ava 3 11/11/96 5:25p Billp $
2 *
3 * Copyright 1996 Horizon Systems Laboratory,
4 * Mitsubishi Electric Information Technology Center America.
5 * All rights reserved.
6 *
7 * CONFIDENTIAL AND PROPRIETARY PROPERTY OF MITSUBISHI ELECTRIC ITA.
8 *
9 * DESCRIPTION
10 * Class providing accessability to the home codebase of the agent
11 *
12 * $Log : /com/meitca/hsl/ zonesjagents/shared/AgentCodebase . Java $
13 *
14 * 3 11/11/96 5:25p Billp
15 * Made correction to company name
16 *
17 * 2 9/30/96 6:23p Walsh
18 * clean up javadoc comments
19 *
20 * 1 9/28/96 6:35p Walsh
21 * intial version
22 3 */
24 package com.meitca .hsl . zonesjagents . shared;
25
26 import java.net.*;
27 import java.io.*
28 import sun . net . www.MeteredStream; 29
30 import com. meitca .hsl . zonesjagents . remoteloader .* ; 31
32 /**
33 * The AgentCodebase class provides accessability to the "home
34 * codebase" of an agent. As an agent travleε, it may construct
35 * an object whose bytecodes may not be installed on the machine
36 * to which it has travelled. In some cases, the agent may have
37 * already constructed another instance of the same class or, the
38 * user or programmer may have specified that this class was a 39 * "related class" when launching the agent. In both of these
40 * cases, the bytecodes for the class should have already been
41 * loaded into the Agent's MobileCodebase . If the bytecodes for
42 * the new object HAVE NOT already been loaded into the MobileCodebase,
43 * the ConduitServer needs a mechanism for finding an retrieving
44 * these bytecodes . The AgentCodebase provides an mechanism through
45 * which Agents can retrieve code from their home locations.
46 * Ssee Agent
47 * @see MobileCodebase
AgentCodebase . j va_l Tue Nov 12 98:01:22 1996
54 * agents codebase.
55 */
56 static final int UNKNOWN = -1;
57 static final int RMI = 0;
58 static final int HTTP = 1;
59 static final int FILE = 2; 60
61 /**
62 * The protocol to use to retrieve bytecodes from the
63 * AgentCodebase
64 */
65 int itsProtocol; 66
67 /** An URL pointing back to the AgentCodebase */
68 String itsURL;
69
70 /**
71 * A ClassFileLoader ooject which may be used to
72 * retrieve agent bycecod- 3 from the local filesystem
73 * (when a file: url s used to identify the codebase
74 */
75 ClassFileLoader itsClc.εsFileLoader ; 76
77 /**
78 * Constructs an AgentCodebase from the given URL.
79 * Oparan url An URL pointing to the AgentCodebase. This
80 * URL can be;<br>
81 * <ul>
82 * <li>An HTTP url pointing to a location on a web server
83 * (such as <b>http : //host/directory</b>)
84 * <li>An RMI url pointing to a RemoteClassLoader
85 * server (such as <b>rmi : //host/RemoteClassLoader/directory<
86 * <li>A FILE url pointing to a local directory
87 * (such aε <b>file :C : \directory</b>)
88 * <li>An empty string or null which indicates that the agents code
89 * is on the CLASSPATH of this machine.
90 * </ul>
91 * Sexception Malf or edURLException I f the url passed in was invalid
92 */
93 public AgentCodebase (String url) throws MalformedURLException {
94 itsProtocol = -1;
AgentCodebase. java_l Tue Nov 12 08:01:22 1996
95 itsURL = null;
96 itsClaεsFileLoader= null;
97 parseURL (url ) ; 98
99 if (itsProtocol == FILE)
100 itsClassFileLoader = new ClassFileLoader () ;
101 } 102
103 /**
104 * Retrieve the bytecodes for the given class
105 * @param classname The name of the class whose bytecodes to
106 * retrieve
107 * Sreturn The classes bytecodes in the form of a byte array
108 * ©exception ClassNotFoundException If the class could not be loaded
109 */
110 public byte [ ] retrieveCode(String classname) throws ClassNotFoundException {
111 switch (itsProtocol) {
112 case RMI:
113 return RemoteClassLoaderlmpl . retrieveRemoteClass (itsURL, classname);
114 case HTTP:
115 return retrieveHTTPClass (classname) ;
116 case FILE:
117 return itsClassFileLoader . loadClassFileFromDirectory (itsURL, classname);
118 default:
119 throw new ClassNotFoundException ( "Unsupported protocol");
120 }
121 } 122
123 /* Used internally to parse URL passes into ctor */
124 private void parεeUR (String url) throws MalformedURLException {
125 if (url '= null) {
126 int sep = url . indexOf ( ' : ' ) ; 127
128 if (sep != -1) {
129 String protocol = url . substring (0 , sep);
130 if (protocol .equals ( "rmi" ) ) {
131 itsProtocol = RMI;
132 itsURL = url;
133 } elεe if (protocol .equalε ( "http" ) ) {
134 itεProtocol = HTTP;
135 itsURL = url; 136 if ( itsURL. endsWith ( " / " ) ) {
137 itsURL = itεURL.εubεtring(0, itεURL. length { ) -1) ;
138 )
139 } elεe if (protocol . equals {" file" ) ) {
140 itεProtocol = FILE; 141
AgentCodebase.java_l Tue Nov 12 38:01:22 1996 4
142 // strip off the file: portion so all we are left with is
143 // the directory spec of the codebase.
144 itsURL = url . substring (sep+1, url . length ()) ;
145
146 } else {
147 // we will assume file since the user might be trying to specify a
148 // DOS style filename (ie C:\WINNT)
149 itsProtocol = FILE;
150 itsURL = url;
151 }
152 } else {
153 // assume file
154 itsProtocol = FILE;
155 itsURL = url;
156 }
157 } else {
158 // the URL was null. This means that the Agents code iε located somewhere on
159 // the class path of this machine. We will set the protocol to FILE and leave
160 // the url as null
161 itsProtocol = FILE;
162 }
163 } 164
165 /* Used internally to retrieve .class files from a web server */
166 private byte [ ] retrieveHTTPClass (String classname) throws ClassNotFoundException {
167 try {
168 // first we will try to load the agent using its fully qualified class
169 // name. If the HTTP URL was http : //host/Agents and the class name
170 // was test .TestAgent, we will build an URL like the following;
171 // http: //host/Agents/test/TestAgent. class
172 URL classUrl = new UR (itsURL + "/" + classname . replace ('.' , '/') + ".class"); 173
174 MeteredStream stream = (MeteredStream) classUrl . getConten () ;
175 int length = stream. available () ;
176 byte dat [ ] = new byte [length] ;
177
178 stream. read (data) ;
179 return data;
180 } catch (IOExcepticn io rror) {
181 // The fully qualified class name didn't work, so letε try to
182 // εtri off all of the pacakge names and εearch for just the
183 // claεs name. If the HTTP URL waε http: //host/Agents and the class name
184 // was test .TestAgent, we will build an URL like the following;
185 // http: //host/Agents/TestAgent .class
186 int lastSep = classname . lastlndexOf ('.') ;
187 if (lastSep != -1) {
188 try {
AgentCodebase . j ava_l Tue Nov 12 03 : 01 : 22 1996 5
189 URL classUrl = new URL(itsURL + "/" + classname . substring (lastSe-
+ 1, classname. length ( i '. -r ".class"); 190
191 MeteredStream stream = (MeteredStream) classUrl . getConten () ;
192 int length = stream. available () ;
193 byte datat] = new byte [ length] ; 194
195 stream. read (data) ;
196 return data;
197 ] catch (Exception error) {
198 throw new ClassNotFoundException ( "Could not load class " + classname + "frcr " + itsURL) ;
199 }
200 } else {
201 tnrow new ClassNotFoundException ( "Could not load class " + classname + "from " + itr RL) ;
202 }
203 } catch (Exception error) {
204 throw new ClassNotFoundException ( "Could not load class " + classname + "from " + itsURL);
205 }
206 }
207 }
AgentConstantβ. java_l Tue Nov 12 08:01:23 1996 1
1 /* $Header: /com/meitca/hsl/zonesjagents/shared/AgentConstants . Java 2 11/11/96 5:25p Billp $
2 3 * * Copyright 1996 Hori zon Systems Laboratory,
4 * Mitsubishi Electric Informat ion Technology Center America .
5 * All rights reserved .
6
7 * CONFIDENTIAL AND PROPRIETARY PROPERTY OF MITSUBISHI ELECTRIC ITA.
8 *
9 * DESCRIPTION
10 * Constants used by Java Agents system. 11
12 * $Log: /com/meitca/hsl/zonesjagents/shared/AgentConstants . Java $
13 *
14 * 2 11/11/96 5:25p Billp
15 * Made correction to company ame 16
17 * 1 10/10/96 5:50p Walsh
18 * initial version
19 *
20 */
21 package com.meitca .hsl . zoneεjagents . shared; 22
23 import Java. io .File;
26 * Class contains constants used within the Java Agent System.
27 */
28 public class AgentConstants {
29 /**
30 * Contains the value of the "zones.home" property (which
31 * points to the Zones installation directory)
32 */
33 public static String ZONES_HOME; 34
35 /**
36 * Contains the value of the "zones .user .home" property (which
37 * points to the Zones αser specific directory)
38 */
39 public static String ZONES_USER_HOME ;
47 /**
AgentConstants. java_l Tue Nov 12 03:01:23 1996 2
48 * Contains the path of the Agent subdirectory of the Zones
49 * installation directory.
50 */
51 public static String AGΞNT_DIR,
52
53 /**
54 * Contains the path of the lib subdirectory of the Zones/Agents
55 * installation directory
56 */
57 publ ic stat ic String zιGENT_LIB_DIR , 58
59 /**
60 * Contains the path of the Agent subdirectory of the Zones
61 * installation directory
62 */
63 public static String USER_AGENT_DIR, 64
65
66 /** Static Intializer is jsed to initialize some of the CONSTANTS */
67 static {
68 Z0NES_H0ME = System getPropert (" zones home', File separator + "Zones')
69 if (ZONES_HOME '= null/ {
70 // termina e the directroy name with a separator if
71 // it's not already terminated
72 if ( ' ZO •JES_HOME endsWith (File separator))
73 ZONES_HOME += File separator 74
75 IMAGE_DIP = Z0NES_H0ME + "images' + File separator
76 AGENT_DIR = ZONES_HOME + "Agents" + File separator,
77 AGENT_LIB_DIR = AGENT_DIR + "lib" + File separator,
78 } 79
80 ZONES_USER_HOME = System getProperty( zones user home' )
81 ii (ZONES_USER_-iOME == null) {
82 / / the zones user home Property was not defined
83 // try the user home Property
84 ZONES_USER_HOME = System getProperty( "user home",""),
85 -f (ZONES_USER_HOME = null) {
86 // terminate the directroy name with a separator if
87 // t's not already terminated
88 if ( ' ZONES_USER_HOME endsWιth(Fιle separator))
89 ZONES_USER_HOME += File separator, 90
91 ZONES_USER_HOME += " Zones",
92 }
93 } 94
AgentConstants. java_l Tue Nov 12 03:01:23 1996 . 3
95 if (ZONES_USER_HOME != null) {
96 // terminate the directroy name with a separator if
97 // it's not already terminated
101 USER_AGENT_DIR = ZONES_USER_HOME + "Agents" + File . separator ;
102 103 104 }
ClassFileLoader. java_l Tue Nov 12 08:01:23 1996 1
1 /* $Header: /com/meitca/hsl/zonesjagents/shared/ClassFileLoader . Java 3 11/11/96 5:25p Billp $
2 *
7 * CONFIDENTIAL AND PROPRIETARY PROPERTY OF MITSUBISHI ELECTRIC ITA.
8 *
9 * DESCRIPTION
10 * Loads a ".class" file off of the local filesystem.
11 *
12 * $Log : /com/meitca/hsl/zonesjagents/εhared/ClaεsFileLoader . Java $
13 *
14 * 3 11/11/96 5:25p Billp
15 * Made correction to company name
16 *
17 * 2 9/30/96 6:23p Walsh
18 * clean up javadcc comments
19 *
20 * 1 9/28/96 6:35p Walsh
21 * intial version
22 *
23 */
24 package com. eitca .hsl . zonesjagents . shared;
25
26 import sun . tools . Java .* ;
27 import Java . io . * ,- 28
29 /**
30 * The ClasεFileLoader class loads a Classes bytecodes off of the
31 * local filesystem. The user can either specify a particular directory
32 * from which the bytecodes should be retieved, have the ClassFileLoader
33 * search the system CLASSPATH or specify a custom Clasε Path which should
34 * be searched for the bytecodes. 35 * ©author Thomas Walsh
36 */
37 public clasε ClassFileLoader {
38 /**
39 * The ClaεsPath which should be εearched for ClassFileε. Thiε could
40 * represent the system CLASSPATH, or a custom ClassPath specified by the
41 * user.
42 */.
43 ClassPath itsClasεPath; 44
45 /**
46 * Constructs a ClassFileLoader obj ect . This constructor sets the
47 * ClassFileLoader up εo that it will search the system' s CLASSPATH .
ClassFileLoader. java_l Tue Nov 12 08:01:23 1996 2
48 */
49 public ClassFileLoader ( ) {
50 itsClassPath = new ClasεPath(System. getProperty ( "Java . class .path" ) )
51 } 52
53 / **
54 * Constructs a ClassFileLoader object. The pathstr parameter specifies
55 * a custom ClassPath from which bytecodes are to be retrieved.
56 * ϋparam pathstr A custom ClassPath from which bytecodes are to be
57 * retrieved
58 */
59 public ClassFileLoader (String pathstr) {
60 itsClassPath = new ClassPath (pathstr) ;
61 } 62
63 /**
64 * Loads a class from the objects class path. Depending on which
65 * version of the constructor was used, this could mean that the
66 * system's CLASSPATH is searched or that a custom user-defined
67 * ClassPath iε searched.
68 * Sparam classname The fully qualified class name of the class to
69 * be loaded.
70 * ϋreturn The bytecodes for the requested class in the form of a
71 * byte array
72 * ^exception ClassNotFoundException If the class could not be located on
73 * the ClassPath
74 */
75 public byte [ ] loadClassFileFromClassPath (String classname) throws ClassNotFoundException {
76 String filename = classname . replace ('.' , File . separatorChar) •*- ".class";
77 ClassFile file = itsClassPath . getFile ( filename) ; 78
79 if (file != null) {
80 try {
81 long length = file. length () ;
82 InputStream stream = file .getInputStream( ) ;
83 byte data [ ] = new byte [ (int ) length] ;
84
85 stream. read (data) ;
86 return data;
87 } catch (IOException e) {
88 throw new ClassNotFoundException (e .getMessage ()) ;
89 }
90 } else {
91 throw new ClassNotFoundException ( "ClassFile not found on ClassPath: " + classname) ;
92 }
93 } 94
JASProperties . j ava_l T-te Nov 12 08 : 01 : 23 1996 1
1 / * $Header / coir /mei tca /r s l / zones j agents / shared /JASPropert ies ]ava 4 11 / 11 / 96 5 25p Bi l lp $
3 2 ** Copyright 1996 Horizon Systems Laboratory,
4 * Mitsubishi Electric Infer- ation Technology Center America
5 * All rights reserved
6
7 * CONFIDENTIAL AND PROPRIETARY PROPERTY OF MITSUBISHI ELECTRIC ITA
8 *
9 * DESCRIPTION
10 * Zones Agent Property File implementation
11 * $Log /com/rreitca/hsl/ zones3agents/shared/JASProperties ;java $ 12
13 * 4 11/11/96 5 25p Billp
14 * Made correctior to company rame
15 *
16 * 3 10/10/96 5 56p Walsh
17 * Make use of constants in AgentConstarts class 18
19 * 2 10/10/96 2 30p Walsh
20 * Add default corstructor
21 *
28 import ]ava 10 *,
29 import 3ava util * 30
31 /**
32 * The JASProperties supports the storage of
33 * user specific and server specific proDerties
34 * <ul>
35 * <lι>User specific properties are stored in
36 * zones user homeXAgents directory If the
37 * zones user home System property is not defined,
38 * user properties are stored in the
39 * user home\ ZonesXAgents directory
40 * <lι>Server specific properties are stored in
41 * zones home\Agentε\Lιb
42 * </ul>
43 * @see Properties
44 * Θauthor Joe DiCelie
45 * Θauthor Tom Walsh
46 */
47 public class JASProperties extends PropertyFile {
ClassFileLoader. java_l Tue Nov 12 08:01:23 1996 4
151 }
152 }
ClassFileLoader. ava_l Tue Nov 12 08:01:23 1996 3
95 /**
96 * Loads a class from a particular directory.
97 * @param dir The directory from which to retireve the class. If
98 * this parameter is null or an empty string, the ClassPath
99 * is searched for the class
100 * @param classname The fully qualified class name of the class to
101 * be loaded.
102 * Θretur s The bytecodes for the requested class in the form of a
103 * byte array
104 * Θexcepticn ClassNotFoundException If the clasε could not be located on
105 * the ClassPath
106 */
107 public byte[] loadClaεsFileFromDirectory (String dir, String classname) throws ClassNotFoundException {
108 // if a null or an empty string was passed in for dir, "fall back to
109 // searching the class path for the clasε
110 if ((dir == null) || (dir . lengthO == 0))
111 return ioadClassFileFromClassPath(classname) ; 112
113 // place a sperator char on the end of the directory specification
114 // if it does not already have one
115 if (! ir .endsWirh (File. separator) ) {
116 dir = dir + File . separator ;
117 118
119 String fullFilaname = dir + classname .replace ('.' , File.separatorChar) + ".class"; I 120
121 try {
122 File file = new File (fullFilename) ; 123
124 if (file. exists!) ) {
125 long length = file. length( ) ;
126 FilelnputStream stream = new FileInputStream( ile) ;
127 byte data[] = new byte [ (int) length] ; 128
129 stream. read (data) ;
130 return data;
131 } else {
132 int lastSep = classname. lastlndexOf ('.') ;
133 if (lastSep != -1) {
134 String filename = dir + classname. subεtring (lastSep + 1, claεsname. length ( ) " .class" ;
135 file = new File (filename) ;
136 long length = file. length ( ) ;
137 FilelnputStream stream = new FilelnputStream(file) ;
138 byte data[] = new byte [ (int) length] ; . 139 140 stream. rea (data) ;
JASProperties . java_l Tue Nov 12 08 : 01 : 23 1996 2
48
49 /**
50 * This constant should be passed into constructor to
51 * specify that this object will contain <b>Server</b>
52 * specific properties.
53 */
54 public static final int SERVER = 0; 55
56 /**
57 * This constant should be passed into constructor to
58 * specify that this object will contain <b>User</b>
59 * specific properties.
60 */
61 public static final int USER = 1 ; 62
63 private static final String PROP_FILE_SUFFIX = ".properties";
64 private static final String DEFAULT_DESC = "Zones Property File"; 65
66 /**
67 * Opens a Properties file and constructε a JASPropertieε object.
68 * Θparam appName A unique name used to identify the application.
69 * The <i>appName</i> is used in constructing the name of the
70 * filename of the corresponding properties file. The
71 * properties file will have a name of the form
72 * "appName .properties"
73 * @param type Idientifieε the type of propertieε file to open.
74 * This parameter can have the value <b>JASProperties .USER</b>
75 * or <b>JASProperties .SERVER</b>. The <i>type</i> parameter
76 * controls where the proerties file is opened from.
77 * <ul>
78 * <li>Uεer specific properties are stored in
79 •* zones .user .homeXAgents directory. If the
80 * zones .user .home System property is not defined,
81 * user properties are stored in the
82 * user .ho e . ZonesXAgents directory
83 * <li>Server specific properties are stored in
84 * zones .homeXAgentsXLib
85 * </ul>
86 * βpara description A description of this JASProperties object.
87 * The description will be written to the header of the
88 * Properties file if the save method is called
89 * Θparam createlfNecessary If set to true, the JASProperties will
90 * create the Properties file if it does not already
91 * exist. If set to false, then the constructor will
92 * throw a FileNotFoundException if the Properties £ile
93 * does not exists.
94 * Sexcepticn FileNotFoundException If the Propertieε file could not
JASProperties. java_l Tue Nov 12 08:01:23 1996 3
95 * be found and the createlfNecessary parameter is false.
96 * Θexception IOException If an error occurred while attempting to
97 * access the Properties file
98 * @excepticn IllegalArgumentException If the value passes into the
99 * type argument was not valid.
100 */
101 public JASProperties (String appName, int type, String description,
102 boolean createlfNecessary)
103 throws FileNotFoundException, IOException, IllegalArgumentException { 104
105 itsDescription = (description != null) ? description : DEFAULT_DESC;
106
107 // Open the default JAS security properties file.
108 itεFile = locatePropertiesFile (appName, type, createlfNecessary); 109
110 loadProperties ( ) ;
111 } 112
113 /**
114 * Builds an "empty" Properties object. This method can be used
115 * to construct a Properties object which returns only default values.
116 * This behavior may be desired if the Properties file can not be found
117 * and the program wishes to continue execution using its default values
118 * or preferences .
119 */
120 public JASProperties () { 121
122 }
123
124 /*
125 * Builds a prperties filename based on the appName and properties
126 * file type
127 */
128 private File locatePropertiesFile (String appName, int type,
129 boolean createlfNecessary)
130 throws IllegalArgumentException, FileNotFoundException, IOException {
131
132 String propDirNa e;
133 if (type == SERVER) {
134 // We are accessing a server properties file.
135 // Server specific properties are stored in
136 // the directory zones .homeXAgentεXLib.
137
138 propDirName = AgentConstants .AGENT_LIB_DIR;
139 } else if (type == USER) {
140 propDirName = AgentConstants . USER_AGENT_DIR;
141 } else {
JASProperties . java_l Tue Nov 12 08:01:23 1996 4
142 throw new IllegalArgumentException ( "Bad Properties File Type: " + type) 143 144 145 146 // See if the propperties directory exists 147 File propDir = new File (propDirName) ; 148 if ( ipropDir .exiεtε () ) { 149 // The directory does not exiεt. 150 // See if we should create it. 151 if (createlfNecessary) { 152 if ( ipropDir .mkdirs () ) { 153 // We could not create the directory. 154 // Throw an IOException 155 throw new IOException ( "Could create properties directory " 156 + propDir . toStringf j
157 } 158 } elεe { 159 // The directory did not exists . 160 // Throw a FileNotFoundException 161 throw new FileNotFoundException ( "Properties directory " 162 + propDir . toString ( ) + " did not exists"), (/ 163 164 165 \ 166 I I see if the properties file exists 167 File propFile = new F le (propDirName + File . separator + 168 appName + PROP_FILE_SUFFIX) 169 if ( ipropFile. exists () ) { 170 // The directory does not exist. 171 // See if we should create it. 172 if (createlfNecessary) { 173 // create the file. 174 FileOutputΞtream out = new FileOutputStream(propFile) ; 175 PrintStream print = new PrintStream(out) ; 176 print .println ( "#" + itsDescription) ,- 177 prin . close ( ) ; 178 // That εhould have created the file 179 } elεe {
186 return propFile; 187
JASProperties. java_l Tue Nov 12 08:01:23 1996 5
188 }
189
PropertyFile.java_l Tue Nov 12 08:01:23 1996 1
1 /* $Header: /ccm/meitca/hsl/zonesjagents/shared/PropertyFile . Java 2 11/11/96 5:25p Billp $
2 *
3 * Copyright 1996 Horizon Systems Laboratory,
4 * Mitsubishi Electric Information Technology Center America.
5 * All rights reserved.
6 *
7 * CONFIDENTIAL AND PROPRIETARY PROPERTY OF MITSUBISHI ELECTRIC ITA.
8 *
9 * DESCRIPTION
10 * Properties (Preference) File object.
11
12 * $Log: /com/meitca/hsl/zonesjagents/shared/PropertyFile. Java $
13
14 * 2 11/11/96 5:25p Billp
15 * Made correction to company name
16 *
17 * 1 10/07/96 5:07p Walsh
18 * intial versions
19 *
20 */
21 package com.meitca .hsl . zonesjagents . shared;
22
23 import java.io.*;
24 import java.util . * ; 25
26 /**
27 * The PropertyFile object extends the behavior of the Properties class
28 * by associating the Properties with a disk file. The PropertyFile
29 * object automatically loads the Proeprties out of the file (using the
30 * Properties . load method) and supplies a method for saving of any updated
31 * Properties back to disk, called saveProperties .
32 * Θsee Properties
33 * Θauthor Joe DiCelie
34 * ©author Tom Walsh
35 */
36 public class PropertyFile extends Properties {
37
38 /** The name of the properties file corresponding to this Properties object */
39 protected File itsFile;
40
41 /** A description of this Properties object. */
42 protected String itsDescription;
43
44
45 /**
46 * Opens the specified Properties file and constructs a
47 * JASProperties object.
PropertyFile. java_l Tue Nov 12 08:01:23 1996 2
48 * βparam propertiesFileName Name of the Properties file to open
49 * ©param description A description of this JASProperties object.
50 * The description will be written to the header of the
51 * Properties file if the save method is called
52 * Sexception FileNotFoundException If the Properties file could not
53 * be found and the createlfNecesεary parameter is false.
54 * Sexception IOException If an error occurred while attempting to
55 * access the Properties file
56 */
57 public PropertyFile (String propertiesFileName, String description)
58 throws FileNotFoundException, IOException { 59
60 itεFile = new File (propertiesFileName) ;
61 itsDeεcription = deεcription;
62 loadProperties ( ) ,-
63 } 64
65 /**
66 * Protected constructor that can be used by derived classes.
67 */
68 protected PropertyFile ( ) {
69 itsFile = null;
70 itεDescription = n ll;
71 // The actual work of loading properties will be
72 // done by derived class
73 } 74
75
76 // loads Properties from the Properties File
77 protected void loadPropert; es ( )
78 throws FileNotFoundException, IOException { 79
80 // open an input stream to the file specified
81 FilelnputStream in = new FilelnputStrea ( itsFile) ; 82
83 // load the propertieε
84 load (in) ;
85 }
86
87 /**
88 * Saves the Properties to the corresponding Properties File
89 * Sexception FileNotFoundException if the Properties file could not be
90 * located
91 * Sexception IOException if an error occurs while accessing the
92 * properties file
93 */
94 public void savePropertieε ( )
PropertyFile. ava_l Tue Nov 12 08:01:23 1996 3
95 throws FileNotFoundException, IOException {
96
97 // open an input stream to the file specified
98 FileOutputStream out = new FileOutputStream(itsFile) ;
99
100 // load the properties
101 save (out, itsDescription) ;
102 } 103
104 /**
105 * Refreshes the Properties object by re-reading the Properties File. Any
106 * changes made to the Properties object will be lost.
107 * Sexception FileNotFoundException if the Properties file could not be
108 * located
109 * Sexception IOException if an error occurs while accessing the
110 * properties file
111 */
112 public void refreshProperties ( )
113 throws FileNotFoundException, IOException {
114 loaάProperties ( )
115 } 116
117
118 }
119
120
121
122
AgentClassInfoGatherer. java_l Tue Nov 12 07:44:46 1996 1
1 /* $Header /com/me: .ca hsl/zones3agents/bootstrap gentClassIn oGatherer ]ava 5 11/11/96 5 13p Billp $
2 *
3 * Copyright 1996 -iorizon Systems Laboratory,
4 * Mitsubishi Electric Information Technology Center America
7 * CONFIDENTIAL AND PROPRIETARY PROPERT 0" MITSUBISHI ELECTRIC ITA 8
9 * DESCRIPTION
10 * AgentClassInfoGatherer class peeks ιi:o an agents class file to
11 * retrieve information needed for agert icjnchmg 12
13 * SLog /com/ e.tca/hsl/zones]age"ts bootstrap/AgentClassInfoGatherer 3ava $
14 *
15 * 5 11/11/96 5 _-p Billp
16 * Made correction to company name
17 *
19 * fix up ]avadoc
20 *
21 * 3 9/27/96 6 _0„ Dxcelie
22 * Minor cnange to loop uhich verified fi t tne class to be launched was
23 * subclasses from ? ~~ ~
24 *
25 * 2 9/10/96 11 46a Walsh
26 * remove bogus imports that 3avac illegal 27
28 * 1 8/29/96 5 20o ' lsh
29 * ntiai version 30
31
32 package com n«=^tca hs"1 zςnes]agents bootstrao 33
34 import }ava 10 *
35 import com meitca hsl zo^esj ge^ s cona..: -gentSkeletor 36 37 /**
38 * This ob3ect peeks irto the class file of an agent to retrieve
39 * some information needed for launching the agent
40 * AgentClassInfoGatherer verifies that the class file indicated
41 * does contain a class oeπved from Agent and then it verifies the
42 * existence of the agsnt's invocation skeleton and finally loads
43 * the skeleton class ι-tc memory and retreives a list of the
44 * agents methods froi the skeleton
45 * θεee Agent
46 * Sεee Bootstrap
47 * Sεee AgertLa ^nchWizard
AgentClassInfoGatherer. ja-va l Tue Nov 12 07:44:46 1996
48 * Sauthor Tl orras a^ sh
49 * /
50 public class Ager .ClεsslnfoGatherer {
51 /** The r-mes of tne agents methods */
52 String!] itsAgentsMethods ,
53 54
55 /**
56 * Constructs a AgentClassIn oGatnerer object Loads the agent
57 * and its s eletor Retrieves a list of the agent's methods
58 * (sparan agentDir The directory containing the agent's
59 * class file
60 * (?para:ι agentFilename The name of the agents 's class file
61 * (sexcepti n F_ .eNotFoundΞxcεption Thrown if the class specified
62 * could not oe opened
63 * (Sεycepticr IOException f an 10 error occurs vπle teymg to
64 * access tne agent's class file
65 * ssForrnatErrcr If tne agent's c.ass file αoes
66 * not contain a valid class
67 * ϋeicepticn NotAgentException If the agent's class file does
68 * not contain an agent
69 * (Jexcppticn ClassNotFoundException If an error occured while
70 * trying to access the agents class file
71 * Sexception No^gentSkeletonException If the agent's invocation
72 * skeleton could not be found
73 */
74 public AgentClassIn oGatherer (String agentDir, String agentFilename)
75 thr >ws FileNotFoundException, IOException, ClassFormatErrcr ,
76 NotAgentException, ClassNotFoundException,
77 NoAgentSkeletonException {
78 ' ' let the loadAgentClasεln o method do all of the real work
79 _ dAgentClassInfo (agentDir , agentFilename),
80 } 81
82 /**
83 * Ver-fies tne existence and correctness of the agent class file
84 * and the agert's skeleton Retrieves a list of the agent's methods
85 * Calle ..ntrnalii by the constructor
86 * (sparaπ agentDir The directory containing the agent's
87 * class file
88 * @param agentFilename The name of the agents' s class file
89 * @except4.on FileNotFoundException Thrown if the agent's class
90 * did not exist.
91 * ©exception IOException If an 10 error occurs while teymg to
92 * access the agent's .class file.
93 * ©exception Cla?sFormatError If the agent's class file does
94 * not contain a valid class.
AgentClassInfoGatherer. ja-va_l Tue Nov 12 07:44:46 1996 3
95 * @except_on NotAgentException If the agent's .class file does
96 * not contain an agent.
97 * ©exception ClassNotFoundException If an error occured while
98 * trying to access the agents class file.
99 * ©exception Nc.-.gentSkeletonException If the agent's invocation
100 * skeleton could not be found.
101 */
102 private void loadAcentClassInfo (String agentDir, String agentFilename)
103 throws FileNotFoundException, IOException, ClassFormatError ,
104 NotAgentException, ClassNotFoundException,
105 NoAgentSkeletonΞxception { 106
107 // load the Agent class
108 ScotStrapCLassLoader ClassLoader = new BoctStrapClassLoader (agentDir ) ,
109 Class agent = ClassLoader . loadAgentClassFromFile (agentFilename, true) ; 110
111 '/ ve-ify that it iε actually an Agent
112 L-ass superclass = agent getSuperclass () ; 113
114 '/ STABILITY: Any way to get these hard coded strings out of here'
115 String s perClassName,
116 do 117
118 s-perC assName = superclass getName ( ) ,
119 if (superClasεName . equalε ( "3ava . lang .Object ") ) {
120 throw new NotAgentException (agentFilename ■> " does not contain an agent");
121 } 122
123 superclass = superclass getSuperclass () ,
124
125 } while ('superClassName equalε("com meitca hsl zones3agents shared .Agen ")) ,
126
127 '/ ck, we have an agent
.28 // lets t to load the skeleton
_29 try {
130 // first lets strip the " class" from the filename
131 STABILITY: Any way to get tnese hard coded strings out of here''
132 String skelClassFileName = agentFilename . substring ( 0 ,
133 agentFilename . length ( ) - ".class" lengthO),
134
135 // append on the _Skel
136 skelClassFileName = skelClassFileName + "_Skel . class " ; 137
138 // now try to load the skeleton class
139 Class skelClass = ClassLoade . loadAgentClassFromFile (skelClassFileName, true) 140
141 // finally retrieve the agents methods.
AgentClasslnfoGatherer. ava_l Tue Nov 12 07:44:46 1996 4
142 Ager.tSkeleton skel = (AgentSkeleton) skelClass . newlnεtance ( ) ;
143 its gentsMethods = skel .getMethods ( ) ;
144 } catch (Exception e) {
145 throw new ClasεNotFoundException ( "Could not find skeleton for agent " + agentFilename)
146 }
147 } 148
149 /**
150 * Retrieves a list of the agents methods. This list is used
151 * by the Agent Launch GUI in order to preεent the user with
152 * a drop down list containing the eligible methods of the agent.
153 */
154 public String!] getAgentMethods ( ) {
155 return itsAgentsMethods;
156 }
157 }
AgentLaunchlnformati;n.java_l Tue Nov 12 07:44:46 1996 1
1 /* $Header: /com/meitca/hsϊ -'zonesjagents/bootstrap/AgentLaunchlnformation . Java 4 11/11/96 5:13p Billp $ 2
3 * Copyright 1996 Horizon Systems Laboratory,
4 * Mitsubishi Electric Information Technology Center America.
5 * All rights reserved.
6 *
7 * CONFIDENTIAL AND PROPRIETARY PROPERTY OF MITSUBISHI ELECTRIC ITA.
8 *
9 * DESCRIPTION
10 * AgentLaunchlπformation encapsulates the information needed to
11 * bootstrap the agent into the system.
12 *
13 * $Loc : /com/meitca/hs ../zonesjagents/bootεtrap/AgentLaunchlnformation . Java $ 14
15 * 4 11/11/96 5:I3p Billp
16 * Made correction tc company name. 17
18 * 3 9/33 '96 6:35p Walsh
19 * fix up javaaoc comments 20
21 * 2 9/11/96 4:46p Walsh
22 * add itsAσent member
23
24 * 1 8/29 S o 5:21p Walsh
25 * intial version 26
27 */
28 package com ..r.ei tea . hsl . zonesjagents . bootstrap ; 29
30 import com.meitca .hsl . zoneε;'agents .conduit . Itinerary;
31 import com.rr.aitca .hsl . zones;agents . shared .Agent ; 32
33
34 /**
35 * The Agent aunchlnformation class encapsulates the information
36 * needed by the Bootstrap class in order to launch and Agent.
37 * This class is used internally by the AgentLaunchWizard and
38 * the Agent command li e launch tool. 39 * ©see Agent 40 * ©see Bootstrap
41 * ©see AcentLaunchVϊizard
42 * ©author Thomas Waiεh
43 */
44 public class AgentLaunchlnformation {
45 /**
46 * The directory (on the local host) containing the agent's
47 * .class file as well as the .class files of any related
AgentLaunchlnformation. java_l Tue Nov 12 07:44:46 1996
48 * classes.
49 '/
50 public String itsAgentDirectory;
51
52 /** The agent's .class file */
53 public String itsAgentFile ;
54
55 /'*
56 * Ar array containing the filenames of any other classes
57 * that should be sent along with the agent. The ConduitServer
58 * has the ability to communicate back to the agents home machine
59 * to retrieve classes needed at runtime (if the RemoteLoader server
60 * is running) . Kith this parameter a programmer can bypass this
61 * and send any needed classes up front.
62
63 public String!] itsRelatedClaεεes ,-
64
65 /** The agents Itinerary */
56 public Itinerary itsltinerary;
67
68 /**
69 * T".e agent itself. This member on needs to be filled in if the
70 * C3_ler wants to call a method on the agent other than the default
71 * constructor. If this field is left blank, then the
72 * Bootstrap . launchAσent method will constuct the Agent contained in
73 * the file itsAgentDirectory by calling its default constructor.
74 * This method gives the programmer the option of constructing an
75 * agent with a ctc other than tne default.
76 */
77 public Agent itsAgent,
78
79 /**
80 * A listing of the agents methods. This member variable need not
81 * be filled in in order to launch the agent, but is uεed internally
82 * ry the Agent aunchWizard
83 */
84 public String!] itsMethods;
85
86 /** Constructs an empty AgentLaunchlnformation object */
87 pub; ic AgentLaunchlnformation ( ) {
88 itsAgentDirectory = new String ("")
89 itsAgentFile = new StringC'");
90 itsltinerary = new Itinerary () ;
91 itsAgent = null;
92 }
93 }
AgentLaunchWizard. ja-va_l Tue Kov 12 07:44:46 1996 1
1 /* $Header. /ccn/meitca/hεl/zoneεjagents/bootstrap/AgentLaunchWizard. ava 10 11/11/96 5 13p Billp $
2 *
3 * Copyright 1996 Horizon Systemε Laboratory,
4 * Mitsubishi Electric Information Technology Center America
5 * All rights reserved
6 *
7 * CONFIDENTIAL AND PROPRIETARY PROPERTY OF MITSUBISHI ELECTRIC ITA 8 9 * DESCRIPTION
10 * GUI tool for launcmc agents into system
11
12 * $Log com/meιtca/hε l/zones3agents/bootstrap/AgentLaunchWιzard ]ava $
13
14 * 10 11.11/9-: 5 13p Billp
15 * Made correction to company name 16
17 * 9 10 '10 '96 5:57p Wals.
18 * Make use of properties JΓ AgentConstants clasε
19 *
20 * 8 10 08/96 10 21a Walsh
21 * Fix name collision oetween bootεtrap StrmgResourceε and
22 * util StπngReεourceε
25 * Save name & ocation o I sst agent launched Reεtart Wizard pointing
26 * at same sgei 27
28 * 6 1C 0"/ 96 3 55p Walsn
29 * Set up c"ie to look in zones .home\ images for GIF file 30 31 * 5 9, 3 '96 6 35p Walsh
32 * fix up j vadoc comments 33
34 * 4 9/27/96 11:52a Walsn
35 * print exception to stderr on LaunchException 36
37 * 3 9/C9/96 3.46p Walsh
38 * replace gj t .MessageDialog with com meitca. hsl util InfoDialog. Create 39 * Security Manager m am 40
41 * 2 9/C4/96 12-34p Walsn
42 * Pop up c ^alog on any problems launching the agent
43 *
44 * 1 8/2 9 / 96 5 : 21p Walsh
45 * intial vers i on 46
47 * /
AgentLaunchWizard. ava_l Tue Nov 12 07:44:46 1996 2
48 package con ηreitca hsl zores3agents bootstrap, 49
50 import 3ava awt *
51 import 3ava 10 *
52 import 3ava v-til * 53
54 import com meitca hsl zi x *,
55 import com me1 tea hsl zoreε;agents secunty *,
56 import com rsitca hεl shared *, 57
58 /**
59 * The AgentLaunchWizard prc-zides a wizard-like GUI for launching
60 * Java Agentε into tne system
61 * ©see Agert
62 * ©see Bootstrap
63 * ©see AgentLaunchlnformation
64 * ©see Wizard
65 * ©author Thomas Walsn
66 */
67 public class AgentLaunc-iWizsrd extends Wizard {
68 /** The launch information */
69 AgentLaunchln ormation ltsAgentlnfo,
70
71 /** Tne filename of the GIF */
72 static final String GIF_FILENAME = AgentConstants IMAGE_DIR + "AgentLaunchWizard gif ' , 73
74 /** Properties (Preference) object */
75 J^SF perties itsProperties 76
77 stati- fin zones agent bootstrap LastAgentDir '
78 static fin ' zones agent bootstrap LastAgentFile'
79 // Static irit^alxzer 80
81 /**
82 * Constructs an AgentLaunchWizard object Bπngε up the GUI and
83 * sets up the first panel
84 */
85 public AgentLaunchWizard ( ) {
86 stper(com meitca hsl zoneε3agentε bootεtrap StnngResources WIZARD_TITLE
87 GIF_FILENAME) ,
88 ltsAgentlnfo = new AgentLaurchlnformation () ,
89 90 try {
91 itsProperties = new JASProperties (
92 com. eitca hsl zones3agents bootstrap StnngResources WIZARD_ PPNAME,
93 JASProperties USER,
94 com meitca hsl zones3agents bootstrap StnngResources PR0P_DESC,
AgentLaunchWizard. java_l Tue Nov 12 07:44:46 1996 3
95 true) ;
96 } catch (Exception e) {
97 itsProperties = null;
98 }
99
100 if (itsProperties != null) {
101 itsAgentlnfo. itsAgentDirectory = itsProperties .getProperty (LAST_AGENT_DIR, "");
102 itsAgentlnfo. itsAgentFile = itsProperties .getProperty (LAST_AGENT_FILE, "");
103 } 104
105 buildPanels ι ) ;
106 f irstPanel ( I ; 107
108 resize(570, 370) ;
109 show ( ) ;
110 } 111
112 /**
113 * Builds the panels of the wizard. The AgentLaunchWizard
114 * contains three panels 1) a panel for specifying the agent's .clasε
115 * ϊiLs (nameε Fi dFilePanel) , 2) a panel for specifying the related
116 * class files for sending with the agent (called RelatedFilesPanel) and
117 * 3) a panel for setting up the agents itinerary (called ItineraryPanel)
118 */
119 protected void buildPanels ( ) {
120 FindFilePanel panell = new FindFilePanel (this , itsAgentlnfo);
121 RelatedFilesPanel panel2 = new RelatedFilesPanel (this, itsAgentlnfo);
122 ItineraryPanel panels = new ItineraryPanel ( his, itsAgentlnfo);
123 } 124
125 /**
126 * The finish method is called by the Wizard base claεε when the
127 * user has successfully filled all the necessary information
128 * into all the panels and haε preεεed the "Finiεh" button. We now
129 * have all of the information we need εo we'll try to launch the agent.
130 */
131 protected void f ir.i εh O {
132 try {
133 // launch the agent
134 Bootstrap. launchAgent ( itsAgentlnfo) ;
135
136 if (itsProperties != null) {
137 try {
138 itsProperties. put (LAST_AGENT_DIR, itsAgentlnfo . itsAgentDirectory) ; 139 itsProperties. put (LAST_AGENT_FI E, itsAgentlnfo . ItsAgentFile) ;
140 itsProperties . saveProperties ( ) ;
141 } catch (Exception e) {
AgentLaunchWizard. java_l Tue Nov 12 07:44:46 1996 4
142 }
143 } 144
145 /.' shutdown.
146 cancel ( ) ;
147 } catch (LaunchException e) {
148 InfoDialog info = new InfoDialog (this,
149 com.meitca. hsl . zonesjagentε .bootstrap . StnngResources .LAUNCH_ERROR_TITLE,
150 com. meitca. hsl . zonesj gents .bootstrap. StringReεourceε ,LAUNCH_ΞRROR) ;
151 info . setBackgroun (Color . lightGray) ;
152 i fo .εhow() ; 153
154 System, err.printlr. (e .getMesεage ( ) ) ;
155 e-printStackTrace () ;
156 }
157 } 158
159 /**
160 * main routine supplied εo that AgentLaunchWizard can be initiated
161 * from the command line
162 */
163 public static void main (String argε [ j ) {
164 / .' Create and install the security manager
165 System. setSecurityManager (new InsecurityManager ( ) ) ;
166
167 AgentLaunchWizard gui = new AgentLaunchWizard () ;
168 } 169
170 }
AgentLaunohWizardPanel . j ava_l Tue Nov 12 07 : 44 : 47 1996 1
1 / * $Header : ,' com/me i tca/hε l / zones j agents /boots trap/AgentLaunchWi zardPanel . J ava 4 11 / 11 / 96 5 : 13p Bi llp $
2 *
3 * Copyright 1596 Horizon Systems Laboratory,
4 * Mitsubiεhi Electric Information Technology Center America.
5 * All rights reserved.
6 *
7 * CONFIDENTIAL AND PROPRIETARY PROPERTY OF MITSUBISHI ELECTRIC ITA. 8
9 * DESCRIPTION
10 * A subclaεs of WizardPanel for use in the AgentLaunchWizard
11 *
12 * $Log : /com/meitca/hsl/zonesjagents/bootstrap/AgentLaunchWizardPanel . Java $
13 *
14 * 4 11/11/96 5:13p Billp
15 * Made correction to company name.
16 *
17 * 3 9/30/96 6:35p Walsh
18 * fix up javadoc comments
19 *
20 * 2 9/10/96 11:46a Walsh
21 * remove bogus imports that javac considers illegal
22
23 * 1 8/29/96 5:21p Walsh
24 * intial version
25 *
26 */
27 package com. eitca .hsl . zonesjagentε .bootεtrap; 28
29 import j av . wt . * ; 30
31 import com.meitea .hsl .util .Wizard,-
32 import com. eitca .hsl .util .WizardPanel ; 33
34
35 /**
36 * AgentLaunchWizardPanel is a base class for the panels of the
37 * AgentLaunchWizard. All of the panels in the launch wizard need
38 * shared access to the AgentLaunchlnformation object describing the 39 * parameters of the launch. This base claεε provideε that
40 * access .
41 * ©see Agent
42 * ©see Bootstrap
43 * ©see AgentLaunchlnformation
44 * ©see AgentLaunchWizard
45 * ©author Thomas Walsh
46 */
47 public class AgentLaunchWizardPanel extends WizardPanel {
AgentLaunchWizardPanel. τ"ava_l Tue Nov 12 07:44:47 1996 .
48 /** The launch parameters of the Wizard*/
49 protected AgentLaunchlnformation itsAgentlnfo;
50
5511 52 Constructs an AgentLaunchWizardPanel. 53 ©parain wizard The Wizard owning this panel (needed by super) 54 ©param info The (shared) reference to the agent launch infomarion 55 */ 56 public AgentLaunchWizardPanel (Wizard wizard, AgentLaunchlnformation info) { 57 super (wizard) ; 58 itsAgentlnfo = info; 59 } 60 61
Bootstrap.java_l Tue Nov 12 07:44:47 1996 1
1 /* $Header: /com/meitca/hsl/zonesjagents/bootstrap/BootStrap . Java 11 11/11/96 5:13p Billp $
2 *
3 * Copyright 1996 Horizon Systems Laboratory,
4 * Mitsubishi Electric Information Technology Center America.
5 * All rights reserved. 6
7 * CONFIDENTIAL AMD PROPRIETARY PROPERTY OF MITSUBISHI ELECTRIC ITA.
8 *
9 * DESCRIPTION
10 * Module for boot strapping agents into the system.
11 *
12 * $Log : /com/meitca/hsl/zonesjagents/bootstrap/BootStrap. Java $ 13
14 * 11 11/11/96 5:13p Billp
15 * Made correction to company name. 16
17 * 10 10/01/96 10:39a Walsh
18 * fix ©exception javadoc tag
19 *
20 * 9 9/30/96 7:33p Walεh
21 * add more javadoc
22 *
23 * 8 9/28/96 6:56p Walεh
24 * Add new version of launchAgent
25 *
26 * 7 9/11/96 4:59p Walsh
27 * allow launchlnfo . itsRel tedClasseε to be null 28
29 * 6 9/11/96 4:46p Walsh
30 * if caller specified Launchlnfo . itsAgent, use that rather than
31 * constructing a new one. 32
33 * 5 9/10/96 11:46a Walsh
34 * remove bogus imports that javac considers illegal
35 *
36 * 4 9/09/96 3:46p Walsh
37 * Move creation of SecurityManager to main to prevent error on multiple
38 * calls to Launch
39 *
40 * 3 9 / 05 / 96 6 : 38p Walsh
41 * Add a main method to handle command line agent launching
42
43 * 2 9/04/96 12:35p Walsh
44 * Add some exception handling. Let ConduitServer handle details of
45 * launching agent. Let RemoteLoader build up the home codebase URL
46 *
47 * 1 8/29/96 5:21 Walsh
Bootstra .java_l Tuβ Nov 12 07:44:47 1996
48 * mtial version 49
54 import 3ava rπ server StubSecurityManager, 55 import jav rri server MarshalOutputStream, 56 import 3ava net TnetAddress 57 import ]ava util *, 58 import ]ava 10 *, 59 60 import com meitca hsl zones;agents shared *, 61 import com me tea hsl zones;agents conduit ConduitServer, 62 import com meitca hsl zones; agents conduit AgentPackage, 63 import com meitca hsl zonesπagents conduit Itinerary, 64 import com meitca hsl zoneε;agents conduit MobileCodebase, 65 import com meitca hsl zores;agents conduit ConduιtOb3ectOutputStream, 66 import com meitca hsl zones;agents conduit Destination 67 import com meitca hsl zones;agents conduit ConduitServerlmpl , 68 import com meitca hsl zonesjagents remoteloader RemoteClassLoaderlmpl 69 import com me_tca hsl zones., gentε security InsecurityManager 70 71 72 73 74 * Bootstrap provides a mechanism for boot strapping (launching) agents 75 * into the system The caxlmg program must provide the launch parameters 76 * in the for1-' of the Agert_,aunchlnformation object Bootstrap takes this 77 * information and provides the necessary εtepε to launch the indicated agents 78 * This includes building creating the MobileCodebase loading any needed 79 * classes (i ducing the aαent) into the MobileCodebase constructing the 80 * AgentPackage contacting the mtial ConduitServer and sending the agent 81 * ©see Agent 82 * ©see AgentLaunchlnformation 83 * ©author Thomas Walsn 84 */ 85 public class Bootstrap { 86 * * 87 * Launches an agent 88 * ©pararn agent The agent to launch 89 * Θparam itinerary The agent's itinerary 90 * Srara agentCodebaseURL An URL pointing to the codebase of the agent 91 * This URL can take the following forms, 92 * <ul> 93 * <lι>A file URL like <b>fιle C \agents</b> - which indicates that th 94 * agent's code is located on the local machine in the directory
Bootstrap. ava_l Tue Nov 12 07:44:47 1996
95 <b>C \agent</b>
96 <lι>An HTTP URL like <b>http /hostname/agents</b> - which indicates a
97 location on a web server from which the agents code can be
98 retrieved (This is very similar to the codebase modifier
99 which can be added to an HTML <b>&ltapplet&:gt</b> tag) 100 <lι>An RMI URL like <b>rmι /hostname/RemoteClassLoader</b> pointing 101 to a RemoteClassLoader object which can retrieve the agents code <br> 102 Thiε RMI URL could also look like 103 <b>rmι /hostname/RemoteClassLoader/C \agents</b> which indicates that 104 the RemoteClassLoader on hostname should be uεed to retrieve 105 the classes and that the agents code is located in the <b>C \agents</b> 106 directory 107 </ul> 108 * fcaian relatedClasses An array of fully qualified claεεnameε of classes which this agent makes 109 use of Theεe classes will be set up to travel with the agent 110 * ©exception LaunchException is the agent could notbe launched 111 */ 112 public :ιc voic launchAgen (Agent agent, Itinerary itinerary. String agentCodebaseURL, 113 Strmg[] relatedClasseε) throws LaunchExcep- on { 114 try { 115 MobileCodebaεe agentCode = new MobileCodebaεe ( ) , 116 Boo-StrapClasεLoader bootstrap = new BootStrapClaεεLoader (agentCodebaseURL, 117 agentCode) , 118 DootStrap loaαAgentClaεs (agent getClasε() getName(), false), 119 120 if (relatedClaεεes '= null ) { 121 for (int ι=0, ι<relatedClasses length, ι++) 122 Class related = bootstrap loadAgentClasε (relatedClasseε [ l ] , false), 123 } 124 125 String absoluteCodebaseURL, 126 if (agentCodebaseURL ' = null) { 127 if ('agentCodebaseURL startεWith ( 'rmi ") && ' agentCodebaεeURL starts.i th ( "http ")) 128 if (agentCodebaseURL startεWith ( ' f ile ")) { 129 abεoluteCodebaεeURL = RemoteClaεεLoaderlmpl buildCodebaεeURL ( 130 InetAddress getLoca ost() getHostName ( ) ,
131 agentCodebaεeURL εul tring (5, agentCodebaεeURL length ( ) ) ) 132 } else { 133 abεoluteCodebaεeURL = RemoteClassLoaderlmpl buιldCodebaseURL( 134 InetAddress getLoca oεt() getHostName ( ) 135 agentCodebaseURL) , 136
Bootstrap. java_l ?ue Nov 12 07:44:47 1996 4
137 } elεe {
138 absoluteCodebaεeURL = agentCodebaεeURL;
139 }
140 } elεe {
141 absoluteCodebaseURL = RemoteClaεεLoaderlmpl . buildRmiURL (
142 InetAddresε . getLocalHost ( ) . c tHostNameO ) ;
143 } 144
145 AgentPackage agentPackage = new AgentPackage (agent ,
146 agen: Code,
147 iti rary,
148 abεo uteCodebaεeURL) ;
149 150
151 // pass the agent along
152 ConduitServerlmpl . εendPackage (agentPackage) ;
153
154 } catch (Exception error) {
155 throw new LaunchException ( "LaunchΞxception : " + error . getMessage ()) ;
156 }
157 } 158
159 /**
160 * Launches an agent based on the given launch parameters
161 * ©para launchlnfo The launch parameters
162 */
163 public static void launchAgent (AgentLaunchlnformation launchlnfo) throws LaunchException { 164
165 try {
166 MobileCodebase agentCode = new MobileCodebaεe ()
167 BootStrapClaεsLoader bootstrap = new BootStrapClassLoader ( launchlnfo . itsAgentDirectory, 168 agentCode) ;
169 Class agentClasε = bootstrap. loadAgentClassFromFile (launchlnfo . itsAgentFile, true);
170
171 if (launchlnfo. itεRelatedClasseε != null ) {
172 for (int i=0; i<launchInfo . itsRelatedClasεes . length; i++)
173 Class related = bootstrap . loadAgentClassFromFile ( launchlnfo . itsRelatedClass [i], true);
174 } 175
176 String codebaseURL = RemoteClasεLoaderlmpl .buildCodebaseUR (
177 InetAddress .getLocalHost () .getHoεtN.'i
Bootstrap. java_l Tue Nov 12 07:44:47 1996
178 launchlnfo . itεAgentDirectory) ;
179
180
181 Agent agent;
182 if (launchlnfo . itεAgent == null) {
183 agent = (Agent ) agentClasε . newlnstance () ;
184 } else {
185 agent = launchlnfo . itsAgent ;
186 }
187 AgentPackage agentPackage = new AgentPackage ( agent ,
188 ager. Code,
189 lau.. hlnfo . itsltinerary,
190 code . aseURL) ;
191
192
193 // pasε the agent along
194 ConduitServerlinpl . εendPackage (agentPackage) ;
195
196 } catch (Exception error) {
197 throw new LaunchException ( "LaunchException : " + error . getMessage ()) ;
198 }
199 } 200
201 /**
202 * Th s method gets invoked when a user tries to launch an Agent from
203 * the command line. The command line should look something like the
204 * fcllowing;<br>
205 * <pre> 206
207 * Usage: bootstrap [ -d hostname, ethod] [-f relatedfile . claεε] [-h] agentfile . class 208
209 * </prexbr>
210 * The user specifies the agent class file as the last parameter to
211 * the command. The destiantions for the Agent are specified with the
212 * <b>-d</b> option. A destination is specified by the hostname followε by a
213 * comma (no space) -followed by the name of the method to invoke.
214 * This could look something like the following; <b>-d hostl, agentMethodl</b> .
215 * The user specifies related class files that should be sent with the
216 * agent using the <b>-f</b> option. Finally, the <b>-h</b> option brings up
217 * some command line help.
218 */
219 public static void main (String args [ ] ) {
220 // Create and install the security manager
Boo strap . j ava_l Tue Nov 12 07:44:47 1996
221 System. εetSecurityManager (new InsecurityManager ( ) ) ; 222 223 // We start by doing some rather brute force parsing of the 224 // command line. The command line args are used to build up 225 // an AgentLaunchlnformation data structure. 226 AgentLaunchlnformation launchlnfo = new AgentLaunchlnformation ( ) 227 Vector destinationStrings = new Vector (); 228 Vector relatedFiles = new Vector (); 229 String agentFile = null; 230 231 for (int i=0; i<args . length; i++ ) { 232 if (argsfi] .equals C-d") ) { 233 String destinationString = args[++i]; 234 destinationStrings .addElement (destinationString) 235 continue; 236 } else if (args [ i] . equals (" -f" ) ) { 237 String fileName = args[++i]; 238 relatedFiles .addElement (fileName) ; 239 continue; 240 } else if (args [i] . equals (" -h" ) ) { 241 System. out .printIn (StnngResources .USAGE) ; 242 return; 243 } else { 244 if (argεfi] .charAt(O) == '-') { 245 System. out .println (StringResources . ILLEGAL_OPTN + argε[i]) 246 System. out .println (StringResources .USAGE) ; 247 return ; 248 } else { 249 agentFile = argε[i] 250 } 251 252 } 253 254 // firεt lets verify that we have a valid agent file, 255 if (agentFile == null) { 256 System. out .println (StringResources . O_AGENT) ; 257 System. out. println (StringResources .USAGE) ; 258 re urn;
259 }
260
261 if ( ! gentFile. endsWith(" .class") ) {
262 System. out.println (StringResources. ILLEGAL_AGENT + agentFile);
263 System. out. println (StringResources. AGENT_HELP) ;
264 return;
265 1
266
267 launchlnfo . itsAgentDirectory = new String!"")
Bootstrap. java_l Tuβ Nov 12 07:44:47 1996 7
268 launchlnfo. itsAgentFile = agentFile;
269
270 for (int i=agentFile . length () -1 ; i>=0; i--) {
271 if (agentFile. charAt(i) == File . separatorChar ) {
272 launchlnfo. itsAgentDirectory = agentFile . substring (0 , i+1) ;
273 launchlnfo. itsAgentFile = agentFile . substring ( i+1, agentFile . length ()) ;
274 break; "
275 }
276 } 277
278 // Now let the AgentClassInfoGatherer verify the existence of the file,
279 t I that the file contains a valid Java Agent and that the skeleton
280 // exists.
281 cry {
282 AgentClassInfoGatherer agentlnfoGatherer = new AgentClassInfoGatherer (
283 launchlnfo. itsAgentDirectory, launchlnfo . itsAgentFile) ; 284
285 launchlnfo . itsMethods = agentlnfoGatherer .getAgentMethods () ;
286 } catch (FileNotFoundException el) {
287 System. out. println (StringResources. ILLEGAL_AGENT + agentFile);
288 System. out .println ( "\t" + StringResources .FILE_NOTFOUND) ;
289 return; i
290 } catch (IOException el) {
291 System. out .println (StringResources . ILLEGAL_AGENT + agentFile);
292 System. out .println (" \t" + StringResources . IOERROR) ;
293 return;
294 } catch (ClasεFormatError el) {
295 Syεte . out .println (StringReεourceε . ILLEGAL_AGENT + agentFile);
296 System. out .println (" \t" + StringResources .BAD_CLASS_FORMAT) ;
297 return;
298 } catch (NotAgentException el) {
299 System. out .println (StringResources . ILLEGAL_AGENT + agentFile);
300 System. out .println (" \t" + StringResources .NOT_AGENT) ; 301 return;
302 } catch (ClassNotFoundException el) {
303 System. out .println (StringResources . ILLEGAL_AGENT + agentFile);
304 System. out .printlnf "\t" + StringResources .BAD_CLASS_FORMAT) ; 305 return;
306 } catch (NoAgentSkeletonException el) {
307 System. out .println (StringResources . ILLEGAL_AGENT + agentFile);
308 Syεtem. out. println( "\t" + StringResources .NO_SKELETON) ; 309 return;
310 } 311
312 / / Lets take a look at the related f iles
313 launchlnfo . itsRelatedClasses = new String [relatedFiles . size ( ) ]
314 for ( int i=0 ; i< relatedFiles . size ( ) ; i++ ) {
BootStra . java_l Tuβ Nov 12 07:44:47 1996 8
315 String fileName = (String) relatedFiles .elementAt (I) , 316 if (fileName endsWιth(" class")) { 317 launchlnfo ltsRelatedClasses [ l] = fileName, 318 } else { 319 System out printl (StringResources ILLEGAL_RELFILE + fileName) , 320 System out println (StringResources RELFILE_HELP) ; 321 return, 322 } 323 i 324 325 I I Finally, lets take a look at those destinations 326 if (destinationStrings sιze() == 0) { 327 System out println (StringResources NO_DEST) , 328 return, 329 } 330 331 for (int ι=0, KdestinationStrmgs sized , ι++) { 332 String destinationString = (String) destinationStrings elementAt (i) , 333 StrmgTokenizer tokenizer = new StrmgTokenizer (destinationString ","), 334 335 if (tokenizer countTokenε ( ) '= 2) {
340 String hostname = tokenizer nextToken ( ) 341 String methodrame = tokenizer nextToken ( ) 342 343 // find out if the methodname actually point to one of the methods 344 // in the Agent 345 irt methodid = -1 346 for (int 3=0 3<launchInfo itsMethods length, 3++) { 347 if (launchlnfo itsMethods [ 3 ] equals (methodname) ) { 348 methodid = 3 , 349 } 350 } 351 352 if (methodid == -1) { 353 System out println (StringResources I LEGAL_METHOD + methodname ) , 354 System out println (StnngResources USAGE) , 355 return , 356 } else { 357 launchlnfo itsltinerary addDestination (new Destination (hostname, methodid)); 358 } 359 } 360 361 // now that we have parsed the command ine and built up t e
Bootstrap. java_l Tuβ Nov 12 07:44:47 1996 9
362 // launchlnfo, we will actually attempt to launch the agent.
363 try {
364 launchAgent (launchlnfo) ;
365 } catch (LaunchException e) {
366 System. out. println (StringResources . LAUNCH_ERROR + ": " + e .getMessage ( ) ) ;
367 e.printStackTrace () ;
368 }
369 }
370 }
BootStrapClassLoader. java_l Tue Nov 12 07:44:47 1996 1
1 /* $Header: /com/meitca/hsl/zones jagents/bootstrap/BootStrapClassLoader . ava 3 11/11/96 5:13p Billp $
2 *
3 * Copyright 1995 Horizon Systems Laboratory,
4 * Mitsubishi Electric Information Technology Center America.
5 * All rights reserved.
8 *
9 * DESCRIPTION
10 * ClassLoader used in agent bootstrap process.
11 *
12 * $Log: /com/meitca/hsl/zonesjagentε/bootstrap/BootStrapClassLoader . Java $
13 *
14 * 3 11/11/96 5:13p Billp
15 * Made correction to company name.
16 *
17 * 2 9/28/96 6:56p Walsh
18 * Use AgentCodebase object to retrieve bytecodes.
19 *
20 * 1 8/29/96 5:21p Walsh
21 * intial version
22 *
23 */
24 package com . mei tca . hs l . zones j agents . bootstrap ;
25
26 import java.io.*;
27 import java.net.*;
28 import Java . rmi . Naming; 29
30 import com. meitca . hsl . zoneε jagents . conduit .* ;
31 import com. meitca . hεl . zones]agents . shared .* ;
32 import com. meitc .hεl . zoneεjagents . remoteloader .* ; 33
34
35 /**
36 * BootStrapClassLoader is used internally by the Bootstrap
37 * class to load agent related classes
38 * ©see Agent
39 * ©see Bootstrap
40 * ©see MobileCodebase
41 * ©author Thomas Walsh
42 */
43 public class BootStrapClassLoader extends ClassLoader {
44 /** An URL pointing to the cobease from which class files should be retrieved */
45 String itsHcmeCodebaseURL; 46
47 /** An object representing the home codebase of the agent */
BootStrapClassLoader. j va_l Tue Nov 12 07:44:47 1996 2
48 AgentCodebase itsHomeCodebase;
49'
50 /** The mobile code base into which to load classes */
51 MobileCodebase itsMobileCodebase;
5
53 /**
54 * object which actually handles the dirty work or retrieving .class
55 * files for a given class.
56 */
57 ClassFileLoader itsClassFileLoader; 58
59
60 /**
61 * Constructs a BootStrapClassLoader.
62 * ©param url The directory from which this ClassLoader should
63 * retrieve .class files
64 */
65 public BootStrapClassLoader (String url) throws MalformedURLException { 66' itsHomeCodebaseURL = url;
67 itsHomeCodebase = new AgentCodebase (url) ;
68 itsMobileCodebase = null;
69 itsClassFileLoader = new ClassFileLoader () ;
70 }
71
72 /**
73 * Constructs a BootStrapClassLoader. When this consturctor is
74 * called, the ClassLoader realizes that their is an associtated
75 * MobileCodebase object. As .class files are read from disk,
76 * they are also written into the MobileCodebase. Once they are
77 * leaded into the MobileCodebase, they are ready to travel.
78 * ©param dir The directory from which this ClassLoader should
79 * retrieve .class files
80 * ©param codebase The associated MobileCodbaεe object
31 * "//
82 p,ublic B_o.o.tStrapClassLoader (String= url, MobileCodebase codebase) throws MalformedURLExceprtion {.
83 tthhiiss ((uurrll)) ;;
84 itsMobileCodebase = codebase;
8 856 >
87 /**
88 * Load a class. The classes .class file must be in the directory
89 * that was specified in the constructor. If a MobileCodebase
90 * was specified in the constructor, the class will also be loaded
91 * into that codebase.
92 * ©param name The class name
93 * ©param resolve True if resolveClasε should be called
94 */
BootStrapClassLoader.java_l Tue Nov 12 07:44:47 1996 3
95 public Qlass loadAgentClaεs (String name, boolean resolve) throws ClassNotFoundException {
96
97 byte[] bytecodes = itsHomeCodebase .retrieveCode (name) ;
98
99 Class c = defineClass (bytecodes , 0 , bytecodes . length) ;
100 if (resolve )
101 resolveClass (c) ; 102
103 if (itsMobileCodebase != null)
104 itsMobileCodebase. storeCode (c .getNa e () , bytecodes); 105
106 return c ;
107 } 108
"109 /**
110 * Load a class from the specified file. The file must be in the
111 * directory that was specified in the constructor. If a
112 * MobileCodebase was specified in the constructor, the class will
113 * also be loaded into that codebase.
114 * ©param name The class filename
115 * ©param resolve True if resolveClass should be called
116 */
117 //STABILITY: Integrate this method with loadAgentClass
118 public Clasε loadAgentClassFromFile (String fileName, boolean resolve)
119 throws FileNotFoundException, IOException, ClassNotFoundException , ClaεsFormatError { 120
121 File file = new File (itsHo eCodebaseURL, fileName);
122 long length = file . length( ) ;
123 FilelnputStream stream = new FilelnputStream (file) ;
124 byte data[] = new byte [ (int) length] ; 125
126 stream. read (data) ;
127 Class c = defineClass (data, 0, ( int) length) ;
128 if (resolve) {
129 resolveClass (c) ;
130 ) 131
132 i f ( i tsMobi leCodebase ! = nul l )
133 i tsMobi leCodebase . s toreCode ( c . getName ( ) , data ) ; 134 return c ;
135 }
136
137 /**
138 * The Java . lang .ClassLoader version of loadClass .
139 * First looks for a standard system class, and then looks for an
140 * agent class in the directory that was specified in the constructor.
141 * If the class is an Agent related class, then its bytecodes are
BootStrapClassLoader. j ava_l Tue Nov 12 07:44:47 1996 4
142 * loaded into the MobileCodebase
143 * ©param name The clasε name
144 * ©param resolve True if resolveClass should be called
145 */ /
146 protected Class loadClass (String name, boolean resolve) throws ClaεεNotFoundException {
147 try {
148 Claεε c = f indSyε emClass (name) ;
149 if (resolve) {
150 resolveClass (c) ;
151 }
152 return c ;
153 } catch (ClasεNotFoundException el) {
154 try {
155 return loadAgentClaεs (name, resolve);
156 } catch (Exception e2) {
157 throw new ClassNotFoundException ( "Could not load " + name) ;
158 )
159 }
160 )
161 )
FindFilePanel. java_l Tue Nov 12 07:44: 7 1996 1
1 /* $Header /com/mei tca/hsl/zones3agent=;/bootstrap/FindFilePanel ]ava 5 11/11/96 5 13p Billp $
2
3 * Copyright 1996 Horizon Systems Laboratory
4 * Mitsubishi1 Electric Infcrmation Technology Center America
5 * All r_ghts reserved
6 *
7 * CONFIDENTIAL AND PROPPIETAR PROPEPT> OF MITSUBISHI ELECTRIC ITA 8
9 * DESCRIPTION 30 * The FindF l(?Pan<=l if thp AgentLaunchWizard 11
12 * $Log com/meιtca/h"=;l/zones3agents/bootstrap/Fιndt:,ιlePanel ]ava $ 13
14 * 5 ll/ll/°6 5 13p BJ 11D
15 * Made correction to company name 16
17 * 4 10/0 /96 4 44p Wal<=;n
18 * Save name & location of last agent launched Restart Wizard pointing
19 * at same agent
20 *
21 * 3 9 / 10 / 96 11 46a Wal sh
22 * remove boαus imports that η avac cons iders il l egal
23 *
24 * 2 9/09/96 3 45p Walsh
25 * replace g3 t MessageDialoσ w/ com meitca hsl util InfoDialog
26 *
27 * 1 8 /2 ° / 9 o 5 21 p Wa l =h
28 * mtial ve- ' on 29
3 0 * /
31 package com ∑oresjagents bootstrap 32
33 import 3ava a*t *
34 import 3ava 10 *
35 import g3t Ut i 36
37 import com me_tca hεl utn Wizard
38 import com me.tea hεl util WizardPanel
39 import com meitca hsl util InfoDialoα 40
41 /
42 * the first panel of the AgentLaunchWizard This panel allows the user
43 * to specify the filename of the class file contaimnα the agent
44 * ©see Agent
45 * ©see AgentLaunchWizardPanel
46 * ©see AgentLaunchWizard
47 * ©author Thomas Wal^n
FindFilePanel. java_l Tue Nov 12 07:44:47 1996 2
48 */
49 public class FindFilePanel extends AgentLaunchWizardPanel {
50 /** The edit field */
51 TextField I tsFileBrowseField , 52
53 /** The "Brcwse " button */
54 Button itsFileBrowseButton, 55
56 /**
57 * Construct the FindFilePanel and all of its components
58 * Sparam wizard The wizard to which this panel belongs (needed by
59 * super)
60 * @param wiinfozard The AgentLaunchlnformation descπnging this
61 * agent launch (needed by super)
62 */
63 public FindFilePanel (Wizard wizard, AgentLaunchlnformation info) {
64 super (wizard, info);
65 buildPanel ( ) ,
66 } 67
68 /**
69 * Verify that the information entered into the panel is valid. Called
70 * after the "Next >" button is pressed 71
72 * The method validates the following things .
73 * 1) A class file name is specified
74 * 2) The file name ends with " class'
76 * 4) The file contains valid Java bytecodes
77 * 5) The file contains a class derived from Agent
78 * 6) An invocation skeleton is available
79 * Sreturrε true if the panel contains valid info, false if not
80 */
81 public boolean val idatePanel ( ) {
82 // we want to break the full filename up into the directory portion
83 // and the filename portion. Find the last occurrence of the
84 // directory seperator character
85 String fullName = ltsFileBrowseField getTextO,
86
87 // Verify that someone typed something into the edit control and that
// what they typed in ends with class
89 if (fullName. length () == 0) {
90 InfoDialog info = new InfoDialo ( itεWizard,
91 StringResources. AUNCH_ERROR_TITLE,
92 StringResources. NO_FILENAME) ;
93 ±nfo . setBackground (Color . lightGray) ;
94 info sho ( ) ;
FindFilePanel. java_l Tue Nov 12 07:44:47 1996
95 return false ;
96 )
97
98 if ('fullName endsWithC class")) {
99 IrfoDialog info = new InfoDialog ( ltsWizard,
100 StringResources LAUNCH_ERROR_TITLE,
101 StringResources ENDSWITH_CLASS) ,
102 lrfo setBackground (Color lightGray),
103 lrfo show() ,
104 return false
105 ) 106
107 itsAgentlnfo itsAgentDirectory = new String ('')
108 itsAgentlnfo itsAgentDirectory = fullName 109
110 for (int ι=fullName length()-l ι>=0, ι--) {
111 if (fullName charAt(ι) == File separatorChar ) {
112 itsAgentlnfo itsAgentDirectory = fullName εubstnngtO, l+l),
113 itsAgentlnfo itsAgentFile = fullName substring ( l+l , fullName length!) ) ,
134 break;
115 }
116 }
1 11178 // Now let the AgentClassInfoGatherer verify the existence of the file,
119 // tnat the file contains a valid Java Aαent and that the skeleton
120 // exists
121 Ty {
122 AgentClassInf Gatherer agentlnfoGatherer = new AgentClassInfoGatherer (
123 itsAgentlnfo i sAgentDirectory, itsAgentlnfo ItsAgentFile 124
125 itsAgentlnfo ltsM thods = agentlnfoGatherer getAgentMethods ( ) ,
126 return true,
127 ) catch (FileNotFoundExcep ion el) {
128 InfoDialog info = new InfoDialog ( l tshizard,
129 StringResources LAUNCH_ERROR_TITLE, 130 StringResources FILE_NOTFOUND) ,
134 } catch (IOException el) {
135 InfoDialog info = new InfoDialog ( 136 StringResources LAUNCH_ERROR_TITLE,
137 StringResources IOERROR) ,
138 info setBackground (Color lightGray),
139 mfo show( ) ,
140 return false;
141 } catch (ClassFormatError el) {
FindFilePanel. java_l Tue Nov 12 07:44:47 1996 4
142 InfoDialog info = new InfoDialog ( ltsWizard,
143 StringResources LAUNCH_ERROR_TITLE,
144 StringResources BAD_CLASS_FORMAT) ,
145 info setBackground (Color lightGray),
146 info show( ) ,
147 return false,
148 } catch (NotAgentException el) {
149 IrfoDialoq info = new InfoDialog ( ltsWizard,
150 StringResources LAUNCH_ERROR_TITLE,
151 StringResources NOT_AGENT) ,
152 info setBackground (Color lightGray),
153 info show( ) ,
154 return false,
155 ) catch (ClassNotFoundException el) {
156 InfoDialog info = new InfoDialog ( ltsWizard,
157 StringResources LAUNCH_ERROR_TITLE,
158 StringResources BAD_CLASS_FORMAT) ,
159 info setBackgroun (Color lightGray)
160 ii fo show( ) ,
161 return false,
162 } catch (NoAgentSkeletonException el) {
163 It foDialog info = new InfoDialog ( ltsWizard,
164 StringResources LAUNCH_ERROR_TITLE,
165 StringResources NO_SKELETON) ,
166 inro setBackground (Color lightGray),
167 info show( ) ,
168 return false,
169 }
170 ) 171
172 /**
173 * Builds the GUI Components for this panel
174 */
175 private void buιldPanel() {
176 setLavout (new GπdBagLayout ( ) ) , 177
178 Label labell = new Label (StringResources FF_TEXT1 , Label LEFT),
179 constrain (this, labell,
180 0, 0, 1, 1,
181 GridBagConstraints HORIZONTAL, GridBagConstraints NORTHWEST, 0 0,
182 0, 0, 0,0),
183
184 Label label2 = new Label (StringResources FF_TEXT2 , Label LEFT),
185 constrain ( his, label2,
186 0, 1, 1, 1,
187 GridBagConstraints HORIZONTAL, GridBagConstraints NORTHWEST, 0 0, 189 0, 0, 0, 0) ,
FindFilePanel. java_l Tue Nov 12 07:44:47 1996
189
190 Label label3 = new Label (StringResources .FF_TEXT3 , Label . LEFT) ;
191 constrain ( this , label3,
192 0, 2, 1, 1,
193 GridBagConstraints. HORIZONTAL, GridBagConstraints .NORTHWEST, 0.0, 0.0,
194 0,0,0,0);
195
196 Label label4 = new Label (StringResources .FF_TEXT4, Label. LEFT);
197 constrain (this, label4,
198 0, 3, 1, 1,
199 Gri BagConstraints. HORIZONTAL, GridBagConstraints .NORTHWEST, 0.0, 0.0,
200 0,0,0,0);
201
202 Panel browsePanel = new Panel ();
203 constrain (.this, browsePanel,
204 0, 4, 1, 1,
205 GridBagConstraints. HORIZONTAL, GridBagConstraints .NORTHWEST, 1.0, 1.0,
206 0,0,0,0);
207
208 browsePanel . setLayout (new GridBagLayout ( ) ) ; v..
209 Label findFileLabel= new Label (StringResources . FF_FIELD_J^βEL, Label .LEFT) ;
210 constrain (browsePanel , indFileLabel , γ
211 1, 0, 1, 1,
212 GridBagConstraints. NONE, GridBagConstraints . NORTHWEST, 0.0, 0.0,
213 0,0,0,0);
214
215 itsFileBrowseField = new TextField (25) ;
216 constrain (browsePanel , i tsFileBrowseField,
217 2, 0, 1, 1,
218 GridBagConstraints. HORIZONTAL, GridBagConstraints .NORTHWEST, 1.0, 1.0,
219 0,0,0,0);
220
221 itsFileBrowseButton = new Button (StringResources .FF_BROWSE_BUTTON) ;
222 constrain (browsePanel , itsFileBrowseButton,
223 3, 0, 1, 1,
224 GridBagConstraints .NONE, GridBagConstraints .NORTHWEST, 0.0, 0.0,
225 0,0,0,0);
226
227 }
228
229 /** Derived from Component .action */
230 public boolean action(Event event. Object what) {
231 if (event .target == itsFileBrowseButton) {
232 doBrowse ( ) ;
233 return true;
234 }
235 return false;
FindFilePanel. java_l Tue Nov 12 07:44:47 1996
236 }
237
238 /**
239 * Ca led in response to selecting the Panel s Browse button Brings up
240 * a Open File Dialog
241 */
242 private void doBrowse() {
243 FileDialor browse = new Fi leDialog (Uti 1 getFrame ( this) , StringResources BROWSE_DLG_TITLE)
244 bro e setrιle( * class ) 245
246 -f (itsAgentlnfo itsAgentDirectory '= null) {
247 if (itsAgentlnfo ItsAgentDirectory length () '= 0) {
248 browse setDirectory ( itsAgentlnfo ItsAgentDirectory) 2^9 }
250 )
251
252 browse show()
253
254 Stπnq ullFileName - n°k Strmαt )
255
256 if (browse getDirectory ( ) = null) {
257 if (browse getDirectory ( ) length () '= 0) {
258 fullFileName = browse getDirectory ( )
259 )
260 ) 261
262 f (b owse getFιle() '= null) {
263 if (browse getFileO length!) '- 0) {
264 fullFileName = fullFileName + browse getFileO
265 )
266 ) 26-7
268 -f (fullFileName length () '= 0)
269 ltsFileBrowεeField setText ( fullFileName)
270 } 271
272 /**
273 * Initializes the Panel for display
274 */
275 public void displayPanel ( ) {
276 String fullFileName =
277
278 if (itsAgentlnfo ItsAgentDirectory '= null) {
279 if (itsAgentlnfo itsAgentDirectory lengthO '= 0) {
280 fullFileName = itsAgentlnfo itsAgentDirectory 281
282 if ('fullFileName endsWith (File separator)) {
FindFilePanel. java_l Tue Nov 12 07:44:47 1996 7
283 fullFileName += File separator,
284 >
285 }
286 }
287
288
289 if (itsAgentlnfo ItsAgentFile •= null) {
290 if (itsAgentlnfo ItsAgentFile length () '= 0) {
291 fullFileName += itsAgentlnfo itsAgentFile
292 )
293 } 294
295 if (fullFileName length () '= 0)
296 ltsFileBrowεeField setText ( fullFileName)
297 } 298
299 300 }
ItineraryGridDataModel. java_l Tue Nov 12 07:44:47 1996 1
1 /* $Header /co /mei tca/hεl/zonesjagents/bootstrap/I tineraryGridDataModel 3ava 3 11/11/96 5 13p 2
3 * Copyright 1996 Horizon Systems Laboratory,
4 * Mitsubishi Electric Information Technology Center America
All rights reservec CONFIDENTIAL AND PROPRIETARY PROPERTY OF MITSUBISHI ELECTRIC ITA
9 * DESCRIPTION 10 * A Data Model class for use in conjunction with the Roque Wave 11 * Grig class 12 + 13 * $Log /com/mei tea /hsl/zones3agents/bootstrap/ItmeraryGridDataModel java $ 14 * 15 * 3 11/11/96 5 13p Billp 16 * Made correction to company name 17 * 18 * 2 9/04/96 12 36p Walsh 19 * Propogate changes to Destination terminology 20 * 21 * 1 8'29/96 5 21p Walsh 22 * mtial version 23 * 24 */ 25 package com meitca hsl zones]agentε bootstrap 26 27 import com roguewave widgets *, 28 import com roguewave widget^ grid * 29 import 3ava u ^l Vector, 30 import 3ava util Enumeration 31 32 import com meitca hsl zoneε;agentε conduit Destination 33 import com meitca hεl zoneεiagents conduit Itinerary 34 35 r 36 * Implements a the necessary com rogue widgets grid * interfaces to 37 * support the display of a Grid object This class is tied to the 38 * Grid control on the ItineraryPanel of the AgentLaunchWizard The 39 * grid is used to specify the Itinerary of the Agent to launch 40 * Osee Itinerary 41 * @see ItineraryPanel 42 * Θsee AgentLaunchWizard
43 * øauthor Thomas Wal εh
44 * /
45 public class ItineraryGridDataModel extends SelectionGridModel {
46 /*"* The rows displayed in the grid */
47 Vector ltsRows
ItineraryGridDataModel. ava_l Tue Nov 12 07:44:47 1996
48
49 /** The ItineraryPanel thiε object iε tied to. */
50 ItineraryPanel itspanel; 51
52 /**
53 * Construct a ItineraryGridDataModel
54 * gparam panel The I ineraryPanel this object is tied to
55 */
56 public ItineraryGridDataModel (ItineraryPanel panel) {
57 itsRows = new Vector () ;
58 itsPanel = panel;
59 } 60
61 /** derived from SelectionGridModel . fetchstrmg */
62 public String etchString ( int row, int column) {
63 try {
64 // vectors are zero based Grids are one based, so we need to
65 // subtract one
66 Destination aRow = (Destination) itsRows elementA (row-1) ;
67 switch (column) {
68 case 1
69 return aRow getDestinationHost ( ) ;
70 default-
71 return " " ,
72 }
73 } catch (ArraylndexOutOfBoundsException e) {
74 return " " ,
75 )
76 ) 77
78 /** derived from SelectionGr ldModel . fetchlnteqer */
79 public int fetchlnteger (int row, int column) {
80 try {
81 // vectors are zero based. Grids are one based, so we need to
82 // subtract one
83 Destination aRow = (Destina ion) itsRows elementAt (row-1) ;
84 switch (column) {
85 case 2 :
86 return aRow. getMethodID( ) + 1;
87 default
88 return 0;
89 }
90 } catch (ArraylndexOutOfBoundsException e) {
91 return 0;
92 )
93 ) 94
ItineraryGridDataModel. java_l Tue Nov 12 07:44:47 1996 3
95 /** derived from SelectionGridModel update */
96 public boolean update (int row, mt column, String value) {
97 Destination aRow,
98
99 try { 100 // vectors are zero based Grids are one based so we need to 301 // subtract one
102 aRc = (Destination) itsRows elementAt (row-1 )
103 ) r-Ttch (Arra> IndexOutO BoundsExceotioπ e){
104 aRow = new Destination!)
105 ιt'Do s insertElementAt (aRow row 1) 106
107 // a new destination has been added to the Itinerary Letε add
108 // a new blank row to the Grid εo that the user has space to type any
109 // more destinations
110 ltεPanel addRowf)
111 } 112
113 switch (column) {
114 case 1
115 aRow setDestinationHoε (value)
116 break
117 default
118 break
119 )
120 return true
121 } 122
123 /** derived from SelectionGridModel update */
124 public boolean update (int row int column int value) { 126
127 try {
128 // are zero based Grids are one based, εo we need to
129 // subtract one
130 aRow = (Destination) itsRows elementAt (row-1 )
131 } catch (ArraylndexOutOfBoundsException e){
132 aRow = new Destination ( )
133 itsRows insertElementAt (aRow, row-1) 134
135 // a new destination has been added to the Itinerary Lets add
136 I I a new blank row to the Grid so that the user has space to type any
137 // more destinations
138 addRow()
139 } 140
141 εwitch (column) {
ItineraryGridDataModel. ava_l Tue Nov 12 07:44:47 1996 4
142 case 2
143 aRow setMethodID(value - 1) ,
144 break,
145 default ,
146 break
147 )
148 return true
149 } 150
151 /*
152 * Retreives the Itinerary which has been specifed by the user
153 */
154 public Itinerary get Itinerary ( ) {
155 Itinerary itinerary = new ItineraryO,
156 Enumeration enum = itsRows elements () 157
158 while (enum hasMoreElements ( ) ) {
159 Destination destination = (Destination) enum nextElement ( ) ,
160 itinerary addDes ination (destination)
161 }
162 return itinerary,
163 }
164 }
ItineraryPanel. java_l Tue Nov 12 07:44:47 1996 1
1 /* $Header /com/mei tca/hsl/zonesjagentε/bootstrap/ItineraryPanel java 3 11/11/96 5 13p Billp $
2 *
3 * Copyright 1996 Horizon Systems Laboratory,
4 * Mitsubishi Electric Information Technology Center America
5 * All rights reserved 6
7 * CONFIDENTIAL AND PROPRIETARY PROPEPTY OF MITSUBISHI ELECTRIC ITA
8 *
9 * DESCRIPTION
10 * The ItineraryPanel of the AgentLaunchWizard
11 *
12 * $Log / com/meitca/hsl/zonesjagentε/bootεtrap/ItineraryPanel ava $
13 *
14 * 3 11/11/96 5 13p Billp
15 * Made correction to company name 16
17 * 2 9/10/96 11 46a Walεh
18 * remove boguε imports that javac considers illegal
19 *
20 * 1 8/29/96 5 21p Walεh
21 * mtial version
22 *
23 */
24 package com meitca hεl zoneεjagentε bootstrap
25 import java awt *
26 import java 10 *
27 import com roguewave wιdqet=; grid * 28
29 import com meitca hsl util Wizard
30 import com meitca hsl util WizardPanel 31
32
33 /**
34 * The third panel of the AqentLaunchWizard This panel allows the user
35 * to specify the Itinerary of the agent
36 * Ssee Itirerary
37 * @see AgentLaunchWizardPanel
38 * @see AgentLaunchWizard
47
ItineraryPanel . j ava_l Tue Nov 12 07 : 44 : 47 1996
48 /** _
49 * Construct the ItineraryPanel and all of its components
50 * øparam wizard The wizard to which this panel belongs (needed by
51 * super)
52 * @pararn wimfozard The AgentLaunchlnforma ion d°scnngιng this
5 * agent launch (needed by super)
54 */
55 public ItineraryPanel (Wizard wizard AgentLaunchlnformation info) (
56 super (wizard info)
57 buildPanelO
58 } 59
60 /**
61 * The W zard calls this method right before it is going to display
62 * the panel In thiε case the Panel needs to recreate the Grid
63 * so that the ChoiceColumn of the grid contains the names of the
64 * available methods of the currently selected Agent
65 */
66 public void dιsplayDanel ( ) {
07 remove ( it Grid)
68
69 // Crate a new grid model
70 ltsDataModel = new ItineraryGridDataModel ( this)
71 // Crate a new Grid in εpreadεheed mode
72 ltεGrid = new Grid (Grid TABLE_MODE ltsDataModel ltsDataModel ltsDataModel ltsDataModel )
73 itsGrid getCel lPanel ( ) setVertLineColor (Color gray)
74 itsGrid getCellPanel ( ) setHorzLmeColor (Color gra )
75 itsGrid editable = true 76
77 // Set the grid column heading panel s attributes //
78 itsGrid setColumnheadmgPanel (new ColumnHeadingPanel ( ) )
79 itsGrid qetColumnhead gPanel ( ) setBackground (Color lightGray)
80 itsGrid getColumnHeadingPanel ( ) setForeground (Color black)
81 itsGrid getColumnhead gPanel () εetThreeDΞtyle (Grid THREED_RAISED)
82 itsGrid getColumnHeadingPanel ( ) setHorzLines ( true)
83 itsGrid getColumnHeadingPanel ( ) setTextL eε ( 1)
85 // Add a text field column to the grid //
86 TextFieldColumnAttribute coll
87 coll = new TextFieldColumnAttribute ( )
88 coll setTitle (StringResources DEST_COL_TITLE)
89 coll εetWιdth(150)
90 ( (TableColumnCollei-tion) itsGrid getColumnCol lection () ) add(coll)
91
92 ChoiceCo LumnAttribu e choiceColu n = new Choκ eColumriAt tribute ( )
93 choiceColumn setTi tie (StringResources ACTION_COL_TITLE)
94 choiceColumn εetWidth ( 150 )
Stinerary anel.java_l Tue Nov 12 07:44:47 1996 3
95 ((TableColumnCollection) itsGrid getColumnCollection ( ) ) add (choiceColumn)
96
97
98 // Set the grid to have 1 row //
99 (itsGrid getRowCollection ( ) ) εetRows(l),
100
101 constrain (thiε, itsGrid
102 0, 6, 1, 1,
103 GridBagConstraints BOTH, GridBagConstraints NORTHWEST, 1 0, 1 0,
104 0,0,0 0), 105
106
107 choiceColumn addltem(' ' ) ,
108 fordnt ι= 0, KitsAgentlnfo itsMethods length, ι++) {
109 choiceColumn addltem( itsAgentlnfo itsMethods [ l ]) ,
110 } 111
112 invalidated
113 validate))
114 } 115
116 /**
117 * Verify that the information entered into tne panel s valid Called
118 * after the Next >' button is pressed
119 * There is no actual verification necessary This method simply
120 * retirpveε the Itinerary from the data model and stuffε it into
121 * the AgentLaunchln o
122 * ^returns true if the panel contains valid info, false if not
123 */
124 public boolean val idatePanel ( ) {
125 itsAgentlnfo itsltinerary = l sDataModel getltinerary!),
126 return true
127 ) 128
129 /**
130 * Builds the GUI Components for this panel
131 */
132 private vo d buildPanelf) {
133 setLayout (new GridBagLayou ( ) )
134
135 Label labell = new Label (StringResources ITIN_TEXT1, Label LEFT),
136 constram(thιε, labell,
137 0, 0, 1, 1,
138 GridBagConstraints HORIZONTAL, GridBagConstraints NORTHWEST, 0 0,
139 0 0 0 0) 140
141 Label label2 = new Label (StringResources II1N_TEXT2 Label LEFT),
ItineraryPanel . java_l Tue Nov 12 07 : 44 : 47 1996 4
142 constrain ( this , label2 ,
143 0 , 1 , 1 , 1 ,
144 GridBagConstraints. HORIZONTAL, GridBagConstraints .NORTHWEST, 0.0, 0.0,
145 0,0,0,0); 146 147
148 Label label3 = new Label (StringResources . ITIN_TEXT3 , Label. LEFT);
149 constrain ( this, label3,
150 0, 2, 1, 1,
151 GridBagConstraints. HORIZONTAL, GridBagConstraints .NORTHWEST, 0.0, 0.0,
152 0,0,0,0); 153
154
155 Label label4 = new Label (StringResources . ITIN TEXT4 , Label. LEFT);
156 constrain (this, label4,
157 0, 3, 1, 1,
158 GridBagConstraints. HORIZONTAL, GridBagConstraints . NORTHWEST, 0.0, 0.0,
159 0,0,0,0); 160
161 Label label5 = new Label (StringResources . ITIN_TEXT5, Label. LEFT);
162 constrain (this, labelδ,
163 0, 4, 1, 1,
164 GridBagConstraints. HORIZONTAL, GridBagConstraints . ORTHWEST, 0.0, 0.0,
165 0,0,0,0); 166
167 Label labelδ = new Label (StringResources . ITIN_TEXT6, Label . LEFT) ;
168 constrain ( this , labelβ,
169 0, 5, 1, 1,
170 GridBagConstraints .HORIZONTAL, GridBagConstraints . ORTHWEST, 0.0, 0.0,
171 0,0,0,0); 172
173 // Crate a new grid model
174 itsDataModel= new ItineraryGridDataModel ( this) ;
175 // Crate a new Grid in spreadsheed mode.
176 itsGrid = new Grid (Grid. TABLE_MODE, itsDataModel , itsDataModel, itsDataModel , itsDataModel ) ;
177 itsGrid. getCellPanel () . setVertLineColor (Color .gray) ;
178 itsGrid. getCellPanel () . setHorzLineColor (Colo .gray) ;
179 itsGrid. editable = true;
180
181 // Set the grid column heading panel's attributes //
182 itsGri . setColumnHeadingPanel (new ColumnHeadingPanel ( ) ) ;
183 itsGrid. getColumnHeadingPanel ( ) . setBackground (Color . lightGray) ;
184 itsGrid. etColumnHeadingPanel ( ) . se Foregroun (Color .black) ;
185 itsGrid. getColumnHeadingPanel () , setThreeDStyle (Grid .THREED_RAISED) ;
186 itsGrid. getColumnHeadingPanel () . setHorzLines ( true) ,-
187 itsGrid. getColumnHeadingPanel () . setTextLines (1) ; 188
ItineraryPanel . java_l Tue Nov 12 07:44:47 1996
189 // Add a text field column to the grid // 190 TextFieldColumnAttribute coll, 191 coll = new TextFieldColumnAttribute () , 192 coll secTitle (StnngResources DE^T_COL_TITLE) 193 coll setWιdth(150) , 194 ((TableColumnCollection) itsGrid getColumnCol lection () ) add(coll), 195 196 ChoiceCclumnAttπbute choiceColumn = new ChoiceColumnAttribute ( ) 197 choiceColumn εetTi ie (StringResources ACTION_COL_TITLE) , 198 choiceColumn setW dth ( 150 ) , 199 ((TableColumnCollection) itsGrid getColumnCollection ( ) ) add (choiceColumn) , 200 201 202 // Set the grid to have 1 row // 203 (itsGrid getRowCσllection ( ) ) εetRowε(l) 204 205 cons tram ( this , itsGrid, 206 0, 6, 1, 1, 207 GridBagConctia ts BOTH GridBagConstraints NORTHWEST, 1 0, 1 0, 208 0,0,0,0),
209
210
211 }
212
213 /**
214 * called by the ItineraryGridDa aModel to signify that a new row should be
215 * added to the Gr d
216 */
217 protected void addRow() {
218 itsGrid getRowCollection ( ) εetRows ( l sGπd getRowCollect ion ( ) count()+l),
219 }
220 )
ItineraryPanel. java_l Tue Nov 12 07:44:47 1996 5
189 // Add a text field column to the grid //
190 TextFieldColumnAttribute coll,
191 coll = new TextFieldColumnAttribute ( )
192 coll setTιtle(StrιngResourceε DEST_COL_TITLE) ,
193 coll εetUιdth(150)
194 ((TableColumnCollection) itsGrid getColumnCollection ( ) ) add(coll), 195
196 ChoiceCclumnAttnbute choiceColumn = new ChoiceColumnAttribute ( ) ,
197 choiceColumn setTi ie (StringResources ACTION_COL_TITLE) ,
198 choiceColumn setWidth (150) ,
199 ((TableColumnCollection) itsGrid getColumnCollection () ) add (cnoiceColumn) , 200
201
202 // Set the grid to have 1 row //
203 (itsGrid getRowCollection ( ) ) setRows(l) 204
205 constrain (th s , itsGrid,
206 0, 6, 1, 1,
207 GridBagConstraints BOTH, GridBagConstraints NORTHWEST 1 0, 1 0,
208 0,0 0,0), 209 210
211 }
212
213 /**
214 * called by the ItineraryGridDataModel to signify that a new row should be
215 * added to the Grid
216 */
217 protected void adαRo ( ) {
218 itsGrid getRowCollection ( ) setRows ( itsGrid getRowCollection ( ) count ()+l),
219 }
220 }
ffoAgentSkeletonException.3'ava_l Tue Nov 12 07:44:48 1996 1
1 /* $Header: /com/meitca/hsl/zones jagents/bootstrap/NoAgentSkeletonException . java 2 11/11/96 5 : 13p Billp
2 *
3 * Copyright 1996 Horizon Systems Laboratory,
4 * Mitsubishi Electric Information Technology Center America.
5 * All rights reserved.
6 *
CONFIDENTIAL. AMD PROPRIETARY PROPERTY OF MITSUBISHI ELECTRIC ITA.
8 *
9 * DESCRIPTION
10 * Exception indicating that Agent invocation Skeleton is missing.
11 *
12 * $Log : /com/mei tca/hsl/zonesjagents/boots rap/NoAgentSkeletonException . java $ 13
14 * 2 11/11/96 5:13p Billp
15 * Made correction to company name.
16 *
17 * 1 8/29/96 5:21p Walsh
18 * intial version
19 *
20 */
21 package com. meitca . hsl . zonesjagents . bootstrap;
22
23 /**
24 * Exception indicates that the system could not locate the Agent
25 * method invocation skeleton. This skeleton is used by the conduit
26 * server to invoke the proper method on the Agent when it arrives
27 * at a destination. The skeleton is generated by the Agent Skeleton
28 * Generator.
29 * @see Agent
30 * @see AgentSkeleton
31 * Sauthor Thomas Walsh
32 */
33 public class NoAgentSkeletonException extends Exception {
34 public NoAgentSkeletonException ( ) { 35 super ( ) ;
36 }
37
38 public NoAgentSkeletonException (String s) {
39 super (s) ;
40 }
41 }
NotAgentException. java_l Tue Nov 12 07:44:48 1996 1
1 /* $Header /com/mei tca/hsl/zones3agents/bootstrap/NotAgentExceptιon 3ava 3 11/11/96 5 13p Billp
2 *
3 * Copyright 1996 Horizon Syεtems Laboratory
4 * Mitsubishi Electric Information Technology Center America
5 * All rights reserved
6 *
7 * CONFIDENTIAL AND PROPRIETARY PROPERTY OF MITSUBISHI ELECTRIC ITA
8 *
9 * DESCRIPTION
10 * Exception indicating that a class File does not contain an Agent
11 *
12 * $Log /com/meιtca/hsl/zones3agentε/bootεtrap/NotAqentExceptιon 3ava $
13 *
14 * 3 11/11/96 5 13p Billp
15 * Made correction to company name 16
17 * 2 9/30/96 6 35p Walsh
18 * fix up javadoc comments 19
20 * 1 8/29/96 5 21p Walεh
21 * mtial version
22
23 */
24 package com meitca hsl zones3agents bootstrap 25
26 /**
27 * Exception indicates the class File specified did not contain
28 * a Java clasε derived riom Agent
29 * @see Agent
30 * Oauthor Thomas
31 */
32 public class NotAgentException extends Exception {
33 public NotAgentException ( ) {
34 super ( )
35 ) 36
RelatedFilesPanel. java_l Tue Nov 12 07:44:48 1996 1
1 /* $Header /com/mei tca/hsl/zonesjagentε/bootstrap/RelatedFilesPanel ]ava 3 11/11/96 5 13p Billp $
2 *
3 * Copyright 1996 Horizon Systemε Laboratory
4 * Mitsubiεhi Electric Information Technology Center America
All rights reserved
6
7 * CONFIDENT!/'. AND PROPRIETARY PROPERTY OF MITSUBISHI ELECTRIC ITA
8
9 * DESCRIPTION 10 * The RelatedFileεPanel or the AgentLauncnWizarα 11
12 * SLog 'com/meitca/hsl/zonesjagentε/bootεtrap/RelatedFilesPanel 3ava $
13 *
14 * 3 11/11/96 5 13p Billp
15 * Made correction to company name
16 *
17 * 2 9/10/96 11 46a Walsh
18 * remove bogus imports that javac considers illegal
19 *
20 * 1 8/29/96 5 21p Walεh
21 * irtial version
22 *
23 */
24 package com meitca hεl zonesjagents bootstrap, 25
26 import java av,r * 27 import ]ava lo * 28
29 import com meiira hsl uti- Wizard,
30 import com meitca hsl util WizardPanel 31
32
33 /**
34 * The second panel of the AgentLaunchWizard This panel allows the uεer
35 * to specify the filenames of claεεes that should be sent with the agent
36 * @see Agent
37 * @εee AgentLaunchWizardPanel
38 * @see AgentLaunchWizard
39 * θauthor Thomas Walsh 40 */
41 public class RelateαFilesPanel extends AgentLaunchWizardPanel {
42 /** The list control form which the user selects files */
43 List itεRelatedClasseεList ,
44
45
46 /**
47 * Construct the FindFilePanel and all of its components
RelatedFilesPanel. java_l TUΘ NOV 12 07:44:48 1996 2
48 * @param wizard The wizard to which this panel belongs (needed by
49 * super)
50 * Θparam wunfozar The AgentLaunchlnf ormation deεcπngmg this
51 * agent launch ( needed by super)
52 V
53 public RelatedFilesPanel (Wizard wizard, AgentLaunchlnformation info) {
54 super (wizard, info)
55 buildPanel () ,
56 ) 57
58 /**
59 * The Wizard calls this method right before it is going to display
60 * the panel In this case, the Panel needs to fill the List
61 * with the names of all the class files in the same directory as
62 * the Agent
63 */
64 public void displa Panel ( ) {
65 File agentDir = new File ( itsAgentlnfo itsAgentDirectory)
66 Strιng[] files = agentDir listfnew ClasεFileFilter ( ) ) ,
67
68 ltsRelatedClassesList clear!)
69 for (mt 1=0, Kfiles length, ι+H {
70 if ('fιles[ι] equals ( itsAgentln o ItsAgentFile))
71 ltεRelatedClaεsesList addl tern ( files [ l ] )
72 } 73
74 )
75
76 /**
77 * Vei-fy that the information entered into the panel is valid Called
78 * after the Next >' button is pressed
79 * Thei e is no actual verification necessary This method simply
80 * ret-reves the list of classes and stuffs tnern into the
81 * AgentLaunchlnfo '
82 * ^returns true if the panel contains valid info, false if not
83 */
84 public boolean validatePanel ( ) {
85 itsAgentlnfo l tεRelatedClasseε = itsRelatedClaεsesList getSelectedltemε ( ) ,
86 return true;
87 }
89 /**
90 * Buildε the GUI Componentε for this panel
91 */
92 private void builαPanelf) {
93 setLayout (new GridBagLayou ( ) ) 94
RelatedFilesPanel. java_l Tue Nov 12 07:44:48 1996 3
95 Label labell = new Label (StringResources . RF TEXT1, Label .LEFT) ;
96 constrain (this, labell,
97 0, 0, 1, 1,
98 GridBagConstraints. HORIZONTAL, GridBagConstraints . NORTHWEST, 0.0, 0.0,
99 0,0,0,0) ;
100
101 Label label2 = new Label (StringResources . RF_TEXT2, Label . LEFT) ;
102 constrain (this, label2,
103 0, 1, 1, 1,
104 GridBagConstraints. HORIZONTAL, GridBagConstraints . ORTHWEST, 0.0, 0.0,
105 0,0,0,0); 106
107
108 Label label3 = new Label (StringResources . RF_TEXT3 , Label ."LEF ) ;
109 constrain (this, label3,
110 0, 2, 1, 1,
111 GridBagConstraints. HORIZONTAL, GridBagConstraints .NORTHWEST, 0.0, 0.0,
112 0,0,0,0); 113
114
115 Label label4 = new Label (StringResources . F_TEXT , Label . LEFT) ;
116 constrain (this, label4,
117 0, 3, 1, 1,
118 GridBagConstraints. HORIZONTAL, GridBagConstraints .NORTHWEST, 0.0, 0.0,
119 0,0,0,0); 120
121 Label labelδ = new Label (StringResources . RF_TEXT5, Label . LEFT) ;
122 constrain(this, label5,
123 0, 4, 1, 1,
124 GridBagConstraints. HORIZONTAL, GridBagConstraints .NORTHWEST, 0.0, 0.0,
125 0,0,0,0); 126
127 Label labelδ = new Label (StringResources . RF_TEXT6 , Label . LEFT) ;
128 constrain ( this , label6,
129 0, 5, 1, 1,
130 GridBagConstraints .HORIZONTAL, GridBagConstraints .NORTHWEST, 0.0, 0.0,
131 0,0,0,0); -i
132
133 itsRelatedClassesList = new List(7, true);
134 constrain(this, itsRelatedClassesList,
135 0, 6, 1, GridBagConstraints. REMAINDER, 136 GridBagConstraints. BOTH, GridBagConstraints . ORTHWEST, 1.0, 1.0,
137 0,0,0,0);
138 }
139 } 140 141 /**
RelatedFilesPanel. java_l Tue Nov 12 07:44:48 1996 4
142 * A FilenameFilter object than scans for file ending in .class
143
144 class ClassFileFil ter implements FilenameFilter {
145 public boolean accept (File dir, String name) {
146 return (name . endsWith (". class ")) ;
147 )
148 }
StringResourcas. java_l Tue Nov 12 07:44:48 1996 1
1 /* $Header /ccm/mei tca/nsl/zonesjagentε/bootstrap/StπngReεourceε 3ava 7 11/11/96 5 13p Billp
2 *
3 * Copyright 1996 Horizon Syεtems Laboratory,
4 * Mitsubishi Electric Information Technology Center America
5 * All rights reserved c *
6
7 * CONFIDENTIAL AND PROPRIETARY PPOPER I Ϋ OF MITSUBISHI ELECTRIC ITA 8 9 * DESCRIPTION
10 * The String fo the boot slap pacl-age
11
12 * $Log /com, meιtca/hs"i /zoneεjagentε/bootstrap/StringResources java $
13
14 * 7 11/11/96 5 13p Billc
15 * Made correction to company name 16
17 * 6 10/07/96 4 44p Walsh
18 * Save name & location of laεt agent launched Restart Wizard pointing
19 * at εame agent
20 *
21 * 5 9/15/96 5 lip Walεh
22 * Fix spelling mistakes 23
24 * 4 9/09/96 5 59p Walsh
25 * Make constants final
26 *
27 * 3 9/05/96 6 37p Walεh
28 * Add some strirσ mn=-t?n' = associated with the c mimand line launch
29 * utility 30
31 * 2 9/04/96 12 36p Walεh
32 * Add launch error message 33
34 * 1 8/29/96 5 21p Walsh
35 * mtial version
36 *
37 */
42 // AgentLaunchWizard java
43 public static String WIZARD_TITLE = "Agent Launch Wizard' ,
44 public static String WIZARD_APPNAME = "AgentLaunchWizard",
45 public static String PROP_DESC = 'Properties file for Zones Agent Launch Wizard' 46
47 // FindFilePanel Java
StringResources. ava_l Tue Nov 12 07:44:48 1996
48 public static final String LAUNCH_ERROR_TITLE = "Launch Error"; 49 public static final String NO_FILENAME = "You must specify the filename of the .class file containing the nt. '
50 public static final String ENDSWITH_CLASS = "You must specify a file ending with .class
51 public static final String FF_TEXT1 = "This wizard will assist you in launching Agents";
52 public static final String FF TEXT2 = "Please select the .class file containing the ";
53 public static final String FF_TEXT3 = "agent you would like to launch.";
54 public static final String FF_TEXT4 = "
55 public static final String FF_FIELD_LABEL = "Class File: ";
56 public static final String FF_BROWSE_BUTTON = "Browse...";
57 public static final String BROWSE_DLG_TITLE = "Open Agent Class File";
58
59 //ItineraryPanel . j va
60 public static final String DEST_COL_TITLE = "Destination";
61 public static final String ACTION_COL_TITLE = "Action";
62 public static final String ITIN_TEXT1 = "An agent's itinerary specifies where an agent travels to and";
63 public static final String ITIN_TEXT2 = "what operations the agent performs as it travels. Please
64 public static final String ITIN_TEXT3 = "specify the itinerary below. You should enter the host- ";
65 public static final String ITIN_TEXT4 = "names of the machines you would like your agent to travel " ;
66 public static final String ITIN_TEXT5 = "to as well as the methods you would like called at each stop.";
67 public static final String ITIN_TEXT6 = "
68
69 // RelatedFilesPanel . java
70 public static final String RF_TEXT1 You may specify a list of classes which should be sent with";
71 public static final String RF_TEXT2 the Agent. These should be classes which the Agent is likely"
72 public static final String RF_TEXT3 to use while it is travelling. " ;
73 public static final String RF_TEXT4
74 public static final String RF_TEXT5 Please select any classes you would like sent with the agent."
75 public static final String RF_TEXT6
76
77 // Bootstrap . java
78 public static final String USAGE "Usage: bootstrap [-d hostname, method] [-f relatedfile . class] \n\t [ -h] a tfile. class" ;
79 public static final String ILLEGAL_OPTN = "bootstrap: illegal option -- ";
80 public static final String SYNTAX_ERROR = "bootstrap: syntax error --
81 public static final String ILLEGAL_AGENT = "bootstrap: Illegal agent file -- ";
82 public static final String NO_AGENT = "bootstrap: No agent specified";
83 public static final String AGENT_HELP = "\tThe agent files must be valid Java class file\n\tand must end w . class " ;
84 public static final String ILLEGAL_RELFILE = "bootstrap: Illegal related filename -- ";
85 public static final String RELFILE_HELP = "\tThe related files specified by the -f option\n\ tmust be valid va class files and must end\n\twith .class";
86 public static final String ILLEGAL_DEST = "bootstrap: Illegal destination specification --
87 public static final String ILLEGAL_METHOD = "bootstrap: Illegal method name --
88 public static final String NO_DEST = "bootstrap: You must specify at least destination";
89
90 // shared strings
StringResources. java_l Tue Nov 12 07:44:48 1996 3
91 public static final String FILE_NOTFOUND = "Could not find the file specified
92 public static final String IOERROR = "An error occurred while trying to access the file specified
93 public static final String BAD_CLASS_FORMAT = 'The file specified did not contain a valid Java cl
94 public static final String NOT_AGENT = "The file specified did not contain a Java Agent "
95 public static final String NO_SKELETON = Could not locate the Agent's skeleton ",
96 public static final String LAUNCH_ERROR = 'An error occurred while attempting to launch the Agent
97
98 }
AgentPackage . ava_l Tue Nov 12 07 : 45 : 01 1996 1
1 / * SHeader ,'com/me ι tca/hε l / zoneεj agen ts /conduιt /AgentPackage j ava 18 11 / 11 / 96 5 15p Bi l lp $
2 *
3 * Copyright 1996 Horizon Syεtems Laboratory,
4 * Mitsubishi Electric Information Technology Center America
5 * All rights reserved
6 *
7 * CONFIDENTIAL AND DROPRIFTAPY PROPERTY OF MITSUBISHI ELECTPIC ITA 8
9 * DESCRIPTION
10 * Agent tran portation package object
11 *
12 * $Log /com/meitca/hεl/zonesjagents/conduit/AgentPackage Java $ 13
14 * 18 11/11/96 5 15p Billp
15 * Made correction to company name 16
17 * 17 10/28/96 6 31p Walsh
18 * Add more debugging info
19 *
20 * 16 10/24/96 5 15p Walεh
21 * add some cebuggiπg information related to memory usage
25
26 * 14 10/11/96 9 ^6a Wal-h
27 * fix compiler bug
28 *
29 * 13 10/10,96 6 02p Wnl-
30 * Add persistence support 31
32 * 12 9/30/96 7 06p Ualεh
33 * clean up javadoc comments 34
35 * 11 9/29/96 4 08p Walεh
36 * Allow Destination methods to be specified by name
37 * Give Agent access to AgentPackage information
38 *
39 * 10 9/11/96 12 24p Walsh
40 * remove uneeded import of CollaboratorAgent
41 *
42 * 9 9/09/96 4 59p Walsh
43 * Call Agent prepareForTransport, completedTransport methodε
44 *
45 * 8 8/23/96 3 58p Walεh
46 * Add support for ad-hoc method invocation 47
AgentPackage. java_l Tue Nov 12 07:45:01 1996 2
48 * 7 8/22/96 5-45p Walsh
49 * Move the custom marshalling of the agent into the AgentPackage class
54 * 5 8/09/<!6 4 38p Walεh
55 * Setting up file headers
56 */ 57
58 package com meitca hsl zoneε agentε conduit, 59
60 import java.io * ;
61 import java net.*;
62 import java rmi server MarshalException 63
64
65 import com meitca hεl zones agents shared Agent,
66 import com. meitca hsl util *, 67
68
69 /**
70 * An AgentPackage contains an Agent, its MobileCodebase and
71 * its Itinerary The AgentPackage is passes between Condui tServers
72 * when the Agent travels
73 * @see Condui tServerlmpl
74 * Θauthor Thomaε Walεh
75 */
76 public claεε AgentPackage {
77 Agent itsAgent,
78 MobileCodebase ItsMobileCodebase,
79 Itinerary itsltinerary,
80 String l tεHomeCodebaεeURL,
81 int itsOID, 82
83 84
85 /**
86 * Con'.tructs an AgentPackage
87 * @param agent The Agent
88 * Θparam code The Agent's mobile codebaεe
89 * Θparam itinerary The Agents itinerary
90 * @param homeCodebasellRL The URL of the Agent 'ε codebase
91 */
92 public AgentPackage (Agent agent, Mobi eCodebase codebase,
93 Itineraiy itinerary, String homeCodebasellRL) {
94 Debug println ( "conduit memory", 3, "AgentPackage " + this + " created"),
AgentPackage. java_l Tue Nov 12 07:45:01 1996 3
95 itsAgent = agent,
96 itsMobileCodebase = codebase,
97 itsltinerary = itinerary,
98 itsHomeCodebaseURL = homeCodebaεeURL
99 ltsOID = 0
100 }
101
102 protected void finalize () thro s Throwable {
103 Debug println (' condui t memory 3 AgentPackage ' + this + ' finalized )
104 "-uper finalize))
105 ) 106
107 /** Retrieves the Agent from the package */
108 public Agent getAgen ( ) {
109 return itsAgent
110 ) 111
112 /** Retrieves the Agent s Mobile Codebaεe from the package */
113 public MobileCodebaεe getMobileCodebase ( ) {
114 return ItsMobileCodebase
115 }
116
117 /** Retrieves the Agent's itinerary from the package */
118 public Itinerary getltinerar ( ) {
119 return itsltinerary
120 ) 121
122 /** Retrieves the Agent ε codebase URL from the package */
123 public String getHomeCodebaseUR ( ) {
124 return I εHomeCodebaseURL
125 ) 126
127 /**
128 * Prepares the Agent package for network transmission This method
129 * performs the conversion of the Agent to a network transmission
130 * format This metiod also calls the Agent 'ε prepareForTransport
131 * method
132 */
133 public void prepareForTransport ( ) {
134 Debug println ( 'conduit ' 2, 'AgentPackage prepareForTransport called'),
1-L3J5:3
136 '/ give the aαent a chance to do any work in preperation
137 // for transport
138 itsAgent prepareForTransport () ,
139 } 140
141 /**
AgentPackage. java_l Tue Nov 12 07:45:01 1996 4
142 * Restores the Agent package for network transmissionfrom its
143 * network transmission format. This method also calls the Agent's
144 * completedTransport method.
145 */
146 public void restoreFromTransportForm( ) {
147 Debug .println ( "condui t" , 2, "AgentPackage . restoreFromTransportForm called");
148
149 // give the agent a chance to do any work in preperation
150 // for arrival at destination
151 itsAgent . completedTransport ( ) ;
152 } 153
154 private void readObject (ObjectlnputStream stream)
155 throws IOException, ClassNotFoundException {
156 Debug .println (" condui " , 2, " AgentPackage . readObject called"); 157
158 itsMobileCodebase = (MobileCodebase) strea . readObject () ;
159 Debug .println ( "conduit " , 4, " read MobileCodebase: " + itsMobileCodebase); 160
161 itsltinerary = ( Itinerary) stream. readObject () ;
162 Debug .println ( "conduit " , 4, " read Itinerary: " + itsltinerary);
163
164 itsHomeCodebaseURL = (String) stream. readObject () ;
165 Debug .println ( "conduit" , 4, " read Codebase URL: " + itsHomeCodebaseURL); 166
167 // do the special deserialization of the Agent using the
168 // ConduitObjectlnputStream class
169 ConduitServerClassLoader ClassLoader = new ConduitServerClassLoader ( itsMobileCodebase, itsHomeCodeh eURL) ;
170
171 // unmarshal the agent, build the AgentPackage and then pass it along to receiveAgent
172 bytef] serializedAgent = (byte []) stream. readObject () ;
173 ByteArraylnputStream bytelnStream = new ByteArraylnputΞtream ( serializedAgent ) ;
174 ConduitObjectlnputStream marshallnput = new ConduitObjectInputStream(byteInStream, classLoaά ) ;
175
176 Debug. println ( "conduit" , 4, " about to read Agent");
177 itsAgent = (Agent )marshallnput . readObject () ;
178 Debug. println ( "conduit" , 4, " read Agent: " + itsAgent); 179
180 // Restore the Agents reference to its Package will be
181 // restored when the agent arrives at the Destination
182 itsAgent . setPackage (this) ,-
183 } 184
185 private void writeObject (ObjectOutputStream stream)
186 throws IOException {
AgentPackage. java_l Tue Nov 12 07:45:01 1996 5
187 Debug .println ( "conduit" , 2, "AgentPackage .writeObject called"); 188
189 stream. writeObject ( itsMobileCodebase) ;
190 stream. writeObject ( itsltinerary) ;
191 stream. writeObject ( itsHomeCodebaseURL) ;
192
193 // do the special deserialization of the Agent using the
194 // ConduitObjectOutputStream class 195
196 // null out the Agents pointer to the AgentPackage. We have to
197 // do this because Java object persistence does not support
198 // isomorphic persistence. Since the AgentPackage has a
199 // reference to the Agent and the Agent has a reference
200 // to the AgentPackage we have a circular reference.
201 // Without isomorphic persistence, this circular referece
202 // vould cause the object serialization code to go into an
203 // infinite loop The reference to itsPackage will be
204 // restored when the agent arrives at the Destination
205 itsAgent setPackage (null ) , 206
207 ByteArrayOutputStream byteOutStream = new ByteArrayOutputStream( ) ;
208 Condui tObj ectOutputStream marshalOutput = new ConduιtObjectOutputStream(byteOutStream) ;
210 // use object serialization to stream the agent to a byte array
211 marshalOutput .writeObject (itsAgent) ;
212 byte[] serializedAgent = byteOutStream toByteArray ( ) ; 213
214 // finally write the serialized agent to the original output stream
215 stream writeObject (serializedAgent )
216 } 217
218 /** Retrieves the AgentSkeleton object corresponding to the Agent. */
219 AgentSkeleton get AgentSkeleton ( ) throws ClassNotFoundException, InstantiationException, IllegalAccessExce {
220 String agentClassna e = itsAgent getClassO getNamef),
221 String skelClassname = agentClassname + "_Skel",
222 ConduitServerClassLoader classLoader = (ConduitServerClassLoader) itsAgent getClassO getClassLoade
223 if (classLoader '= null)
224 return (AgentSkeleton) ( classLoader loadClass (skelClassname) .newlnstance ()) ,
225 else
226 return (AgentSkeleton) (Class forName (skelClassname) newlnstance ()) ;
227 } 228
229 void setOID(int oid) {
230 itsOID = oid;
231 }
AgentPackage. java_l TUΘ NOV 12 07:45:01 1996 6
232
233 int getOIDO {
234 return itεOID;
235 )
236
AgentSkeleton. java_l Tue Nov 12 07:45:01 1996 1
1 /* SHeader /com/mei tca/hsl /zoneεjagents/conduit/AgentSkeleton java 3 11/11/96 5 15p Billp $
2 *
3 * Copyright 1996 Horizon Systems Laboratory
4 * Mitsubishi Electric Information Technolog\ Center America
5 * All rights reserved
7 * CONFIDENTIAL ANC PROPRIETAPY PROPERTY 0" MITSUBISHI EijΞCTPIC ITA
8 *
9 * DESCRIPTION
10 * Aqent method invocation ^leleton interface
11
12 * $Log /com/meitca/hsl/zonesjagentε/conduit/AgentSkeleton java $
13
14 * 3 11/11/96 3 15p Billp
15 * Made correction to company name
16 * 3
17 * 2 : 8/29/96 5 15p Walεh
18 * Add getMethodε method
19 *
20 * 1 8/23/96 3 ^OD Wal^
21 * Initial versiorε
22 */
23 package com meitca hsl zonesjagents conduit
24
25 import com meitca hsl zoαeεnagents shared Agent
26
27 /**
28 * An interface ret me ι_ho 5 inv cation s)eletcn
29 * The skeleton make a call tr any method within
30 * the Agent At ruitime *-he ConduitServer looks ft the Agent ε Itinerary
31 * and determines ivhat method should be called at the current location The
32 * skeleton allo ε the Concuit Server to call the method
33 * @εee Agent
34 * @εee Condu i tServer
35 * øauthor Thorras Walsh
36 */
37 public interface AgentSkeleton { 38
39 I * *
40 * Invokes a method on an agent
41 * Θparam agen1- The agent whoεe method to invoke
42 * Θparam ι The method ID number of the method to invoke
43 V
44 public void invoke (Agent agent int i) thro ε II leqalAcceεεException
4 ^5
46 /**
47 * R triPv<- a 1 I - 1 f the agont methodε which c in tie invoked h\
AgentSkeleton. java_l Tue Nov 12 07:45:01 1996 2
48 * the skeleton.
49 */
50 public String[ ] getMethodε ( ) ;
51 52
AgentThread. ava_l TUΘ NOV 12 07:45:02 1996 1
1 /* $Header /com' eitca/hεl/zonesjagents/conduit/AgentThread java 4 11/11/96 5 15p Billp $
Δ 2 *
3 * Copyright 19S6 Horizor Systemε Laboratory
4 * Mitsubishi Electric Information Technology Center America
5 * All rights reserved
6 *
7 * CONFIDENTIAL ^ D PROPPIETAPY PROPERTY OF MITSUBISHI ELECTRIC ITA 8
9 * DESCRIPTION
10 * provides the thro^d m viich an Agent will executes
11 *
12 * $Log /com/π eitca/rsl/zones jagentε/conduit/AgentThread java $
13 *
14 * 4 11/11/96 5 15p Billp
15 * Made correctior to company name 16
17 * 3 10/29/96 5 ">8p Wain
18 * Use ErrorLog cla^-ε to report errorε
19 *
20 * 2 10/28/96 6 31p Wa]-n
21 * Add more debugging info
22 *
23 * 1 10/25/96 5 02p Walsn
24 * Make AgentThread public
25
26 */
27 package com meitca ^l zone^iaqentε conαu^t 28
29 import ava util * 30
31 import com meitca hεl zoneεjaαentε shared *
32 import com meitca h=l util * 33
34 /**
3 5 * A εubc laεs o f Ui^a Agen tThread provides the thread in vihich an Agent wi l l
36 * execute
37 * @εee Agent
38 * @εee ConduitServer
39 * Sauthor Thomas Walεh
40 */
41 public class AgentThread extends Thread {
42 AgentPackage itsPackage 43
44 /**
45 * Constructs an AgentThread
46 * Pparam aσentPackaqe The package containing the agent, its code and
47 * its itinerary
AgentThread. java_l Tue Nov 12 07 : 45 : 02 1996 2
48 */
49 public AgentThread (AgentPackage agentPackage) {
50 Debug println (" conduit memory', 3, "AgentThread " + this + " created"
51 itsPackage = agentPackage,
52 this start ()
5 543 '
55 protected void finalize () thro ε Throwable {
56 Debug pr int ] n (' condui t Memory 3 Aqentlhread ^ this + " finalized")
58 ) 59
60 / * *
61 * Retrieves a reference to the Agent which is executing within thiε
62 * AgentThread
63 */
64 public Agent getAgent() {
65 return itsPackage getAgent(),
66 )
67
68 /**
69 * Retrieves a reference to the AgentPackage contained within thiε
70 * AgentThread
71 */
72 public AgentPackage getAgentPackage ( ) (
73 return ιt=Package,
74 } 75
76 /**
77 * Begmε the Agent ε execution
78 */
79 public void rjn ( ) {
80 try {
81 ConduitServerlmpl getPerεiεtenceStore ( ) addToStore ( itsPackage)
82 Aσen Skeleton skel = itsPackage getAgentSkeleton ( ) ,
83 Destination current = itsPackage qetlt merar ( ) getCurrentLocation ( ) , 84
85 if ( .urrent getMethodID ( ) == Destination UNKNOWN_METHOD_ID) {
86 current convertNameToId ( skel ) ,
37
88 89 εk=l invoke ( ltεPackage getAgentj
90 current getMethodID ()) ,
91 ltεPackage getltinerary ( ) getCurrentLocation ( ) εetCompleted ( ) ,
92 ConduitServerlmpl getPerεiεtenceStore ( ) updateStore ( ltεPackage) ,
93 } catch (Exception error) {
94 ErrorLog println ( "condui AgentThread'
AgentThread. java_l Tue Nov 12 07:45:02 1996 3
95 ErrorLog.SEVERITY_ERROR,
96 "An error occurred while executing Agent:",
97 error) ;
98 } 99
100 ConduitServerlmpl .decrementAgentCounters ( ) ;
101
102 try {
103 // pass the agent along.
104 ConduitServerlmpl . sendPackage ( itsPackage) ;
105 } catch (NoSuchElementException done) {
106 Debug . println ( "conduit " , 1, "AgentThread . un : No more destinations for Agent " +
107 itsPackage .getAgent () .get? tIDO) ;
108 } catch (Exception error) {
109 ErrorLog .println ( "conduit .AgentThread" ,
110 ErrorLog.SEVERITY_ERROR,
111 "An error occurred while transporting Agent:",
112 error) ; 313 }
114
115 // remove the agent from the persistence store
116 ConduitServerlmpl . getPersistenceStore ( ) . removeFromStore ( itsPackage ) ;
117 118
ConduitObjectlnputStream. java_l Tue Nov 12 07:45:02 1996 1
1 /* $Header: /com/meitca/hsl/zones agents/conduit/ConduitObjectlnputStream. java 9 11/11/96 5:15p Billp $ 2
3 * Copyright 1996 Horizon Systems Laboratory,
4 * Mitsubishi Electric Information Technology Center America.
5 * All rights reserved.
6 *
7 * CONFIDENTIAL AND PROPRIETARY PROPERTY OF MITSUBISHI ELECTRIC ITA.
8 *
9 * DESCRIPTION
10 * Specialized Object InputStream used for agent deserialization
11
12 * $Log: /com/meitca/hsl/zonesjagents/conduit/Condui tObj ectlnputStream. java $
13
14 * 9 11/11/96 5:15p Billp
15 * Made correction to company name.
16 *
17 * 8 11/01/96 5:32p Walsh
18 * Modify debugging levels of debug output
19 *
20 * 7 10/21/96 4:26p Walsh
21 * Add debug logging
22 *
23 * 6 9/30/96 7:05p Walsh
24 * clean up javadoc comments 25
26 * 5 9/11/96 6:40p Walεh
27 * fix compiler error
28 *
29 * 4 9/11/96 6:33p Walsh
30 * derive from Marshal *Stream
31 *
32 * 3 8/22/96 2:19p Walsh
33 * Clean up code a little 34 35 * 2 8/13/96 5:09p Walsh
36 * Added comments & documentation. resolveClass now uses
37 * ConduitServerClassLoader
38 *
39 * 1 8/12/96 7 : 17p Walsh
40 * Initial versions
41 */
42 package com. eitca . hsl . zonesjagents . conduit ;
43
44 import java .10. InputStream;
45 import java . io . IOException;
46 import jav . io . StreamCorruptedExcep ion ;
47 import java . lang .ClassNotFoundException;
ConduitOb3ectOutputStream.3'ava_l TUΘ Nov 12 07:45:02 1996 1
1 /* $Header: /com/meitca/hsl/zonesjagents/conduit/ConduitObjectOutputStrea . java 7 11/11/96 5:15p Billp $
2 3 ** Copyright 1996 Horizon Systems Laboratory,
4 * Mitsubishi Electric Information Technology Center America.
5 * All rights reserved.
6 *
7 * CONFIDENTIAL AND PROPRIETARY PROPERTY OF MITSUBISHI ELECTRIC ITA. 8
9 * DESCRIPTION
10 * Specialized MershallnputStream used for agent deserialization
11 *
12 * $Log: /com/meitca/hsl/zonesjagents/conduit/ConduitObjectOutputStream. java $ 13
14 * 7 11/11/96 5:15p Billp
15 * Made correction to company name. 16
17 * 6 11/01/96 5:32p Walsh
18 * Modify debugging levels of debug output
19 *
20 * 5 10/21/96 4:26p Walsh
21 * Add debug logging
22 *
23 * 4 9/30/96 7:06p Walsh
24 * clean up javadoc comments
25 *
26 * 3 9/11/96 6:33p Walsh
27 * derive from Marshal*Stream
28 *
29 * 2 8/22/96 2:19p Walεh
30 * Clean up code a little 31
32 * 1 8/12/96 7 : 17p Walsh
33 * Initial versions
34 */
35 package com. eitc . hsl . zonesjagents . conduit ; 36
37 import java . io . OutputStream;
38 import java . io . IOException ;
39 import java . io .StreamCorruptedException ;
40 import java . lang .ClassNotFoundException;
41 import java . rmi . server .MarshalOutputStream;
42
43 import com.meitca .hsl . util .* ; 44
45 public class ConduitObjectOutputStream
46 extends MarshalOutputStream { 47
ConduitObjectlnputStream. ava_l Tue Nov 12 07:45:02 1996 3
95 Debug .println ( "conduit . classload" , 3, "ConduitObjectlnputStream. resolveClass called for " + classr
) ;
96
97 return itsClassLoader . loadClass (classname) ;
98 }
99 }
ConduitObjectlnputStream. java_l Tue Nov 12 07:45:02 1996 2
48 import java rmi server MarshallnputStream
49 import ava net MalformedURLException
50 import java net URL,
51 import ava rmi server StubClassLoader oz 53 import com meitca hsl util *
54
55 /**
56 * A subclass of Obj ectlnpu Stream which is uεed to handle deserialization
57 * of Agent objects ConduitObjectlnputStream overrides the
58 * ObjectlnputStream resolveClass method As the deserialization process
59 * encounterε object contained within the agent, resolveClass is called for
60 * each unique class resolveClass makes use of a ConduitServerClaεεLoader
61 * object to search the agents MobileCodebase for class bytecodes
62 * Ssee Agent
63 * Θsee ConduitServerClassLoader
64 * @see Ob ectlnputStream
65 * @see MobileCodebase
66 * ©author Thomas Walsh
67
68 class ConduitObjectlnputStream
69 extends MarshallnputStream {
70
71 /** Class loader object uεed for deserializing an agent */
72 ConduitServerClassLoader itsClassLoader 73
74 /**
75 * Constructs a ConduitObjectlnputStream
76 * Θparam is Tie InputS^reara containing the Agent object
77 * @param classLoader A ConduitServerClaεεLoader capable of loading
78 * classes from the Agent's MobileCodebase
79 */
80 public ConduitOb ectlnputStreamdnputStream is ConduitServerClassLoader classLoader)
81 thrcws IOException, StreamCorruptedException {
82 super (is)
87 /**
88 * Resolves a fully qualified class name to a Class object resolveClass uses a
89 * ConduitServerClasεLoader to actually perform the class loading
90 * @param classname Tne classes fully qualified claεε name
91 */
92 protected Claεε resolveClass (String classname)
93 throws IOException, ClassNotFoundException ( 94
ConduitObjectOutputStream. va_l Tue Nov 12 07:45:02 1996
48 public ConduitObjectOutputStrea (OutputStream is)
49 throws IOException {
50 super (is ) ;
51 } 52
53
54 protected vcid annotateClass (Class cl) throws IOException {
55 Debug .println ( "condui . classload" , 3, "ConduitObjectOutputStream. annotateClass called for " + cl);
56 }
57 }
ConduitServer. java_l Tue Nov 12 07:45:02 1996 1
1 /* $Header /com/mei tca/hεl/zoneεjagentε/condui t/ConduitServer java 9 11/11/96 5 15p Billp $ 2
3 * Copyright 1996 Horizon Syεtemε Laboratory,
4 * Mitsubishi Electric Information Technology Center America
5 * All rights reserved
6 *
7 * CONFIDENTIAL AND PROPRIETARY PROPERTY OF MITSUBISHI ELECTRIC ITA 8 9 * DESCRIPTION
10 * Conduit Server distributed interface
11
12 * $Log /com/meitca/hsl/zonesjagentε/conduit/ConduitServer java $
13
14 * 9 11/11/96 5-15p Billp
15 * Made correction to company name 16
17 * 8 9/30/96 7 06p Walsh
18 * clean up javadoc comments 19
20 * 7 8/27/96 3 51p Walsh
23 * 6 8/22/96 5 45p Walεh
24 * Move the custom marshallinq of the agent into the AgentPackage class 25
26 * 5 8/19/96 5 26p Walsh
27 * Add support for remote class loading 28
29 * 4 8/13/96 11 47a Walεn
30 * Add documentation t< conm°ntε Change signature of receivePackage
31 * method 32
33 * 3 8/12/96 7 15D Walsh
34 * ConduitServer no» performs Marεhalling 35
36 * 2 8/09/96 4 38p Walεh
37 * Setting up file headers
38 */ 39 40 package com meitca hεl zoneε agents conduit,
41
42 import java rmi Remote,
43 import java rmi RemcteException
ConduitServer. java_l Tue Nov 12 07:45:02 1996 2
49 /**
50 * ConduitServer is an RMI distributed interface It provides some RMI glue
51 * that allows conduit εerverε to communicate ConduitServer lε implemented
52 * by the ConduitServerlmpl class Conduit servers provide for Agent travel
53 * and execution
54 * @εee ConαuitServerlmpl
55 * ©author Thomas Walsn
56 */
57 publ i c i n t- prf acp Condu i Sei 'ei py '" Pn - Rpiri i te { 58
59 /**
60 * Receive an Agent from the previous conduit server in its Itinerary
61 * Sparam aPackage The package containing the agents ltε mobile
62 * codebaεe and it itinerary If a communication error occurs
65 public void receivePackaqe (AgentPackaqe aPackage)
65 throws Re oteEyception
ConduitServerClassLoader. java_l Tue Nov 12 07:45:02 1996 1
1 /* $Header: /com/meitca/hsl/zonesjagents/conduit/ConduitServerClassLoader . java 12 11/11/96 5:15p Billp $
2 *
3 * Copyright 1996 Horizon Systems Laboratory,
4 * Mitsubishi Electric Information Technology Center America.
5 * All rights reserved.
6
7 * CONFIDENTIAL AND PROPRIETARY PROPERTY OF MITSUBISHI ELECTRIC ITA.
8 *
9 * DESCRIPTION
10 * Conduit Server ClassLoader subclass
11 *
12 * $Log: /com/meitca/hsl/zonesjagents/conduit/ConduitServerClassLoader . java $
13 *
14 * 12 11/11/96 5 : 15p Billp
15 * Made correction to company name.
16 *
17 * 11 11/01/96 5:32p Walsh
18 * Modify debugging levels of debug output
19 *
20 * 10 10/24/96 5:15p Walsh
21 * add some debugging information related to memory usage.
22 *
23 * 9 10/21/96 4:26p Walsh
24 * Add debug logging
25 *
26 * 8 9/30/96 7:06p Walsh
27 * clean up javadoc comments
28 *
29 * 7 9/28/96 6:37p Walsh
30 * use the AgentCodebase class to retrieve bytecodes 31
32 * 6 8/22/96 5:42p Walsh
33 * Cache Classes we define 34
35 * 5 8/19/96 5:25p Walsh
36
37 * 4 8/13/96 5:09p Walsh
38 * Added comments & documentation. loadClass now looks in MobileCodebase.
39 *
40 * 3 8/13/96 11:19a Walsh
41 * remove obsolete loadMobileClasses method
43 * 2 8/09/96 4:38p Walsh
44 * Setting up file headers
45 */ 46
47 package com. eitca .hsl . zonesjagents . conduit ;
ConduitServerClassLoader. j ava_l Tue Nov 12 07:45:02 1996 2
48
49 import java rmi Naming
50 import java io * ,
51 import java net *,
52 import java util *
53
54 import com meitca hsl zone<-jaqentε shared *
55 import com meitca h<=-l util * 56
57 I * *
58 * A specialized ClassLoaαer object used by the conduct server to manage agent
59 * creation, deserialization, snd sub-object creation ConduitServerClassLoader
60 * eytends the base system class loading behavior by allowing for classes to be
61 * loaded from the MobileCodebase of an Agent For example, an Agent object might
62 * be created on one particular server on a network When it lε created, ltε
63 * bytecodeε are added to the MobileCodebase The aqent nov. travels to a new
64 * εerver The bytecodes for thiε particular agent have not been installed on the
65 * new server Under normal circumstances when the object deserialization code
66 * attmeptε to reconstruct the agent a ClaεεNotFoundException would reεult εince
67 * the agents code ones net exist anywhere on the new server
68 * ConduitServerClassLoader allowε the Java virtual machine to look for an Agentε
69 * code in the Mobi 1 "Codebase vhich allows Agent object to travel and pull their
70 * code with them
71 * @see Agent
72 * Θsee ConduitServer
73 * Θsee MobileCodebase
74 * Θsee ClaεεLoader
75 * @author Thomaε Walεh
76 */
77 public clasε Condui ServerClassLoader
78 extends Cla sLoader { 79
80 /** The MobileCodebaεe corresponding to the Aqent being managed */
81 MobileCodebase l tsMob_ l°Codebase 82
83 /** An URL back to the coebase of this agent on its home machine */
84 AgentCodebase itsHomeCodebase 85
86 /**
87 * A hashtable containing the Clasε objectε we have already
88 * defined during the εeπalizat ion process
89 */
90 Hashtable 1 tsPrevιous lγDef medClasεeε
91
92 /**
93 * Constructs a ConduitServerClassLoader
94 * @param codebase The MobileCodebase corresponding to the
ConduitServerClassLoader. va_l Tue Nov 12 07:45-02 1996 3
95 * Agent being managed
96 * @param homeCodebaεeURL An URL back to the codebaεe of this o * agent on its home machine
98 * θexceptirn Malfo ι=dURI Exception if the URL pasεesd in aε the
99 * homeCodebaseURL parameter is invalid
104 1 t'-Mobi leCodebase - codeoase
105 ltεHomeCodebaεe = new AgentCodebase (homeCodebaseURL)
106 ltεPreviouslvDef medClasses = new Hashtable ()
107 } 108
109 protected void finalize () throws Throwable {
110 Debug println ( -onduit memory 3 ConduitServerClassLoader + this + finalized )
111 εuper fmaliz )
118 * @pararn na e Fully qualified name of the class to be loaded (le <b>
119 * java lang String </b>)
120 */
121 public Class loadClass ( String name)
122 throws ClassNotFoundException {
123 return loadClass (name Tue)
124 ) 125
126 /**
127 * Loads a class Inherited from ClassLoader First check on the local
128 * system and then loo^s in the Mobi eCodebase
129 * @param name Fully qualified name of the claεs to be loaded (le
130 * java lang String
131 * @param boolean value indicating wether or not the claεs
132 * should be resolved via the ClasεLoader resolveClass method
133 */
134 protected Class loadClass (String name boolean resolve)
135 threws ClassNotFoundException (
136
137 Debug prιrtln( conduit claεsload 2 ConduitServerClaεsLoader loadClaεε called for +
38 Debug pπrtl conduit classload 2 reεolve is + reεolve)
139
140 // firεt check the cache to see if we have encountered this class
141 // ' ofore Not= A ClassLoader object should always do something
ConduitServerClassLoader. ava_l Tue Nov 12 07:45:02 1996 4
142 // like this In order for Java ' ε type checking to work properly,
143 // everytime a loadClaεs lε called for a particular claεs name, the 344 // EXACT SAME Claεε object muεt be returned
145 Clasε cache = ( Claεε ) itsPre louεlyDef niedClaεεes get (name),
146 if (cache ' = null) {
147 Debug println (' condui t claεεload' 3, "Claεε found in cache"),
148 return cache
149 } 150
151 try {
152 // first check this system
153 Class c = indSystemClass (name) ,
154 Debug print In ( "condui t claεεload", 3, "Clasε found on system"),
155 if (r»solve) {
156 resolveClass (c)
157 )
158 return c,
159 } catch (ClasεNotFoundException e) {
160 // wasn't found on thiε syεtem Check the MobileCodebaεe
161 b\ te [ ] ytecodeε = i sMobi eCodebase getCode (name) ,
162
163 if (bytecodes '= null) (
164 Debug println (' condui t claεεload", 3, 'Clasε found in MoblleCodebaεe" ) , 165
166 // bytecodes for the claεε were found in the MobileCodebase
167 // Try tr- define a clasε from them
168 Claεε c - def meClass (HΛ t erodes , 0, bytecodes length)
169 if [resolve! (
170 ιe"ιlve( lar- ( - ) 171
172 // εtore this claεε in the cache
173 l tεPreviouεlyDef medClass°ε put (name, c),
174 )
175 return c
176 ) elεe {
177 Debug println ( "condui t clasεload', 3, "Looking in home codebase'),
178 return loadClasεFromHomeCodebaεe (name, resolve),
179
180 }
181 }
182
183
184 /**
185 * Loads a clasε using the remote claεε loader
186 * Θparam name Fully qualified name of the class to be loaded tie
187 * ava lang String
188 * Θparam reεolve boolean value indicating ΛPther or not the class
ConduitServerClassLoader. java_l Tue Nov 12 07:45:02 1996 5
189 * should be resolved via the ClassLoader . resolveClass method
190 */
191 protected Class loadClassFromHomeCodebase (String name, boolean resolve)
192 throws ClassNotFoundException {
193
194 Debug . pr int ln ( " condui t . class load " , 2 , " Condu itServerClassLoader . loadClassFromHomeCodebase called f *
" + name) ;
195 Debug .println (" condui t . classload" , 2, "resolve is " + resolve);
196
197 byte [ ] bytecodes = itsHomeCodebase . retrieveCode (name) ;
198
199 // bytecodes for the class were found in at remote location.
200 // store them in the MobileCodebase for future reference
201 itsMobileCodebase . storeCode (name, bytecodes); 202
203
204 // Try to define a class from them.
205 Class c = defineClass (bytecodes , 0, bytecodes . length) ;
206 if (resolve) {
207 resolveClass (c) ; 208
209 // store this class in the cache
210 itsPreviouslyDef inedClasses . put (name, c);
211 }
212 return c ;
213 }
214 }
ConduitServerlmpl. java_l Tue Nov 12 07:45:02 1996 1
1 /* {Header /com/meitca/hsl/zonesjagentε/conduit/ConduitServerlmpl java 23 11/11/96 5-15p Billp $
2 *
3 * Copyright 1996 Horizon Systems Laboratory,
4 * Mitsubishi Electric Information Technology Center America
5 * All rights reserved 6
7 * CONFIDENTIAL AMD PROPRIETARY PROPERTY OF MITSUBISHI ELECTPIC ITA
8 *
9 * DESCRIPTION
10 * Conduit Server implementation
11
12 * $Log /com eitca/hsl /z^neε jagentε/condui t /Condui tServerlmpl Java $
13
14 * 23 11/11/96 5 15p Billp
15 * Made correction to company name
16 *
17 * 22 10/30/96 2 52p Walεh
18 * Allow Debug and ErrorLog settings to be set m propertieε file
19 *
20 * 21 10/29/96 5-28p Walsn
21 * Use ErrorLog class to repoit errors 22
23 * 20 10/28/96 6 31p Walsh
24 * Add more debugg.ng info 25
26 * 19 10/25/96 5 02p Walsn
27 * Make AgentThread public Mcve to own source file
28 *
29 * 18 10/24/96 5 1 P Wal-n
30 * add some debugσinα information related to memory uracie 31
32 * 17 10/23/96 2 2?p Walsh
33 * add more Debug println ε 34
35 * 16 10/21/96 4 26p Walsn
36 * Add debug logging
37
38 * 15 10/11/96 2 2 Op Walεh
39 * remove reεtarted agents from perεiεtence εtore
40
41 * 14 10/10/96 6 02p Walεh
42 * Add persiεtence εucport 3 *
44 * 13 9/29/96 4 08p Walεh
45 * Allow Deεtination methods to be specified by name
46 * Give Agent access to AgentPackage information 47
ConduitServerlmpl. java_l Tue Nov 12 07 : 45 : 02 1996 2
48 * 12 9/09/96 6 : 02p Walεh
49 * make conεtant final
50
51 * 11 9/04/96 12:32p Walsh
52 * Centralize manipultation of Condui erver ' s RMI URL.
53 * Move test εecurity mnnayer out of this file.
54
55 * 10 8/30/96 3 : 3p Walεh
56 * null out itsPackage (in AgentThrea . run ) to try to nudge the garbage
57 * collector 58
59 * 9 8/23/96 3 : 58p Walεh
60 * Add support for ad-hoc method invocation 61
62 * 8 8/22/96 6:36p Walεh
63 * Add static reference to the one Condui Server that exists. 64
65 * 7 8/22/96 5:45p Walεh
66 * Move the custom marshalling of the agent into the AgentPackage claεε 67
68 * 6 8/19/96 5:26p Walsh
69 * Add support for remote class loading 70
71 * 5 8/13/96 5 : 12p Walεh
72 * Changed signature of receivePackage . Changed marshalling,
73 * un-marεhall ing code to arhεal only Agent and not entire AgentPackage 74
75 * 4 8/13/96 10:35a Walεh
76 * Add εome comments and documentation
77 *
78 * 3 8/12/96 7 : 16p Walεh
79 * ConduitServer now performs Marshalling
80
81 * 2 8/09/96 4:38p Walεh
82 * Setting up file headers
83 */
84 package com. meitc . hsl . zoneε jagents . condui t ;
85
86 import java . rmi . server .UnicastRemoteServer ;
87 import java . rmi . RemoteExcept ion ;
88 import java . rmi .Namin ;
89 import java . rmi .NotBoundException;
90 import java.net.*;
91 import java.io.*;
92 import java. util.*; 93
94 import co .mei tea . hεl . zones agents . shared .* ;
ConduitServerlmpl. java_l Tue Nov 12 07:45:02 1996 3
95 import com meitca hsl util *,
96 import com meitca hεl zonesjaαentε εecurity InsecurityManager, 97
98 /**
99 * An RMI diεtribtted object which provides for Agent travel and execution
100 * ConduitServerlmpl implements th<= ConduitServer mterfa r> ConduitServer
101 * is an RMI distributed interface ConduitServerlmpl is responεible for
102 * receiving incoming agents, providing for execution of aqents, and for
103 * transmitting agents to other d°εt natιonε
104 * @see Agent
105 * @εee ConduitServer
106 * øauthor Thomas Walεh
107 */
108 public class Condui tServei Impl
109 extends UnicaεtRemoteServer
110 implements ConduitServer { 111
112 /**
113 * The conduit server _s a Sentinel object There hill only be one of
114 * them running within a given Java vertual machine The εtatic member
115 * theServer is a pointer to that one Condui Serverlmpl object
116 */
117 εtatic Condui tServerInol theServer,
118
119 /** The conduit servers name */
120 String itsName, 121
122 /** The conduit server proterties fil */
123 JASPropert ies i ts Proper t ies , 124
125 /** An object representing the εerverε perεiεtence store */
126 Condui tServerPersiεtenceStore l tεPer=" lεtenceStore 127
128 /** String constants */
129 /**The name to which a conduit server is bound in the RMI Registry */
130 static final String RMI_NAME = "ConduitServer",
131 static final String PROP_DEΞC= 'Properties File for Conduit Server", 132 133
134 I *
135 * The following member variables store some statistical information
136 * about the performan e of the Conduit Server
137 */
138 /** The date and time when this Conduit Server waε εtarted */
139 Date l tsStartTime ; 140
141 /** The number of Aqents currently in the εytem V
ConduitServerlmpl . j ava_l Tue Nov 12 07 : 45 : 02 1996 4 42 lonq i tεCurrentAgen tCount ,
143
144 /**
145 * The total number of Agents to travel through the system
146 * since startup
147 */
148 long itsTotalAgentCount ,
149
150 /**
151 * The largest number of Agent to be in tho εystem at any one time
152 */
153 long itsPeakAgentCount ;
154 155 156
157 /**
158 * Constructs a conduit server
159 * Oparam name The servers name
160 * Oexcppticn F°r^tDException If an error occurs setting up network
161 * communicat ions
162 */
163 public ConduitServerlmpl (String name) throwε RemoteException {
164 ltεName = new String (name)
165 theServer = thiε,
166
167 // intialize the counterε
168 ItsTotalAgentCount = 0,
169 l tεCurrentAgentCount = 0,
170 itsPeakAαentCount = 0 71
17? try {
173 itsProperties = new JASProperties (RMI_NAME,
174 JASPropertieε SER 175 PROP_DESC,
176 falεe) ,
183 // Construct an empty Properties object
184 itsProper ies = new JASProperties () ,
185 }
186
187 // Set up the debug and error logging facilities usinq the
188 // Conduit ^IVPΓ specific properties
ConduitServerlmpl. java_l Tue Nov 12 07:45:02 1996 5
189 Debug . enable ( itsProperties ) ;
190 ErrorLog . initialize ( itsProperties) ; 191
192 itsPersistenceStore = new ConduitServerPersistenceStore ( ) ;
193 } 194 195
196 /**
197 * Send the Agent on to the next conduit server in its Itinerary.
198 * Θparam agentPackage The Agent Package containing the Agent.
199 * ^exception NoSuchElementException If the agent has completed its
200 * Itinerary.
201 * øexception RemoteException If an error occurs communicating with
202 * the next server.
203 * Sexception NotBoundException If the server name indicated as the
204 * next destination in the Itinerary cannot be found on the
205 * network.
206 */
207 public static void sendPackage (AgentPackage agentPackage)
208 throws NoSuchElementException, IOException,
209 RemoteException, NotBoundException{
210
211 // retrieve a remote reference to the next destination
212 ConduitServer nextConduit = (ConduitServer ) Naming . lookup (
213 buildRmiURL (agentPackage .getltinerary ( ) . nextDestination ( ) . getDestinationHost
) ) )
214
215 agentPackage .prepareForTransport ( ) ;
216
217 // pass the agent along
218 nextConduit . receivePackage (agentPackage) ;
219 } 220
221
222 /**
223 * Receive an Agent from the previous conduit server in its Itinerary.
224 * @param agentData A stream of bytes containing the serialized
225 * agent .
226 * dparam codebase The agents MobileCodebase
227 * Spararn itinerary The agents Itinerary
228 * ^exception RemoteException If an error occurs communicating with
229 * the prior server.
230 */
231 public void receivePackage (AgentPackage agentPackage)
232 throws RemoteException {
233 Debug. println( "conduit" , 2, "ConduitServerlmpl . receivePackage called");
234 agentPackage. restoreFromTransportFormO ;
ConduitServerlmpl. ava_l Tue Nov 12 07:45:02 1996 6
235 Debug println ( "condui t " , 1, "Agent " + agentPackage getAgent ( ) getAgentlDO +" has arrived");
236
237 lr crementAgentCounters ( )
238
239 AgentThread neωThread = new AgentThread (agentPackage) ,
240 } 241
242 static public void restartAgent (AgentPackage agentPackage) {
243 Debug println (' condui t " , 1, "Restarting Agent ' + agentPackage getAgent() getAgentlDO), 244
245 lπcrementAgentCounters ( )
246
247 try {
248 if (agentPackage getltinerary ( ) getCurrentLocation ( ) hasCompleted () ) {
249 Debug println ( "conduit " , 1, "\tAgent had completed execution on this Conduit Servei
250 Debug println (' conduit " , 1, Agent to next Destination"), 251
252 decrementAgentCounters ( ) ,
253 sendPackage (agentPackage) , 254
255 // remove the agent from the persistence store
256 getPersistenceStore ( ) removeFromStore (agentPackage) ,
257 } elεe {
258 Debug println! ' conduit" , 1, "\tAgent had not completed execution on this Conduit Se er") ,
259 Debug pr intin (" condui t " , 1, ' \ tRestarting execution"),
260 AgentThread newThread = new AgentThread (agentPackage) ,
261 }
262 } catch (Exception e) {
263 ErrorLog println (' conduit ConduitServerlmpl",
264 ErrorLog SEVERITY_ERROR,
265 "An error occurred while restarting agent ",
266 e) ,
267 } 268
269 }
272 * REtrieves a property from the Conduit Server
273 * βparam key The name of the propery to retrieve
274 * @param def A default value which will be returned if
275 * the property cannot be found
276 * Oreturn the propery value (a string)
277 */
278 public static String getProperty (String key. String def) {
279 return theServer itsProperties getProperty (key, def),
ConduitServerlmpl. java_l Tue Nov 12 07:45:02 1996 7
280 }
281
282 /**
283 * Returns the conduit εerverε name
284 * Sexception RemσteE> ception If any network error occurs
288 } 289 290
291 /**
292 * This method is used internally to build a full RMI URL for a conduit
293 * server on the given host
294 */
295 protected static String buildRmiURL (String hostname) {
296 return new StnngC'rmi //' + hostname + /' + RMI_NAME) ,
297 }
300 /**
301 * Returns a refernece to the conduit εerverε persistence store
302 */
303 public static ConduitServerPersiεtenceStore getPersiεtenceStore ( ) {
304 return theServer itsPersistenceStore,
305 ) 306
307 /**
308 * Returns the ^ta' up tune I tins conduit servei
309 */
310 public static Date getStartupTime ( ) {
311 return theServer ltεStartTime
312 } 313
314 /**
315 * Returns the uptime of this conduit server (in milliseconds)
316 */
317 public static long getUpTimeO {
318 return (System currentTimeMilliε ( ) - theServer ltsStartTime getTimeO),
319 }
322 * Returns the total number of agents to pass through this
323 * Conduit Server since it was started
324 */
325 public static long getTotalAgentCount ( ) {
326 return theServer i sTotalAgentCount
ConduitServerlmpl. java_l Tue Nov 12 07:45:02 1996
327 ) 328
329 / * *
330 * Returns the number of agents currently executing
331 * in this Conduit Serv°r
332 */
333 public static long getCurrentAgentCount ( ) {
334 return theServer i sCurrentAgentCount
335 } 336
337 /**
338 * Returns the maximum number of agents to be executing
339 * at any ore time in tiiε Conduit Server
340 */
341 public static long getPeakAgentCount ( ) {
342 return theServer itsPeaKAgentCount ,
343 } 344
345
346 /**
347 *
348 */
349 public static synchronized void incrementAgentCounters ( ) {
350 if (theServer '= null) {
351 theServsr ιtsTotalAgentCount++ ,
352 theServer ιtεCurrentAgentCount++
353 if (theServer ltsCurrentAgentCount > theServer itsPeakAgentCount)
354 theServer l tεPeakAgentCount = theServer ltsCurrentAgentCount,
355 }
356 } 357
358 /**
359
360 */
368 * Performs εerver εtartup taskε
369 */
370 void εtartupO (
371 ltsPersistenceStore reεtorePerεiεtedObjects ( ) ,
372
373 // Monitor memory if conduit memory facility is εet to
ConduitServerlmpl. java_l Tue Nov 12 07:45:02 1996 9
374 // debug level 4
375 if (Debug enabled ( "conduit memory watch", 4)) { 76 MemoryWatch watch = new MemoryWatch ( ) ,
377 )
378
379 ltεStartTime = new Dated,
380 ) 381
382 /**
383 * A simple bootεtrap rfnich brings the conduit server into existence,
384 * registers it name with the RMI naming service and begins listening
385 * for Agent requeεtε The main routine allows ConduitServerlmpl to
386 * be intiated from the command line via the java command
387 */
388 public static void main (String args [ ] ) {
389 // Create and install the security manager
390 //System εetSecurityManager (new StubSecurityManager))),
391 System setSecur i tyManager (new InsecurityManager!) )
392
393 try {
394 // construct the εerver and register it with the RMI Naming service
395 Debug print In ( "-ondui " , 1, "Create an Conduit Server");
396 String rl = bui ldRmiURL ( InetAddress getLocalHos ( ) ge HostName ( ) ) , 397
398 Condui tServerlmol server = new Condui tServerlmpl (url ) , 399
400 Debug println (' conduit " , 1, "Bind it to name " + RMI_NAME) ,
401 Kamnq rebmd (RMI_NAMF server) 402
403 server tartupO
404 Debug print In (' condui t , 1, "Conduit Server ready )
405 ) catch (Exception e) {
406 ErrorLog print In (' condui t mam", ErrorLog SEVERITY_FATAL,
407 'an exception occurred during startup-", e) ,
408 )
409 }
410 }
ConduitServerPersistenceStore.java_l Tue Nov 12 07:45:02 1996 1
1 /* $Header: /com/meitca/hsl/zonesjagents/conduit/ConduitServerPersistenceStore . java 6 11/11/96 5:15p Billp $
2 *
3 * Copyright 1996 Horizon Systems Laboratory,
4 * Mitsubishi Electric Information Technology Center America.
5 * All rights reserved.
6
7 * CONFIDENTIAL AND PROPRIETARY PROPERTY OF MITSUBISHI ELECTRIC ITA.
8 *
9 * DESCRIPTION
10 * Conduit Server persistence Store
11 *
12 * $Log: /com/mei tca/hsl /zonesjagents/condui t/ConduitServerPersistenceStore . java $ 13
14 * 6 11/11/96 5:15p Billp
15 * Made correction to company name. 16
17 * 5 10/29/96 5:29p Walsh
18 * Use ErrorLog class to report errors
19 *
20 * 4 10/21/96 4:26p Walsh
21 * Add debug logging
22 *
23 * 3 10/21/96 11:38a Walsh
24 * mirror change in Persistence API 25
26 * 2 10/18/96 10:58a Walsh
27 * synch with change to findObject API 28
29 * 1 10/10/96 6:01p Walsh
30 * initial version 31
32 */
33 package com. meitca .hsl . zonesjagents . condui t ; 34
35 import java . io . File ;
36 import java.util.*,- 37
44 * @see ConduitServerlmpl
45 * βauthor Thomas Walsh
46 */
47 class ConduitServerPersistenceStore {
ConduitServerPersistenceStore. java_l Tue Nov 12 07:45:02 1996
48 // String constants representing the propery names of
49 // two properties of interest
50 private static final String ENABLE_PERSISTENCE = " condui t . persistence . Enable " ;
51 private static final String PERSISTENCE_FILE = "conduit . persistence . FileName" ;
52 private static final String DEFAULT_FILENAME = "persist . store" ;
53
54 /** The PersistentStoreManager object used to manager the persistence store */
55 Persisten StoreManager itsStore;
56
57
58 * Constructs the PersistenceStore . Persistence will be enabled only
59 * if the conduit . persistence . Enable Property is set to "true". The
60 * PersistenceStore will be stored in the file named in the
61 * conduit .persistence . FileName property. If this Property is not set,
62 * the store will be placed in the file " zones . home/Agent/persist . store"
63 * only
64 */
65 ConduitServerPersistenceStore ( ) {
66 if (new Boolean (ConduitServerlmpl . getProperty (ENABLE_PERSISTENCE, " false ")) . booleanValue () ) {
67 Debug .println ( "conduit .persistence" , 1, "Persistence enabled.");
68
69 String filename = ConduitServerlmpl . getProperty (PERSISTENCE_FILE, " " ) ;
70 Debug . rintln ( "conduit .persistence" , 3, " condui . persistence . FileName property set to " + f ename) ;
71
72 if (filename. length () == 0) {
73 filename = AgentConstants .AGENT_DIR + DEFAULT_FILENAME;
74 }
75
76 try {
77 // construct the PersistentStoreManager
78 Debug . println ( "conduit .persistence" , 2, "Persistence filename is " + filename);
79 itsStore = new PersistentStoreManager ( filename) ;
80 } catch (PersistentStoreException e) {
81 ErrorLog. print In ( "conduit .Persistence" , ErrorLog . SEVERITY_ERROR,
82 "An error occurred constructing the persiste ce store e) ;
83 ErrorLog .println ( "conduit .Persistence" , ErrorLog . SEVERITY_WARNI G,
84 "Continuing without persistence.");
85
86 // null out the itsStore reference. We will continue
87 // executing with persistence disabled
88 itsStore null;
89
90
91 } else {
92 // null out the itsStore reference. This will
ConduitServerPersistenceStore. java_l Tue Nov 12 07:45:02 1996
93 // disable persistence
94 itsStore = null;
95 } 96
97 }
98
99 /**
100 * Adds an AgentPackage to the persistence store.
101 * Θparam aPackage The package to add.
102 */
103 void addToStore (AgentPackage aPackage) {
104 if (itsStore != null) {
105 if (aPackage. getOIDO == 0) {
106 Debug .println ( "conduit .persistence" , 3, "Adding agent to persistence store: " + aPc. age) ;
107
108 try {
109 int oid = itsStore . insertObject (aPackage) ;
110 Debug .println ( "conduit .persistence" , 4, "Agent's oid is: ". + oid);
111 aPackage. setOID(oid) ;
112 } catch (PersistentStoreDuplicateObjectException el) {
113 try {
114 Debug . println ( "conduit .persistence " , 4, "Agent already in store try g update" )
115 int oid = itsStore . findObject (aPackage') ;
116
117 if (oid != PersistentStoreManager . INVALID_OID) {
118 Debug .println ( "conduit .persistence" , 4, "Agent found in sto oid : + oid) ;
119 itsStore .updateObject (oid, aPackage) ;
120 aPackage . setOID (oid) ;
121 } else {
122 ErrorLog .println ( "conduit .Persistence" , ErrorLog . SEVERITY_E
OR,
123 "An error occurred adding agent " + aPackag getAgent ( ) .getAgentID( ) +
124 " to the persistence store.");
125
126 ErrorLog .println ( "conduit . Persistence" , ErrorLog . SEVERITY_E OR,
127 "PersistentStoreManager . findObject returned ull even though " +
128 "PersistentStoreManager . insertObject threw
129 "PersistentStoreDuplicateObjectException . " )
130
131 ErrorLog. rintIn ( "conduit . Persistence" , ErrorLog . SEVERITY_W
ConduitServerPersistenceStore. java l Tue Nov 12 07:45:02 1996
NING,
132 'Continuing without persistence "),
133
134 // null out the itsStore reference We will continue
135 // executing with persistence disabled
136 itsStore = null ,
137 }
138 } catch (PersistentStoreException e2) {
139 ErrorLog println (' conduit Persistence", ErrorLog SEVERITY_ERROR,
140 "An error occurred adding agent " + aPackage getAgentO getAgentlDO +
141 1 to the persistence store ", e2),
142
143 ErrorLog println (' condui t Persistence" ErrorLog SEVERITY_WAR ING,
144 "Continuing without persistence "),
145
146 // null out the itsStore reference We will continue
147 // executing with persistence disabled
148 itsStore = null,
149 }
150 catch (PersistentStoreException e3) {
151 ErrorLog pr intin (' condui t Persistence'1, ErrorLog SEVERITY_ERROR,
152 'An error occurred adding agent " + aPackage getAgent
() getAgentlDO
153 to the persistence store ' , e3 )
154
155 ErrorLog println (' conduit Persistence", ErrorLog SEVERITY_WARNING,
156 Continuing without persistence "), 157
158 // null out the itsStore reference We will continue
159 // executing with persistence disabled
160 itsStore = null,
161
162 }
163 }
164 }
165 166
167 * Updates an AgentPackage in the persistence store
168 * Θparam aPackage The package to add
169 */
170 void updateStore (AgentPackage aPackage ) (
171 if ( itsStore ' = nul l ) {
172 Debug println ( "conduit persistence", 3, "Updating agent in persistence store " + aPackage),
173 Debug pVmtln ( "conduit persistence", 3, "Agent's old is " + aPackage getOIDO), 174
175 try {
ConduitServerPersistenceStore. java_l Tue Nov 12 07:45:02 1996
176 itsStore updateObject (aPackage getOIDO, aPackage),
177 } catch (PersistentStoreException e2) {
178 ErrorLog println ( "conduit Persistence", ErrorLog SEVERITY_ERROR,
179 "An error occurred updating agent " + aPackage getAgent() g
AgentID () +
180 " in the persistence store ", e2 ) ,
181
182 '-"rrorLog println ( "condui t Persistence', ErrorLog SEVERITY_WARNING,
183 "Continuing without persistence "),
184
185 // null out the itsStore reference We will continue
186 // executing with persistence disabled
187 itsStore = null,
188
189
190
191 }
192
193 /**
194 * Removes an AgentPackage to the persistence store
195 * Θparam aPackage The package to remove
196 */
197 void removeFromStore (Ager tPackage aPackage) {
198 if (itsStore '= null) {
199 Debug print In (' condui t persistence", 3, 'Removing agent from persistence store " + aPackag
200 Debug println ( conduit persistence", 3, 'Agent's oid is " + aPackage getOIDO),
201
202 try {
203 itsStore deleteObject (aPackage getOIDO),
204 } catch (PersistentStoreException e) {
205 ErrorLog println ( "conduit Persistence", ErrorLog SEVERITY_ERROR,
206 "An error occurred removing agent " + aPackage getAgent () g
AgertlDO +
207 ' from the persistence store ' , e) ,
208
209 ErrorLog println ( "conduit Persistence", ErrorLog SEVERITY_WARNI G,
210 'Continuing without persistence "),
211
212 I I null out the itsStore reference We will continue
213 // executing with persistence disabled
214 itsStore = null,
215
216
217 }
218
219
ConduitServerPersistenceStore. j va_l Tue Nov 12 07:45:02 1996 6
220 * Restores ail Agents m the Persistence Store and
221 * passes them into the ConduitServerlmpl restartAgent method
222 * so that they are restarted
223 */
224 void restorePersistedObj ects () {
225 if (itsStore '= null) {
226 Debug println (' conduit persistence", 3, "Restoring all persisted Agents"), 227 228 Enumeration enum = itsStore getOIDs ( ) ,
229
230 while (enum hasMoreElements ( ) ) {
231 Ob ectID objectID = (ObjectID) enum nextElement () ,
232 int oid = objectID getOIDO, 233
234 Debug println ( "conduit persistence", 4, 'Restoring Agent Old is " + oid);
235
236 if (oid '= 0) {
237 try {
238 AgentPackage aPackage = (AgentPackage) itsStore fetchObject (oid) ;
239 Debug println ( "conduit persistence", 4, "Agent Package is " + aPac age) ,
240 aPackage setOID(oιd) ,
241 ConduitServerlmpl restartAgent (aPackage) ,
242 } catch (PersistentStoreException e) {
243 ErrorLog println ( "conduit Persistence", ErrorLog SEVERITY_ERROR,
244 "An error occurred restoring persisted Agent ", e),
245
246 ErrorLog println (' condui t Persistence', ErrorLog SEVERITY_WARNING,
247 'Continuing without persistence "), 248
249 // null out the itsStore reference We continue
250 // executing with persistence disabled
251 itsStore = null,
252 }
253 } 254
255 }
256 }
257 }
258 }
Destination. java_l Tue Nov 12 07:45:03 1996 1
1 /* $Header /com/meitca/hεl/zoiesjagents/conduit/Destination ava 7 11/11/96 5 15p Billp $
2 *
3 * Copyright 1996 Horizon Systems Laboratory,
4 * Mitsubishi Electric Information Technology Center America
5 * All rights reserved
6 *
7 * CONFIDENTIAL ANE =R0P^1ETAPV PROPERTY OP MITSUBISHI ELECTRIC ITA
8
9 * DESCRIPTION
10 * An agents destination Contains RMI UPL of conduit server and
11 * method id of method to irvo e at that location
12 *
13 * $Log /com/ite^tca /h= i/zonesjagentε/conduit/Deεtmation java $ 14
15 * 7 11/11/96 5 15p Billp
16 * Made correction to company rame 17
18 * 6 10/10/96 6 02p Walεh
19 * Add persistence εuoport 20
21 * 5 9/30/96 "" CSp Walεh
22 * clean up javadoc co mεntε
23 *
24 * 4 9/29/96 4 C3p Walεh
25 * Allow Destmatior methods to oe εpecifieα by name informatio
28 * 3 9/04/96 II 31p Walsh
29 * Destination now holds orlv n hostname of the ConduitServer not the
30 * entire RMI URL 31
32 * 2 8/29/96 5 16p Jalεh
33 * add default cons'ructor and εet* methods 34
35 * 1 8/23/96 3 50p Walsh
36 * Initial versions
37 */
38 package com meitca hs1 zonesjag≤ntε conduit
39
40 import com meitca hεl zonesjagents conduit InvalidMetbodNameExcept ion
41
42 /**
43 * An object representing a Destination in an Agents Itinerary The
44 * Destination is ccmposed of tΛic partε <br>
45 * <ol>
46 * <iι>the nostname of the conduit server in which to travel
47 * <lι> An .dentifer indicating the method of the agent to call
Destination. java_l Tue Nov 12 07:45:03 1996 2
48 * at that ConduitServer This identifier can either be an
49 * number representing a (zero based) ID of the method or the
50 * name of the method in the form of a String
51 * </ol>
52 * @see Agent
53 * @see ConduitServer
54 * Θsee Itinerary
55 * Θauthor Thomas Walsh
56 */
57 public class Destination implemsrts Cloneable {
58 εtatic final int UINKNOWNJ_METHOD_ID = -1, 59
60 /** The hostname of the Conduit Server in which to travel */
61 String itεr-ostName , 62
63 /** The method ID number of the method to invoke */
64 int itsMethodID, 65
66 /** The name of the metiod to invoke */
67 String itsKethodName ,
68
69 /**
70 * A boolean indicating wether execution at this destination
71 * has completed
72 */
73 boolean itεFaεCompleted, 74
75 /**
76 * Constructs a Destination object
77 * @param hostname The hostname of the conduit server in which to
78 * travel
79 * βparam methodNa e The name of tne method to invoke
80 */
81 public Destmatior (String hostname, String methodName) {
82 lts ostName = hostname,
83 ItsMethodID =
84 itεMethodNaire = methodName;
85 it shasCompleted = false;
86 } 87
90 * Constructs a Destination object This constructor is uεed
91 * internally to constrict a Destination
92 * @param hostname The hostname of the conduit εerver in which to
93 * travel
94 * dparam method The method ID number of the method to invoke
Destination. j ava_l Tue Nov 12 07:45:03 1996 3
95 */
96 public Destination (Stri i hostname, int method) { I itsKoεtName = hostname;
98 itsMethodID = mathod;
99 itsMethodName = null;
100 itsKasCompleted = falεe;
101 } 102
103 /**
104 * Construct" an »mpty ",°εtmatιon object
105 */
106 public Destination ( ) {
107 itεhostName = new String!"");
108 itsMethodID = UNKNOWN_METHOD_ID; 109 itsKethodName = null,
110 itsKasCompleted = false,
111 } 112
113 /**
114 * Retrieve? the hof.i? <=■ of the conduit server in which to travel
115 */
116 public String getDeεtmationHcεt ( ) { 111 return itsHostName;
118 }
119
120 /**
121 * Retπeveε the method ID number of the method to invoke
122 */
123 public int getMethodID ( ) {
124 return itεrethc≤ID,
125 } 126
127 /**
128 * Setε the U^L of th= -onduit server in which to travel
129 */
130 public void εetDest nationKos (String hostname) {
131 itεhostName = hostname,
132 } 133
134 /**
135 * Sets the method ID nimber of the method to invoke
140 } 141
Destination. java_l Tue Nov 12 07:45:03 1996 4
142 /**
143 * Retπeveε the raet-.o name of the method to invoke
144 */
145 public String getMetnod ame ( ) {
146 return itsMethodName,
147 } 148
149 /**
150 * Makes a clone of the Destination object
151 */
152 public Destination clor sDestination ( ) {
153 Destination cone = neiv Destination ( )
154 clore ltsHcεtNa e = ltsHoεtName
155 clone ltsMetno≤ID = itsMethodID ,
156 clore itsMetnodName = itsMethodName,
157 re u n clc-e
158 } 159
160 /**
161 * Se*-s the internal state of the Destination to
162 * incicate that execution has been completed
163 * /
164 void εetCompletedO {
165 itsKasCompleted = true,
166 } 167
168 /**
169 * Checks the internal ^tate of the Destination to
170 * see if execut.c neε been completed
171 */
172 boolean hasCompleted ( ) {
173 return ltεtπaεComDleted
174 } 175
176 /** Uεed internally to convert a method name into a method id */
177 protected void COΓN ertNameToId (AgentSkeleton εkel)
178 throws InvalidMethodNameException {
179
180 if (itεMethodName == null) {
181 throw new InvalidMethodNameException ( "No name εpecified for destination"),
182 } 183
184 String [ ] methoαε = ske l getMethods ( ) ,
185 f or ( int 1=0 , Kmethods length ; 1++ ) {
186 if (itsMethodName equalε (methodε [ 1 ]) ) {
187 ItsMethodID = 1,
188 ltsbethodName = null
Destination. va_l Tue Nov 12 07:45:03 1996 5
189 return;
190 }
191 }
192 throw new InvalidMethodNameException ( "Method name " + itsMethodName + "does not match any methods o agent") ;
193 }
194 }
InvalidMethodNameException. java_l Tue Nov 12 07:45:03 1996 1
1 /* SHeader: /ccm/meitca/h= 1/zonesjagents/conduit/InvalidMethodNameException . java 3 11/11/96 5;15p Billp S
2 *
3 * Copyright 1996 Horizon Systems Laboratory,
4 * Mitsubishi Electric Information Technology Center America.
5 * All rights reserved. 6
7 * CONFIDENTIAL AND PROPRIETARY PROPERTY OF MITSUBISHI ELECTRIC ITA.
8 *
9 * DESCRIPTION
10 * Exception indicating that Method Name speicifed in a Destination
11 * is not a valid name 12
13 * $Log : /com/meitca/hsl/zonesjagents/conduit/Invalid ethodNameException . java $ 14
15 * 3 11/11/96 5:15p Billp
16 * Made correction to company name.
17 *
18 * 2 9/30/96 7:06p Walεh
19 * clean up javadoc comments
20 *
21 * 1 9/29/96 4:C7p Walsh
22 * initial version
23 *
24 */
25 package com. meitca .hsl . zonesjagents . conduit ;
26
27 /**
28 * An exception which indicates that the method name that was specified
29 * in a Destination was not the name of a method of the agent which
30 * is travelling.
31 * @see Agent
32 * @see AgentSkeleton
33 * @author Thomas Walsh
34 */
35 public class InvalidMethodNameException extends Exception {
36 public InvalidMethodNameException ( ) {
37 super () ;
38 }
39
40 public InvalidMethodNameException (String s) {
41 super (s) ;
42 }
43 }
Itinerary. j va_l Tue Nov 12 07:45:03 1996 1
1 /* $Header /com/meitca/hsl/ronesjagents/conduit/Itinerary java 5 11/11/96 5 15p Billp $
2 *
3 * Copyright 1996 Horizon Systems Laboratory
4 * Mitsubishi Electric Information Technology Center America
5 * All rights reserved
6 *
7 * CONFIDENTIAL AND OR0PFT-riRY PROPERTY CF MITSUBISHI ELECTRIC ITA 8 9 * DESCRIPTION
10 * Agent itinerary object
11 *
12 * $Log /com/mextca =-ι zones jagents/conduit/Itmerary java $
13 *
14 * 5 11/11/96 5 15D Billo
15 * Made correction to co oa" name
16 *
17 * 4 9/29/96 4 08o walsh
18 * Allow Destination et^oαε to be soecified by name
19 * Give Agent access to Λc-~_Dackage information
20 *
21 * 3 8/23/96 3 58p Walεh
22 * Add εupoort for ad c τ^-^od invocation
23 *
24 * 2 8/09/96 4 38p Wal=h
25 * Setting UD file ^=>ad-<-s
26 */
27 package com meitca hsl 28
29 import ava util * 30
31 /**
32 * An object representing ar Agent s Itinerary The Itinerary
33 * indicated WHERE an agent srould travel and indicated Ϊ'HAT
34 * the Agent should do at eacn stoo
35 * @see Agent
36 * @see ConcuitServer
37 * @see Destination 38 * Sauthor Thomas Walεh
39 */
40 public clasε Itinerary {
41 Vector ltεDestinations 42 int ltεCurrentStop
4 434 /**
45 * Construc t " an I t ] lerary obj ec t 46 * /
47 publ i c I t inerary ) )
Itinerary. java_l Tue Nov 12 07:45:03 1996 2
48 ltsDest at ons = new Vector ()
49 ltsCurrent top = -1
50 }
51
52 /**
53 * Adds a nsi dest.ration to the end of the Agents Itinerary
54 * (?param deεt.-ation The new dest-nat on
55 */
56 oublic void addCestmatior (Destination destination) {
57 .tεOestmatio^s aααEIe-^ent (aestivation )
58 i 59
60 /»*
61 * Clears all dest^nat.o-'S from the Agentε Itinerar
62 -/
63 oublic void c.earl _~erary ( ) {
64 i tεDeε ti^-t.cs removeAHΞleme" tε ( )
65 }
66
67 r
68 * Reεetε the Iti-erary back to tne mit.al Destination
69 * This method cc ld ce uεed to force an Age~t to restart
70 * ltε Itinerary c re^_s_t ail Destinations
71 '
72 public void () {
73 tεCurrentS-oo = -"
74 } 75 76 77
78 * Retrieves tne ceεt_-a~_o-' oojett .de^t^t i^ t-= current
79 * location r the - e--
30 * Θreturns T e Agent ε current locat_c-
31 * Sexcect." NcSuc-rlementExcection If the Age-- aε not 82 * travelled S3 */
84 public Destin tion ge^C-rrentLocat.on ( ) throws NoS^chΞlementExceotion {
85 try {
86 return (Deεtmati-- ) itεDeεtinationε element t ( itsCurrentStop)
87 } catch (ArraylndexOutOfBoundsException boundError) { thrc new NoSuchElementEvcep ion ( )
89 }
90 }
91
92 /**
93 * Retrieves the αest.nation object identifying the current
94 * location of the r-σe-t
Itinerary. java_l Tue Nov 12 07:45:03 1996 3
95 * Θreturns The Agent's next destination
96 * @exception NoSuchElementException If the Agent has not
97 * travelled
98 */
99 publ ic Dest i nation getNextDes t mat ion ( ) throws NoSuchElementException {
100 try {
101 return (Des tira ion) ltsDeε tinations elementAt ( l tsCurrentStop+1 ) ,
102 } catch (ArraylndexOutOfBoundsException boundError) {
103 throw new NoSuchElementException ( )
104 )
105 } 106
107 /**
108 * Retπeveε a" enum ration of all of the Destinations ir the
109 * Itinerary
110 * Θreturns An enumeration of all of the Destinations in the
111 * Itinerary
112 */
113 public Enumeration destinations!) {
114 return i tsDestmationε elements (),
115 }
116
117 /**
118 * Makes a clone of the Itinerary If the reset parameter is true
119 * then the new Itinerary is reset to the first destination If
120 * reset is false, t en the new itinerary is set such that its next
121 * destination is tne same aε that of the original
122 * dpararn reset true if the new itinerary srould be reεet to
123 * the first destination
124 * (?returns -v cion= of the oπgi-al Itinerary
125 */
126 puolic Itinerary clo^el tmerary (boolean reset) {
127 Itinerary clone = new Itinerary)) , 128
129 Enumeration enum = itsDeε tinations elements!),
130 while (enum nasMoreEle ents ( ) ) {
131 Destination original = (Destination) enum nextElement ( ) ;
132 Destination cloneDest = (Destination) original cloneDestination ( ) ,
133 clone addDest mat ion (cloneDeεt )
134 }
135
136 if ('reset)
137 clone I tsCurrentStop = l tsCurrent top
138
139 return clone
140 } 141
Itinerary. java_l Tue Nov 12 07:45:03 1996 4
142 /**
143 * Retrieves the next destination to which an Agent should
144 * travel ard increments the Itineraries internal state to
145 * the next destination Thiε method is called internally
146 * by the ConduitServer when it is preparing to transport
147 * the Agent to its next destination
148 */
149 protected Destination nextDes tmation ( ) throws NoSuchElementException {
150 try {
151 return (Destinat on) ltsDestmations elementAt ( ++ ltεCurrentStop) , 152
153 } catch (Ar ylndexOutOfBoundsException boundError) {
154 throw new NoSucnElementException ( ) ;
155 }
156 }
157 }
MemoryWatch. ava_l Tuβ Nov 12 07:45:03 1996 1
1 /* $Header /com/mei ca/hsl /zones jagentε/conduit/MemoryWatch ava 3 11/11/96 5 15p Billp $
2 *
3 * Copyright 1996 Horizon Systems Laboratory,
4 * Mitsubiεhi Electric Information Technology Center America
5 * All πghtε reεerved
6
7 * CONFIDENTIAL ANϋ PROPRIETARY PROPERTY OF MITSUBISHI ELECTRIC ITA
8
9 * DESCRIPTION
10 * Conduit Server implementation
11 *
12 * $Log /com/meιtca/hs_/zoneεjagentΞ/conduιt/MemoryWatch java $ 13
14 * 3 11/11/96 5 15p Billp
15 * Made correction to company name
16 *
17 * 2 10/28/96 6 31p Walsn
18 * Add more debugcirg info
19 *
23 */
24 package com meitca hsχ zoneεjagerts conduit, 25
26 import ava util * 27
28 import com meitca hsl util "* 29
30 /**
31 * The memory <ιatch class provides an minimum priority thread which
32 * reports the total amourt of memory allocated to the Java VM as
33 * well as the amount of tree memory currently available
34 *
35 * To enable the MemoryWatch the Conduit Server should be started
36 * up with the following switch passed into java exe
37 * -DDebug=" conduit memory watch=4 '
38 * Θauthor Thcrras alsn
3 "9 * '/
40 c lass MemoryWatch e den - Thread {
41
42 /** The nunoer of f-illiseconds between pollε of the VM */
43 εtatic int collmglnterval = 5000, // in millisec 44
45 /** Constructs a MemoryWatch object */
46 Memory atch ( ) {
47 Debug pr tln ( 'condui t memory watch 1 Memory Watch t read εtartmg )
MemoryWa ch . j ava_l Tue Nov 12 07:45:03 1996 2
48 setPriority (Thread.MIN_PRIORITY) ; 49 start () 50 } 51 52 /** Performs memory polling */ 53 public void run() { 54 while (true) { 55 Debug .println ( "conduit .memory .watch" , 4, " " ) ; 56 Debug .printlnf "conduit .memory. watch" , 4, "Server up since: " + ConduitServerlmpl . getStartu me ( ) ) ; 57 58 long uptime = ConduitServerlmpl .getUpTime () ; 59 Date up_date = new Date (uptime) ; 60 Date bigBang = new Date(0) ; 61 Debug .println ( "condui .memor .watch" , 4, "Server uptime: " + 62 (up_date .getYear ( ) - bigBang . getYear () ) + " years, " + 63 (up_date .getMonth ( ) - bigBang .getMonth () ) + " months, " + 64 (up_date .getDate ( ) - bigBang .getDate () ) + " days, " + 65 (up_date . getHours ( ) - bigBang . getHours () ) + " hours, " + 66 (up_date .getMinutes ( ) - bigBang .getMinutes () ) + " minutes,
67 (up_date . getSeconds ( ) - bigBang . getSeconds () ) + " seconds.
68
69 Debug . println ( "condui .memory .watch" , 4, "Total number of Agents : \ t\t\ " + ConduitServerlm getTotalAgentCount ( ) ) ;
70 Debug .println ( "condui t . memory .wa ch" , 4, "Current number of Agents :\t\t" + ConduitServerlm getCurrentAgentCount ( ) ) ;
71 Debug . println ( "condui t memory watch", 4, "Peak number of Agents : \ \ \ " + ConduitServerlmp etPeakAgentCount ( ) ) ;
72 Debug .println ( "condui .memory .watch" , 4, "Total memory allocated to system:\t" + Runtime. g untime ( ) . totalMemory ( ) ) ;
73 Debug .println ( "conduit .memory .watch" , 4, "Total free memory available : \t\t " + Runtime .getR ime ( ) . freeMemory( ) ) ;
74 Debug .println ( "condui .memory .watch" , 4, " " ) ;
75 try {
76 sleep (pollinglnterval ) ;
77 } catch (InterruptedException e) {
78 Debug .println ( "condui t .memor .watch" , 4, "Some thread interrupted the MemoryWatch ing sleep. Continuing");
79 }
80 }
81 } 82
83 }
MobileCodebase. java_l Tue Nov 12 07:45:03 1996 1
1 /* $Header.: /com/mei ca/hsl/zonesjagents/condui /MobileCodebase . Java 5 11/11/96 5:15p Billp $
2 *
3 * Copyright 1996 Horizon Systems Laboratory,
4 * Mitsubiεhi Electric Information Technology Center America.
5 * All rights reserved.
6
7 * CONFIDENTIAL AND PROPRIETARY PROPERTY OF MITSUBISHI ELECTRIC ITA.
9 * DESCRIPTION
10 * Agent Mobile codebase object
11 *
12 * $Log: /com/meitca/hsl/zonesjagents/conduit/MobileCodebase . Java $
13 *
14 * 5 11/11/96 5:15p Billp .
15 * Made correction to company name.
16 *
17 * 4 9/30/96 7:06p Walsh
18 * clean up javadoc comments
19 *
20 * 3 8/13/96 11:18a Walsh
21 * Add documentation & comments. Set up use of HashTable for bytecode
22 * storage.
23 *
24 * 2 8/09/96 4:38p Walsh
25 * Setting up file headerε
26 */
27 package com. meitca . hεl . zones jagents . condui t ; 28
29 import java . util . Hashtable ;
30
31
32 /**
33 * Contains the bytecodes for the objects that travel with an Agent.
34 * dsee Agent
35 * Sauthor Thomaε Walsh
36 */
37 public class MobileCodebase {
38 /**
39 * Provides for easy εtorage and retrieval of bytecodes. Bytecodes
40 * are stored in a Hashtable and are accessible by fully qualified
41 * Clasε name (ie " ava . lang . String" ) .
42 */
43 Hashtable i tsByteCodes ;
44
45 /**
46 * Constructs a MobileCodebase object
47 */
MobileCodebase . j ava_l Tue Nov 12 07 : 45 : 03 1996 2
48 public MobileCodebase!) {
49 itsByteCodes = new Hashtable ();
50 }
51
52 r
53 * Stores an objects bytecodes into the MobileCodebase
54 * βparam name The fully qualified Class name (le
55 * <b>"java lang Stπng"</b>)
56 * Θparam code The Class's bytecodeε
57 */
58 public void storeCode (String name, byte[] code) {
59 itεByteCodes put (name, code),
60 } 61
62 /**
63 * Retrieves an objects bytecodes from the MobileCodeoaεe
64 * Θparam name The fully qualified Claεs name (le
65 * <b>"java lang Stπng"</b>)
66 */
67 public byte [ ] getCode (String name) {
68 return (byte[J) itsByteCodeε get (name),
69 )
70 )
RemoteClassLoader. ava_l Tue Nov 12 07:45:14 1996 1
1 /* $Header: /com/mei tca/hsl /zonesjagents/remoteloader/RemoteClassLoader . Java 4 11/11/96 5:15p Bill
2
3 * Copyright 1996 Horizon Systems Laboratory,
4 * Mitsubishi Electric Information Technology Center America.
5 * All rights reserved. 6
7 * CONFIDENTIAL AND PROPRIETARY PROPERTY OF MITSUBISHI ELECTRIC ITA.
8 *
9 * DESCRIPTION
10 * Remote claεε loader distributed interface
11
12 * $Log : /com/mei tca/hs l / zones jagentε / remote loade /RemoteClassLoader . j ava $
13
14 * 4 11/11/96 5:15p Billp
15 * Made correction to company name
16 *
17 * 3 9/28/96 6:39p Walsh
18 * Add new parameter to ret r ieveClass method 19
20 * 2 8/27/96 4:10p Walsh
21 * retrieveClaεs throws ClassNotFoundException (compiler games)
22
23 * 1 8/19/96 5:28p Walsh
24 * Initial version
25 */
26 package com. meitca .hsl . zones agents . remoteloader ; 27
28 import java . rmi . Remote ;
29 import Java . rmi . Remo eExcep ion ; 30
31
32 /**
33 * RemoteClassLoader is an RMI diεtributed interface. It provideε a
34 * mechanism by which conduit servers can retrieve bytecodes for classes
35 * that exist on machines other than the one on which the conduit
36 * server iε loading.
37 * Θsee Condui Server
38 * Θauthor Thomas Walsh
39 */
40 public interface RemoteClasεLoader extends Remote {
41
42 /**
43 * Retrieve the bytecodes for the εpecified class.
44 * Θparam classURL An URL εpecifying the claεε to be loaded.
45 * This εhould be of the form /directory_path/classπame
46 * Θreturn The bytecodeε for the claεs.
47 * Sexception RemoteException If an error occurs communicating.
RemoteClassLoader. java_l TUΘ Nov 12 07:45:14 1996 2
48 */ 4 499 public byte[) retrieveClaεε (String codebaεeURL, String className) throws RemoteException,
5 500 ClassNotFoundException; 51 )
RemoteClassLoaderlmpl. java_l Tue Nov 12 07:45:14 1996 1
1 /* SHeader /com/mei tca/hs 1 / zones jagen ts/remoteloade /RemoteClassLoade Impl java 8 11/11/96 5 15p Billp $
2 *
3 * Copyright 1996 Horizor Systems Laboratory
4 * Mitsubishi Electric Information Technology Center America
5 * All rights reserved
6 *
7 * CONFIDENTIAL ΛIID PROPRIETARY PROPERTY OF MITSUBISHI ELECTRIC ITA 8
9 * DESCRIPTION
10 * Remote class loader implementation
11 *
12 * $Log /com/meitca/hsl/zonesjagents/remoteloader/RemoteClassLoaderlmpl java $ 13
14 * 8 11/11/96 5 15p Billp
15 * Made correction to company name
16 *
17 * 7 10/29/96 5 31p Walsh
18 * Use ErrorLog class to report errors 19
20 * 6 10/21/96 1 26p Walsh
21 * Add some debug output
22 *
23 * 5 9/28/96 6 40p Walsn
24 * Use AgentCodebase class to load byte codes
25 * Add retr leveRemoteClass to encapsulate RMI code 26
27 * 4 9/04/96 12 33p Walsh
28 * Centralize manipulation or RMI URL Use the test security manager 29
30 * 3 8/27/96 4 18p Walsh
31 * Add silly constructor (because Sun compiler wants it) 32
33 * 2 8/23/96 3 59p Walεh
34 * Add logging message
35 *
36 * 1 8/19/96 5 28p Walsh
37 * Initial versior
38 */
39 package com meitca hsl zonesjagents remoteloader
40
41 import java rmi Remote,
42 import java rmi RemoteException
43 import java rmi server Unir a tRemoteServet
44 import java rmi server StubSecurityManager,
45 import 3ava rmi Naming
46 import java io *,
47 import java lang Clas NotloundExcept ion
RemoteClassLoaderlmpl. java_l Tue Nov 12 07:45:14 1996
48 49
50 import com meitca hεl zoneεjagentε εecurity *,
51 import com meitca h=l zoneε agents shared *,
52 import com meitca hεl util *,
53
54 **
55 * An RMI distributed object which provides for remote retrieval of clasε
56 * bytecodeε Remoter l aεεLoederlmpl implementε the Remot°ClassLoader interface
57 * Θsee RemoteClassLoader
58 * Θauthor Thomas Walsh
59 */
60 public class RemoteClassLoade lmpl
61 extends Unicast emo'-eServer
62 implements RemoteClasεLoader ( 63
64 /**The name co whic ti a conduit εerver is bound in the RMI Regiεtry */
65 static String RMI_NAME = 'RemoteClassLoader",
66
67 /**
68 * object which actually handleε the dirty iork or retrieving class
69 * files for =a given class
70 */
71 ClassFileLoader ItsClassFileLoader 72
73
74 public RemoteClassLoader Impl ( ) throws Pemo teExcept ion {
75 itsClassFileLoader = new ClassFi leLoader ( )
76 ) 77
78 /**
79 * Retrieve the bytecodes for the specified claεs This method is invoked
80 * by RMI The calling program on the other side of the RMI connection
81 * usually invokes the RMI by calling the
82 * RemoteClassLoader ret leveRemoteClass method below
83 * Sparam claεεJRL An URL specifying the class to be loaded
84 * This εhould be of the form /dιrectory_path/classname
85 * Θreturn The bytecodes for the clasε
90 Debug println (" remoteloader ' , 2, "loading " +
91 c 'stJame t- ' from ' + codebnse_dιr ) 9?
93 if ( (r odeb?se_dιr =- null) | | (codeb εf _ ir length!) == 0)) {
94 Doturj print In ( r not e 1 t> κ]< t ' 1 ' 1 > id i πcj f t om r\ Λ ,'TΛ ] II ' ) ,
RemoteClassLoaderlmpl . j ava_l Tue Nov 12 07 : 45 : 14 1996 3
95 ' return i tsClaεsFi leLoader . loadClasεFi leFromClaεεPath ( c lassName ) ,
96 ) elεe {
97 Debug println (" remoteloader " , 3, "loading from directory");
98 return l εClaεεFileLoader loadClasεFileFromDirectory (codebase_dιr , className),
99 } 100 }
101
102 /**
103 * Retrieve the bytecodeε for the specified clasε from the remote
104 * codebaεe specified by codebase_URL This method lε called internally
105 * by the Java agent system whenever an object wants to retrieve code
106 * from a RemoteClassLoader Thiε method hideε the details of the RMI
107 * Θparam codebase_URL An URL specifying the class to be loaded.
108 * This should be of the form /directory_path/claεεname
109 * Θparam className The fully qualified class name of the class whose
110 * bytecode should be retrieved
111 * Θreturn The bytecodes for the class
112 * Θexception RemoteException If an error occurs communicating
113 */
114 public static byte[] retrieveRemoteClaεε (String codebaεe_URL, String clasεName)
115 throws ClassNotFoundException {
116
117 Debug pr in In '" remoteloader " , 2, ' ret r loveRemoteClass loading " +
118 class lame + ' from " + codebase_URL) ,
119
120 irt count = 0,
121 int index = 0,
122 whi le (count < 4) (
123 index = codebaεe_URL indexOff ', index),
124 if ( index == -1)
125 break, 126
127 count++ ,
128 indeχ++;
129 ) 130
131 String rmiURL,
132 String code_dιr;
133
134 if (index '= -1) (
135 rmiURL = codebase_URL εubεtrιnq(0, (index - 1));
136 code_dιr = rndehase_URI, =-ubsr t i ncj ( l ndex , eodoba '. URL length!)),
137 ) elεe { 138 rmiURL = codebaεe_URL,
139 code_dir - null,
140 ) 141
RemoteClassLoaderlmpl. java_l Tue Nov 12 07:45:14 1996 4
14 Debug pri t In i, "remoteloader " , 3, "remote object URL " + rmiURL) ,
143 Debug println ( ' emoteloader " , 3, "remote code dir " + code_dιr) ,
144
145 tr {
146 RemoteClassLoader remote = (RemoteClasεLoader) aming lookup (rmiURL)
147
148 return remote retr leveClaεε (oode_dιr , className)
149
150 ) catch (Exceotion e) {
151 throw new ClaεεNotFoundExcept ion ( Cound not load ' + className + e getMessage ( ) )
152 }
153 } 154
155
156 /**
157 * This method is used internally to build a full RMI URL for a remote
158 * class loader on the given host
159 */
160 public static String buildRmiURL ( tring hostname) {
161 return new String ("rmi //" + hostname J- /' + RMI_NAME)
162 }
163
164 /**
165 * This method is used internally to build a full RMI URL for a remote host
168 public static String buildCodebaseURL (String hostname, String codeDir) {
169 return new r ing (bu l ldRmiURL (hoε tπame ) f / + codeDir) ,
170 } 171
172 /**
173 * A simple bootstrap which bπngε the remote clasε loader into existence,
174 * registers it name with the RMI naming service and begins listening
175 * for recuests The mam routine allows RemoteClassLoaderlmpl to
176 * be intiated from the command line via the java command
177 */
178 public static void maιn(Stnng args [ ] ) {
179 // Create and install the security manager
180 System εetSecuri yManager (new InsecurityManager!) ) ,
181 182 try {
183 // construct the εerver and regist r it with the RMI Naming service
184 Debug println ( "remoteloader " , 1, Create an RemoteClassLoader )
185 RemoteClassLoaderlmpl loader = new RemoteClassLoaderlmpl!), 186
187 Debug println ( " remoteloader ' , 1, "Bind it to name ' + R I_NAME) ,
188 Naming rebmd lRMI_MAME, loader),
RemoteClassLoaderlmpl. java_l Tue Nov 12 07:45:14 1996 5
189
190 Debug print In (" remoteloader " , 1 , "RemoteClassLoader Impl ready "),
191 ) catch (Exception e) {
192 ErrorLog print In (" remoteloader main", ErrorLog ΞEVERITY_FATAL,
193 "an exception occurred during startup-", e),
194 }
195 } 196
197 )
Generator. java_l Tue Nov 12 07:45:33 1996 1
1 /* $Header: /ccm/meitca/hs 1/zonesjagents/skeleton/Generator . java 5 11/11/96 5-16p Billp $
2 *
3 * Copyright 1996 Horizon Systems Laboratory,
4 * Mitsubishi Electric Information Technology Center America
5 * All rights reserved
6 *
7 * CONFIDENTIAL AND PROPRIETARY PROPERTY OF MITSUBISHI ELECTRIC ITA
8 *
9 * DESCRIPTION
10 * Agent Skeleton Generator 11
12 * $Log /com/mei ca/hsl/ zonesjagents/εkeleton/Generator java $
13 *
14 * 5 11/11/96 5 16p Billp
15 * Made correction to ccmpany name 16
17 * 4 9/30/96 7 20p Walεh
18 * add javadoc comments
19 *
20 * 3 9/29/96 4 32p Walsh
21 * Allow agents to be in packages 22
23 * 2 9/12/96 ll-OOa Walsh
24 * Automatically commie the εkeleton file 25
26 * 1 9/06/96 4 54p Walεh 27
28 */
29 package com meitca hεl zoneε agents skeleton, 30
31 import sun toolε Java *,
32 import εun tools javac * 33 import Java io *,
34 import ava util *,
35
36
37 /**
38 * The Generator cl?εε generates an Method Invocation Skelton for an
39 * Agent A Method Invocation Skelton allowε the ConduitServer to
40 * dynamically invoke any method of an Agent The Skeleton εerves a
41 * similar purpose as does an RMI εkeleton or an RPC server side stub
42 * Before any Agent can travel, it is requires that a Skeleton be
43 * generated by it A programmer can generate a skeleton by executinq
44 * Generator with a ommand line like the iollowinq, - br ^
45 *<pre>
46 * java com meitca hεl zones jagents skeleton Generator agentClassname
47 * </pre>
Generator . java_l Tue Nov 12 07:45:33 1996
48 * The agentclassrame paramter should be the fully qualified class
49 * name of the agent
50 * @see ConduitServer
51 * @see Agert
52 * @εee AcentSkeleton
53 * @author Thomas Walsn
54 */
55 public class Generator {
56 57 * the main method allows Generator to be called Lrom the command 58 * line 59 */ 60 public static void main (String [ ] args) { 61 // Sanity check the command line arguments 62 f (args length < 1) { 63 Syεtem err println (StringResources NO_AGENT) 64 System err println (StringResources USAGE) 65 return 66 67 68 (args length > 1) { 69 Syεtem err print In (StringResources TOO_MANY) 70 System err print In ( tringResources USAGE), 71 return 72 73 74 String agentClassName = args[0] 75 String packageName, 76 String εhor tClaεsName 77 78 irt lastSep = agentClassName las tlnαe 0 ( '), 79 if (lastSep '= -1) ( 80 packageName = agentClassName subεtπng(0, lastSep) , 81 εhor ClaεεName = agentClassName substring ( lastSep + 1, agentClassName length!) ), 82 ) else { 83 packageName = null, 84 shortClassName = agentClassName, 85 86 87
92 String (J methodε = f indAgentMethods (agentClassName) , 93 PnntStream out = new Pr lntΞtream (new FιleOutputStream(skelFιleName) ) 94
Generator . j ava_l Tue Nov 12 07:45:33 1996
95 96 gererateSkel (agentClassName, packageName, εho ClassName, methodε, out) 97 co pileSkel (εkelFileName) , 98 catch (ClaεεNotFound el) { 99 Syεte err println (StringResources N01_FOuND + agentClassName) , 100 catch (IOExueption e2) { 101 System err prin In (Str ingReεources IO_ERPOR + εkelFileName) , 102 Syεtem err pπntln(e2 getMeεεage ( ) ) 103 e2 pπntStackTrace ( ) , 104 105 106 107 static void generateSkel (S r ing agentClaεεName, 108 String packageName, 109 String εhortClassName, 110 StπngU methods, 111 PrintStream stream) ( 112 113 // Ok This is going to be a fairly brute force approach 114 // First lets put a comment on the file 115 stream p int In ("/ /Skeleton for " + agentClassName) ; 116 stream pr ιr in ("/ /Generated by com meitca hεl zonesjagents skeleton Generator") 117 118 // The package statement 119 if (packageName '= null) 120 stream p int In ( "package + packageName + 121 122 stream println ( ' ) , 123 124 // Now some imports 125 stream pr l nt I (' impor java lang II l»cn lΛr c-essExcept ion , " ) , 126 stream println! 'import com meitca hsl zonesjagents shared Agent,"); 127 stream print In (" import com meitca hsl zonesjagents conduit AgentSkeleton,"), 128 stream print In (" import " + agentClassName + ", '), 129 stream println!""). 130 131 //now the class itself 132 stream print In ( "public final class + shortClaεsName + "_Skel implementε AgentSkeleton { 133 134 135 136 / define the static member variable containing the names of 137 // the objects methods 138 String methodsMember = "\tstatic public String methodε[] = { 139 for (int ι=0, i<methodε length, l+ ( 140 if (l ' = 0) { 141 methodsMember = methodsMember + " ,
Generator. java_l Tue Nov 12 07:45:33 1996 4
142 }
143 methodsMember = me hodsMember + "new Stnng(\"" + methodsfi] + "\")",
144 }
145 methodsMember = methodsMember (- " },",
146 stream println (methodsMember ) ;
147 stream prmtln(""); 148
149
150 // now the invoke method
151 stream prin In (" \ tpubl IC void ιnvoke(Agent agent, int i) throws IllegalAccessException {"),
152 stream. println ( "\t\tswitch (l) {");
153 for (int i=0, Kmethods length, ι++) {
154 stream printin (" \ t\ t\ tease " + l + " ") ,
155 stream pπntln( "\t\t\t\t (( " + shortClassName + "(agent) " + methods[ι] + "(),"),
156 stream p intln ( " \ t \ t\ \ tbreak ; " ) ,
157 }
158 stream. rintln! " \ t\ t\ tdefaul t ")
159 stream println (" \ t\ t\ t\ throw new IllegalAccessException ( \ "Method \" + i + \" out of range \ "),"), 160
161 // close the switch
162 stream println (" \t\t} ') , 163
164 // close the invoke method
165 stream pr in t In ( " \ t } " ) ,
166 stream println!""), 167
168 // now the getMethods method
169 stream p int n {" \ tpubl ic String [] getMethods!) {')
170 stream. println (" \t\ t return methods,"),
171 // close the getMethods method
172 stream println (" \t} ") , 173
174 // close the class definition
175 stream. println ("}") ;
176 } 177
178 static String [] f indAgentMethods (String agentClassName) throws ClassNotFound {
179 ClassDeclaration classDecl = new ClassDeclaration ( Identi ier . lookup (agentClassName) ) ;
180 BatchEnvironment env = new BatchEnvironment (new ClassPath (System getProperty (" java class pal ))),
181 ClassDef lπition classDef = classDecl getClassDe mi tion (env) ,
182 Vector agentMethods = new Vector!); 183
184 FieldDe inition fieldDef = classDef . getFirstField () ;
185 while (fieldDef '= null) {
186 if (f leldDef . isMethod() && ' fieldDef . isConstructor ( ) && fieldDef . isPublic () ) {
187 Type argTypes [ ] = fieldDef getTypef) getArgumentTypes ( ) ;
Generator. java_l Tue Nov 12 07:45:33 1996 5
188 if (argTypes length == 0) {
189 if (fieldDef getType!) getReturnType ( ) == Type tVoid) {
190 agentMethods addElement ( fieldDef getNamef) toStringO)
191 }
192 )
193 }
1 94 f j.e ldDe f = f i e ldDe f ge tMextF ie ld ( )
195 ) 1 96
197 //turn it into an array
198 String!] arra = new String [agentMethods size!)]
199 for (int ι=0 KagentMethods size!) ι++) {
200 array[ι] = (String) agentMethods elementAt ( l) ,
201 ) 202
203 return array
204 }
205
206 εtatic void compi leSkel (St ing skelFileName) (
207 Main compiler = new Mam(Syεtem out, "javac")
208 String (] params = new String [1]
209 params [0] - skelFileName,
210 if ('compiler compil (paramε) ) {
211 System err p int I 'StringResources COMPILE_ERROR + skelFileName)
212 }
213 )
214 }
StringResources. java_l Tue Nov 12 07:45:33 1996 1
1 /* SHeader /ccm/me l tea/ hs 1 / zones jagents/skeleton/Str lngResources java 3 11/11/96 5 16p Billp $ 2
3 * Copyright 1996 Horizon Systems Laboratory
4 * Mitsubishi Electric Information Technology Center America
5 * All rights reserved 6
7 * CONFIDENTIAL AND PROPRIETARY PROPFRTY OF MITSUBISHI ELECTRIC ITA
8
9 * DESCRIPTION
10 * The String Resources for the skeleton package 11
12 * $Log /com/rrei tca/hsl / zonesjagents/skele ton/ tringResources ava $ 13
14 * 3 11/11/96 5 16p Billp
15 * Made correction to company name 16
17 * 2 9/12/96 11 00a Walsn
18 * Automatically compile the skeleton file
19 *
20 * 1 9/06/96 4 54p Walsh
21 *
22 */
23 package com meitca hsl zonesjagents skeleton 24
25 class Str ngResources { 26
27 // Generator java
28 public static String USAGE = Us qe generator agent c lasεname
29 public static String N0_AGEN1 = generator You must specify an aqent class name '
30 public static Strirg TOO_MANY - generator Too many parameters specified "
31 public static String NOT_FOUND = generator Agent class not found -- ',
32 public static String IO_ERROR = 'generator IO error while attempting to write the skeleton file --
33 public static String COMPILE_ERROR = generator Anb error while attempting to compile the skeleton file -
34 }
Mitsubishi Electric ITA
Patent Disclosure for
Dynamic Synchronous Collaboration
Framework for Mobile Agents
November 12, 1996
Horizon Systems Laboratory
Mitsubishi Electric ITA
1432 Main Street
Waltli m, MA 02154
Mitsubishi Electric ITA Confidential Patent Disclosure for Dynamic Synchronous Collaboration I- .amework for Mobile Agents
Patent Disclosure for Dynamic Synchronous Collaboration Framework for Mobile Agents
1. Introduction
This document serves as a patent disclosure on the invention enlitledDy/z .nic Synchronous Collaboration Framework for Mobile Agents. This document includes a discussion of: prior art. problems with prior art. details of the invention, and improvements of this invention over prior art.
2. Prior Art
"Agent" is one of the most overused terms in the soltvvare industry today. Although the term may be used in a wide variety ol contexts, software Agents can be classified into two major categories: Intelligent Agents and Mobile Agents. Although the two differ in scope and capabilities, both types of Agents are able to perform work asynchronously and autonomously on behalf of their owners. Intelligent Agents are endowed with some degree of reasoning and learned behavior and may make decisions on behalf of their owners. These Agents are generally stationary and execute on a single system. Mobile Agents, on the other hand, may be transported across nodes in a network, performing computations as they migrate.
The original concept for Agents stems horn the Artificial Intelligence community. The behavior of Intelligent Agents may be determined by programming or by decisions made by the Agents on behalf of their owners. As an example, an Intelligent Agent may search a database for unusual outdoor scenery, making its own decisions as lo whether or not each scene meets the specified criteria.
Intelligent Agents generally employ both synchronous and asynchronous modes of communication. Agent communicalion may take the form of queries or collaborative computations. In the realm ol Agent computing collaboi ai ion may be del ined as "the coordination of the computations of multiple Agents to achieve a desired result" (e.g.. to solve a complex problem). Collaboration often results from discovery (i.e. the need to
Mitsubishi Electric ITA Confidential
1 - Λ ST - Patent Disclosure for uynamic Synchronous Collaboration rramework for Mobile Agents
collaboiate with a specific Agent lcgarding a certain subiect is not known a priori, but is. rather, detcimincd as a result ol the Agent's computations )
Both the inlet action between these Agents and the context in which they execute must be tormally specilicd. Standaidi/ation has not yet been achieved lor these objectives Howevci , the pievalent means loi accomplishing these results is via implementing a usei model and specilying queues and asseitions by using a knowledge lepiesenlation language, the most populai ol which is cuiiently Knowledge Queiy Manipulation Language (KQML), and by developing Ontologies. 01 vocabulai ies ol common tcims to be utilized by mteiacting Agents KQML is compnsed ot both a language, with a syntax unlike piocedural 01 ob)ect-oπented languages, and a communications protocol. An Ontology is delined as "an explicit specilication ol a conceptualization" The syntax and semantics ol an Ontology aie generally extensions oi a tirst-oidei picdicate calculus, typically the Knowledge Inteilace Format (KIF)
The combination ol KQML. KIF. and Ontology development is a complex task Some implementations utilizing these mechanisms aie being developed in the Aitificial Intelligence community But this approach has not caught on in other soltvvare applications
In contiast to Intelligent Agents. Mobile Agents aie usually explicitly piogrammed to accomplish a speed ic task. As an example, a Mobile Agent could migrate to travel agencies on the Woild Wide Web and determine the lowest cost air tare between two cities In this case, theie is no need loi learned behavioi oi complex reasoning
However, the amount ol lnlonnation accessible on distributed systems, including databases, the Internet and Intianets. is growing at a staggering pace and much ot it is available in incompatible stoiage lormats. The need to tiltei lnlormation and make decisions based on its content is lncicasing, and with it, the need for increased cυllaboi ation among Mobile Agents
The need toi collaboiauon is lllustiated by extending the above navel agency example A Mobile Agent may need to clone itself and instinct each ol its counterpaits to migrate to a dillcrcnt travel agency site to obtain the best package for a trip to one or more ski resorts meeting certain paiameleis. lrcludmg an laic, lodging, me.'l.s bi t tickets, and cai lental rui thei moie, tiie inhu mation may, itsell, be . oied m dilletcnt foimals (databases, etc.) necessitating some amount ot tiltcπng and data reformatting Once the Agents have obtained their intormation, they need to collaboiate with each othci to con elate their icsulls and determine the best package available at each resou l oi difteicul tiavel dates ana the overall best deal.
Mobile Λgc'iis aie e /olving to .nckide i" .ιcu.>ed mtelli C . and collaboiauon Some lescaich organizations have begun lncoipoiating KQML and Ontologies into Mobile
Mitsubishi Electric ITA Confidential 2 - Λ Sζ> - Patent Disclosure for Dynamic Synchronous Collaboration Framework for Mobile Agents
Agent implementations, while other utilize different knowdedge representation languages to implement Agent communication. Still, others use proprietary object languages.
3. Problems with Prior Art
The KQML/Onlology mechanism and other knowledge representation languages arc ill- suited for general-purpose soltware applications. They require programmers to learn multiple languages to formally specify communications and to develop complex dictionaries of teπns - a task that is currently ill-defined. The knowledge representation languages are also extremely unlike the procedural and object-oriented languages utilized in building business and general-purpose software applications.
The need to support asynchronous collaboration adds significant complexity to Agent systems implemented via knowledge representation languages (e.g. KQML) and Ontologies. Furthermore, there exists a class of Mobile Agents which solely require synchronous collaboration, e.g.. the travel agency application described above. This type of Agent application essentially subdivides a larger task into smaller pieces and creates Agents to migrate throughout the network lo accomplish it. For these Agents, there is no benefit in die added complexity of coding in multiple languages and developing Ontologies, nor in the support for asynchronous communication. A synchronous collaboration framework in the Agent's language is the best means for these Agents to coordinate their results and implement adaptive behavior.
4. Some Details of the Invention
The dynamic synchronous collaboration I amework utilizes a distributed synchronization point plus object-oriented abstractions to provide synchronous collaboration for Mobile Agents in a distributed system. The lramewoik simplifies collaboration for applications which subdivide a complex problem into several pieces and farm out the work to multiple Mobile Agents.
This framework enables Mobile Agents within an application lo perform synchronous collaboration with one or more affiliated Agents in the application's native language. This is accomplished via [hcAgenr Group abstraction. Agents wishing to collaboiate with each other must belong to one (or more) ol the same Agent Groups. The fundamental principle behind Agent Group collaboration is that Mobile Agents perfonning sub-computations, possibly on different nodes in a distributed system, will need to periodically correlate their results, and potentially adapt their behavior based on the rcsulLs of the correlation. The Agent Gioup acts as a distributed synchronization point ioi i is type of syncluonous collaboration.
Mitsubishi Electric ITA Confidential
3 _ S ^ _ Patent Disclosure for uynamic Synchronous Collaboration f-ramfev ork fornΛobue Agents
The dynamic natuie of the Agent Group enables Agents lo join and leave the group at will. Hence no a pπoi i knowledge ol the actual Agents comprising a group is lequπed and gioup membeiship may change over time
A distnbuted name space maintains a teterencc to each Agent Gioup Hence, Agent Gioups may be located via then entiy the name space When an Agent Gioup is cieated. U is automatically added to the name space.
The Agent Gioup s pnmaiy lesponsibilily is to lacilitale synchi onous collaboration foi Mobile Agents I lowevei, it also selves as a cential point loi disliibuting asynchi onous events to Agents in the gioup A typical event may be the teimination ol a paiticulai Agent. As a side etlect, the Agent Group also tracks the n avels ol its constituent Agents throughout the netwoik
The tiavel agency example lllustiates the lunclion ol Agent Gioups The pioblem to be solved can be stated as f ollows A usei wishes to deiei mine the best package lor a trip to a ski iesoil T he Agents must deiei mine the best navel date and time (e.g any week in Februaiy stai tmg on a Satuiday, and f lying bef ore noon) and lodging must meet certain ciitcna (e.g , a two-bedioom condominium) The tup includes all expenses (e g.. an faic. lodging, meals, li anspoi tation. and lift tickets) The usei may also speedy several possible tiavel destinations
This application is composed of multiple Agents -- each is lesponsiblc loi querying one oi more data souices (in peihaps dilferent loimats) loi specil ic inloi mation (e g , scaiching a pai ticulai tiavel agency's database ol promotional tups to deiei mine it any meet the catena specilied by the usei ) Some Agents may queiy legacy database systems, whereas otheis may sea: ch ODBC compliant databases (The actual mechanisms loi handling dilleient data souices is beyond the scope ol this invention )
Belore the Agenls aie tianspoitcd thioughoul the netwoik they join a new Agenl Gioup The Agent Gioup Hacks Us Agents' navels thioughoul the netwoik. At any point, an Agent may be in one of several stales Figure 1 depicts thiec Agents in an Agent Group perloi ing computations and one Agenl in-transit between nodes
At dil leient points din ing then migiauoii. Agents may wish in ( υnelate then lesults. and potentially change then migiation plans oi behavioi Suppose each Agent migrates lo a local travel agency Bcloie migrating to tiavel agencies in dilfcicnt cities, the Agenls mav wish lo coiK'lale then lesulls and potentially adjust then behavioi Suppose one of the Agenls dctei imnes that a paiticulai ιkι iesoi l. say Taos, has no iwo-bedioom condominiums available dunng Febuiai y The Λgents in the gioup may wish lo di np al' luilher queues about tups lo Taos
Agent Gioup collaboration is implemented via a distnbuted synchronization point (also known as a collaboiauon point) and a soltwarc loutine to analyze the results 01 each
Mitsubishi Electric ITA Confidential 4 - ΛSX -
Patent Disclosure for Dynamic Synchronous Collaboration Framework for Mobile Agents
Agent's computation The Agent Gioup abstiaction provides the distnbuted synchronization point Fach application need only provide its own sollwaie method to analyze the results and potentially allow each Agent to adapt its behavioi
The disliibuled synchiomzalion scheme lequnes thai each Agenl auive at the collaboiauon point bcloie collaboiauon may commence Hence, it is best suited to applications that subdivide a complex pioblem into many sub-tasks that need to con elate their lesulls As each Agenl ai rives at the collaboiauon point, it posts the icsults ol its computations to the Agent Gioup. and blocks until all the olher Agents in the gioup aπive Figuie 2 depicts one Agent in the group waiting lo collaborate while three others aie still perloπning computations
The Agenl Group collects the icsults ol each Agent's sub-computation When all Agents have arrived at the collaboiauon point, as shown in Figuie 3, the Agenl Gioup nolihes them lhat collaboiauon may commence When it unblocks the waiting Agents, the Agent Gioup passes the collected lesulls lo each Agent Each Agent then calls the apphcation- specilic method lo analyze the icsults and potentially adapt its behavioi Figure 4 shows that all Agents have ainved al the collaboiauon point and aie now in the analysis stage
The synchionous collaboiauon hamewoi k suppoits both paiallel and serialized collaboiauon analysis Figuie 4 depicts a parallel analysis implementation. Figure 5 illustrates a sci ialized collaboration analysis, which one Agent is in the Analysis state. while the iesl lemain wailing in the Collaboiate slate
The distnbuted collaboiauon point may be implemented via an ob|ect tianspoi t oi by an RPC mechanism It may also be implemented in any piocedural oi ob|ccι-oncnted language Olηeci-oπented languages simplif y the implementation, as the application need only subclass the Agenl Group abstraction and piovide a concrete method to analyze the lesulls and potentially adapt the Agent's lutuie behavior
The Agenl Gioup cnsuies that all Agents in Ihe gioup aiπve at the synchronization point by H acking the Agent s migiation thiough Ihe netwoik In the current implementation, as part of a mobile Agent system, a scivcr (known as the Conduit Server) on each node manages the Agent's migiation and infoims each ol Us Agent Gioups when the Agent ai rives and departs Should an Agent lail to ainve al a coϋaboiation point in a pie- deleimiued. conliguiable length ol lime. Ihe Agent Gioup will "ping" Ihe Agent by sending a message to ensuie lhat it is still alive, as shown in Figuie 6. (In the cunenl implementation, this is peilormed via the Conduit Servei on the node whcie the Agent is executing II the Agent f ails lo respond to the ping, the Agent Gioup notifies (lie other membeis ot the gioup by distributing a Collaboiauon Failed asynchronous cvcnl to them lhat indicates thai a pai ticulai Agenl is not lesμondmg l'lie Agents may then indicate whelhci or not they wish to proceed with the collaboration Figure 7 depicts the Agent Gioup's distiibution of a Collaboiauon Failed event followed by the remaining Agents
Mitsubishi Electric ITA Confidential
5 Patent Disclosure for Dynamic Synchronous Collaboration Framework for Mobile Agents
indicating that they wish lo continue the collaboiauon Alternatively the Agents could decide to abort the collaboiauon
T he Agent Group also implements deadlock detection b means ol the time-out mechanism and Agent ping descπbed above T he ping aciuallv letuπvs the state ot the Agent in question (via the Conduit Sei vei ) II the Agent is aheadv in the Collaborate stale but has not aiπved at this collaboi auon point a deadlock has occuned 1 his is shown in Figuie 8 In this case the Agenl Gioup will aboit the collaboration and notily the Agenls in the gioup ol the deadlock b sending them a Deadlock F v ent as shown in I lguie 9 Note that since Agenl Gioup collaboi auon is designed loi closely coordinated Agents the existence oi a deadlock is generally a lesult ol a programming erroi Hence, the Agent Group does not need to employ a ote sophisticated scheme tor deadlock detection or avoidance
Agent Gioups piovide reliability by saving the state ol each Agent in the gioup to peisistent storage If the Agent Gioup should terminate unexpectedlv. it is icstaited and leads the slate ol the group members liom peisistent stoiage The Agenl Group s icslart is tiansparcnl to the Agenls They actually communicate with an Agent Gioup Proxy (instead ol an Agent Gioup) which shields them liom Agent Gioup failures
Figure 1 1 illusuates the How ol a typical collaborating Mobile Agenl Each Agent cieaies an Agent Gioup Pi oxy loi each Agenl gi oup ii wishes lo join I he pioxv s pnmaiy responsibility is to maintain an aclive connection to us associated Agenl Gioup and to re establish the connection oi ic cieale the Agent Gioup as needed dui g Agenl Gioup lailuies
When the Agent Gioup Proxy is initialized it establishes a connection with the appiopπate Agent Gioup It lust attempts to l ind a icleience to u in ihe name space II this tails, it cieaies the Agent Group and enteis a icleience to it into the name space The algonlhm guarantees the atomicity ol this operation
Altei the proxy has cieated the Agent Gioup oi established a connection lo it the Agent continues its compulations and migrations 1 ventuallv it may allempt lo collaboiate its results T his is accomplished by means of the APCIU Gi oun Proxv II the Agent Gioup has failed oi is in a unknown state, the pioxy wil' be unable to contact ii If this occuis Ihe Agent Gioup Pioxy letπcs the communication If al this point ihe proxy is still unable to communicate with the Agent Gioup, it lecieates it and updates the name space with a rclcicnce to the new Agent Gioup Hie ic cication ol the Agent Gioup is serialized lo pievcnt multiple Agenl Gioup Pioxies liom simultaneously doing so II a pioxy detei mines lhat the vgent Gioup is in the pioces1- ol being ic ueaied u simplv waits until U can tind a reference to the new group in uic name s t., '.):ICL the Agenl Gioup has been ie-created the pioxy retries the collaboiauon
Mitsubishi Electric ITA Confidential G _ λ >o- Patent Disclosure for Dynamic Synchronous Collaboration Framework for Mobile Agents
As mentioned earlier. Agent Groups provide a distributed events mechanism in addition to the synchronous collaboration framework. The distributed events mechanism enables the Agenl Group to notify members of Ihe group of outstanding events, such as the termination of an Agent, or ihe detection of a collaboration deadlock. Agents may build on this mechanism lo lorwai d application-generated events to other members in the group Hence, if an Agent catches an application-generated exception it may notify the other Agenls in the group before terminating. Figure 10 illustrates how the Agent Group forwards an Exception Event, generated by one of its Agents, to the rest to the group.
Currently, the Agent Group handles distributed events by maintaining a (possibly remote) reference to an event queue associated with each Agenl. The Agent Group forwards all events it receives to the other members of the group by enqueuing it. The Agent Group may be implemented without a remote referencing capability, but this would add significant complexity. In the cuireni implementation, each Agent contains an events thread which is responsible for dequeuing ihe event and calling the application-specific event handler. (This thread could easily be a process, if threads were not available.)
In addition to forwarding events to members of the group, the Agent Group may generate its own events and distribute those lo the group members. As an example, the Agent Group distributes a Deadlock Event to the group members when its detects a deadlock situation, as illustrated in Figure 9.
As mentioned earlier. Agent Groups track the migrations of their constituent Agents, with help from the Conduit Server (in ihe current implementation). If an Agenl is in transit when the Agent Group is forwarding events, il queues Ihe events locally, as shown in Figure 10. Once the Agent arrives at its destination, il notifies the Agent Group, via the Conduit Server. The Agent Group then flushes the events it stored locally for that Agent.
*
Agenl Groups implement varying levels of persistence, as defined by the actual configuration. Memberships and Agent stales arc updated infrequently, so'they are generally written to persistent storage. However, local queues maintained on behalf of in- transit Agents may also be saved in persistent storage, if desired.
Implementation of Ihe Agent Group in an object oiienied language enables applications io extend its functionality, if required, by subclassing the Agent Group object.
5. Benefits of the Invention
The work described above provides several benefits. It greatly simplifies the implementation oi synchi onous collaborating Mobile Agents, especially loi applications that subdivide a complex task into a series of rclaled sub-tasks. There is no need for application developers lo learn knowledge query representation languages, such as KQML, or to develop complex Ontologies. The dynamic synchronous collaboration framework provides a natural programmatic implementation that may be programmed in a
Mitsubishi Electric ITA Confidential 7 - ΛQ. K - Patent Disclosure for uynamic Synchronous Collaboration Frame αrK, for Mbbile Agents
number ol languages An added benefit of this scheme is that collaboration is implemented as part ot the application, programmed in the same language as the rest ol the application The cuiient implementation in an objeci-oπenied language (Java) also enables the technology to be easily extended so that moie complex intelligence schemes may be supported.
Agenl Gioups tacihtate Mobile Agent H cking and may also be queued by tools thai monitoi Agents In addition, collaboration may be peiloimed thiough discovery, as with many knowledge lepiesentation languages
Agent Gioups also otlei reliability by piovulmg peisistent Agenl Gioup membership and Agent state inloimation Fuitheimoie, Agenl Gioup shield Agents liom ihe ettects ot Agent Gioup tailuies They delect an Agenl Gtoup's lailuie and automatically lestail the lailed Agent Group (which then lestores ihe state ot its membership lrom persistent storage) and retry the cuirent operation (e g , collaboration) The algorithm also guarantees the atomicity ol Agent Gioup cieation and le-crealion
An Agent Group also delects Agent iailutes and deadlocks and toiwauls this information to the othei membeis ot the group via its distnbuted events mechanism Fuiihermoie, this mechanism allows Mobile Agents lo asynchionously notity associated Agenls ol ielevani events, such as the catching ol an exception
ImplementUion ol Agent Gioups in an ob]ect-oπented language also enables additional application-specific functionality to be easily added via lnheπtance and polymorphism.
Mitsubishi Electric ITA Confidential 8 Patent Disclosure for ijynamic Synchronous Collaboration Framework for Mobile Agents
6. Figures
Compute Compute
Aaeiit (Node Λ) Λsieiu (Node B )
Λgent Group ( Node Λ)
In-iransil
( 'ompute
Asient (Node !))
Agent (Node C
1 igure 1 Agents in Compute and In-ir.insii Stale
Compute Comptiie
Aaent (Node A) Agent (Node B)
Λgent Group (Node A)
Compute
Collaboiate
ΛuenKNode D)
Λ»eni ( Nod C)
igure 2 Agents in Compute and Collaboration Wait Slates
Mitsubishi Electric ITA Confidential 9 Patent Disclosure for uynamic Synchronous Collaboration Framfe.«ork for Mobile Agents
Agent (Node C) Agent (Node D)
Figure 3: Agents in Collaboration Wait Slate
Mitsubishi Electric ITA Confidential 10 - Λ &« - Patent Disclosure for dynamic Synchronous Collaboration Framework for Mobile Agents
Agent (Node C) Agenl (Node D)
1 lgine 4 Agents m Parallel Analysis Slate
Collaborate Analysis
Λ»eni (Node Λ) Agenl (Node B)
Agenl Gioup (Node A)
Collaborate Collaborate
Agent (Node C) Agent (Node D)
igure 5 One Agent tn Serialized Analysis Stale, Others in Collaboration Wail Stale
Mitsubishi Electric ITA Confidential 11 Patent Disclosure for dynamic Synchronous Collaboration Framev.urk for Mobile Agents
Agent (Node A) A«ent (Node B)
i
Λuent (Node C Λϋeiil ( Node I ))
Figure 6. Agent Group Pings Agenl Λl iei Collaboiauon Tunes Oui
Mitsubishi Electric ITA Confidential 12 Patent Disclosure for uynamic Synchronous Collaboration Framework for Mobile Agents
Agent (Node A) Agent (Node B)
Collaborate Unknown
Collaboration Collaboration Failed kveni Failed F.venl
Agent Group ( Node A )
Collaboration Collaboration Continue Failed Fveni Conliiuie tailed F.venl
Collaborate Collaborate
Agent ( Node C ) Agent (Node I ))
1-ιguιe 7 Co iiinued ( 'ollaborati in Despue the Failure ( 1 An Ag :nι to Respond
Mitsubishi Electric ITA Confidential 13 Patent Disclosure for Dynamic Synchronous Collaboration Framev.urk for Mobile Agents
Agent ( Node A) Agenl (Node B) Agent (Node A) Agent (Node C)
Collaboiate Collaborate Collaborate Collaborate
Agent Group 1 (Node A) Agent Group 2 (Node C)
Collaborate Collaborate Collaborate
Agenl (Node C) Agent (Node D) Agent (Node D)
Figure Collaboration Deadlock (1 'ai l 1
Mitsubishi Electric ITA Confidential 14 Patent Disclosure for uynamic Synchronous Collaboration Framework for Mobile Agents
Λaent (Node A) Λϋcnt (Node B) Agent (Node A) Λucni (Node 0)
Λ'_ent (Node C) Λaent ( Node D) Agent (Node D)
Fiaure ') Collahoraiion Deadlock (Pan 2)
Mitsubishi Electric ITA Confidential 15 Patent Disclosure for uynamic Synchronous Collaboration Framework for Mobile Agentε
<\:>ent (Node A)
Agent (Node B)
Compute
In-iransu
Fxeeplion Fvent
Queued
Agent Group (Node A) Fxeepuon
F.venl
Exception ixception Event Fven I
Compute Exception
Agent (Node C) ΛuenKNode D)
FigurelO. Fxeepuon Propagation via Agent Group Distnbuted Events
Mitsubishi Electric ITA Confidential 16 Patent Disclosure for uynamic Synchronous Collaboration Framtwork for Mobile Agents
Mitsubishi Electric ITA Confidential
17 Mitsubishi Electric ITA
Design Specification for Java Agent Coordination
Version 0.2 November 12, 1996
Horizon Systems Laboratory
Mitsubishi Electric ITA
1432 Main Street
Waltham, MA 02154
Mitsubishi Electric ITA Confidential ; Mitsubishi Electric ITA Confidential
Design Specification for Java Agent Coordination
Version 0.21
1. Introduction
Java agents have the capability ot αxirdinating their activities I bis coordination takes two mam loi ms synchronized collaboration and asvnclironoiis notilϊcauons t hese modes ol communication complement each other and their i plementations aie related
Collaboration he collaboration paradigm is implemented as lollows
• multiple agents pcrtorm compulations at dillereiu nodes die network,
• alter perlorming all or a subset ol their operations, agents wail al a distributed synchroni/auon point until all agents have "arrived",
• agenis coordinate bv potentially serialized execution ol a synchionized method
Coordination can take ihe loπn ol perlorming coinpuiaiions on intermediate results and/or updating agenl itineraries
Notification
I he notification scheme uses a distributed events mechanism to communicate agenl state changes that occur asynchronously It is mainly utilized lor distributed exception handling, but may also be used to nouly related agenls ol events, such as another's termination
As described alx)ve, agent coordination utilizes distributed synchronization and event handling However. Java possesses neither of these Actually, its synchronization primitives a> e limited ιυ cntical sections on a single system and a notilicalion scheme that can only handle a single ι ρc ol event Hence, a great deal ol the complexity in the task ot agenl coordination is comprised ot implementing mechanisms to overcome Java's unsuitability tor distributed processing These mechanisms aie described in ihe remainder of this document, along vvnh ihe new objects lhat implement them
' Revision Histoiy
07/26/96 Version 0 1 Initial lcvision
1 1/12/96 Version 0 2 Ma|or changes lo Notifications and hxceptions and Collaboration sections to retlecl aeiual implementation Removed Events section
■lava Agent Collaboration/Exception Handling (11/12/96) itsubishi Electric ITA Confidential
2. Synchronization
Λs mentioned above, agent coordination requires distributed synchronization mechanisms, such as locks and events Since Java does not provide any distributed locking, we are laced with the following choice
1 Utilize a centralized locking scheme
2 Develop our own distributed locking paradigms
3 Use Java's native methods to intei lace with the operating system's synchronization primitives
The latter choice is unacceptable because it compromises the portability ol our agent intrasiructure, whereas the first option may potentially introduce considerable network overhead The second alternative also requires significant development ellorl even to implement a well-known solution to the problem
In the interest ot expediency (as required by the tightness ol our schedule), the initial Java agent intrasiructure uiihzes RMI to implement a centralized locking scheme Locking is implemented via method invocations on a potentially remote object (called an AgentGioup See Section 3 lor detail ) Λgeni coordination is implemented hv (remote) invocations on a method which requires synchronized access (See Section 3 )
3. CollaboratorAgent and AgentGroup
Agents that may wish to eollalxirate their icsults subclass CollabυiatoiA i'ent, an abstract class derived Iroin Agent Collaborator Λgeni contains a minimum ol two threads - one to perlorm computation and to travel and another to handle asynchronous event notifications Applications that contain collaborating agenls subclass CollaboratorAgent and, ot course, these derived classes may implement several computation ilueads
F.ach collaborating agent belongs to one or moie agent groups, which are descπbed by Agent ( ii oup oh|ccis Agenl ( Si oup is actually a distributed RMI object AgentGioup defines the intei lace, AgeiuGivuplmpl, an abstract base class derived Iroin PerusientEvenlGiouphtφ provides Ihe implementation (See Design Speajicat.υn Jar Di stubnied Java Events for a description ot Persistent! '.venlCiroupImpl )
An AgentGroup is essenually a unit ol coordination Hence agents may coordinate: with all die othei agents m an Λgi-niGi up They may also create new ΛgentGroups on demand, and join and leave groups at will ( In practice, AgentGroup must be subclassed lo implement agent collaboiauon However, this document does not distinguish between the base class and us derived classes and refers lo them collectively as AgentGroups )
An ΛgeniGi oup is an ob|ecl lhat is essentiall y shai ed among Ihe memlx'rs o! an agent cooidiiiution gioup It is owned by the Agent dial initially ci eaies ihe gioup (an agenl group is created by instantiating AgentGroup) and accessed via a potentially remote RMI reference.
The relationship between CollaboraiorAgenl and AgentGroup is similar lo dial of Thread and ThreadGroup A ThreadGroup maintains reierences lo the Threads composing ihe group, an AgentGroup maintains a similar list ol its CollaboratorAgents Both ThreadGi oups and AgenlGroups form a hierarchy and each contains a reference to its parent group Thread's constructors are eidier passed a reterence to a I'hreadGroup or they save a
Java Agent Collaboration/Exception Handling (11/12/96) 3 Mitsubishi Electric ITA Confidential
reference to die parent's 'I bread's group Likewise, CollaboratorAgent's constructors may be passed one or more AgentGroups or save a relcrence to AgentGroup ol ns parent, il it exists
However, there is one noticeable dif ference between ihe two types ol groups A 1 bread mav only belong to one I hi eadGroup at a nine, whereas a Collaboraloi Agent ay simulianeotish lie a member ol several Ageuldroups. which constitute a hierarchy Hence, 1 hi cads contain a reterence to then associated l hrcαdCu oup, bin CollaboratorΛgcnts maintain a list ol references lo iheir AgentGroups
Support loi multiple AgentGroups facilitates cooidinaiion among related gi oups ol agents and also enables the creation ot an AgentGroup hierarchy through which communication may be propagated 'I he pilot application may utilize multiple agenl groups, as shown in figuie 1
This figure portrays an example ol two AgentGroups AgentGroup A consists of three agents - one on each LAN in ihe system, whereas AgentGroup B contains agents on multiple nodes on LAN 3 A distributed application running on a configuration such as this typically creates multiple Ageuldroups w hen it needs to travel sc the WAN In ibis case, 3 agents are ci eaied in AgentGioup A one lor each LAN Once ihev arrive on a node, ihese agents clone themselves, creating more agents lo be distributed across ntκles on the LAN (e g , AgentGroup B) I his approach minimizes network iratlic over die WAN and lorms a multilevel hierarchy ol Ageuldroups Agents in the intra-LΛN groups (e g , AgentGroup B) can communicate then iesuhs, which can ihen Ix; coordinated with the inter-LAN group (1 e , AgentGioup )
Java Agent Collaboration/Exception Handling (11/12/96) Mitsubishi Electric ITA Confidential
By default, RMI passes all local objects by copy. However, the above scheme requires lhat each Agent actually maintain (remote) references to its AgentGroups. Hence, the agent infrastructure overrides some of RMI's object serialization methods to generate tlie required references.
4. Notifications and Exceptions
Boϋi asynchronous notification and collaboration are implemented via the associated AgentGroup object. 1 he following description serves as an example of asynchronous notification handling via distributed events. (See Design Specification Jor Distributed Java Events for more details on event handling.)
1. An agent catches an exception and wishes to noiily the other members of the group.
The agent posts an A to the AgentGroup via the group's postEvent method The AgentHxceptionliveni indicates ie type of exception that occurred
3 The AgentGroup posts the Λgenihxcepuonhvcni to Ihe oilier agenls in ihe group
4. Lach agent' s F.venl Handler performs application-specific handling of the πxceptionLvent.
If the agent that caught ihe exception wishes to notily another associated Λgeni Group, it repeals the above procedure with the next AgentGroup object.
Occasionally, ihe Agent Group may genei ate events that it directly lot wards lo a member of the group (e.g., lo "ping" il after it tails to arrive at a collaboration po i ) or others that it "multicasi.s" to its members (e.g., an Ageiu's failure to reply to a ping).
5. Collaboration
Agent collaboration is more complicated than asynchronous notifications. It is implemented as follows:
1. An ageni performs some computation and arrives at a synchronization poini. o The agent performs a (remote) invocation of the AgeniGroup's collaborate method, passing ii an AgentSiams object.
3. If no collaboration is in-progress (i.e., this is ihe first agent thai has requested collaboration), collaborate calls Us synchronized beginCollabυraie method, which initializes the number of agents to wail for before collahoraiion may Iwgin (i.e., n- \ for an H-agent group. ) (Race conditions are handled by checking if ihe agent cotinl has been initialized (i.e.. it is non-zei o) hef'oi e continuing. A l ace implies that Iwu agenls aie attempting to iniiiaie the same collahoraiion. Otherwise the application is semantically incorrect.) This routine saves die requesting agent's unique II) (obtained from the AαentStatus object) and starts a collaboration timer (with sufficient time for agents to arrive across tlie WAN) by passing a configurable lime-out value lo the AgeniGroup's wait method.
4. Otherwise (i.e., if a collaboration is in-progress), collaborate calls the synchronized decrenientCollaborate method to add the requesting agent's unique ID lo the list of
Java Agent Collaboration/Exception Handling (11/12/96) Mitsubishi Electric ITA Confidential
agents arriving at the collaboration point and to decrement the waiting agent counter. If the counter is non-zero, ilns method hhxks with no time-out value Otherwise, ihe Agent Group awakens the other threads waiting lor collaboration to commence
5 If the timer expiies, all agents did not arrive ai ihe collalxiration point in lime Tins may occur because an agenl received an uncaughi exception and terminated unexpectedly oi because a deadlock condition exists (Since agenls may belong to multiple groups, overlapping collaboiations could result m deadlock However, a properly coded application will not generate dcadhx'ks because the collalxiration points must be known a priori and must be executed in ihe same order among collaborating agents, i e , collalxiration must fu st handled at the leal Agent Group and propagated up the hierarchy ) It a time-out exxurs, Ihe Agent Group thread initialing the collalxiration (on behall of its associated CollaboratorAgent) is awakened and perlorms (he lollowing.
• It calls Ihe AgeniGroup's c liet k Ciillaborate method which returns the collalxiration slate (cither CollaboiatiυnSmcecded or CollaboiauυnFailed, depending on the value ot the waiting agenl count)
• If the collaboration tailed, ihe collaborate method calls recovei Collaborate 'I bis nietluxl attempts to communicate with the agents that did not arrive at the collaboration point by "pinging ' them (Il determines these agents by comparing (he list ot arrived agents with the group membership ) The ping is actually perlormed via a message to the Conduit Server on Ihe node where each agent was last known to be executing II the agents are kxatcd and any ol them is in the Collaboiate state and but has not arrived at tins collalxiration point, a collalxiration deadlock has occurred and the collaboration state is sel to CollaborationDeadlock It any ot the agents cannot be located, the collalxiration stale is sel to Cυllaborauonl'ailed Otherwise, it is set to CollaboiatioiiRein and the Agent Group thread retries the collaboi auon up to a configui able number ol nines (atier which Ihe siale will Ix; sel lo Collaboiatioiil-ailed it tlie collaboiauon slid limes oui )
• The initialing Agent Gioup thread wakes up (he oilier blocked threads by calling notijvAll on the Λgentt iroup
6 Once all the collaborating Agent Gioup threads have been awakened, (euher because the counter has dropped to 0 or a time-oui occurred), they call ihe AgeniGroup's checkCollabυiate method II this nietluxl returns a stale other the CollaborationSucceeded, each thread returns the appropriate exception (I e , either CollaborattonFailedException or ColkώoiatiυnDeadlockl. xception) to its invoking CollaboratorAeeni
7 II ihe collalxiration slate is CollaboraiionSucceeded, collaboration commences by executing a potentially synchronized applicaiiυn-specific nietluxl, unal zeResults, to perform the collaboration analyzekesiilts is an absiiact AgentGroup nietluxl lhat must be implemented by derived classes to pri loi ni application-speci fic collalxiration As a result ol collaboiauon, agαit uineiai .es may be updaicJ
8 As each thread completes its collahoraiion, it replies to the remote collaborate invocation, passing any stale specilied by Ihe implementation, (e g , updated itineraries) The agents then continue execution on their current inxle and travel as required by dieir itineraries
Java Agent Collaboration/Exception Handling (11/12/96) ~ \y-\ ^-
Mitsubishi Electric ITA Confidential
As descπbed above, collaboration requires complex mechanisms However, most of these are necessitated by the limited synchronization primitives provided by Java
Java Agent Collaboration/Exception Handling (11/12/96) Mitsubishi Electric ITA
Design Specification for Distributed Java Events
Version 0.2 November 12, 1996
Horizon Systems Laboratory
Mitsubishi Electric ITA
1432 Main Street
Waltham, MA 02154
Mitsubishi Electric ITA Confidential ; Mitsubishi Electric ITA Confidential
Design Specification for Distributed Java Events
Version 0.2
1. Introduction
This document describes a general-purpose solution to distributed event management.
2. Overview
This section provides a high-level description of Ihe objects that implement the distributed events Iiaine ork
2.1. Objects
Events
Hvents are descrilied by classes that derive from EvciitTxpe l -.ach HventType objeci includes: a unique ID (a Siring) generaled by Ihe constructors and a description of ihe eveni (a String) optionally passed to die constructors.
Event Handler
The Eventtiandler interface specifies the liandleEveiuO method which implements an livent Handler, l-ach application must provide its own F.venl Handler to perform application- specific event management.
Event Notification
The EveniPυst interface specifies the postEvenK ) nietluxl which implements event notification. Several of die classes described below implement this interface.
Eveni Gueufi
Any objeci receiving notification D( events must own an I -.vent Queue and an associaied thread that manages ihe queue. The I -.vent Queue's constructor is passed an kventl landler stub. It instantiates an Eveni iteueTinead (a proiecicJ class derived from Tliread) to manage the queue and passes ihe fan ici siuli to its constructor. Tlie EventQueueThread's ninQ mediod removes events from the queue and calls the handlelZventO method.
' Revision History:
09/26/96 Version 0.1 Initial revision.
1 1/12/96 Version 0.2 Expanded discussion of F.veiH Manager and livcnl (iroup. Added Reliability
Features and Garbage Collection sections.
Distributed Java Events (11/12/96) Mitsubishi Electric ITA Confidential
An Event Queue is a distributed RMI objeci F.vcniQueuelmpl implements the EventPost interface by appending the specified HventType object to the queue and calling the associated EventQiteneTliread' nietluxl I ins action wakes up the hveniQueuc'I hread tit it was blocked) I he thread then proceeds to dequeue each pending event and pass it to the handlehventO method
Event Manager
The hvent Manager handles ihe registration, posting, and notification ol events When objects request notification ol specilic event lypes, they must pass the hvent Manager a reterence to their EventPost interlace. I he I -.vent Manager saves the reference in a hash table that it uses to map event types to Iheir notification requests When an object posts an event (via the hvent Manager's posiEveniO meiluxl), ihe l-.vent Manager obtains Ihe list ol objects lo notily Irom ihe hash table and calls each ol their posihveniO methods
The hvent Manager also maintains a hsl ol objecls lhat have i cquested notification ol all events Whenever it i cceives an eveni, the hvent Manager also loi wards it to these objects, by calling each ol their posthventO methods hveiuManager is an RMI distributed oh|eci E\ entMana^eι dcscπlx;s the interlace, whereas EveniManagerlmpl provides the implementation hveiuManager defines methods lo manage event registrations (e g , add and delete legislations) hventManagerlmpl also lmplemenis the EventPost interlace Its posthventO nietluxl is passed an event Irom its oπginaioi and notifies ie leeipienis ol ihe event by invoking their posthventO methods
Λt most one hvent Manager runs on each nixie in Ihe Agent system A relerence lo il can be obtained via the RMI Registry
Event Group
A group ol objects interested in a common set ol notifications may lorm an Event Group hveniCiroup is a distributed RMI object EveniGroiψ defines ihe interlace, enιGrouplιnpl consists ol the implementation hvenlGroup defines methods that manage the group (e , add and remove members)
Whereas the Event Manager filters posted events on behall ol Us clients, lorwarding them only die events they requested, the hvent Group perlorms no filtering hveniGroupImpl implements the EventPost interlace However, its posthventO nietluxl torwai ds each event it receives lo every member ol Ihe group (by calling their posthventO methods)
In piacttce, Event Groups should he IHCCI spai ingly becau se (key could allow .in abusive application io gcnci aic unwanted notifications 'I he Agent h amework does utilize (his mechanism, but n lfi s that all events are genei aied bv a group niembei and it only uiilr/es the Event Gioup for some well-known events, such as ihe term ination ol an Agent hach hvent Group is ldentilied by a unique name either s e u< us const, u ioi or assigned by it. Objects may obtain a handle lo a particular hvent Group by presenting the RMI regislry widi this unique name
2.2. Reliability Features
The Distributed Events framework uicoi porates several reliability features These generally lake the lorm ol persistent slate and pioxy objects
Distributed Java Events (11/12/96) - - S i -
Mitsubishi Electtic ITA Confidential
Event Manager
The Distributed Evenls iramew k shields objects li om ihe ellects ot Event Manager tailures in two ways
• by sav ing its stale ( i e , eni icϋistralions) to pei sistent storage, and
• bv encapsulating us lunclionaliiN in a prow ob|ecl
The Event Managei saves ihe follow ing items in ihe pei sistent store
• the hash table mapping specilic types to the objects registered to receive Ihein and
• the list ot obiecis to be notif ied ol all events
I ach time an ol ecl either registers or iinregistei s ns interest in receiving anv (or all) events, Ihe Event Manger writes ihe updated event registrations (1 e , either the hash table or the list ol objects, but not both) to persistent storage \ ιa the Persistent Storage Manager l hese are lairlv lntrequeni operations, so the pei lorinance impact ol this process should be negligible (See Design Spec ific ation loi Aqent Pei sisienc e Package lor details on the Persistent Store Manager j
Whenever the 1 vein Manager is started, 1 is mitiah/aiion code attempts to recover anv existing event registi auons Irom persistent stoi gc Hence, registrations are not lost when the Event Manager lads
In addition, the 1 vein Managei Pi ow also pievulls Objects Irom experiencing the e llects ol 1 \ ent Manasei laihnes II aeis as a wiappei olηcci lor the 1 vent Manager 1 ach Object w ishing lo communicate wiih the 1 s ent Managei nnisi first create an / object I he proxy obtains a relerence lo the 1 vein Manager via the RMI Registry It, at am [loini, the proxv is unable to communicate with the 1 \ enι Manager, il will attempt to obtain a new relerence Irom the rcgistn It will reti v this operation several times belore throwing an exception
Furthermore, il the 1 vent Managei should la , it will automatically be re-stai ted b\ the Java Agent System
Persistent Event Group
I he Dismbuied 1 veins l jncwι„ ,^ rrovuιc> a ener al purpose implementation oi 1 vent Groups (l e , 1 veniGroupl, as descnbed ,iπo\ e i lowevci a also piovidcs ,ι reliable implementation ol Eveni Groups I'ersislcnl I vein Groups l'ei st cnt I wnt Group is a distributed RMI object thai extends EveniGroup the interface is defined bv PeiststeniEventGioiip and Ihe implementation is piovided by Peii entLventGioiψl ipl, a subclass ol EveniGioisnlinpl ei sisieei 1 veni Gioup mili/es persistent storage in much ιh( same manner as die livent Manager Whenever an Object joins or leaves the gioiφ, it s ve a reference to it in persisienl storage
Each Persistent Event Group is also encapsulated m a proxy object PersislentEvenlGwupProπ Hits proxy operates somewhat dillereuily than die Event Manager Proxy, depending on how u is constructed In some cases, it will attempt to locate a named Persistent Event Group in the RMI registry If a name is not supplied to the constructor, it will cieate a new Persistent Event Group and register it
Distributed Java Events (11/12/96) - Λ Z Z. _
Mitsubishi Electric ITA Confidential
Since Eveni Groups are temporary objecls, unlike the Event Manager, which is a persistent server, their proxies cannot expect their associated Persistent E.vent Groups to be automatically re-stai ied upon failure. Hence, a proxy may i c-creaie Ihe group if it is unable to obtain a reference lo il alter sul licieiil ictries.
This, however, introduces a race condition wherein multiple |)roxy objects may simultaneously attempt lo re-ci eale the Persistent E.vent Group. This is handled by ihe following mechanism:
• If ihe owner of the Persistent Event Group delects the failure, it re-creates the group. (The owner is defined as ihe proxy that initially created the group.)
• If the owner does not detect the failure m a configurable length of time, otfier proxies may attempt to re-create it.
'I he Persistent Event Group is re-created via the following steps:
• Attempt to create a temporal y binding in the RMI name pace with a well-known name derived from the Persistent Event Group's unique name.
• If the binding dtx;s not return an AlreadxIknindE.xcepiion, proceed to re-create the PersistentEventGroiip and then remove the temporary binding. (Otherwise, another proxy is re-creating it. So wait for its completion.)
2.3. Garbage Collection
Both Ihe Eveni Manager and Eveni Group ob|ccιs musi Ix: prcjinred to garbage collect stale references. This is simply pei loi med by deleting any objects (i e., EventPost stubs) thai il cannot communicate with. Hence their posiEventO inethixls handle gai bage collection alter notifying all interested objects ol ihe eveni.
3. Changes to Agent Implementation
CollaboratorAgent
The Collaborator A qeiU class contains a reference to an event tjueue (i.e., an Evcnt'. ucuelmpl object), which is instantiated by us constructors.
The Event Queue dcxi.s not persist across an Agent's travels. Hence, its prcpareE'orTransiH ) method Hushes the queue and voids Ihe Agent's relerence to the queue before it travels. Its associated Agenl Groups save any events that occur while the Agent is in-transit. The conψletetl'l'raitspoili ) method, called al'lei Ihe Λgeni amves al us destination, consli ucts a new EveniQueueln.pl object and i lnsl-i s an evenu _a-. -.d by the associated Agent Groups while the Agent was in-transit.
AgentStatus
The AgentStatus class contains a reference to the EventPost interlace implemented by the CollaboratorAgent's Event Queue. It also contains an Agent's unique II) and current status. Hence, it will serve as both an Event Queue and a status indicator.
Distributed Java Events (11/12/96) Mitsubishi Electric ITA Confidential
AgentGrouplmpl
The AgentGrouplmpl class derives Irom PersisicniEventGroupImpl Thus, it not only enables Agent collaboration, but also provides reliable group event handling
As a result, Agent (jroups may implement dillei ent levels ol pei sistence Group niemhoi ship is always written lo persisient storage, bin queued events lor in-transit agents will also be saved il Ihe Agent Group's conliguiation allows it
Occasionally, Ihe Agent Group may generate events that it diiecily torwards to > member ol the group (e g , to "ping" it alter it tails to aπ ive at a collalxiration point) or others lhat it "multicasis ' to its members (e g , an Agent's lailure to l eply to a p g) Group members mas also broadcast an event to ihe group (e g , an Agent may inlorni the group that it has encountered an exceptional condition)
AgentEvent
T he A t>entEvenι class is the superclass of all events generaled by Agents It includes the Agent's unique ID
Distributed Java Events (11/12/96) AgentGroup. java_l Mon Nov 11 16:25:52 1996 1
1 /* $Headeι • /com/me_ tca/hs.. zonesjagent 'col labcrate /AgentGroup 3ava 5 10/01/96 3-40p Noemi $
2 *
3 * Copyright 1996 Horizon Systems Laboratory, Mitsubishi Electric
4 * Information Technology C3rιter America
5 * All rights reservec 6
7 * CONFIDENTIAL ANT, PROPRIETARY PROPERTY OF MITSUBISHI ELECTRIC ITA
8
9 * DESCRIPTION
10 * Agent Group distributed interface 11
12 * $Log 'cora/reitca/ sl ' zonesjagents , collaborate/ AgentGroup . java $
13
14 * 5 10/01/96 3 40p Noemi
15 * Added some 3avad;c comments 16
17 * 4 9/10/96 5 0"p Nor-π
18 * Changed return value of collaborate method from a void to an Object 19
20 * 3 9/06/96 3 34p Noemi
21 * Added UpdateAger method. changed argument to addAgent
22 *
23 * 2 8/30/96 4 24p N~emι
24 * Added addAgent, reraoveAge t, and getGroupSize metnodε
25 *
26 * 1 8/28/96 2 : 13p Noer
27 * Basic AgentGroup f j.ictical i ty No F ipport for remote groups or agent
28 * mobility yet
29 */ 30
31 package com.meitce '-si zoreε;agents collaborate,
32
33 impor t j ava . ut i l K ~SuchE emfc i tExcept i on ,
34
35 import j ava . rmi . Remo te ;
36 import j ava . rmi . Rerac ieExce . i :n ;
37
38
39 /**
40 * AgentGroup is an RMI distributed interface The actual
41 * implementation o-' AgentGro p is handled by AgentGrouplmpl
42 * This class provides RMI glue that enables Agents to invoke
43 * (remote) operations on on associate agent gioup 44
45 * Agents may belong to one c r more agent coordination groups
46 * (AgentGroups), which act as focal points for distributed
47 * synchronous agent collaboration and asynchronous notifications
AgentGroup. ava_l Mon Nov 11 16:25:52 1996 2
48 * among members of the age it gioup
49 *
50 * ©see Agent
51 * @see AgentGr n.ulmpl
52 * ©author Noemi Par orek
53 */ 54
55 public interface AτentGrcuo
56 extends Remote 57
58 // Instance methods
59 /**
60 * Collaborati n interface
61 * @param resu.t Ti; result of the agent's computation
62 * RemoteException If an error occurrs setting up network
63 * connections
64 * (sexception •icιentGrc pFv cept ion If the collaboration imes out
65 * ©return An ODject tnat describes the result cf collaboration
66 */
67 public Object collaborate ( AgentResult result)
68 throws RemoteException AgentGroupExcep ion
69
70 /**
71 * Adds an Agent to the gro p
72 * Θparam status The AgentStatus object that describes the Agent
73 * ©exception RemoteException If an error occurrs setting up network
74 * connections
75 */
76 public void adα^gent (Age Status status-)
77 throws RerroteExceotio 78
79 /**
80 * Locates ana removes the AgentStatus object cortairing the specified ID
81 * ©param agentID An Agent's unique ID
82 * ©exception Renott-rxc-ction It an error orcurvs retting up network
83 * connections
84 * ©exception NoSuchElementException If the AgentStatus object does
85 * not exist
86 */
87 public void removeAgent (Sti mg agentID)
88 throws RemoteException, ArraylndexOutOfBoundsExcep ion, NoSuchElementExcep ion
89
90 /**
91 * Replaces the AgentStatus object for the specified ID
92 * This method may be used to change an Agent's status, ID, or both
93 * ©param c-gentID An Agent's unique ID
94 * ©param newStatus An AgentStatus object to replace the existing one
AgόntGroup. ava_l Mon Nov 11 16:25:52 1996 3
95 * ©exception RemoteExcep on If an error occurrs setting up network
96 * connectior,;-
97 * ©exception NoSuchElementException If the AgentStatus object does 98 * not exist
99 */
100 public void dateAgent (S "r mg agentID, AgentStatus status)
101 throws Rferc eExceptio , ArraylndexOutOfBoundsException, oSuchElementException ; 102
103 /**
104 * Returns the number of Agents in the group
105 * ©return The number of Agents in the group
106 * ©exception RemoteExcep ion If an error occurrs setting up network
107 * connections
108 */
109 public int getGroupSxze ( .
110 throws RemoteException- 111
112 / *
113 * TURN ON LATER
114 * 115
136 public void agentExceptioi. (String agentID, Exception type) throws RemoteException, 117
113 public void agsntTerminatic.n (String agentID) throws RemoteExcep ion,
119 120 121 122 123
AgentGroupException. ava_l KOΛ 'JO 11 16:25:52 1996 1
1 /* $Header /com/, itca/r ε 1 / : ;nesjagents/collabcrate/AgentGroupExceptιon java 2 10/01/96 3 41p Noemi $
2
3 * Copyright 1996 Horizon Systems Laboratory, Mitsubishi Electric
4 * Information Technology Center America
5 * All rights reserved 6
7 * CONFIDENTIAL ^ND PROPRIETARY PROPERTY OF MITSUBISHI ELECTRIC ITA
8
9 * DESCRIPTION 10 * Agent Group exceptions 11
12 * $Log 'co- mei ca hεl tonesj agents /col laborate/AgentGroupException Java $ 13
14 * 2 10/01/9c 3 41p iosri
15 * Added a prote ted default constructor and some javadoc comments 16
17 * 1 8/28/96 I 16 o Nc -r
18 * AgentGroup re_ated except- --ns
19 */ 20
21 package com meι__a hsl zonesjagents collaoorate
22
23 import com meitca hεl zonesjagents shared Age^t
24
25 /**
26 * AgentGroupEx - ,tιon defines exceptions that occur during
27 * AgentGroup operations
28 *
29 * ©see Agen'
30 * ©see AgentSrouo
31 * ©author Noem_ Pac orek
32 */ 33
34 public class AσertGrouoException extends Exception {
35 '
36 //Constructors
37
38 /**
39 * Constructs -n AgentGrouj Exception
40 * ©except- n Illeg lAccessException Whenever called
41 */
42 protected Agt -' OroupExcep i n ( )
43 throws I - galAcceεsException { 44
45 System out cπntln ( "Default constructor called for AgentGroupException" ) ,
46 throw new . egalAccessException ( ' AgentGroupException Default constructor"),
47 }
AgentGroupException. java_l Mon Λov 11 16: 5:52 1996
48 49 50 Constructs AσentGroupΞxception 51 ©param tv A Strirg describing the exception 52 53 public AgentGr' ODΓX'" =p l nn (String type) ( 54 super (type! 55 56 57
AgentGroupImpl.3 ava_l Ilor. -JO 11 16:25:52 1996 1
1 /* $Header /cor m« tca/hsl/z~nesjagents /collaborate/AgentGroudmpl ava 7 10/01/96 3 43p Noemi $
7 Thread ci rrentri read ( ) stop()
8 * CONFIDENTIAL AND PROPRIETARY PROPERTY OF MITSUBISHI ELECTRIC ITA 9
10 * DESCRIPTION
11 * Agent Group disli jbuted clrics
12 *
13 * $Log /coir/ e tca/hsl/ 7ones]agents/col laborate/AgentGrouDlmpl ava S 14
15 * 7 10/01/96 ' 43p Noemi
16 * Added javadoc cc pine tc
loσ c to
21 *
22 * 5 9/10/96 5 0rp Noer-i
23 * Changed collaborate anc -na
24 *
25 * 4 9/06/96 3 33D ifoeiri
26 * Added removeAgert update^ς^nt and indexOfAσent r t ιc "-»nq»ι
27 * addAge it ε argun-nt t^ ^r A~entrtt tuε ooiect 28
29 * 3 9/04/96 3 ι<ι, Noen 1
30 * Added αetCi upK τι mc c 31
33 * Turned on code _n constructor and fma.izer that 'eqi'-μ" a-d
34 * dereqisters ith tne RliI nare rerv»r 35
36 * 1 8/28/96 2 16D Noemi
37 * Basic synchronous agent collaboration functionality No supoort for
38 * remote groups cigen- mobility or asynchronous no ifications
39 */ 40
41 packaqe com raPitca 1 = 1 zonesjaqent collaborate 42
43 import java util *
44 import java 10 *
45
46 import ava rmi server Jπcas t emoteServer
47 import java rmi Re r Exo=pt- 1 on
Age-itGroupImpl. java_l Won Ncv 11 16:25:52 1996
48 import java. rmi Naming;
49 import java rmi Nr LLundExcestion, 50
Jl import java net Iret ". dre ^
'-2
53 /**
54 * AgentGrouplmpl s an RMI distributed object This is a base claεs
55 * that implements the Age-c roup interfaces 56
37 * Agents may bel no to one or more agent coordination groups
58 * (AgentGroups), »h:c act r.s focal points for distributed
59 * synchronous agent collaboration and asynchronous noti ications SO * (e g , exceptions) among members of the agent group
SI
62 * @see Agent
63 * @see AgentGroup
64 * Θauthor Noemi Pac-_or=k
65 */ 66
67 abstract public c^as-- AgentGrouplmpl
68 extends
69 implements AgentGroup { 70
71 // Constants
72 /**
"3 * Default tιrr=out for c~l laborat ion m s
74 */
75 public static tiral long DΞFAUL1_TIME0UT = 100000,
76 // public stat. - -inal long DEFAU T_TIMEOUT = 5000 77
78
79 // Class varia. l^s
80 protected stat.c mt qrc DlD = 0,
81 '
82 // Instance vai .ables
83 protected long timeout, // collaboration timeout in ms
84 protected Stnrg groupName; // name to register with RMI Name Server
85 protected Vect r agentList, // Agent IDs of group members
86 protected Vector resultList; // results shared via collaborate
87 protected boolean ccllabora.ionlnProgress ,-
88
89 90 //Constructors 91 /** 92 * Constructs an AgentGrouplmpl object 93 94 " I
AgentGrouplmpl. java_l Mon Nov Jl 16:25:52 1996
95 public AgentGrcuplr.pl . ,
96 throws RemcteExcepcion {
}
; o ς
100 /**
101 * Constructs an geπtGroucImpl object
102 * @param i eo Tne collaboration timeout in milliseconds 103
104 */ 105
106 public AgentGrc_.pImpl ( long .iraeout)
107 throws RemoteExcep ion { 108
109 this timeout = (timeout > 0 ) ~> timeout DEFAULT_TIMEOUT
HO agentList = new v e :>_ (>,
111 resultLiεt = null;
112 collaborat. jnlnProgress = false 113
114 /*
115 * Create a rame to represent this instance of an agent group
116 * and register it MΓ- the RMI name service
117 */
118 groupName - 'AgentGroup" + nextGroupID ( ) , ιl9 System out j irtln ( "gr cupName = " + groupName) 120
121 try { ι 22 Naming j < - mi (ci lUcName thu )
123 } catch (Ex' option e) {
124 System cut print In (" ^gentGroupImol can't rebmd ' * e getMessage ( ) ) ,
125 e print =tackTrace ( )
126 }
127 }
128 : 129
130 // Finalizer .31 protected vo.d finalize!) x32 throws Thrcvaole {
133 34 System out or m In ( "Age tGrouplmpl Finalizer called"),
135
136 // Remove t ns AgentGr -up ' s Name from the RMI registry
137 try {
138 Naming unbind (groupName) ,
139 ) catch (Exception ej {
140 Systerr out print lr ( 'AgentGrouplmpl can't unbind " + e getMessage ()) ,
141 print StackPrace M
AgentGrouplmpl. java_l Mon Nov 11 16:25:52 1996
142 }
143
144 super f me-.-.ze ( ) ,
145 } 146
147
148 // Class methods
149 private final ynchron zed int nextGroupID ( ) {
150
151 152
153
154 // Instance πet-o s
155 /**
156 * Returns the Agent Grcup's unique ID
157 * ^return the -qent Group s unique ID
158 */
159 public final String g=tCro,_pName ( ) {
160 return gr~ rN=m°
161 ) 162
163
164 I * "
165 * Converts an Accent Group nto its string representation
166 * @return A c _^g representing the Agent Group
167 */
168 public String >-~S πn * ,
169 return oro Hιm=
170 } 171
172
173 // Methods to -nr.pjlate rαent ist
174
175 /**
176 * Adds an Agent to the gr rup
177 * Θparam status The AcsntStatus object that describes the Agent
178 */
179 public synchronized void aodAgent (AqentStatus status) (
180 agentList addElement (status ) ,
181 System out -r intin (' Added Agent, ID = ' + status getAgentlDO +
182 ", St. i 's = ' * status getStatuo() + ' to group")
183 ) 184
185 /**
186 * Locates arJ removes the AgentStatus object containing the specified ID
187 * Sparam aαent D An Age-t's unique ID
188 * ^exception Nι SuchEl=ιτ entExcept ion If the AgentStatus object doe=-
AgentGrouplmpl. ava_l Mon Ncv 11 16:25:52 1996 5
189 * not exist
190 */
191 public synchronized void rεmoveAgent (String agentID)
192 throws KoS chElementE>.-ept ion , ArraylndexOutOfBoundsException {
193
194 int index = _ndexOf ς° ^z (agent ID)
195 if (index -- 1)
196 throw - w Kcc,jτ: ent Exceot ion ( "Can ' t f nd 'ι|ιjntID")
197 agentList r crnoveElemen tAt ( index)
198 System oui cπntlnC Rera wed fger", ID - " + ag^nt:rι ■* from qrnup' ) ,
199 } 200
201 /**
202 * Replaces t~ Agen Status object frr the specified IL
203 * This ethoo -ay be used to change an Agent's status TD or both
204 * Θparam ecentID An Agent's unique ID
205 * Θparam r-wStatus An AgentStatjs object to replace the existing one
206 * NoSuchElementE> cept on If the AgentStatuε object does
207 * not exist
208 */
209 public synchronized voic updateAgert (String agentID, AgentStatus newStatus)
210 throws NoSuchElementException, ArraylndexOutOfBoundsException {
211
212 removeAgen (agentID)
213 addAgent (rewStatus) ,
214 System out -nntln ( "Updated Agent ID from " agentID + " to New ID = ' +
215 new tat s cetA;c i1- ID ( ) + ctatuε = ' > newcfptuε qetStatusf))
216 ) 217
218 '*
219 * Walks the aner'L.it l -kmσ fci an AgentStatus ob]='-t with the
220 * specified ID
221 */
222 private .nt mnexOf Age- ( c tr mg eqertϊD) {
223 int index, numAgents,
224 for (index = 0, numAge-tε = agentList sized, index < numAgents, index4-!) {
225 AgentStatus status = (AgentStatus) agentList elementA ( ndex)
226 if (agentID corrpareTo (status getAgentlDO) — 0)
227 return index
228 }
229 return -1
230 }
231
232 /**
233 * Determines how many agents in the group have the εoecified status
234 * Θparam status The status value to search for
235 * Θreturn The number cf agent's with the specified rtatus
AqentGroupImpl. ava_l Mon No-j 11 16:25:52 1996 6
236 * @see Agen'Sratus
237 V
238 public int a jen tεWi th tat ι= ( int εtatus) {
239 int agen" = 0
240 for (Enu eration e = c gentLiεt elements () e hasMoreElements ( ) ) {
241 AgentStatus aStatus = (AgentStatus ) e nextElem=- t ( )
242 if (aSt-ituε getS-«.cus() == status)
243 ageιts++
244 }
245 return agent'
246 } 247
248
249 /**
250 * Returns the nunber of Ag»nts in the group
251 * dreturn "he number of ^ ents in the group
252 */
253 Dublic finao. irt getGrcucSize ( ) {
254 return st sited
255 256 257
258 '/ Methods to mplemen- co.laboration 259 260 261 Collaborate ( is fe p_blιc interface to collaboration It calls 262 beginCollabcration ( ) to synchronize the 263 and to a.t 'or all ac- r tc arrive 264 265 If all aα-n ration 266 point each zeResul ts ( ) 267 method to 268 269 Otherwise the agent tnat initiated the collaborate calls 270 recoverCc ^ _abτratιor ) 271 272 273 Θparam 'esult Th= result of the agent s c-mpjtatmn 274 Sexception i moteExcec ion If an error occurrs netting up network
275 * connections
276 * @exceptιc , AgentGroupException If the collaboration times out
277 * Oreturn An Obnect that describes the result of collaboration
278 */
279 public Ob ect collaborate ( AgentResult result)
280 throws Re-1 teΞxcepti - AgentGroupException {
281
282 System out F -ntln(' col Laborate RMI')
AgentGrouplmpl. java_l Mon Kov 11 16:25:52 1996 7
283
284 boolean f .rεtrd labors tor = begmCollaborat ion ( resul ) ,
285
286 /*
287 * If collc-bc-ati'-n failed and this is the agent that initiated
288 * collaboration, it woke up because its timer expired It retries
289 * once before ahro jp the other agents 290
291 */
292 if ( f lrstCc llaborεtor <*& ' collaborationSucceed? ( ) ) {
293 Systerr out pr r'lnC'fciUiibn-'ririiin Tilled r t iyinq ")
294 synchroni zed ( ι_r i ) {
295 try <
296 this 'ai t ( imeout ) ,
297 } :tch ( InterruptedException e) { }
298 }
299 } 300
301 /*
302 * If al_ agents m th e group have arrived at the collaboration
303 * point, =ar agent calls the applica ion-specific analyzeResul tr
304 * method to dete ii e the agent s next course of action
305 */
306 if (collah-rationSuccesdedO ) {
307 Syster- out pr±ntlr ( "Ready to do collabora ion'),
308 Object col laborati on = analyzeResul ts ( res l t rt elements!)) 309
310 /*
311 * The αert fa .mtiated collaboration c ars up
312 */
313 if (f-iSoCcllaccrator)
314 encCo.laboration ( ) , 315
316 return -'-.laborati-in
317 } elεe {
318 /*
319 * If th s is the agent that originated the collaboration,
320 * it v-,ke up becaise the timer expired It must wake up
321 * the other blocked agents (which are still sitting in
322 * beg- -Collabora e () ) and then recover from the error
323
324 if (iirstCcllaborator) {
325 System out prπtln ( "Collaboration Failed while " +
326 agentεWithStatus (AgentStatus INTRA SIT) +
327 ' agents wsre in transit"); 328
329 synchronized (t.nis) {
AgentGrouplmpl . ava_l Mon Ncv 11 16:25:52 1996 8
330 th„s notifyAllO,
331 )
332 rscoverCollaboration ( ) ,
333 } else
334 Ξvε teπ ou t o nt ln ( ' Col labora t ion Fa i l ed ' )
335 "
336 throw new AgentGro-pException (' Collaboration timed out"),
337 } 338
339 }
340
341
342 /**
343 * beginCollaboration ( ) is called internally by collaborate ( ) to
344 * synchronize each agent's recording of results and to wait for
345 * all agents to ari lve at the collaboration point This method acts
346 * as a distro-butel rendezvous, of sorts Each caller blocks until
34 * all agents _n the grouo have "arrived" at the collaboration point 348
349 * This method returns a ooolean that indicates if the agent initiated
350 * the collaboration
351 *
352 * Θparam re= .c Th= result of the agent's computation
353 * Sexception AgentGroupException If the group only has one member
354 * (ireturn A boolean indicating if the collabora ion was successful
355 *
356 */
357 protected synchr r ized bor lean ben inCol labor at ion (Aqenireru \ t remit)
358 throwε AgentGrouoE> cept ion { 359
360 boolean f _rstCol labor? or = falεe col laborat ion' )
364 if ( ' collaboraticnlr^r jgresε) {
365 /*
366 * It thiε agent is initiating the -ollaboration , allocate the
367 * resultLiεt Vector and add result to it Then wait for all
368 * agents to arrive at the collaboration point or for the
369 * collaboration timer to expire
370 V
371 i f ( r gen tLι s t s i ze O < 2 ) {
372 en CoolaDorat LOΠ ( ) ,
373 tnrow new Agen GroupExcept ion (' AgentGroup too small")
374 } 375
376 coll jgreεs = true
AgentGrouplmpl. java_l Mon Nov 11 16:25:52 1996 9
37? f lrε^CollaboratC- = true,
3 8 resU tlist = Victor (),
3 9 resuit ist addEl emant (result )
380
381 try <
382 tnis iai t ( time out )
386
387 /*
388 * id this agent's reεultε to reεultLi'-t If this is the
389 * last agent to arrive wake up the other agents Otherwise
390 * wait for the -ect of the agents in the grouo to arrive
391 */
392 resu.tList addElement (result )
393 if (co_ laborationS JΓ ceede ( ) )
394 ~n_s notifyAIll)
395 else
396 tiy
397 this »a (
398 ^tc (In*-?' UDtedExcept ion e) { }
399 }
400 }
401
402 return f ι:f lia le*- o
403 } 404
405
406 /**
407 * Cleans up af- " a s cces ul c"llab ration
408 */
409 protected vo - endCol labor at ion ( ) {
410 collabor or InDro"re=s = false
411 } 412
413
414 /**
415 * Cleans αp afte- a failed collabora ion
416 */
417 protected o c, . eccvarC^ llaborat ion ( ) {
418 endCo1 laloiationO 419 420
421
442222 423
AgentGrouplmpl. java_l Mon Nov 11 16:25:52 1996 10
424 * anal zeRc= si lt= ( ) is an abstract method that must be overridden by
425 * each application It orovides the application-specific behavior
426 * requ.ref to implement collaboration This method is invoked on
427 * behalf f each agent i- the grouo It _ε passed the results
428 * computec \ each agen" and determines the courεe of action fo the
429 * calHng t-Or- t if anv based or th° computec resnl ε
434 */
435 abstract prot= t 3 Obn-c analyteKesul ts (Enume-at ion r sult*-) 436
437 /*
438 * Private method to dete.mme if all agents have reached the
439 * collaboration point li.s method is εynchronized tc prevent
440 * races iΛith agents icni q and !-av.ng the qroup
441 */
442 private εynchronized bcole n col laboratιonSucceed°d ( ) (
443 return (reεultList s ϋ=() == agentList ειze())
444 }
445
446
447
448 /*
449" * TURN ON LATER
450
451
452 // Methods tc hanαlc °x-ep ons a"d -ther notif cati n^
453 piblic void α i^n E ceptιon(ζμπn- anentID Ex'-ec. I r - t c)
454 thro Ret feE> "ti'i-r (
455 } 456
457 public void ag = " Termmati r(Strιrq aσentID)
458 throws Ren Exception '
459 } 460
461 * I 462 463 }
AgentResult. ava_l Mon Nov 11 16:25:52 1996 1
1 /* $Header: /com/mc- tca/hsl /. nesjagentε/collaborate/AgentResul t . java 4 10/01/96 3:43p Noemi $
2 *
3 * Copyright 1996 Horizon Systems Laboratory, Mitsubishi Electric
4 * Information Technology Center America.
5 * All rights reserved.
1s * * CONFIDENTIAL AND PROPRIETA { PROPERTY OF MITSUBISHI ELECTRIC ITA.
8
9 * DESCRIPTION
10 * This object holdπ the esult of an acient's compu tions. 11
12 * $Log : /com/m i ea / hε 1 / zonesj agents /col laborate/AgentResul t . j ava $
13
14 * 4 10/01/96 3-.43p Noemi
15 * Added some javad-c comments 16
17 * 3 9/06/96 3-48p Noemi
18 * Added a protected default constructor to enεure that the public
19 * constructors . - ' v.c instance variables correctly. 20
21 * 2 8/30/96 4- 22p Noemi
22 * Changed private protected instance variables to projected.
23
24 * 1 8/28/96 2 : l"ϊp Noemi
25 * A generic class that represents the result of an agent computation.
26 * (Used by collaboration cede.)
27 */ 28
29 package co . ei t ca . hε 1. zoner gent s collaborate; 30
31 /**
32 * AgentResult co: tains an ;-.r;nt ID and a result tc be shared
33 * via collaborat i .in 34
35 * @see CollaboratorAgent
36 * @see AgentGrouplmpl
37 * dauthor Noemi Paciorek
38 */
39
40 public class AgentResult {
42 // Instance variables
43 protected String agentID: // ID of agent that computed reεult
44 protected Object reεult; // actual result computed
45
46 //Constructors
47 /**
AgentResul . java_l J-on Nov 11 16:25:52 1996 2
48 * Protected Default Constructor for an AgentResult object
49 * (Sexception X 1 legalAce=-ssFxoept ion Whenevpr called
50 */
51 protected AgentResul ( )
52 throws I ϊlegalΛcrerεEx rept ion {
53
54 System. out pr in lr (' Default constructor call'd foi AgentResul "),
55 throw new 1 legalAcceεsExcept ion ( " gentResul default constructor"),
56 } 57
58 /**
59 * Conεtructε an AgentResult object
60 * Sparam agentID The Agent's unique ID.
61 * @param remi The resilt to be shared via collaboration
62 */
63 public AgentResul (St ing agentID, Obnect result) {
64 this. agentID = ag-ntID
65 this result = res,: i
66 } 67 68
69 // Instance me t cds
70 /**
71 * Gets an Age^f" u"ic e ID from this AgentResult object
72 * Oreturn Ar -ce-t's -rique ID
73 */
74 public final String getAgentlDO {
75 return age: l^,
76 } 77
78 /**
79 * Gets the reεult to be snared via collaboration
80 * from this AqentRes^lt conect
81 * @return The esi.lt tc be εhared via collaboration
82 */
83 public Object getResultO
84 return result
85 } 86 87 }
AgentStatus. ava_l Mon Nov 11 16:25:53 1996 1
1 /* SHeader /com/ne tca/h^l I zc leεnagent^/collaborate/AgentStatuε java 2 10/01/96 3 44p Noemi $
2 3 ** Copyright 1996 Foπzon Systems Laboratory, Mitsubishi Electric
4 * Information Te-nnolcgy Center America
5 * All rights leserved
7 * CONFIDENTIAL h Z PROPRIETARY PROPERTY OF MITSUBISHI FLECTRIC ITA
8 *
9 * DESCRIPTION
10 * Thiε object ho.dε an Agent s status (e g AClIvΞ)
11
12 * $Log /co τe tca/hεl/zones jagentε/collaborate/AgentStatus java $
13
14 * 2 10/01/96 3 d-.p Noemi
15 * Added some javacoc comments 16
17 * 1 9/06/95 3 "lp Noemi
18 * This claεε repr, =entε an agert ε current status (e g ACTIVE)
19 */ 20
21 packaqe com meitci hsl zones- agents collaborate 22
23 /**
24 * AgentStatus contains an agent ID and a status value Each ^gentGrouo
25 * contains ar Ag-ntctatus object for each Agert m the group 26
27 * @see Col labjrr tor gent
28 * @see AgentGrouplmpl
29 * Sauthor No=mι p r pr=>
30 */ 31
32 public class ^αen- S"atjε ; 33
34 / / Conεtantε
35 pr i vate ε tat i c I -a l nt FIR T^S^ATUS = 1
36 /**
37 * Agent lε active
38 */
46 */
47 public εtatic final int UNKNOWN = 3,
AgentStatus. ava_l Mon Nov 11 16:25:53 1996 2
48 private stat c final int ^ST_STATUS = UNKNOWN,
49
50 // Instance variables
51 protected Sf _ng agentID, // ID of agent
52 mt status // current εtatuε
53
54 //Construct!
55 /**
56 * Constructs =.n AgentStatjs object
5 * henr-ver called
58 */
59 protected Ai ^ntStatus ( )
60 throws _ _egalAccesεExceptιon { 61
62 System r t cr.ntln (' Default constructor called for AgentStatus"),
63 throw ne _ 1 _<=galAcceεsExcept ion ( " Agent^tatuε default constructor' ),
64 } 65
66
71 public AgentStatus (String agentID) {
72 this (agentID, ACTI\Ξ),
73 } 74 75 76 / * *
77 * Constructs an AgentStatus object
78 * @param agentID The Agent's unique ID
79 * @param ta s t e Ag^nt s statuε
80 */
81 public AgentStatus (String agentID, mt status) {
82 this age-t D = agentID,
83 this stat is = ((status < FIRST_STATUS) | | (status > LAΞT_STATUS) ) ~
84 UNKN' Λ7N status
85 }
86 87
// Instance rd"
89 / **
90 * Extracts an Agent'ε umq> ID from an AgentStatus object
91 * Oreturn An Agert's uniqe ID
92 */
93 public final jti iπq qc t / κ> tID() (
94 return a- 3t-tID
AgentStatus. ava_l Mon Nov 11 16:25:53 1996 3
95 }
9 976 /**
98 * Extracts an Ac-mt's curr snt εtatuε from an AgentStatuε object
99 * Sreturn An <λg<-t ε cαrr-nt statuε 100 */
101 public final t getStatuε ( ) <
102 return statu«
1 03 } 104
105 }
CollaboratorAgent. ava_l Mon Nov 11 16:25:53 1996 1
1 /* SKeader /com/nei cca/h= 1 'zonesjagents/collaborate/CollaboratorAgent java 5 10/01/96 3 45p Noemi $
2 3 ** Copyright 1996 Horizon Systemε Laboratory, Mitsubishi Electric
4 * Information Technology Center America
All rights reservpc
7 * CONFIDENTIAL & "D PROPRIETARY PROPER'!/ OF MITSUBISHI ELECTRIC ITA
8
9 * DESCRIPTION
10 * Derived claεs fri nobije Ag-nt rc 1 laborat ion 11
12 * $Log /co-/ τιeι tca/hsl /zones jagentε /collaborate 'Col laboratorAgent java $ 13
14 * 5 10/01/96 3 45p Noemi
15 * Added some javad~o com ent 16
17 * 4 9/20/96 4 Ito Noemi
18 * Changed finalizer to ensure that it performs cleanup nc more than once
19 * ( A bug the ga baqe '-cllector may cause the final itt-r to be called
20 * mr re than once') 21 2'2 * 3 9/10/96 3 OΪ-D Noemi
23 * Renamed εe Intrans ^tStatuε and εetAct lveStatuε to preoare^orTranεport
24 * and completedTra^εoor r=scec"ιvely
25 *
26 * 2 9/06/96 3 57p No -i
27 * Added tie fcllovi.ng Sta tuε
28 * f»t I tra"sι t ^ t j 29
30 * 1 9/04/96 3 _~o Noemi
31 * Suoclass of Aqent that ιmcl=nents a c^llabcratmq Aqent 32
33 */
34 package r-om meitca h=l zones agents collaborate 35
36 import java util *,
37 import java net 38
39 import com meitca hε_ z ~nes jaσents shared Agent 40
41 /**
42 * A subclass of Agei t that enables collaboration among aqents in a qroup
43 * Agents wishing to ollabcrate must extend this class to do some useful work
44 * They must also b- ong to an agent coordination group (AgentGroup) Generally,
45 * an application fi- cr=ar»ε an AgentGroup Then it obtains a reference to
46 * the RMI interfac ror "e nroup by looking up the group in the local RMI name
47 * service Subεeqi :- ly, it creates new CollaboratorAgents and populates the
CollaboratorAgent. ava_l Mon Nov 11 16:25:53 1996 2
48 * group with them (by passing the contructor a reference to the interface) 49
50 * Ssee Agent
51 * Ssee AgentGroup
52 * @author Noemi Paciorsk
5 */
54 public abstract claεr CollaboratorAgent
55 extends Agent 56
57 // Instance- variables
58 protected ec or group .εt; // AgentGr ups this agent belongε to 59
60 // Conεtructorε
61 /**
62 * Constructs a CollaboratorAgent
63 * Sexcept.on IllegalAccessException Whenever called.
64 */
65 protected Col labr vatorAgen ( )
66 throws I l l ecia „Acc<?εεEκo=pt i on { 67
68 System. out . println ( "Default constructor called f r CollaboratorAgent");
69 throw new I 1 egalAcceεsΞxception ( "Col laboratorAgent Default constructor");
70 } 71
72 /**
73 * Constructs a CollaboratorAgent
74 * @param grr-up The AgentGroup to which this Ag°nt belongε.
75 */
76 public Ccl . ahc.rat^r Ag÷_.t (AgentGroup group) ' 77
78 * Store a copy of the agentID in the AgentGroup and save a
79 * reference to the AgentGroup in groupLiεt.
80 */
81 groupList = new Vector ();
82 addGrou (group) ;
83 } 34
35
86 /**
87 * Constructs a CollaboratorAgent
88 * ?param grcups A list of AgentGroupε to which this Agent belongε. 39 */
90 public CollaboratorAgent (Vector groups) {
91 thiε (groups, null);
92 }
93
94
CollaboratorAgent -java_l Mon Nov 11 16:25:53 1996 3
95 /**
96 * Construe ε a Col lsocratorAgent
9 * Θparam groupε A list of AgentGroups to which this Agent belongε.
98 * θparam oidID Th-s unique ID of an agent to be replaced by thiε agent.
99 */
100 public Col -dboratorΛge it (Vector groups, String oldID) {
101 /*
102 * Sa ,r a copy of agentID in each cf the aεsociated AgentGroups and
103 * sto"-- a reference to each AgentGioup in groupLift
104 */
105 groupLiεt r jw Vect irO ,
1C6 for (Enumeration e = groups elements(); e hasMoreElements ( ) ; ) { 107 AgentGroup group = (AgentGroup) nextElement ( ) , i 8 gr-uplist addElement (group) ,
I1'' 9
110 try
111 _f (oldID == null)
112 gr p addAgen (nerf Age- tStatuε (agent ID) ) , .13 "lεe
114 group jpdateAgen (oldID, new AgentStatus (agent ID) ) ,
115 Syεtem cut println ( "Group εi∑e - " ι group σetGroupSi ze ( ) ) ,
116 } catch (Exception ex) {
117 System out println ( "Agent construct cu can't add agent to group " +
118 ε>. g-t,":essage ( ) ) ; 219 System. ou .println ( "AgentID = " + agentID + ", oldID = " + oldID) ,
120 ex pπntStackTrace ( ) .
121 } 122
123 )
U4 }
125 126
1..7 // Finalizc-
±28 protected void finph∑el)
129 throws Thrc.arle { ι30
131 System out cπntln ( " Col laboratorAgent Finalizer called") ;
132
.36 if (grc .lp'oist '= mil) {
137 for .Enumeration e = groupList . elements () ; e .hasMoreElements () ; ) {
138 AgentGroup group = (AgentGroup) e . nextElement () ; 139 try {
140 group re oveAgen (agent TD) ;
141 ) catch (Exception ex) (
CollaboratorAgent. java_l Mon Nov 11 16:25:53 1996 4
142 Syεtem out println ( "Col laboratorAgent finalizer- can't remove agent from group
143 ' ex getMessage ()) ,
144 e>- r --ι-ι StackTrace ( ) ,
145 }
146 }
14 groupL_=t = null // in case finalizer gets called twice (it has been1 )
148 }
149 super linalizeO ,
150 } 151
152 // Instance- nethods
153 /**
154 * Returns a ust of groups the Collaborator gent belongs to
155 * (?return The .ist o*" groups th s CollaboratorAgent belongε to
156 */
157 public final cynchrc-i zed Enumeration getGroupε ( ) {
158 return groupList elements)),
159 } 160
161 /**
162 * Add a group to this agent's groupLiεt and add the agent 163 * to the σioup's agent list 164 * Θparam group The group tc be added 165 */ 166 public sync hromzed void addGroup (AgentGroup group) { 167 grotpL.^t addElement (group) 168 169 try 170 grc addAg - ( iΛ AgentStatuε (agentID) ) 171 Syεtem out pri"1 tin ( "Group εize ( ) ) , 172 cf ter (Exception , x) { 173 Syεtem out pr inzln ( ' Can ' t add agent to group ' + ey getMessage () ) 174 ex Di-i-itStacKTrace ( ) , 175 176 177 178 /'
186 try {
187 gr.,up removeAg- it (agentID) ,
188 } catch (Exception ex) {
CollaboratorAgent. java_l Mon Nov 11 16:25:53 1996 5
189 System out p i^tln ( "Can ' t remove agent from group " + ex getMessage 0) ,
190 ex pr intStackTrace () ,
191 )
192 }
193 194 195 /**
196 * Upcate in agent - citus in all group' it b^lrni*- to
197 * @param status Th= new εtatus
198 */
199 public synchronized oid updateStatuε ( mt status! {
200 if (groupList '= null)
201 for (Enumeration e = groupList elements!) , e hasMoreElements ( ) , ) {
202 AgentGroup group = (AgentGroup) e nextElement () ,
203 try {
204 grouo updateAgent (agent ID, new AgentStatus (agent ID, status)) ,
205 } catch (Exception ex) {
206 System nut print In ( "Col laboratorAgent finalizer can't remove agent from group
207 ex getMesεage ( ) ) ,
208 ex pn itStackTraceO , 209
210 }
211 } 212
213 /**
216 public void preua r-=ForTran?port ( ) {
217 updateStatuε 'AgentΞtat.ε ΪNTRANSIT)
218 } 219
220
221 / * -
222 * Set a- agent •- s atus to ACTIVE after tranεport
223 */
224 public void cc~ipietedTranspcrt ( ) {
225 updateStat„ε (AgentStatus ACTIVE),
226 ) 227
228 }
EventException. ava_l Mon Nov 11 16:26:41 1996 1
1 /* SHeader: /com/mei tca/hsl /zonesjagents/event /EventExcep ion . Java 1 10/14/96 6:55p Noemi $
2 *
3 * Copyright 199c Horizon Systems Laboratory, Mitsubishi Electric
4 * Information Technology Center .America.
5 * All rights reserved. 6
7 * CONFIDENTIAL AND PROPRIETARY PROPERTY OF MITSUBISHI ELECTRIC ITA.
8
9 * DESCRIPTION 10 * Event exceptions 11
12 * SLog : /cort./meitca/hεl/ zonesjagents/event /EventExcept ion . java $ 13
14 * 1 10/14/96 6:55p Noemi
15 * Base class for exceptions generated during event processing.
16 */
17 package com. eitca i-si . zoneεj gents . even ; 18
19 /**
20 * Exceptionε encountered by Events. 21
22 * @see EventType
23 * Sauthor Noemi Paciorek
24 */ 25
26 public class EventException extends Exception { 27
28 // Constructors
29 /**
30 * Constructs an EventException.
31 * Sexception IllegalAccessException Whenever called.
32 */
33 protected EventExcept ion ( I
34 throws 11 l-OJ-.lAccoεεΞ.-.cept i cr. ( 35
36 System. out p intln ( "Defaul constructor called fι-r EventException");
37 throw new IllegalAccessException ( "EventExcep ion Default constructor");
38 } 39
40 /**
4 1 * Cons t r uc t s fi n F'vi -n I [ yc-: -. i on .
42 * taparam tyc e A st r i ng descr ibi ng the except i on .
43 */
44 public EventEx: ept ion (String type) { 45 super (type) ;
46 l 47 }
EventGroup. java_l Men Nov 11 16:?6:41 1996 1
1 /* SHeader- /com/nr-itca/hsl/zc .=s jagents/even /EventGroup ava 1 10/14/96 6:59p Noemi S 2
3 * Copyright 199 f Horizon Systems Laboratory, Mitsubishi Electric
4 * Information Tec nr.o logy Cent, r America
5 * All rights reserved 6
7 * CONFIDENTIAL AXO "'RCPRiπTA"" PFOPF.RTY OF MITSUBISHI ELECTRIC ITA 8
9 * DESCRIPTION
10 * Event Group d stribu ed inti ifac
11
12 * SLog: /cor, "ei tca/hsl /zonesjagents/event 'EventGroup . -java $
13
14 * 1 10/14/96 6.59p Noemi
15 * Event Group interface. 16
17 * I 18
19 package com meitca hs_ z^ne iag^nts event, 20
21 import Java util .'- SuchElementExcept ion ; 22
23 import Java . rmi . Remot ;
24 import Java rmi Remci eException
25 "
26 /**
27 * EventGroup is =ι : "tribated l-'I interface for event croups 28
29 * An EventGroup -r-εiεts f a cioup of objects that v. ; c h 'c receive
30 * events generated by the oth - members of the group The EventGroup
31 * serves aε a gate i?.y between the objects in the group and forwards
32 * events posted tc it to the -r mbers of the group. 33
34 * The members of tr>- group muε- all implement the EventPost interface 35
36 * @see EventGroupImpl
37 * ^author Noemi Faciorek
38 */
40 public interface EventGroup
41 extends Remot-» ,
42
43 /**
44 * Addε a memcer to the event croup.
45 * Spara orrnect An Object that implements the EventPost interface.
46 * @exception i noteExc ept on Tf an error occur ]■- -' t t i cig up network
47 * connections
EventGroup. java_l Mon Nov 11 16: -.6:41 1996 2
48 * Sexception "lassCaεtExceotion If ob3ect does not implement EventPost
49 */
50 public void aάovember (Cb3ec1 ob3ect)
51 throws Remc teFxc=pt ion "laεsCastExcept ion 52
53 /**
54 * Removes a member from tne group
55 * Θparam ob;ect The Object to remove
56 * Sexception Remote >cept _on If an error ticcurr' ccttιng up networl
57 * connections
58 * Sexception n uchElemen Exception If ODJM t is not a member of the group
59 */
60 public void ren-veMe oer (Oo ct object)
61 throws Rer teException, iJoSuchElementException 62
63 }
ZventGroupIn.pl. java_l Mon Nov 11 16:26:41 1996 1
1 /* SHeader- /com, meitca/hsl/zoπas-jagents/event /EventGroupImpl . java 2 10/22/96 7-10p Noemi S
2
3 * Copyright 1996 Horizon Systems Laboratory, Mitsubishi Electric
4 * Information T=~hnology Center America
5 * All rights leserved 6
7 * CONFIDENTIAL AND PROPRIETARY PROPERTY OF MITSUBISHI ELECTRIC ITA
8 *
9 * DESCRIPTION
10 * Event Group distributed obje t
11
12 * SLog I con -e i tc a /hs l / zces j agents , event /EventGroupImpl j ava $
13
14 * 2 10/22/96 "" lOp Noemi
15 * Changed the thr ε claαεe of the poεtEvent method 16
17 * 1 10/14/96 59p Noemi
18 * Event group lmp-ementat on 19
20 */ 21
22 package com ire i tca nsl conesjage- ts e vent ,
23
24
25 import java util *
26 import 3ava io *, 27
28 import ]ava rmi seivi-r
29 import 3ava rmi RemoteException
30 import 3ava rmi Namrg,
31 import 3ava rmi All e=> y3oαndΞ'> -eotion 32
33 import com meitca -si util UniquelD 34
35 /**
36 * EventGroupImpl -ε an R'I disti .tuted object that implementε
37 * Event Group and EventPoεt
38 *
39 * An EventGroup consists of a yrjup of cbjects that wish to receive
40 * events generated by the other members of the group The EventGroup
41 * serves as a gateway between -he objects in the group and forwards
42 * events posted t' i to the members of the group
43 *
44 * The members of the group must all implement the EventPost interface
45 *
46 * @see EventGroup 47 * Sauthor Noemi Pjcυ rek
EventGroupImpl. ava_l Mon Nov 11 lb:26:41 1996 2
48 */
49
50 public class EventGrc^pI p^
51 extends UnicastRemoteServer
52 implemen-s EventGroup Fvent^oεt {
5
54 // Instance
55
56 /** A list of t le group's meTbers */
57 protected Vect r memberList 58
59 // Const-uctor
60 /**
61 * Constructs an ΞventGrouc_-Ol object
62 * Sexception R<=mot=Εxcept_ n If an error occurrs '-etting UD network
63 * connectionε
64 */
65 public EventGroupImpl ( )
66 throws Rer^teExcept ion
67 /*
68 * Create membe1' ' 1st air event queue
69 */
70 memberList - new \ector )
74
75 / FvoηtG-oup " c -
76 /"
77 * Add a me ber t~ the eve-^t grojp
78 * Oparam o„ ect An Object that implements the Eve1tDost interface
79 * no1- molement EventPost
80 */
84 try {
85 EventPost eventPost - (EventPost ) oL ect
86 } catch (C.aεsCaεtExceotion e) {
87 Syεter out pπntlnC . JdMember Object does nof imolement Event Post')
88 throw
89 }
90 memberLi ' L addEl emen t ( obj ^ct )
91 92
93
94 / * *
EventGroupImpl. ava_l Mon Nov 11 16:26:41 1996 3
95 * Remove a member fro;τ the group
96 * Θparam object The Object to remove
97
98
99 p 100 throws NoSuchEleτien tExcept ion { 101
102 if ('memberLi-t re veElement (ob ect ) )
103 throw new NoSuchElementException ( "Object not member of group')
104 } 105 106
107 // EventPost methods
108 /**
109 * Forward an event tc all members of the group
110 * Sparam event The event to oost
111 * FventEx-ept ion I* an error occurs r"s<-ιng the event
112 */
113 public void postLvent (E entType event)
114 throws RemoteExcep ion EventException I0Ξ> ~er " i n { 115
116 for (Enuneratic- e = memberLiεt elements () e hasMoreElements ( ) ) {
117 EventPost event ueue = (EventPoεt)e nextElement () ,
118 eventQueue postEvent (event )
119 }
120 121 122 }
EventHandler . j ava_l Mon Nov 11 16:26:41 1996 1
1 /* SHeader /com/me Ltca/hsl 'zonesjagents/event/EventHandler java 1 10/14/96 6 56p Noemi $
2 3 ** Copyright 1996 Hoπzo-i Systems Laboratory, Mitsubishi Electric
4 * Information Technology Center America
5 * All rights u serveα
7 6 ** CONFIDENTIAL AND PROPRIETARY PROPERTY OF MITSUBISHI ELECTRIC ITA
8 *
9 * DESCRIPTION
10 * Event handler interf ace
11 *
12 * SLog /com/meit a hsl/zoneεjagents/event/EventHandler java $ 13
14 * 1 10/14/96 6 5Sp Noemi
15 * Event handler interface
16 */ 17
18 package com meitca -Si zonesiagents event
19
20 import Java rmi Remcte
21 import java rmi RemcteE ceotion
22
23 /**
24 * EventHandler is a distributed RMI interface for handling events
25 *
26 * "author Noemi "acicek
27 */ 28
29 public interface Even*-Ha idjεr { 30
31 // Instance methods
32 /**
33 * Event handler
34 * θparam event Current event
35 * Θexception F-^-no ,-~xceptιon If an error occurrs setting up network
36 * connections
37 * ©exception Ξve-itExceotion If an error occurs handling the event
38 */
39 public void hardleEvert (Ei/entType event)
40 throws RemoteExceoticn EventException
41 }
42
EventManager. java_l Mon Nov 11 16:26:41 1996 1
1 /* SHeader /com/meitca/hsl/ zonesjagents/event/EventManager Java 2 10/22/96 7 12p Noemi S
2 *
3 * Copyright 1996 Horizon Systems Laboratory, Mitsubishi Electric
4 * Information Teτι ology Center America
5 * All rights reserved s *
7 * CONFIDENTIAL AJΛT PROPRIETARY PROPERTY OF MITSUBISHI ELECTRIC ITA
8 *
9 * DESCRIPTION
10 * Event Manager Int t. fac
11 *
12 * SLog /com/meitca/rεl/ zcreεjagentε/event/EventManager java S 13
14 * 2 10/22/96 7 _2p Noemi
15 * Changed registerEvents and unregisterEvents to take an array of
16 * Strings, rather than an ai-ray of EventType Also changed several of
17 * the throws clauses
18 *
19 * 1 10/14/96 6 58p Noemi
20 * Event Manager interface
21 */ 22
23 package com meitca r=l zonesjagents event 24
25 import java 10 *
26 import java rmi Rer>~te
27 import ava rmi Reir- teΞxcep ion 28
29 /**
30 * EventManager is a distributed RMI interface for event management 31
32 * Θsee EventManager Impl
33 * "author Noemi Pa- orek
34 */ 35
36 public interface EΛ entManager
37 extends Remote { 38 39 // Instance metnods
40 / / Methods useα to regi s ter mtereεt m spec i f ied events
41
EventManager. java_l Mon Nov 11 16:26:41 1996 2
48 * connections
49 */
50 public void registerEvents (String events [] , EventPost eventQueue)
51 throws RemcteExceoticn, IOExcention ;
54 * Reσ —iεter interest 1- receivmc— all events ooεtec to th s Even_tManager
55 * dpararn ever Queue The associated event queue's EventPost interface
56 * ©exception RemoteException If an error occurrs setting up network
57 * connections
58 */
59 public vcid rec sterAll (EventPost eventQueue)
60 tnrowε RemoteException, IOException, 61
62 // Metnods to ur.regiεter events
63 /*"
64 * Remove registration for specified events
65 * Spara evsnts A.-, array cf tne names of events that an ooject
66 * is no longer interested in receiving.
67 * @param evs-tQueue Tne associated event queue's EventPost interface
68 * ©exception RemoteException If an error occurrs setting up network
69 * connections
70 * ©exception EventManagerException If the event queue was not registered
71 * for one or tore of the specified exceptions
72 */
73 public void unregiεterEvents (String events [], EventPost eventQueue)
74 throws RemoteException, IOException, ΞventManagerΞxceoticn ; 75
76 '**
77 * Remove registration for all events.
78 * Sparam eventQueue The associated event queue's EventPost interface.
79 * Sexception RemoteException If a- error occurrs setting up network
80 * connections
81 */
82 puolic void um sg εterA.ll (EventPost eventQueue)
53 throws RemoteException, IOException; 84
85 }
EventManagerException. java_l Mun Nov 11 16:26:41 1996 1
1 /* $Header /com/meitca/hsl/ zones3agents/event/EventManagerExceptιon 3ava 1 10/14/95 6 57p Noemi $
2 *
3 * Copyright 1996 Horizon Systems Laboratory, Mitεubiεhi Electric
4 * Information Technology Certer ^erica
5 * All nghtε reεervec
6
1 * CONFIDENTIAL AND ^ROPFIETARY PROPERTY OF MITSUBISHI ELECTPIC ITA
8
9 * DESCRIPTION
10 * EventManager excec^ιon=- 11
12 * $Log /com/ ι- _ tea/ εl zoneε3agentε/event/EventManagerExceptιon 3ava $ 13
14 * 1 10/1^/96 6 57p Noemi
15 * Exceptions generated by the Event Manager
16 */
17 package com meitca hεl zoneε-agentε event 18
19 /**
20 * Except i ons encoun t ered o\ the EventManager
21 *
22 * @see EventMangei Irol
23 * ©author Noemi Pac orek
24 */ 25
26 public class EventManagerExceotion extends EventException { 27
28 // Constructors
29 /**
30 * Constructs <r>n EventManagerExceotion
31 * ©exception - 1 leqa1 ! cc ^εεEx'-e tion Whenever called
32 */
33 protected EventManagerException ( )
34 throws Il_egalAcceεεΞxceptιon { 35
36 System out println (' Default constructor called for EventManagerException"),
37 throw new I I.egalAcceεεException ( "EventManagerExceotion Default constructor")
38 }
39
40 /**
41 * Constructs an EventManagerException
42 * Θparam type A String describing the exception
43 */ •
44 public EventManagerException (String type) {
45 super (type)
46 }
47 }
EventManagerException. java_l Mon Nov 11 16:26:41 1996
48 49 50
51
EventManagerlmpl. ava_l Mon Nov 11 16:26:42 1996 1
1 /* $Header /com/neitca/hsl/zones3agents/event/EventManagerImpl 3ava 3 10/24/96 4 57p Noemi $
2 *
3 * Copyright 1996 Horizon Systems Laboratory, Mitsubishi Electric
4 * Information Technology Center America
5 * All rights reservec
6 *
7 * CONFIDENTIAL AND PROPRIETARY PROPERTY OF MITSUBISHI ELECTRIC ITA
8 *
9 * DESCRIPTION
10 * Event Manager c_εtrιbated object
11
12 * $Log /com/meitca hsl/ zont =3agents/event/EventManager Impl 3ava $
13
14 * 3 10/24/96 4 57p Noemi
15 * Added support fcr an Event Manager propertieε file and propertieε that
16 * specify if persistence is =~abled and the name of the persistent
17 * εtorage file
18 *
19 * 2 10/22/96 ~ 28p Noemi
20 * Save full and specific event registrations to perεiεtent εtcrage
21 * Constructor reads pers.stent data and reconstructs noti ications
22 * EventManager rercves evert queues that it can t post events to
23 * Changed registerEver ts and unregisterEventε to take an array of String
24 * Made constructor protected and added a main method
25 * Perform cleanup I'-PΓ receiving conflicting registrations (full vε
26 * specific)
27 *
28 * 1 10/14/96 6 58p Nceτι
29 * The Event Managei
30 */ 31
32 package com meitca ^εl zcneεjagents event
33
34 import java util *
35 import ja a io *
36
37 import 3ava rmi server Unicaεt emoteServer
38 import ]ava rmi RemcteE -.cept ,01
39 import ]ava rmi Nan ing ,
40 import 3ava rmi NotBcundExcept ion ,
41 import ]ava rmi Alreadv BoundFx~eptιon
4^2 '
43 import com meitca hs_ zoneεjaqentε εhared *
44
45 import com meitca hεl zoneεjagentε εecurity InsecurityManager 46
47
EventManagerlmpl . j ava_l Mon Nov 11 16 : 26 : 42 1996 2
48 /**
49 * EventManagerlmpl xS an Event Manager that implements the RMI
50 * EventManager and E^entPoεt interfaces
51 *
52 * This class allovε objects to register their interest in receiving
53 * specified events and to ael=te their registrations
55 * Objects Dost events by calling the EventManager s poεtEvent method
56 * (defined by the E^enfo't interface) 57
58 * The EventManager „=; a scntn = l object (l e there is only one
59 * per system 60
61 * @see EventManager
62 * @see EventPost
63 * @εee EventHandler
64 * @see EventManage.. Proxy
65 * @author Noemi "ac_ore>
66 */ 67
68 public clasε Event anager Impl
69 extends UnicastRenoteServer
70 implements EventManager Ξ.enfost { 71
72 // Constants
73 private static __-al Strmc EvENT_MAN^GEP_ AME = EventManager' 74
75 private εtatic :mal String PRODERTIES_DESCFIPTION = Propertieε File for EventManager
76 private εtat-c final Sfiig ENAB E_PEPSISTE CE = EventManager Derεiεtence Enable
77 private static final String PERSISTENCE_FILE = EventManager persistence FileName'
78 // private static final String DEF?ULT_PERSISTENCE_FILE = 'C \ \temp\ \EventManager store
79 private εtatic fmal String DΞFAULT_PΞRSISTENCE_C,ILE = EventManager store 80 81
82 /* IDs for persis e-*" oc-e ts */
83 private εtatic final mt EVΞNT_REGISTRATION_ID = 1
84 private stat.c f.nal mt FJ L_REGISTRATION_ID = 2 85 86 private static .nal li ST RAGE_PADDING = 1024,
89 // Instance variables 90
91 /**
92 * Hash table that maps class names derived from EventType to
93 * registered Eve-ifost stubs
94 */
EventManagerlmpl. java_l Mon Nov 11 16:26:42 1996 3
95 protected Hashtabie eventRagistrations ,
9 976 /** List of EventPost stubs registered to receive all notifications */
98 protected Vector fullRecistrations ,
99
104 */
105 protected Hashtab.e evenlU _ι f icat ιon< 106
107 /** A reference to tmε EventManager ' s persistent store handler */
108 protected PerεistentStoreHandler persiεtenceManager 109
110 /** Name of the persistent storage file */
111 protected String persiεtentStoreFile 112
113 /** The properties file */
114 protected JASProperties properties,
115
116 // Constructors
117 /**
118 * Constructs an EventManager EventManagerlmpl has no public
119 * constructors Applications wishing to utilize the Event Manager's
120 * services must access _t via EventManagerProxy
121 */
122 protected EventManager rn-^1 ( )
123 throws Ξxcec ion { 124
125 /*
126 * Locate oro ertieε file
127 */
128 try
129 properties = new JASProperties (EVΞNT_MANAGER_NAME,
130 JASProperties SERVER, PROPERTIES_DESCRIPTION, false),
131 System cut println ( "EventManagerlmpl Located properties file") 132
133 } catch (Exception e) {
134 System out println ( "EventManagerlmpl Couldn't access Propertieε file for Conduit S
135 System out println (' with defaults ")
136 // Construct an empty Properties object
137 properties = new JASProperties () ,
138 )
139
140 /*
141 * Recover -vent av- fu.l registrations from storage,
EventManagerlmpl. ava_l Mon Nov 11 16:26:42 1996 4
142 * if required Then reconstruct event notif icat lonε
143 */
144 recoverRegiεtrationε ( ) ,
145
146 /*
147 * Register this instance with the RMI registry
148 */
149 try {
150 Naming reomd (EVENT_MANAGER_N<ΛME, this),
151 } catch (Exception e) {
152 System out println ( EventManagerlmpl can't bind " + EVENT_MANAGER_NAME + " " + e getMessage () )
153 e .printStackTrace ( )
154 throw e,
155 }
156 } 157 158
159 // Finalizer
160 /**
161 * Removes the tventManager ' s entry from the RMI registry
162 */
163 protected void -.nalizeO
164 throwε Thro^able {
165
166 System. out println ( "EventManagerlmpl Finalizer called"), 167
168 // Remove this Ξvent'ls l r ' ε Name from the RMI regiεtry
169 try { 170 Naming . unbind ( EVΞKT_KANAGER_NAME ) ,
171 } catch (Exception e) (
172 Syεtem out println ( EventManagerlmpl can't unbind " + e getMessage!) )
173 e printStackTrace ()
174 } 175
176 // Delete reference to Persistent Store Manager
177 persistence!'?, nager = n_ 1, 178
179 super finalize ( . ,
180 } 181 182 183
184 // Instance methods
185
186 // Methods to add event registrations
187 /**
188 * Register interest in receiving specified events
EventManagerlmpl. java_l Mon Nov 11 16:26:42 1996 5
189 * To remove these registrations use
190 * unregisterEvents (EvencType events [] , EventPost eventQueue) 1S1 * clparam events ?-n array of the names of events that an object
192 * is interested in recε.v g
193 * @param eveni Queue The associated event queue's EventPost interface
194 V
195 public synchronised voic regiεterEvents (String eventε[], EventPost eventQueue)
196 throws IOException { 197
1°8 /*
199 * If the event queue nas already regiεtered to receive all
200 * notifications, ignore this request
201 */
202 if ( fullRegistratiorε contains (eventQueue ) )
203 return 204
205 /*
206 * Get the list of e^ rtε the queue has registered
207 * for not- neat ion If the list doeε not exiεt create it
208 */
209 Vector not.fi List = (Vector ) eventNotif icat lonε q=t (eventQueue) ,
210 if (notifyLifct == null) {
211 notιfyLι=t = new vector ()
212 eventNc t i f icatio-ε out (eventQueue , notifyList)
213 }
214
215 for ( t 1 = 0 l < ev≡ntε length 1 +- ;
216 String eventName = jventε[ι],
217 System out pnntl-( re iεterEventε event = ' * eventName) 218
219 /*
220 * Add ev t t - the σ„eue ε list of registered events
221 */
222 if ('n.tifyLiεt containε (eventName) ) {
223 Syεtem out pr ι- tin ( ' registerEventε adding event name to notify list"),
224 notnyList aαoΞlement ( eventName) ,
225 } 226
227 /*
228 * Look up the event name in the eventRegistrations hash table
229 * and add the queue to the list of regiεtered Objects for the event
230 */ '
231 Vector registryList = (Vector • eventRegiεtrat i onε qet (eventName) ,
232 if (registryList == null) {
233 regιεtryL_εt = new Vector (),
234 eventRegistrations put (eventName, registryl ist ) ,
235 System out pi m In (' registerEventε , adding pvnnt queue to registry lι*-t')
EventManagerlmpl. java_l Mon Kov 11 16:26:42 1996 6
236 registrvL.εt εddElement (eventQueue) ,
237
238 } else if ('registryList contains (eventQueue) ) {
239 Syεtem out println (" registerEvents, adding event queue to registry list')
240 regiεtrvL ct c odElement (eventQueue)
241 }
242 }
243 /*
244 * Write the ~ooated e.°ntRegιstratιons table to
245 * persistent storage
246 */
247 updateEventReg.strations ( )
248 } 249
250
251 /**
252 * Register interest receiving all events posted tc thiε EventManager
253 * To remove the== reg.str jtions use
254 * unregiεterAl. lEventPcs*- eventQueue)
255 * @param evntQueue Pn= associated event queue s EventPost interface
256 */
257 publ ic synchronize: JΌ I O =cι ε terAl 1 ( EventPoε t <=ventQueue )
258 throws IOEx-eot ion {
259
260 System out prι"tln( reg_sterAll ' ) 261
262 /*
263 * If this event queue already registered to receive
264 * specific l egistratio is remove them
265 */
266 if ( (Vector) eventNot . r ications get (eventQueue) '= null)
267 unreg. s ti rAl l ( ev entQueue ) 268
269 /*
270 * If the event queue nds already been registered for
271 * all notifications ignore this request
272 * Otherwise add t e q_.eue the the list of full registrations
273 */
274 if ( ' fullRegiεtrations contains (eventQueue) ) {
275 System out println) regiεterAll, adding event queue to full registrations')
276 fullRegistrationε audElement (eventQueue)
277 /*
278 * Write the updated fullRegiεtrations list to
279 perε_stent εtorage
280 */
281 updateF_llRegιεtrat-onε ()
282 }
EventManagerlmpl. java_l Mon Nov 11 16:26:42 1996
283 } 284
285
286 // Methodε to r-nove registrations
287
288 /**
289 * Remove registration for specified events
290 * Sparam events An array of the names of events that an object
291 * is no longer interested in receiving
292 * @param eventQueue The associated event queue's EventPost interface
293 * Sexception EventManagerException If the event queue was not registered
294 * for one or rore of the specified exceptions
295 */
296 public synchronized voiα unregisterEvents (String events [] , EventPost eventQueue)
297 throws EventManagerException, IOException { 298
299 /*
300 * Get the ..st of events the queue has registered
301 * for rot.ticatior
302 */
303 Vector = ( "ector ) eventNotif ications get (eventQueue) ,
304 if (notifyLiεt == null)
305 throw r=w EventKa "lagerException ( "Bad event queue");
306
307 for (mt l = 0, l < events length ι ++) {
308 String eventName = events [l],
309 Syεtem cut pπ-tl- ( "unreg.sterEvents event = ' + eventName), 310
311 /*
312 * Remote tne event from the queue ' ε list of regiεtered events
313 */
314 System out println ( "unregisterEvents, removing event name from notify list"),
315 notifyL.εt re-ioveElement (eventName) 316
317 /*
318 * Look up tne event name in the eventRegiεtrations hash table
319 * and remove the queue from the list of registered Objects for
320 * the event. If tne list is empty, remove the event's hash
321 * table entry
322 */
323 Vector registryList = (Vector ) eventRegistrat ions get (eventName) ;
324 if (registryL.st == null)
325 throw new EventManagerException ( "Bad event"),
326
327 System. cut println ( "unregisterEvents, removing event queue from registry list"),
328 registrvLiεt rerroveElement (eventQueue) , 329
EventManagerlmpl . java_l Mon Nov 11 16:26:42 1996 8
330 if (registryList . isEmptyO ) {
331 System out println ( "unregisterEvents , removing hash table entry for event " + eventName);
3 2 eve-itRegistrations remove (eventName) ,
333 }
334 } 335
336 /*
33 * Write t e updatec eventRegistrations table to
338 * perεiεte-t storage
339 */
340 updateEventRegiεtratlons ( ) 341
342 /*
343 * If the queue's list of registered events is empty, remove
344 * the queue's naεr t ole entry
345 */
346 if (notify iεt ()) {
347 System ou . printl ( "unregisterEvents , removing event queue's hash table entry"),
348 eventKot l f icaticrε remove (eventQueue) ;
349 }
350 }
356 * This method is often called by finalizerε, εo it ignores errors
357 */
358 public synchronized VCJC I nregiεterAl 1 (EventPost eventQueue) 359 throws IOE> ceDt-or {
360
361 if ( ullRegiεtrat icns contains (eventQueue) ) {
362 /*
363 * If the event queue was registered to receive all registrations,
364 * remove it from the ful iRegiεtrat ions hash table
365 */
366 Syεtem cut pr tlr ( "unregiεterAll , removing full registration");
367 fullRegι=*-ratιons removeElement (eventQueue) ,
368 369
370 * Write the updated fullRegistrations list to
371 * persistent storage
372 */
373 updateFullRegiεtrationε ( ) ,
374 } else {
375 /*
376 * Locate the queue's list of registered events
EventManagerlmpl. java_l Mon Nov 11 16:26:42 1996 9
377 */
3 8 Vector rotifyL st = (Vector ) eventNotifications get (eventQueue) ,
379 if (nctilyList == null)
380 return 381
382 Syste"- out Dπntlnf unregisterAll , removing event registrations' ) ,
383
384 for (Enumeration e = notifyLiεt elements (), e hasMoreElements () , ) {
385 String eventName = (String)0 nextElement ( )
386 v stern out pr l ~ tin ( ' nregiεterAl 1 , event - + eventName) 387
388 vector registryList = (Vector ) eventRegiεtrations ge (eventName) ;
389 if (registryList == null)
390 continue
391 / "
392 For each event in the list, remove the queue from the
393 * event's list of registered Objectε
394 " If the lιs_ lε empty remove the event s hash table entry
395 '/
396 System out prntln ( "removing event queue from registry list")
397 registryList removeElement (eventQueue)
398 if (registryList isEmptyO) { 399 Syεtem out println ( ' unregisterAll, removing hash table entry for event " + eventName),
400 eventRegiStrations remove (eventName)
401 registryList = null, 402
403 >
404
405 /*
406 * V te the uodated eventRegiStrations table to
407 * poisiεtent storage
408 */
411 /*
412 * Re~cve the event queue ε haεn table entry
413 */
414 Syster out println ( "unregisterAll, removing event queue'ε hash table entry"),
415 eventϊ*ct.ιfications remove (eventQueue) ,
416 }
417 }
418
419
420 // Methods tc post events and send notifications
421
422 /**
423 * Notify ob__ctε tnat an event occurred (EventPost interface)
EventManagerlmpl. java_l Mon Nov 11 16:26:42 1996 10
424 * ©param event Event eing posted.
425 * ©exception EventException If an error occurs posting the event.
426 */
427 public synchronized void postEvent (EventType event)
428 throws ReϊoteException, EventException, IOException {
429
430 System out println ( "EventManager , posting event"),
431 /*
432 * Handle specific registrations for this event Locate this event'?
433 * entry m the eventRegiStrations hash table and post the event to
434 * each ot the event queues on .ts hash chain
435 */
436 String eventName = event getClass (). getName () ;
437 System out println ( "postEvent , event = " + eventName) , 438
439 Syεtem out p intln ( "o: εtEvent , checking specific registrations.");
440
441 /*
442 * Post tr.- event to t-3 event queues registered to
443 * receive it
444 */
445 Vector b dEventRegiε ra lonε = new Vector!) , 446
447 Vector regiεtryList = (Vector ) eventRegiStrations get (eventName) ;
448 if (regiεtryLiεt '= null) {
449 Syεtet out .println (" registryList contains " + registryList . εize ( ) +
450 ' elements"! 451
452 ' - (Enumeration e = registryList elements (), e . hasMoreEle entε ( ) , ) {
453 EventPost eventQueue = (EventPcεt)e nextElemen ( > , 454
455 System tut pr tln ( "Pcst g event' .,
456
457 try {
458 eve-t jeue poεtEv?rt(eve"tl ,
459 ; catch (Exception e2) {
460 System out .prmtln ( "Event post failed");
461 badF --- tRegistrations addElement (eventQueue) ;
462 >
463 }
464 }
465
466 /*
467 * Post the event to all Objects that have requested notification
468 * of. ll events
469 */
470 SysteT out print In ( 'postEvent , checking full registrations").
EventManagerlmpl . ava_l Mon Nov 11 16 : 26 : 42 1996 11
4 1 System out print l i ( ' fu l lRegistrations contains " + ful lRegistrations size d +
472 " elements" )
473 4-74 Vector oadFullRegiεtrations = new Vector () 4-75 for (Frumerat.cn e = fullRegistrations elements (), e hasMoreElements () , ) { 4-75 EventPost eventQueue = (EventPost) e nextElement ( )
4/7
4 8 Syεtem out prir -In ( 'Posting event')
479 try <
480 eventQueue postEvent (event )
481 ) catrn (Exception e3 ) {
482 System cut println ( "Event post failed'),
483 badFullRegiεtrations addElement (eventQueue) ,
484 }
485 } 486
487 /*
488 * If the EventManager was unable to contact any event queues,
489 * remove them from eventRegiStrations and/or fullRegistrations
490 * and update the a~fected reσiεtrationε in perεiεtent εtorage
491 */ "
492 if ( ' badEventRegistre -ions isEmptyO) {
493 for (Enumeration e = badEventRegiεtrationε elements)), e hasMoreElements ( ) ) {
494 EventPost eventQueue = (EventPoεt)e nextElement ( )
495 Syεtem out pr tln ( "Removing bad event queue from registry list"),
496 registryList removeElement (eventQueue) ,
497 }
498 updateEv«P ι. = g. sf i-≤tions O
499 )
500 badEλ =ntF r.st = '- ι r— s - null 501
502 if ( l±F°ι is"ra- 1 ~ c- icEmotyO) {
503 for Enuπeratic- e = badPullRigiεtra t ions elements)), e hasMoreElements ( ) ) {
504 EventPcεt eventQueue = (EventPost)e ne> tElement ( )
505 Syεtem cut pr tln (' Removing bac event αueue from full list'),
506 f l eoi = trationε rerroveElem=τ t (e\ entQueue) 507
508 upda-εFu_iRegι=t-atιons ( )
509 }
510 badFullRegiεtrations = null, 511
512 } 513
514
515 // Methods to handle persistence
516
517 /**
EventManagerlmpl. java_l Mon No\ 11 16:26:42 1996 12
518 * Allocate a persistent store manager and restore
519 * eventRegiStrations ana fullRegistrations (If they
520 * don't exist in the persistent store, instantiate
521 * new ones.) Tnen reconstruct eventNotif ications from
522 * eventRegiStrations
525
526 Boolean erab.ed = new Eoolean (qetProper tv (ENΛBLE_PERSISTENCE, false )),
527 if ('enables booleanValue ( ) ) {
528 /*
529 * If persistence is disabled perform initialization,
530 * but net rec-very
531
532 System cut crirtli ( recoverRegistrations persistence disabled )
533 persiεtentStoreFile = ' ",
534 persiεtenceManager = null
535 eventRegiStrations = nee Hashtable ()
536 fullReciεtrations = new \ector(),
537 eventKc t i f icat lens = new Faεhtable()
538 return
539 540
541 Syεtem o_t prmtln ( Persistence enabled ' )
542 persistentStoreFlle = getProperty (PERSISTENCE_FILE, " ),
543 System out pri- tin (' EventManager persistence FileName property set to " persistentStoreF 544
545 /*
546 * If no file is specified use the default
547 *
548 if length)) == 0)
549 persistentStoreFlle = AgentConstants AGENT_DIR + DEFAULT_PERSIΞTENCE_FILE
550 System out o__nι_m( Perε.εtert Store File + perεiεtentStoreFile) 551
552 persistence m? ' - n= rκ=rειstentStoreHandler (pei «- istentStoi eFile) 553
554 /*
555 * Fetch registrations from the persistent store If they don't exist,
556 * instantiate e/ertRogistrations and fullRegistrations
557 */
558 System out prmtln ( eventRegiStrations )
559 if ( (eventRegiStrati
560 (Hashtable) perεistenceManager fetchObject (EVENT_REGISTRATION_ID) ) == null)
561 eventRegiStrations = new Hashtable () ,
562
563 System out println) Fetching fullRegistrations')
564 if ((fullRegistrations =
EventManagerlmpl. java_l Mon Nov 11 16:26:42 1996 13
565 (Vector)persιstenceManager fetchObject (FULL_REGISTRATION_ID) ) == null)
566 fullReg.straticns = new Vector!) 567
568 /*
569 * Reconstruct the e e-1: no ifications using event registrations Then
D70 * truncate t e oers,: ^nt store and write out the registrations
571 */
572 Syεtem out r..rtln ( ' 'e-onrtr.rtim ev n notifications')
573 reconstruct' oti fir? t ions ( ) 574
575 System out println (' Sa ing registrations')
576 saveRegistrations ( )
577 }
579
580 /**
581 * Truncate persistent storage and ur.te out event and full
582 * regiεtraticr s
583 */
584 protected void saveRegistrations ( ) {
585 if (persiεtence anaσe" == null)
586 return
587
588 perεistenceManager truncateFileStore ( )
589 persistenceManager msertOb] ect (E,/ΞNT_REGISTRATION_ID,
590 eventRegiStrations STORAGE_PADDING) ,
591 persistenceManager insertObject
592 fullReσ_stratιcnε STORAGE_PADDING)
593 } 594
595
596 /**
597 * Update even^ reqiεtr? t ions m persistent storage
598 */
599 protected void updateEventRegiεtrations ( ) {
600 if (persistenceManager == null)
601 retur-
602
603 System out prmtln (' Updating eventRegiStrations")
604 persistenceManager updateObject (EVENT_REGISTRATION_ID, eventRegiStrations),
605 }
606
607 608
609 * Update full registrations in persistent storage
610 */
611 protected void uιodateFu l lR-=g ιs trat i ons ( ) {
EventManagerlmpl . ava_l Mon No 11 16 : 26 : 42 1996 14
612 if (persisterce anage; == null)
613 return
614
615 System out pr_πtln( Updating fullRegistrations'),
616 persistenceManager updateObject (FULL_REGISTRATION_ID, fullRegistrations),
617 ) 618 619
620 /**
621 * Reconstruct the event noti ica ion^ table from tb«
622 * event regie traticnε table
623 */
624 protected vo d leconstruct otif ications ( ) {
625 eventNotif icatiopε = new Hashtable)), 626
627 if (persistenceManager == null)
628 retuπ 629
630 /*
631 * Reconεtruct the eventNotif ications haεh table βy walking
632 * the EventRegis-rat.onε haεh table and extracting registrations
633 */
634 for cEnumeration registryKeyε = eventRegiStrations keys ( ) ,
635 regiεtryKeyε nasMoreElements ( ) ) { 636
637 /
638 * For each k°j, (event name! in the table obtain the list of
639 * regiεtered evert σueue^ 540 */
641 String eventName = (String) registryXeyε nextElement ( )
542 Syεtem out on n~lr- (' reconεtructNotifications , event = " + eventName),
-43 Vector recistryL εt = (Vector ) ventRegiStrations get (eventName)
544
645 /*
546 * If no objects have regiεtered to receive this event
547 * re-cve it from the eventRegiStrations hash table
648 */
649 if ( (.registryList == null) | | (registryList lsEmoty)))) {
650 Syεtem out crintlnf reconεtructNotif ications , removing haεh table entry for event ' + event 551 eventRegiStrations remove (eventName) ,
652 cont inue
653 }
554
555 / '
>56 * Add the event name to the eventNotif ications entry of
557 * each of the registered event queues, creatmq ha=-h table
558 * entries as necessary
EventManagerlmpl. java_l Mon Kov 11 16:26:42 1996 15
559 */
560 for (Enumeration regiεtryElements = registryList elements)),
561 reg-str Fleme^tε hasMoreElements ( ) ) {
664 Vector notιf_n.ιst = (Vector ) ever tNot if ic? t: onε get (eventQueue) ,
665 if (rotifyList == null) {
666 not fyLiεt = new Vector ( )
667 eventNotif ications put (eventQueue , notifyList),
668 System o_t onntln( reconεtructNoti icat lonε , created eventNotif ications haεh table ent
669 }
670 notifyLiεt addElement (eventName)
671 }
672 } 573 }
674
575 // Miεc metho ε
576 /** Returns th= EventManager ε name */
577 protected εtat'c String cetEventManagerName ( ) {
678 return EVENI _ιAN<\GEP„NAS
679 } 580 681
682 /** Returns the value cf a oroperty */ 583 protected String getProperty (String key, String det) {
684 ret.-i properties getProperty (key def)
685 } 586
687 // Mam methoo
588 /**
589 * EventManagerlmpl Dcctε-rarj Thiε is the only way to start
590 * the EventManaαβπ. Sι"ce it haε no public constructors
591 */
592 public εtat-c void mainiStnng args [ ] ) {
593 System setSe -_r_ tyManager (nev. Insecurity Manager ()) , 594 try {
595 EventFanagerlmtj e^ntManager = nevi EventManager Imol ( )
596 } catch (Exception e; {
597 System out omtln("An exception occurred setting up the EventManager ' + 698 e getMessage))),
599 e printStackTrace () 700
701 )
702
703 }
704
705
EventManagerProxy. java_l Mon Noir 11 16:26:42 1996 1
1 /* $Header: /co-./meitca/hsl/ zonesjagents/event/EventManagerProxy . Java 1 10/22/96 7:30p Noemi $ 2
3 * Copyright 1996 Horizon Systems Laboratory, Mitsubishi Electric
4 * Information Technology Center America
5 * All rights reserved 6
7 * CONFIDENTIAL AND PROPRIETARY PROPERTY OF MITSUBISHI ELECTRIC ITA 8
9 * DESCRIPTION
10 * A client proxy fcr tne Fvc itManager
11
12 * SLog • /com/meitca/hsl/ zcneε3agentε/event /EventManagerProxy 3ava $
13
14 * 1 10/22/96 " 3Cp Noemi
15 * EventManagerProxy lε tne puclic interface to the EventManager It
16 * εhields users from the effects of EventManager crashes
17 */ 18
19 package com.meitca hεl zcnes3= entε event, 20
23 import 3ava rmi RemoteException,
24 import nava.rmi Naming,
25 import Java rmi Remote;
26 '
27
28 /**
29 * EventManagerProxy is the ouclic interface to the EventManager As a
30 * proxy for the Event *>'anac r, it maintains a reference to the actual
31 * Event Manager and sh eldε users from the effects of Event Manager
32 * crashes. Whenever the proxy fails to communicate with the Event Manager
33 * it attempts to re-establish a connection to it 34
35 * @see EventManager
36 * @see EventManagerIrol
37 * Sauthor Noemi Pactcrek
38 */
39
40 public class EventManagerProxy {
4 421 // Constants
43 protected static final int DEFAULT_RETRIEΞ = 2;
44 protected static final long DEFAULT TIMEOUT = 10000,
45
46
47 // Instance variables
EventManagerProxy. java_l Mon Nov 11 16:26:42 1996 2
48 /** Stub for EventManagerlmpl ' s EventManager interface */
49 protected EventManager eveitManager
50
51 /** Stub for EventManagerI ppl ' s EventPost interface */
52 protected EventPost eventPost
53
54 / * * The Even ^ma gerlmpl s name * /
55 protected St _ g even tManac erName 56
57 /**
58 * The number cf times to retry when an invocation
59 * on the EventManager fails
60 */
61 mt retrieε 62
63 /** The timeout per_oα n -s for requests to the EventManager */
64 long timeout 65
66
67 // Constructors
68 /**
69 * Construct'' ~n TventMa^acerProxy
70 */
71 public EventMaragerProxv ( )
72 throws Eiceotion { 73
74 this (DEFAULT RET^IFS EE~AULT_TIMEOUT)
75 } 76
77
78 I * *
79 * Constructs an EventManaσerProxv
80 * Sparam retries The nαtoer of timeε to retry if an operation fails
81 */
82 public EventKanacerProxy ( I"- 1 retries)
83 thro s E> section { 84
85 this (retries DEFAULT TIMEOUT)
37 88
89 /**
90 * Constructs an EventManagerProxy
91 * @param timeout The time to wait in ms between retries
92 */
93 public EventMaragerProxy ( long timeout)
94 throws Exception {
EventManagerProxy . j ava_l Mon Lvlov 11 16 : 26 : 42 1996
95
96 this (DEFAULT_RETRIES timeout),
97 } 98
99 100 /**
101 * Constructs, an EventManagerProxy
102 * @param retries The n^oer of times to retry if an operation fails
103 * @param t_meout The t-re to wait in mε between retries
104 */
105 public EventManagerProxy ( j-t retries long timeout)
106 throws Exception { 107
108 this retr.es = (retries >= 0) > retries DEFAULT_RETRIES
109 this timeo.t = (timeout > 0 ) ' timeout DEFAULT_TIMEOUT 110
111 /*
112 * Lookup the EventManager
113 */ "
114 initialize))
115 } 116 117
118 // Instance r ethcds
119 /*
120 * Lookup the Event Manager in the RMI registry and obtain a
121 * stub for _t= E entManager and EventPost interfaces
122 */
123 private void _mtιalιze ( )
124 throws Exception { 125
125 eventManagerNarre = Even-Manaaerlm.pl getEventMa^agerName ( *
127 try {
128 Remote εtuo = λamng lookup (eventManagerName)
129 eventManaσer = (EventManager ) εtub
130 eventPost = (EventPost ) εtub
131 } catch 'Exception e) {
132 Syεta- out prmtln (' initialize error looking up EventManager
133 - e getMessage ()) ,
134 e printStackTrace ( )
135 throw e,
136 }
137 }
138
"39
140 /*
141 * Block for the timeout i-terval Then look up the
EventManagerProxy. j ava_l Mon Nov 11 16:26:42 1996
142 * EventManaσ=r
143 */ 144 private void waitAndlnitialize ( ) 145 throws Exception { 146 147 synchron-zed ( this ) { 148 try { 149 this wait i timeout) , 150 } catch ( InterruptedException e) { } 151 } 152 initialize I ) . 153 } 154 155 /* 155 * Convert the evert class names to strings 157 */ 158 private Strin r] eventKametoStπng (Event ype [ ] eventε) { 159 160 int length = events length, 161 String evertrameεP = new String [ length ] 162 for (int 1 = 0, ι -v. ^ength, ι++) { 163 eventKaiτts [ l] = events[ι] getClassO getName ( ) 164 System out print In (" eventNametoStr mg , event = -J- eventNameε [ l ] ) 165 } 166 return e\ er Nameε 167 158 169 170 171 // Methodε to nardle rec iεtratmns 172 173 174 * Register _ιterεst receiving εoecified eventε 175 * Sparam events An array of eventε an obnect lε _nterested in receiving 176 * Sparam t -/entQueue The associated event queue's EvertPost interface 177 * RemoteException If an error cccurrs sett_ng up network 178 * connectionε 179 * Sexception lOExceotien If the tranport layer generates one 180 */ 181 public void registerEverts (EventType events [] , EventPost eventQueue) 182 throws Exception { 183 184 r 185 * Convert the event class names to strings 186 * Then invoke the EventManager ' s registerEvents 187 * method and retry the operation, if necessary 188 */
EventManagerProxy. java_l Mon Nov 11 16:26:42 1996 5
189 String eventNames L ] = eventNametoStnng (events)
190 for (int ^ = 0 i <= retries ι++) {
191 try <
192 eventManager registerEvents (eventNames eventQueue)
193 return
194 ] catch (RemoteException el) {
195 if (i =" ret jes) {
196 System cu- prmtln (' registerEvents Throwing RemoteException'),
197 throw el
198 )
199 Sytem out prmtln (' registerEvents Caught RemoteException')
200 ; catch (IOExceotion e2) {
201 if d == retries) {
202 cystem cut prmtln (' registerEventε Throwing IOException')
203 ι hrow e2
204 }
205 S =ten out t_ rtln( registerEvents Cauαht IOException' )
206 }
207 /*
208 * Block ιθr t1-- timeout interval Then look up the
209 * EventManager before retrying the operation
210 */
211 waιtA^cInιtιa_ιz=: ( )
212 }
213 ) 214
215
216 /**
217 * Register interest m receiving all eventε posted to this EventManager
218 * Θparam ev-τtQueje Tne associated event queue ε EventPoεt interface
219 * ©exception RemoteException If an error occurrs setting up network
220 * connections
221 * ©exception IOExceot_on If the tranport layer generates one
222 */
223 public void reαiεte All I Ex entDoεt eventQueue)
224 throws Excecticn { 225
226 /*
227 * Invoke tne EventManager ' ε regiεterAll
228 * method ard retry the operation, if necessary
229 */
230 for (int _ = 0 l <= retries ι++) {
231 try {
232 ev/entManager regis terAl l ( eventQueue )
233 return
234 } catch (RemoteException el) {
235 if (l == retries) {
EventManagerProxy. java_l Mon 'Jov 11 16:26:42 1996 6
236 System out prmtln (" registerAll Throwing RemoteException"),
237 t ire,) el
238 }
239 Syεte.n out prmtln ( ' egisterAl l Caught RemoteException ' ) ,
243 throw e2
244 }
245 System out p_ i ntln ( ' rpqi ε terAl 1 Cauqht IOException")
246 }
247 /*
248 * Block for the timeout interval Then look up the
249 * EventManager, before retrying the operation
250 */
251 waitAndli i ialize ( )
252 }
253 } 254
255
256 // Methods to jn-egister events
257 /**
258 * Remove registration for specified eventε
259 * Sparam eventε An array of eventε an ob3ect is interested in receiving
260 * Sparam ev=ntQueue Tne aεεociated event queue's EventPoεt interface
261 * Sexception emo'-eΞxctptιon If an error occurrε setting up network
262 * connections
253 * Sexception Ev>nt aracerEyceptιon If the erent σueue was not registered
264 * for one or mere of the SDecified exceptions
265 * Sexception "Orλc°ptιcn If the tranport layer generates one 256 */
267 public void unregisterEvents (EventType events[], EventPoεt eventQueue)
268 throws Excεcr.on { 269
270 /*
271 * Convert the event clasε nameε to strings
272 * Then ιnvoka tne EventManager ' s registerEventε
273 * method a-α retry the operation, if necessary
274 */ '
275 String eventNames [] = eventNametoStrmg (events )
276 for (int l = 0 i <= retries, ι++) {
277 try {
278 eventManager unregisterEvents (eventNames , eventQueue) ,
279 return,
280 } catch (RemoteException el) {
281 if (- == ret-mε) {
282 System out print In (' unregisterEvents Throwing RemoteException')
EventManagerProxy. ava_l Mon Nov 11 16:26:42 1996 7
283 throw el
284 "
285 Syεtem out prmtln (' unregi sterEvents Caught RemoteException")
286 } catch (IOException e2) {
287 -f (i == retries) {
288 Syεtem out println) unregisterEvents Throwing IOException' ) 289 throw e2
290 '
291 Syεtem out prmtln ( unregiεterE/entε Caught IOException' )
292 }
293 /*
294 * BICC for the timeout interval Then look up the
295 * E\ ertf'anager , before retrying the operation
296 */
297 waitAnd- itialize ( ) ,
298 }
299 }
300 301 302 /
303 * Remove registration f^r all eventε
304 * θparam evie-itQue The aεεociated event αueue'ε EventPoεt interface
305 * This method is often called by finalizers so it does not
306 * propagate a-iy errorε
307 */
308 public void u-'egis terAl 1 (EιΛentDoεt e' (
309 /*
310 * Invoke tne Ev=rt'""anaαer s registerAll
311 * method a^o retry the operation if neceεεary
312 */
313 for ( t _ = D l <= retrieε ι ++) {
314 trv i
315 eventManager unregiεterAll (eventQueue)
317 } catch (RemoteException el) {
318 Syεtem out prmtln ( "unregisterAll Caught RemoteException' ) ,
319 } catch (IOException e2) {
320 System out prmtln ( "unregisterAll Caught IOException' ) ,
321 }
322 /*
323 * B-Ock for the timeout interval Then look up the
324 * EventManager, before retrying the operation
325 */
526 try {
327 waitAndlmtializeO ,
328 } eaten (Exception e3 ) {
329 System out println (' waitAndlnitialize failed )
EventManagerProxy. java_l Mon Nov 11 16:26:42 1996
330 }
331 }
332 }
333
334
335 // Methods to post e/ents
335
337 /**
338 * Event notification interface
339 * θparam event The event to post
340 * Sexception RemoteExceotion If an error occurrε setting up network
341 * connections
342 * Sexception EventException If an error occurs posting the event
343 * Sexception If the tranport layer generates one
344 */
345 public void postEvent (L a" tType event) 345 throws E>ceotj.on {
347 /*
348 * Invoke the EventManager ' s eventPost 3 -a 9 * methc 1 and retry the operation if necessary
350 */
351 for (int _ = 0 i <-= retries ι^+) {
352 try <
353 eventPoεt postEvent (event )
354 retu_n
355 } catch (RemoteException el) {
356 f (l == retries) {
357 System c_t orintlrl ostEvent Throwing RemoteExceotion')
359 ^
360 System out println ( oostΞ,ent Caught RemoteException )
361 } catch (τOΞxceotιm e2)
362 f (l == ret.mε) {
363 Syεtem c_t orintlnl postEvent throw c lOExceot ion' )
365 }
366 Syεtem out prmtln ( postEvent Caught lOExceotion' ) 367 }
368 /*
369 * Block for the timeout interval Then look up the
370 * Eλ'entMdnager before retrying the operation
371 */
372 waitnrdlritialize ( )
373 }
374 )
375 } 376
> o z a o s
o μ o> S
S u c
> w EventPost. java_l Mon Nov l 16:26:42 1996 1
1 /* SHeader /com/meitca/hsi zcneεnagentε/event/EventPoεt 3ava 2 10/22/96 7 lOp Noemi $
2 *
3 * Copyright 1996 Horizon Systems Laboratory Mitsubishi Electric
4 * Information Technology' Center America
5 * All rights rescrveα 6
7 * CONFIDENTIAL AND PROPR'ET^Y PROPERTY OF MITSUBISHI ELECTRIC ITA
8
9 * DESCRIPTION 10 * Interface for event notui ation 11
12 * $Log /com/me_tca hsl /zcnes agentε/event/EventPoεt ]ava $ 13
14 * 2 10/22/96 n Op Noemi
15 * Changed the th^c v clause of the postEvent method 15
17 * 1 10/14/96 6 5^p Noemi
18 * Interface used f^ c st o = cents
19 */
23 import nava io *
24
25 import 3ava rmi Remote
26 import nava rmi Re' -t^Ex-ep i ~ ~ 27
28 /**
29 * EventPost lε a _ st^but- "UJI interface for notification of eventε 30
31 * Sauthor Noemi "eci-re
32 */ 33
34 public interface '-i-'Piit
35 extends Remote 36
37 // Instance methods
38 /**
39 * Event notificat oi interface 40 * Spara evert The event to poεt
41 * Sexception RemoteΞxceo" ion If an error occurrs setting up network
42 * connections
43 * Sexceotion E^entExceotion If an error occurs poεting the event
44 */
45 public void poεtEvent (EventType event)
46 throws RemoteException EventException IOException 47
WO 98/21662 - 2 £~ - PCT/US97/20232
> o '_. c o
E
EventQueuelmpl. java_l Mon Nov 11 16:26:42 1996 1
1 /* $Header /com/me tca/hsl /zonesnagentε/event/EventQueuelmpl ava 1 10/14/96 6 58p Noemi $
2 *
3 * Copyright 1996 horizon Systems Laboratory, Mitsubishi Electric
4 * Information Technology Center America
5 * All rights reserved
6 *
7 * CONFIDENTIAL AND
8
9 * DESCRIPTION
1 0 * Event queue d i ε t l u ted bτ ~
11
12 * SLog /com/meιtca/h=l/zores lagents/event/EventQueuel pl 3ava $
13
14 * 1 10/14/96 6 58p Noemi
15 * Event queue implementation
16 */ 17
18 package com meitca hε_ zcneε-iagentε event 19
20 import nava uti] *
21
22 import 3ava rmi server Uncast;-ιnteServer
23 import ]ava rmi
24 import java rmi
25 import ]ava rmi NotSoundExcep ion
26
27 /**
28 * EventQueuelrmol is ?n event iieue that implemen ^ the FMI
29 * EventPoεt mter_ = ce
30 *
31 * Event notification lε performed by appending an event to the queue
32 * Each queue has an associated EventQueueThread started by the constructor
33 * The thread dequeu s everts ai calls their handlers 34
35 * θsee EventQueueThread
36 * Ssee EventPost
37 * Sauthor Noemi c cιorek
38 * /
39
40 publ ic class EventQueuelmpl
41 extends UmcastRemoteServer
42 implements EventPos1- {
43
44 // Instance variables
45 /** The event σueue */
46 protected Vectci eventQueue 47
EventQuauelmpl. java_l Mon Nov 11 16:26:42 1996 2
48 /** The thread that manages this queue */
49 protected EventQueueThread queueThread; 50
51 // Constructors
52 /**
53 * Protected De f au l t Cons tru ' tor f or EventQueuelmpl
54 * ©exception IllegalAccessException Wn^never called
55 */
56 protected EventQueuelmpl ( )
57 throws RemoteException, IllegalAccessException { 58
59 Syεtem out prmtln ( "De ult constructor called for EventQueuelmpl"),
60 throw new IllegalAcceεsException ( "EventQueuelmpl default constructor"); 51 }
52
63 /**
64 * Constructs an EventQueuelmpl
65 * βparam hardier An EventHandler interface
66 */
67 public EventQueuelmpl (EventHandler handler)
68 throws RemoteException v
69 eventQueue = new Vector ();
70 queueThread = new EventQueueThread ( this , handler),
71 )
72
73 /**
74 * Constructs an EventQueuelmpl
75 * θparam handler An Ξve-tHandler interface π β * θparam timeout The tint m ms to wait between consecutive queue
77 * examinations
78 */
79 public EventQueuelmpl (EventHandler handler, long timeout)
80 throws RemoteExceptio*-
81 eventQueue = new Vector!) ;
82 queueThread = new EventQueueThread ( this , handler, timeout),
83 } 84
85 // Instance methods
86 /**
87 * Posts an event by enqueueing it and waking up the
88 * queue's thread
89 * Sparam event The event to post
90 */
91 public synchronized void postEvent (EventType event) {
92 System, out .pr tln ( "EventQueuelmpl, posting event");
9 933 eennqquueeuuee ((eevveenntt )) ;;
94 this notify, 11 ()
EventQueuelmpl. java_l Mon Nov 11 16:26:42 1996
95 }
96
97 /**
98 * Enqueues an event 99 * Sparam event The eve t to σueue
ICO */ '
101 protected final εynchromzeα void enqueue (EventType event) {
102 eventQueue addElemen (event )
103 } 104
105 /**
106 * Dequeues an evert
107 * θreturn The first eve-, in the queue
108 */
109 protected final εynchronized EventType dequeue ( )
110 throws ArraylndexOutOfBι undsException { 111
112 if ('eventQueue lεEmpty v ) ) {
113 EventType event = (EventType) (eventQueue f lrεtElement ( ) ) ,
114 eventQueue removeElementAt ( 0 )
115 return event,
116 }
120 121 122 123 124 125 126 127
EventQueueThread. java_l Mon Nov il 16:26:42 1996 1
1 /* $Header: /com/meitca/hsl/zonesjagentε/event/EventQueueThrea . java 1 10/14/96 6-59p Noemi $
2 *
3 * Copyright 1996 Horizon Systems Laboratory, Mitsubishi Electric
4 * Information Technology Center America
5 * All rights reserved * CONFIDENTIAL AND PROPRIETARY PROPERTY OP MITSUBISHI ELECTRIC ITA
' , * ζ * DESCRIPTION
10 * Thread that manages an event queue 11
12 * $Log /co /meitca/hsl/zoneεjagentε/event/EventQueueThread ava $ 13
14 * 1 10/14/96 6 59p Noemi
15 * Thread to manage the event α =u e
16 */ 17
18 package com meitca hs_ zoneεjagentε event, 19
20 /**
21 * EventQueueThread lε a Thread that manages an event queue
22 * Event notification is implemented by appending an event to the queue
23 * and waking up its EventQueueThread to process the event by calling its
24 * event handler.
25 * The EventQueueThread lε instantiated by the EventQueuelmpl constructor
26 *
27 * θεee EventQueuelmpl
28 * θsee EventPost
29 * θsee EventHandler
30 * θauthor Noemi Pacore
31 */
32 class EventQueueThread
33 extends Thread ' 34
35 // Constants
36 /** The default timeout value in ms */
37 public static firal long DΞF2>ULT_TIMEOUT = 1000, 38
39 // Instance variables
40 /** This thread's event queue */
41 protected EventQueuelmpl eventQueue;
42
43 /** The application's event handler */
44 protected EventHandler evencHandler ;
45
46 /** The time ι- ms between consecutive examinations of the queue. */
47 protected long timeout,
EventQueueThread. java_l Mon Nov -.1 16:26:42 1996
48
49 // Constructors
50 /**
51 * Protected Default Constructor for an EventQueueThread
52 * SexceDtion IllegalAccessException Whenever called
53 */
54 protected EventQueueThread)
55 throws Illega1 { 56
57 System out cnntln( Default constructor called for EventQueueThread' ) ,
58 throw new I HegalAccessException ( "EventQueueThread default constructor"),
59 } 60
61 /** Constructs an EventQueueThread
62 * Sparam queue The associated event queue
63 * Sparam handler The associated event handler interface
64 */
65 public EventQueueThread (EventQueuelmpl queue, EventHandler handler) { 65 this (queue, han ler DE" ULT_TIMEOUT) 67 } 68
69 /** Constructs an EventQue-eThread
70 * θparam σueue The associated event queue
71 * θparam hardier The aεεociated event handler interface
72 * θparam timecut The time in mε to wait between consecutive σueue
74 */
75 public EventQue leThreed ( i = tQueuiImt l αueue, EventHandler handler long timeout) {
76 eventQueue = queue
77 eventHandi-i = handler
78 thiε timeout = tιmeo_t
79 thiε start')
80 } 81
82 // Instance met'odε 83 84 /**
85 * The thread ε run method
86 */
87 public void ru^ {
88 while (true {
89 try {
90 ε nchronized (eventQueue)
91 eventQueue wait ( timeout) ,
92 } 93 } catch (InterruptedException e) { }
94
EventQueueThread. java_l Mon Nov 11 16:26:42 1996 3
95 EventTy e event,
96 while i (event = eventQueue dequeue () ) '= null) {
97 Syεtem out prin 3 n (' EventQueueThread, handling event"),
98 try {
99 eventHandler handleΞvent (event) ,
100 } catch (Exception ex) {
101 System out println ( EventQueueThread can't handle event " +
102 ex getMessage ()) ,
103 ex printStackTrace () , 104
105 }
106 }
107 }
108 } 109 110 111 112 113
1 14
EventType . j ava_l Mon Nov 11 16:26:43 1996 1
1 /* $Header- /com/meitca/hsl/zones jagents/event/EventType ]ava 1 10/14/95 6-55p Noemi $ 2
7 * CONFIDENTIAL AND PROPRIETARY PROPERTY OF MITSUBISHI ELECTRIC ITA
9 * DESCRIPTION 10 * Base class lor distributed even s 11
12 * $Log /co /me-tca/hsl ' zoneε3agentε/event/EventType 3ava $ 13
14 * 1 10/14/96 6:55p Noemi
15 * Base class for distributed events IS */ 17
18 package com meitca hsl zonesjagents event, 19
20 import com meitca hsl util UniquelD; 21
22 /**
23 * Base claεε for diεtributed eventε EventType describes an event
24 * It contains- a unique ID (generated by the EventManager) and a description
25 * (optionally paεεed to the constructors)
26 *
27 * Aoplicationε ~,uεt derive and nandle tneir cw evert types 28
29 * Sauthor Noemi Pacicrek
30 */ 31
32 abs tract publ i c c laεε Eι/en tTyp» 33
34 // Constants
35 private static final String UNKNOWN = "Unknown",
36 private static final Strmσ TYPE = "event", 37
38 // Instance variables
39 /** A unique ID representing the event */
40 protected String eventID,
41
42 /** A description of the event */
43 protected Ξtrirg description,
44
45
46 // Constructors
47 /** Constructs an EventType */
EventType. java_l Mon Nov 11 16:26:43 1996 2
48 public EventType () {
49 this 'UNKNOWN) ,
50 }
51
52 /** Constructs an EventType
53 * Spara descriotion String describing the event
54 */
55 public Evenf~vpe(S πrc ι°ccπptιon) { i.6 eventID = UmquelD q-tMextID (TYPE, this) ,
5 System out pr tln ( 'eventID = ' + eventID)
58 this description = description
59 } 60
61
62 // Instance methods
63 /**
64 * Stπrg representation of event
65 * θreturn a String representation of the event
66 */
67 public f_nal String toStringO {
68 return (eventID * + description)
69 ) ^0
71 /**
72 * Retrieve an event ε ID
73 * Sreturn Tie e s ID
74 */
75 public fιna_. Strmσ getEven- "D ( ) {
76 return eventID
77 } 78
79 /**
80 * Retrieve an event's dsscription
81 * θreturn ? oesc-'ctici - tne event
82 */
83 public final String getE^e-tleεcr lption ( ) {
84 return descimtion
85 }
86 87
89 90 91
92 93 94
> o z ti o
Mon Nov 11 16:23:18 1996 1
1 /* $Header /com/meitca/hsl/zones agents/shared/PersistentStoreHandler 3ava 1 10/22/96 7 32p Noemi $
2 *
3 * Copyright 1996 Horizon Systems Laboratory, Mitsubishi Electric
4 * Information Technology Center America
5 * All rights reserved
6 *
7 * CONFIDENTIAL AND PROPRIETARY PROPEPTY OF MITSUBISHI FLFCTRIC ITA 8
9 * DESCRIPTION 10 * Persistent Store Manager wrapper that handles exceptions 11
12 * $Log /com/meitca/hsl/zonesjagentε/shared/PersistentStoreHandler java $ 13
14 * 1 10/22/96 7 32p Noemi
15 * A generic wrapper for PersistentStoreManager that catches exceptions
16 * and retries operations as necessary
17 */ 18
19 package com meitca hsl zonesjagents shared
20
21 import com meitca hs_ zonesjaσentε persistence * 22
23 /**
24 * A wrapper claεε tor the persistent storage manager
25 * (persistence PersistentStoreManager ) that catches
26 * all its exceDtionε ana performs the appropriate cleanup
27 * θsee PersistentStoreManager
28 * Sauthor Noemi Paciorek
29 */
30 public class "ersiscentStoreHandler { 31
32 // Inεtance variables
33 /** A reference to tne persistent store manager */
3 pi-c tected "erii"- mtΞtιr=Manaoer persistenceManager 35
36 // Constructorε
37 /**
38 * Constructs a Persistent StoreHandler
39 * θparam filename The name of the persistent storage file
40 */
41 public PerεiεtentStoreHandi =r (Str i ng filename) {
42 try {
43 persistenceManager = new PersistentStoreManager ( filename)
44 } catch (PersistentStoreException e) {
45 System out println ( "PerεiεtentStoreHandler can t create persiεtent store manager ' + e getMeε
46 e printStackTrace () ,
47 pers.sterceManacer = null
Mon Nov 11 16 : 23 : L8 1996 2
48 }
49 } 50
51 // Finalizer
52 /**
53 * Deletes refeience to Per_εtentStoreManager
54 */
55 protected void fmalιze(,
56 throws Throe < θle { 57
58 System out or mtln ( " PerεiεtsntStoreHandler Finalizer called"),
59
60 // Delete reference to Persistent Store Manager
61 persistenceManager = n_.-.i 62
63 super final. e()
64 } 65
66
67
68 // Instance methods
69 /**
70 * Find an object in the persist εtore
71 * Spara object The Object to locate
72 * Sreturn The Object s persistent storage ID
73 */
74 public int findObject (Object object) {
75 return pers.stenceManagsr findObject (object )
76 } 77
78 /**
79 * Inεert an Object into persistent εtorage
80 * If a εtorage manager exception occurs, attempt to
81 * truncate the persistent εtorage and disable persistence
82 * θparam object The Object represented by id
83 * Sreturn The Object s persistent storage ID
84 * A return val le of PersistentStoreManager INVALID_OID indicates
85 * an unsuccesstul attempt tc insert the object
86 */
87 public mt insertObject (Object object) {
88 return insertObject ( 0 , object, 0),
89 } 90 91
92 / * *
93 * Inεert ar Obj ect into pers i stent storage
94 * I f a ε torαgr r inagei » ~ ->pr ι on oc ii i '- , <ι t t on,pt I n
Mon Nov 11 16:23:18 1996 3
95 * truncate the persistent storage and disable persistence
99 * θreturn The Object s persistent εtorage ID
100 * A return value of PersistentStoreManager INVALID_OID indicates
101 * an unsuccessful attemot o nεert the object
102 */
103 public int insertObject (Object object, mt space) {
104 return insei tObj ect ( 0 , object, space)
105 } 106
107
108 /**
109 * Inεert an Ooject into persistent εtorage
110 * If a storage manager exception occurs, attempt to
111 * truncate the persistent ' orage and disable persistence
112 * θparam id The Object's persistent εtcrage ID
113 * θparam Object The Oo ect represented by xά
114 * θreturn The Object's persistent storage ID
115 * A return val e of PersistentStoreManager INVALID_OID indicates
116 an unsuccesε_ul attempt to insert the object
117 */
118 public int use tObject(ιrt i , Object object) {
119 return inse 'tOb ect ( id object, 0)
120 } 121
122
123 /**
124 * Inεert an Object into persistent storage
125 * If a storage manager exctotion occurs, attempt to
126 * truncate the persistent storage and disable persistence
127 * θparam id The Object's persistent storage ID
128 * Sparam Object The Object represented by id
129 * Sparam space The add tional space in byteε to oe preallocated
130 * for this object
131 * A return value of PersistentStoreManager INVALID_OID indicates
132 * an unsuccessful attempt to insert the object
133 */
134 public int insertObject ( t id, Object object, int space) {
135 if (persistenceManager == null) 136 return PersistentStoreManager INVALID_OID,
137
138 try {
139 if (id == 0)
140 return persistenceManager insertObject (object , space),
141 return -ersistenceM nager insertObject cid, object, space)
Mon Nov 11 16:23: LS 1996 4
142 } catch (Pe sistentStoreDuplicateObjectException el) {
143 try {
144 id = persisterce.'janager findObject (object) ,
145 if (_d '= PersistentStoreManager INVALID_OID) {
146 persistenceManager updateObject ( id object),
147 eturn id
148 }
149 } catch (Pers εtentStoreException e2) {
150 System out prmtln (' insertObject duplicate object found' + e2 getMessage ()) ,
151 e2 printStackTrace () ,
152 truncateFileStore () ,
153 perSiStencefanaπ-r = null
154 }
155 } catch vPersistentStorelnvalidOb ectException e3 ) {
156 System out println (' insertObject invalid ID" + e3 getMessage ()) ,
157 e3 printStackTrace () ,
158 } catch cPerεiεtentStoreException e4) {
159 System out ormtln (' insertObject can't insert object " + e4 getMessage () )
160 e4 prmtΞtac-cTrace (
161 truncateFileStore!)
162 pers1 εtenceManacer - IJII
163 }
164 return Pers^tεntStcre atager INVALID_OID
165 }
166
167
168 /**
169 * Fetch an Object from perε tent εtorage
170 * If a εtorage manager exception occurs, attempt to
171 * truncate the perεiεtent εtorage and disable oerεiεtence
172 * θparam id The Object ε oerεistent storage IP
173 * θreturn Object The Object represented by id, or null,
174 * if the Object -.as not fcu-d persistent storage
175 */
176 public Object fetcnOoject ( t id) {
177 if (persistenceManager -- null)
178 return null
179
180 try {
181 retirn persistenceManager fetchObjec ( id) ,
182 } catch (cersιstentStore;bj ectNotFoundException el) {
183 System out println (" fetchObject Object not found in persistent store, ID = " + id),
184 } catch (PersistentStorelnvalidObjectException e2) <
185 System out prm_.n (' fetchObject invalid ID" + e2 getMessage ()) ,
186 e2 printStackTrace!),
187 } catch (PersistentStoreException e3) {
188 Syεter out prmtln (' f etchObject can't fetch object ' + e3 getMessage ()) ,
Mon Nov 11 16:23:13 1996 5
189 e3 printStackTrace (j
190 truncateFileStore))
191 persistenceManager = null,
192 }
193 return null
194 }
195 196
197 /**
210 persistenceManager uciateObj ect ( lα object)
211 return t.ue
212 } catch (Persiεter tStoreCojectNotFoundException el) {
213 System out pr tln ( uodateObject Object not found in persistent store, ID = + id)
214 try t
215 pe sιεtenceManage - insertObject ( id object) 215 ret rn true
217 } catch I'erSxStentStoreExceotion e2) {
218 Sy^tfe"- out oπnt n( uodateObject can t mεert object * e2 getMessage () )
219 e2 c mtStacKTrace O
220 truncateFi leStore ( )
221 per= εtenceManager = nul l
222 }
223 } catch (Perε_εtentStoreInvalιdObjectExceptιon e3 ) {
224 Ξyε-em out prmtln (' pdateObject invalid ID + e3 getMeεεage ( ) )
225 e3 cintStacKTr -te()
226 } catch (Pei sistentStoreException e4) {
227 Syster out prmtln( uoαateObject can t update object + e4 getMessage ()) ,
228 e4 printStackTrace (
229 truncateFileStore ()
230 persisterceManager = null
231 }
232 return fa_εe
233 234 235
Mon Nov 11 16:23:16 1996 7
283 try {
284 persistenceManager . truncateFileStore () ;
285 return true;
286 } catch (Exception e) {
287 Syste" . out .println (' runcateFileStore : can't truncate εt~re " + e . getMessage ()) ;
288 e .pr _ntStackTrace ( )
289 persistenceManager - null;
290 return alεe;
291 }
292 } 293
294 /**
295 * Return a reference to the persistent storage manager.
296 */
297 public PersistentStoreManager getPersiεtenceManager ( ) {
298 return persistenceManager;
299 }
300 ) 301 302 3 03 304
Mon JJJOV 11 16 : 25 : 18 1996 6
236 /**
237 * Delete an cbject from persistent storage
238 * If a storage manager exception occurs, attempt to
239 * truncate the persistent storage and disable persistence
240 * θparam id The Object's oers.stent storage ID
241 * θreturn P boolean md.cating if the deletion was successful
242 */
243 public ooolean de.eteObject nt id) {
244 if (persistenceManager -= null)
245 return fa se 246
247 try {
248 persist enceManaqe.. u.-_eteOb ec t ( id)
249 return true
250 } catch (FersJ.stentStoreC-]cctNctroun Exceptinn el) ι
251 Syεtem out prm ±n( deleteObject Object net found _n persistent εtore ID = + id)
252 > catch (Pel sistentStorp validOb ectExceotion e2) {
253 Syεtem out pnn_l- ( deleteObject lt'.ahd ID + e2 getMessage () )
254 e2 trmtStackTrac=()
255 } catch (PersistentStoreException e3) {
256 Syster cut prmtln ( oeleteOb ect can t delete object + e3 getMessage () )
257 e3 printStackTrace (
258 truncateF_leΞtore ( )
259 persistenceManager = null
260 }
261 return fa.se
262 } 263
264
265 /**
266 * Diεaole stor e cf ob ectε m oersistent store This method
267 * a.so tmnc?--'-
268 */
269 publ_c void d_ ->-ι-_>() /
270 truncateFileStore ( )
2""1 nersistencc '?nager = pu 1
272 }
273
276 * Truncate the persistent s-orage file to 0 bytes If a storage manager
277 * exception o^cu^s disable persistence
278 */
279 public boolean truncateFileStore ( ) {
280 if (persistenceManager == null)
281 return raise 282
Mon Nov 11 16:33:05 1996 1
1 /* $Header /com/me cca/hsl/util/UmquelD Java 1 10/15/96 7 20a Billp $
3 ** Copyright 1996 Honzc- Systems Laboratory, Mitεubiεhi Electric
4 * Information C--ter America
5 * All πghtε reserve:.
6 *
7 * CONFIDENTIAL AND
8 *
9 * DESCRIPTION
10 * This claεε generates IDs tnat are uniαue across d.^f-ibuted systems
11 * $Log /com/meitca/hεl 'uti _/UnιqueID java $ 12
13 * 1 10/15/96 7 20a Billp
14 */ 15
16 package com meitca hsl uti
17
18 import java util *,
19
20 import java net InetAddissε
21
22 /**
23 * This class generates IDs tnat are unique within a Java VM
24 * It is used by clasεeε tnat need to generate unique IDs
25 *
26 * Sauthor Noemi Paciorek
27 */
28 public class UmαuelD f 29
30 // Claεs variables
31 /** A counter used generating IDs */
32 protected εtatic long ID u " = 0 33
34 /** A unique ID .epresentng the host * /
35 protected εtatic String host 36
37 // Static initializer
38 static {
39 /*
40 * Try to obtain tne host's name and IP address If this fails,
41 * construct a pseudo-random name and hope for the best1 (Of course,
42 * this εnould rever happen )
43 */
44 try {
45 host = InetAddress getLocalHoεt ( ) toStringO,
46 } catch 'Exception e) {
47 hoεt = ' 1-OSTID " + new Random () nextLong () ,
Mon Nov 11 16:33:05 1996 2
48 }
49 }
50 51
52 // Constructors
53 // No accessible constructors
54 /**
55 * Protected Default Ccnctructor for UmquelD
55 * This class never need; to be instantiated since all its variables 57 * and methods are static 53 * Sexception IllegalAcceεεExcept ion Whenever called
59 */
60 protected Unique D(;
61 throws Illega_-ccessE-' ception { 62
63 System out .pr_ntin ( 'Default constructor called for UmquelD" ) ,
64 throw new IllegalAccessException ( "UmquelD default constructor"),
65 } 66 67
68 // Class methodε
69 /**
70 * Thiε method attempts to create an ID that lε unique across
71 * Java VMs . The ID is created from- the hostname, an application type
72 * (e.g , agent), the current time in mε , and the virtual memory
73 * address of tn cbject being created 74
75 * θparam type A String containing an application type, e g , "agent"
76 * θparam objpct The this" reference of the calling object
77 */
78 public εtatic itr g getN<= xtID (String type, Object object) {
79 return (host + ' '' + type + nextlDNumO + '/" +
80 Syεtem currer tTimeMillis ( ) + Integer toHexStnng (object hashCode ( ) ) ) ,
81 } 82
83
84 private static final .-.mchronized long nextlDNumO {
85 return ^IDNu , 85 } 87 88 }

Claims

- ϋtC, _CLAIMS What is claimed is:
1. In a computer network including at least a first computer and a second computer, an apparatus for performing a task in a second computer, comprising: a routine that generates a mobile agent object in the first computer, the mobile agent including both data and executable code; a protocol for transmission of the mobile agent from the first computer to the second computer, wherein execution of the mobile agent in the second computer following such transmission prompts the task to be performed in the second computer; and an itinerary containing a reference to each destination computer to which the mobile agent is designated to migrate and a reference to a method associated with each respective destination computer reference, the respective method being invoked when the mobile agent is present on the respective destination computer.
2. The apparatus of claim 1 wherein the transmission protocol includes a routine in the first computer for serializing the mobile agent to generate a stream of data therefrom.
3. The apparatus of claim 2 wherein the transmission protocol includes a routine in the second computer for deserializing the stream of bytes to regenerate the mobile agent therefrom. '
4. The apparatus of claim 1 wherein the task is data gathering, and wherein the mobile agent is transmitted back to the first computer from the second computer following completion of such data gathering.
The apparatus of claim 1 wherein the mobile agent migrates to a plurality of destination computers within the computer network.
6. The apparatus of claim 1 wherein at least one destination computer reference is a Uniform Resource Locator.
7. The apparatus of claim 1 wherein at least a portion of the executable code required for invoking the method is retrieved from a mobile codebase portion of the executable code included in the mobile agent.
8. The apparatus of claim 7 wherein the mobile agent includes a reference to a home codebase located on the first computer, the reference being employed to retrieve required executable code which is not present in the mobile codebase.
9. The apparatus of claim 8 wherein required executable code is sought first in the computer on which the mobile agent is executing, then in the mobile codebase, and finally on the home codebase.
10. The apparatus of claim 8 wherein a new thread is formed for execution of the mobile agent in the destination computer following receipt of the mobile agent, and wherein a security feature prevents the mobile agent from operating outside a scope assigned to such thread.
11. The apparatus of claim 8 wherein the mobile agent further includes sub-objects.
12. The apparatus of claim 1 wherein a persistent local copy of the mobile agent is stored following receipt of the mobile agent, and wherein such copy is overwritten with an updated persistent copy following agent execution. - .€. , _
13. In a computer network including at least a first computer and a second computer, a method for performing a task in a second computer, comprising the steps of: generating a mobile agent object in the first computer, the mobile agent including both data and executable code; transmitting the mobile agent from the first computer to the second computer; receiving the mobile agent in the second computer; and executing the mobile agent in the second computer in accordance with an itinerary which contains a reference to each destination computer to which the mobile agent is designated to migrate and a reference to a method associated with each respective destination computer reference, the method associated with the second computer being invoked when the mobile agent is present on the second computer.
14. The method of claim 13 including the further step of serializing the mobile agent to generate a stream of data therefrom in the first computer.
15. The method of claim 14 including the further step of deserializing the stream of bytes to regenerate the mobile agent therefrom in the second computer.
16. The method of claim 13 wherein the task is data gathering, and including the further step of transmitting the mobile agent back to the first computer from the second computer following completion of such data gathering.
17. The method of claim 13 including the further step of causing the mobile agent to sequentially migrate to a plurality of destination computers within the computer network.
18. The method of claim 13 including the further step of employing a Uniform Resource Locator as one of the at least one destination computer reference.
19. The method of claim 13 including the further step of retrieving at least a portion of the executable code required for invoking the method from a mobile codebase portion of the executable code included in the mobile agent .
20. The method of claim 19 wherein the mobile agent includes a reference to a home codebase located on the first computer, and including the further step of employing the reference to retrieve required executable code which is not present in the mobile codebase.
21. The method of claim 20 including the further step of searching for required executable code first in the computer on which the mobile agent is executing, then in the mobile codebase, and finally on the home codebase.
22. The method of claim 21 including the further step of forming a new thread in the destination computer for execution of the mobile agent following receipt thereof, and wherein a security feature prevents the mobile agent from operating outside a scope assigned to such thread.
23. The method of claim 21 including the further step of inserting sub-objects into the mobile agent.
24. The method of claim 13 including the further step of storing a persistent local copy of the mobile agent following receipt thereof, and overwriting such copy with an updated persistent copy following agent execution.
25. In a computer network including at least a first computer and a second computer, an apparatus for performing a task in a second computer, comprising: a routine that generates a mobile agent object in the first computer, the mobile agent including both data and executable code; a protocol for transmission of the mobile agent from the first computer to the second computer, wherein execution of the mobile agent in the second computer following such transmission prompts the task to be performed in the second computer, at least a portion of the executable code required for execution being retrieved from a mobile codebase portion of the executable code included in the mobile agent; and a reference to a home codebase located on the first computer, the reference being employed to retrieve required executable code which is not present in the mobile codebase.
26. The apparatus of claim 25 wherein the transmission protocol includes a routine in the first computer for serializing the mobile agent to generate a stream of data therefrom.
27. The apparatus of claim 26 wherein the transmission protocol includes a routine in the second computer for deserializing the stream of bytes to regenerate the mobile agent therefrom.
28. The apparatus of claim 25 wherein the task is data gathering, and wherein the mobile agent is transmitted back to the first computer from the second computer following completion of such data gathering.
29. The apparatus of claim 25 wherein the mobile agent migrates to a plurality of destination computers within the computer network.
30. The apparatus of claim 29 wherein the mobile agent further includes an itinerary containing a reference to each destination computer to which the agent is designated to migrate and a reference to a method associated with each respective destination computer reference, the respective method being invoked when the mobile agent is present on the respective destination computer.
31. The apparatus of claim 30 wherein at least one destination computer reference is a Uniform Resource Locator.
32. The apparatus of claim 25 wherein required executable code is sought first in the computer on which the mobile agent is executing, then in the mobile codebase, and finally on the home codebase .
33. The apparatus of claim 25 wherein a new thread is formed for execution of the mobile agent in the destination computer following receipt of the mobile agent, and wherein a security feature prevents the mobile agent from operating outside a scope assigned to such thread.
34. The apparatus of claim 25 wherein the mobile agent further includes sub-objects.
35. The apparatus of claim 30 wherein a persistent local copy of the mobile agent is stored following receipt of the mobile agent, and wherein such copy is overwritten with an updated persistent copy following agent execution.
36. In a computer network including at least a first computer and a second computer, a method for performing a task in a second computer, comprising the steps of: generating a mobile agent object in the first computer, the mobile agent including both data and executable code; transmitting the mobile agent from the first computer to the second computer; receiving the mobile agent in the second computer; retrieving at least a portion of the executable code required for invoking the method from a mobile codebase portion of the executable code included in the mobile agent; employing a reference to a home codebase located on the first computer to retrieve required executable code which is not present in the mobile codebase; and
executing the mobile agent in the second computer such that the mobile agent prompts the task to be performed in the second computer.
37. The method of claim 36 including the further step of serializing the mobile agent to generate a stream of data therefrom in the first computer.
38. The method of claim 37 including the further step of deserializing the stream of bytes to regenerate the mobile agent therefrom in the second computer.
39. The method of claim 36 wherein the task is data gathering, and including the further step of transmitting the mobile agent back to the first computer from the second computer following completion of such data gathering.
40. The method of claim 36 including the further step of causing the mobile agent to sequentially migrate to a plurality of destination computers within the computer network.
41. The method of claim 40 wherein the mobile agent further includes an itinerary which contains a reference to each destination computer to which the agent is designated to migrate and a reference to a method associated with each respective destination computer reference, and including the further step of invoking the method associated with the respective destination computer when the mobile agent is present on the respective destination computer.
42. The method of claim 41 including the further step of employing a Uniform Resource Locator as one of the at least one destination computer reference.
43. The method of claim 36 including the further step of searching for required executable code first in the computer on which the mobile agent is executing, then in the mobile codebase, and finally on the home codebase.
44. The method of claim 36 including the further step of forming a new thread in the destination computer for - L^-\ _
execution of the mobile agent following receipt thereof, and wherein a security feature prevents the mobile agent from operating outside a scope assigned to such thread.
45. The method of claim 36 including the further step of inserting sub-objects into the mobile agent.
46. The method of claim 41 including the further step of storing a persistent local copy of the mobile agent following receipt thereof, and overwriting such copy with an updated persistent copy following agent execution.
EP97948189A 1996-11-14 1997-11-12 Itinerary based agent mobility including mobility of executable code Withdrawn EP1021766A4 (en)

Applications Claiming Priority (3)

Application Number Priority Date Filing Date Title
US3090696P 1996-11-14 1996-11-14
US30906P 1996-11-14
PCT/US1997/020232 WO1998021662A1 (en) 1996-11-14 1997-11-12 Itinerary based agent mobility including mobility of executable code

Publications (2)

Publication Number Publication Date
EP1021766A1 true EP1021766A1 (en) 2000-07-26
EP1021766A4 EP1021766A4 (en) 2003-03-12

Family

ID=21856628

Family Applications (2)

Application Number Title Priority Date Filing Date
EP97948189A Withdrawn EP1021766A4 (en) 1996-11-14 1997-11-12 Itinerary based agent mobility including mobility of executable code
EP97946570A Withdrawn EP0938798A4 (en) 1996-11-14 1997-11-12 Dynamic synchronous collaboration framework for mobile agents

Family Applications After (1)

Application Number Title Priority Date Filing Date
EP97946570A Withdrawn EP0938798A4 (en) 1996-11-14 1997-11-12 Dynamic synchronous collaboration framework for mobile agents

Country Status (4)

Country Link
EP (2) EP1021766A4 (en)
JP (2) JP2001504609A (en)
AU (2) AU5171798A (en)
WO (2) WO1998021863A1 (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP0928089A2 (en) * 1997-11-13 1999-07-07 Mitsubishi Denki Kabushiki Kaisha Mobility of agents in a network

Families Citing this family (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6065039A (en) * 1996-11-14 2000-05-16 Mitsubishi Electric Information Technology Center America, Inc. (Ita) Dynamic synchronous collaboration framework for mobile agents
US6317754B1 (en) * 1998-07-03 2001-11-13 Mitsubishi Electric Research Laboratories, Inc System for user control of version /Synchronization in mobile computing
JP3689564B2 (en) * 1998-07-31 2005-08-31 キヤノン株式会社 OA device, OA system, control method, and storage medium
JP3777092B2 (en) * 1998-08-01 2006-05-24 インターナショナル・ビジネス・マシーンズ・コーポレーション Method and system for running distributed applications
JP3697531B2 (en) * 1998-11-24 2005-09-21 オムロンエンタテインメント株式会社 Agent system, communication device, and communication method
GB2366398B (en) * 2000-08-25 2005-02-23 Motorola Inc Agents
US7861252B2 (en) 2001-03-21 2010-12-28 Andrzej Uszok Intelligent software agent system architecture
US6816895B2 (en) 2001-03-26 2004-11-09 Motorola, Inc. Updating the capability negotiation information of a mobile station with an editing application downloaded from a service provider
US8335813B2 (en) 2007-05-01 2012-12-18 Illinois Institute Of Technology Systems, methods, and protocols for process migration and group membership management

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP0634719A2 (en) * 1993-07-08 1995-01-18 General Magic, Inc. System and method for distributed computation based upon the movement, execution, and interaction of processes in a network

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US4503535A (en) * 1982-06-30 1985-03-05 Intel Corporation Apparatus for recovery from failures in a multiprocessing system
JPH0451335A (en) * 1990-06-20 1992-02-19 Oki Electric Ind Co Ltd Data base processor
US5499364A (en) * 1993-10-14 1996-03-12 Digital Equipment Corporation System and method for optimizing message flows between agents in distributed computations

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP0634719A2 (en) * 1993-07-08 1995-01-18 General Magic, Inc. System and method for distributed computation based upon the movement, execution, and interaction of processes in a network

Non-Patent Citations (6)

* Cited by examiner, † Cited by third party
Title
BERGHOFF J ET AL: "Agent-based configuration management of distributed applications" CONFIGURABLE DISTRIBUTED SYSTEMS, 1996. PROCEEDINGS., THIRD INTERNATIONAL CONFERENCE ON ANNAPOLIS, MD, USA 6-8 MAY 1996, LOS ALAMITOS, CA, USA,IEEE COMPUT. SOC, US, 6 May 1996 (1996-05-06), pages 52-59, XP010164685 ISBN: 0-8186-7395-8 *
CHUCK MCMANIS: "The basics of Java class loaders" JAVAWORLD, [Online] October 1996 (1996-10), XP002186623 Retrieved from the Internet: <URL:http://www.javaworld.com/javaworld/jw -10-1996/jw-10-indepth.html> [retrieved on 2002-01-04] *
MAGEDANZ T ET AL: "Intelligent agents: an emerging technology for next generation telecommunications?" PROCEEDINGS OF IEEE INFOCOM 1996. CONFERENCE ON COMPUTER COMMUNICATIONS. FIFTEENTH ANNUAL JOINT CONFERENCE OF THE IEEE COMPUTER AND COMMUNICATIONS SOCIETIES. NETWORKING THE NEXT GENERATION. SAN FRANCISCO, MAR. 24 - 28, 1996, PROCEEDINGS OF INFOCOM, L, vol. 2 CONF. 15, 24 March 1996 (1996-03-24), pages 464-472, XP010158104 ISBN: 0-8186-7293-5 *
ORDILLE J J: "When agents roam, who can you trust?" EMERGING TECHNOLOGIES AND APPLICATIONS IN COMMUNICATIONS, 1996. PROCEEDINGS., FIRST ANNUAL CONFERENCE ON PORTLAND, OR, USA 7-10 MAY 1996, LOS ALAMITOS, CA, USA,IEEE COMPUT. SOC, US, 7 May 1996 (1996-05-07), pages 188-191, XP010164899 ISBN: 0-8186-7585-3 *
PERRET S ET AL: "Mobile assistant programming for efficient information access on the WWW" COMPUTER NETWORKS AND ISDN SYSTEMS, NORTH HOLLAND PUBLISHING. AMSTERDAM, NL, vol. 28, no. 11, 1 May 1996 (1996-05-01), pages 1373-1383, XP004018235 ISSN: 0169-7552 *
See also references of WO9821662A1 *

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP0928089A2 (en) * 1997-11-13 1999-07-07 Mitsubishi Denki Kabushiki Kaisha Mobility of agents in a network
EP0928089A3 (en) * 1997-11-13 2002-03-27 Mitsubishi Denki Kabushiki Kaisha Mobility of agents in a network

Also Published As

Publication number Publication date
AU5430498A (en) 1998-06-03
AU5171798A (en) 1998-06-03
WO1998021662A1 (en) 1998-05-22
EP1021766A4 (en) 2003-03-12
WO1998021863A1 (en) 1998-05-22
EP0938798A4 (en) 2003-02-12
EP0938798A1 (en) 1999-09-01
JP2001504609A (en) 2001-04-03
JP2001502093A (en) 2001-02-13

Similar Documents

Publication Publication Date Title
US6389452B1 (en) Method of communicating between objects and agents across a computer network
US7415522B2 (en) Extensible framework for transferring session state
Rozier et al. The Chorus distributed operating system: some design issues
US6415315B1 (en) Method of moving objects in a computer network
Wetherall Service introduction in an active network
US5481721A (en) Method for providing automatic and dynamic translation of object oriented programming language-based message passing into operation system message passing using proxy objects
US6654793B1 (en) System and method for facilitating dynamic loading of stub information to enable a program operating in one address space to invoke processing of a remote method or procedure in another address space
US6233601B1 (en) Itinerary based agent mobility including mobility of executable code
EP0623876A2 (en) Method and apparatus for linking object managers for cooperative processing in an object oriented computing environment
US20020138659A1 (en) Method and system for application development and a data processing architecture utilizing destinationless messaging
US6535928B1 (en) Method of determining the timing for reclaiming a remote object
USRE41706E1 (en) Moving objects in a distributed computing environment
JPH08115223A (en) Method and system for data processing to be executed by computer
JP2002132739A (en) Stab retrieval loading system and method, server device, client device and computer readable recording medium
US6442586B1 (en) Method of moving objects across multiple locations in a computer network
WO1998021662A1 (en) Itinerary based agent mobility including mobility of executable code
US6834389B1 (en) Method of forwarding messages to mobile objects in a computer network
US6519653B1 (en) Method of communicating between agent objects in a computer network
US6321261B1 (en) Method of constructing an object remotely across a computer network
AU2004264626B2 (en) Transparent session migration across servers
Hiltunen Configuration management for highly customisable software
Hamilton A remote procedure call system
JP3924279B2 (en) Service application architecture for integrated network service providers
Kono et al. An implementation method of migratable distributed objects using an RPC technique integrated with virtual memory management
Broos et al. Mobile agent platform assessment report

Legal Events

Date Code Title Description
PUAI Public reference made under article 153(3) epc to a published international application that has entered the european phase

Free format text: ORIGINAL CODE: 0009012

17P Request for examination filed

Effective date: 19990611

AK Designated contracting states

Kind code of ref document: A1

Designated state(s): AT BE CH DE DK ES FI FR GB GR IE IT LI LU MC NL PT SE

RIC1 Information provided on ipc code assigned before grant

Free format text: 7G 06F 13/00 A, 7G 06F 9/46 B

A4 Supplementary search report drawn up and despatched

Effective date: 20030127

17Q First examination report despatched

Effective date: 20030408

STAA Information on the status of an ep patent application or granted ep patent

Free format text: STATUS: THE APPLICATION IS DEEMED TO BE WITHDRAWN

18D Application deemed to be withdrawn

Effective date: 20040217