| By P.G. Sarang, Ninad Kamerkar | Article Rating: |
|
| February 4, 2007 05:00 PM EST | Reads: |
12,093 |
File Transfer Agent (Slave)
The File Transfer
Agent (Slave) is the third agent in our application and like the File
Search Agent it doesn't have a GUI. Figure 3 shows the Master Agent
screen containing the search results. When the user selects one of the
files from the search results and clicks the Fetch & Open button, this agent is created and dispatched to the remote machine on which the File Search Agent
found the file. This agent is responsible for bringing the actual
contents of the selected file to the sender machine. So it moves to the
remote machine to read the contents from the selected file. After
gathering the contents it comes back to the sender machine and gives
the fetched contents to the Main File Agent. The Main File Agent then
asks the user to save the contents to a file on the local disk. After
saving the contents, the Main File Agent opens the file in its
registered native editor for the user to review or edit. This agent
disposes of itself once it's transferred a file.
It is created again when the user wants to do the next file transfer operation. In the similar way the user can select another file from the list and send this agent to bring the contents of the next file maybe from another remote machine by clicking on the Fetch & Open button.
Application Dataflow
Figure 4 depicts the complete dataflow in the application.
The communication between the requestor and the remote machine takes place as follows:
- The user creates and sends a File Search Agent to the remote machine to search for a specified file.
- After reaching the remote machine the File Search Agent searches for the required file and sends the results back to the client machine.
- The user selects the required file from a list of results displayed on the file search GUI and sends a File Transfer Agent to bring back the contents of that file.
- The File Transfer Agent comes back with the required file and asks the user to save it on the local disk so he can view it.
- The user can stop the search operation at any point simply by sending a message to stop the search to the File Search Agent.
The GUI contains an input box called File Name\Extension where the user can enter the file name\extension to be searched on the remote machine. The user has the option of searching the entire remote system or only a particular remote folder. Next he has to enter the remote URL in the URL input box. The Search Path (Drive\Folder) input box should contain the folder to be searched. When the user clicks the ADD button the remote URL and search path is added to the Remote URL list box. This way the user can enter any number of Remote URL and search paths to the Remote URL list box. He can also delete any of these elements from the Remote URL using the delete button. Once the list as specified above is ready, the user can click the START button. This sends one copy of FileSearchAglet per Remote URL so that the search can be done in parallel on all specified remote machines.
A search in progress can be stopped in two ways. The user can select a desired path from the Remote URL list box and click the STOP button to stop the search on that remote location. The user can stop the entire search on all the remote machines by clicking the STOP ALL button.
As the search progresses on remote machines, the results are displayed in the Search Result list box. The results contain the remote path on which the required file was found and the URL of that remote machine as shown in Figure 3. The user can select the required file from that list box and click on the Fetch & Open button to get the contents of the file from the Remote URL mentioned in the element selected from the list box.
Application Code
The MainFileAglet is the main and
the starting aglet of our file search utility. This agent is also
called the Master Agent because it controls the other agents. It is a stationary aglet because it doesn't move on the network. This aglet stores the IDs of the created FileSearchAglets in a vector:
//This vector stores the IDs of the aglets created for search.
Vector agletIdVector=new Vector();
The MainFileAglet creates a FileSearchAglet for each search path. Each aglet is identified by a unique ID that's used to obtain its proxy. All the aglets communicate with each other using their proxies.
MainFileAglet provides the GUI through which the user enters the file search criteria and controls the other agents. When this aglet is first launched on the Tahiti server (the installation of the Aglet development kit and the Tahiti server is provided at the end of the document), its onCreation method is executed first where we create the user interface:
//Creating object of MainAgletGui class to show the GUI for this aglet.
SearchGUI=new MainAgletGui(this);
We pass a reference to the MainFileAglet in the constructor of the MainAgletGui. Using this reference the GUI code obtains a reference to SearchGUI object that contains the search criteria. The user interface is depicted in Figure 2.
Starting the Search
Once the list containing the Remote URL and the Search folder is ready the user can click the START button. When the START
button is clicked the code checks if a search is in progress. If so
then the user gets a warning message that asks him to stop the current
search and start a new one:
//checking whether any aglets exist or not
if(MainAglet.agletIdVector.size()>0)
{
JOptionPane.showMessageDialog(frame,
"Please stop all the agents before"
+" starting new search.","WARNING",JOptionPane.WARNING_MESSAGE);
}
The code checks if a search is in progress by getting the size of the vector that contains the IDs of the aglet that have been created in the previous search.
If no aglet exits it checks to see if the Remote URL list box and File Name input box are empty. It then calls the broadCastAglets method on the MainFileAglet:
else
{
//checking whether Remote URL list box & whether
//txtFileName input box is empty or not.
if (addressVector.size()>0 && txtFileName.getText()!="")
{
MainAglet. broadCastAglets();
}
else
{
JOptionPane.showMessageDialog(frame,"Please enter filename"
+"& remote location to search in \"Remote Url\"." ,
"WARNING", JOptionPane.WARNING_MESSAGE);
}
}
Published February 4, 2007 Reads 12,093
Copyright © 2007 SYS-CON Media, Inc. — All Rights Reserved.
Syndicated stories and blog feeds, all rights reserved by the author.
More Stories By P.G. Sarang
Dr. Sarang in his long tenure of 20+ years has worked in various capacities in the IT industry. Dr. Sarang currently holds the position of Director (Architecture) with Kynetia, Spain and has been a Consultant to Sun Microsystems for last several years. He has previously worked as a Visiting Professor of Computer Engineering at University of Notre Dame, USA and is currently an adjunct faculty in the Univ. Dept. of Computer Science at University of Mumbai. Dr. Sarang has spoken in number of prestigious international conferences on Java/CORBA/XML/.NET and has authored several articles, research papers, courseware and books.
More Stories By Ninad Kamerkar
Ninad Kamerkar is currently pursuing a master's degree in computer science at the University of Mumbai in India. His research interests involve mobile agents, networking, and distributed systems. Besides his studies, he is interested in painting and listening to music.
- The Top 150 Players in Cloud Computing
- Commercial vs Federal Cloud Computing
- Why IBM’s Server Chief Got Busted
- Industry Experts Discuss the State of Cloud Computing
- Cloud Expo New York Call for Papers Now Open
- Cloud Computing on Gartner's Top 10 List and SYS-CON Events' 2010 Calendar
- US Federal Government is Major Cloud Computing Innovator
- Google Wave
- Ulitzer.com Named Exclusive "New Media" Sponsor of Cloud Computing Conference & Expo
- Tactical Cloud Computing Panel at 1st Annual GovIT Expo
- Adaptivity & Cloud Computing: Exclusive Q&A with CEO Tony Bishop
- 4th International Cloud Expo: Photo Album
- The Top 150 Players in Cloud Computing
- SYS-CON.TV: Cloud Computing Expo Power Panel
- Commercial vs Federal Cloud Computing
- Why IBM’s Server Chief Got Busted
- 1st Annual GovIT Expo: Letter from the Technical Chair
- Industry Experts Discuss the State of Cloud Computing
- Deputy CIO of the CIA to Keynote 1st Annual GovIT Expo
- SOA World Power Panel on SYS-CON.TV
- CIA was Headed to an Enterprise Cloud All Along: Jill Tummler Singer
- Cloud Expo New York Call for Papers Now Open
- 1st Annual Government IT Conference & Expo: Themes & Topics
- Stock in Focus: Dragon Capital
- The i-Technology Right Stuff
- Who Are The All-Time Heroes of i-Technology?
- Get the Message
- Where Are RIA Technologies Headed in 2008?
- i-Technology Viewpoint: Is Web 2.0 the Global SOA?
- i-Technology Viewpoint: Thinking Outside the VC Box
- ESB Myth Busters: 10 Enterprise Service Bus Myths Debunked
- i-Technology Viewpoint: When to Leave Your First IT Job
- SOA Web Services Edge Conference Coverage on SYS-CON.TV
- Five Reasons Why Web 2.0 Matters
- SYS-CON.TV's "SOA Web Services" and "Enterprise Open Source" Programs To Air in December
- SOA World Conference & Expo SYS-CON.TV Power Panel Live From Times Square









Cloud computing is a game changer. The cloud ...





















