1 / 12

Integrating Command Line Programs with Java Clients

Explore the process of integrating Java with command line programs using CLTerm technology, resolving I/O issues, and implementing a network architecture for seamless communication. Learn about PTY implementation, Java client interactions, and the benefits of CLPanel.

mgardner
Download Presentation

Integrating Command Line Programs with Java Clients

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Integrating Command Line Programs with Java Clients Will Fisher PPPL Summer Intern Science Education Program August 11th, 2005

  2. Motivation • What did we want out of a command line system? • Access the suite of command line utilities from a standalone application. • Preserve the functionality and performance. • Minimize changes to the programs. • Editing the programs was not an option. • Must capture their output and feed them input. • Add graphical user interface to the command line. • Java is a good language to use for the client application given its portability. • Ultimate goal: Java client  command line program.

  3. Issues with Standard I/O • Buffering • Causes problems for reading and writing data as needed. • Java API does not work well, directly, with terminal applications because of buffering. • Java communication, apparently, has no such issues as client/servlet communication is handled fully and completely by the Java system.

  4. PTY Implementation • Pseudo-terminals • Special interprocess communication channel that acts like a terminal. • One end is called the master, the other end is called the slave. • Data written to the master is received by the slave as if it were the result of a user typing at an ordinary terminal. • Data written to the slave is sent to the master as if it were written on an ordinary terminal. • Our use of them • Used for communication with the command line program. • Fakes a terminal device that reads from and writes to the command line program. • Set terminal attributes in order to kill the buffering and the echoing.

  5. CLTerm Technology Solution • Forking the program • Use the forkpty() command to fork CLTerm into two processes. • The two processes are connected via a master-slave pseudo-terminal. • The child process replaces its own program image with the image of the command line program by calling the subroutine execl(program). • The new program thinks it’s running normally but is connected to a pseudo-terminal. • The parent monitors the output and feeds input to the child. • Java client   CLTerm   Command Line Program

  6. System Architecture User Computers Bob’s Computer Alice’s Computer Frank’s Computer Java Client 1 Java Client 3 Java Applet Java Client 2 The Network Chasm Transpgrid — PPPL Cluster HTTP Servlet clterm genxpl clterm rplot clterm trxpl clterm rplot

  7. The Servlet • Servlet complements Java applet / application • Applet has limited “sandbox” on user’s computer • Servlet runs on cluster – http connection to client • Run programs • Access user files • Enforce security • Added 2 methods: • Runcl – start a new clterm session • Inputcl – send a line of user input to clterm

  8. CLTerm.c • How it works • One instance of CLTerm is launched for each client. • Each instance connects to one command line program. • It forks a new child process which in turn launches the program in its place. • They talk via a pseudo-terminal and CLTerm forwards the output to the servlet and feeds the data it gets from the servlet into the child via the pseudo-terminal. • CLTerm checks each iteration of its I/O loop, that the child is still “alive.” If not then it sends an exit byte down the line.

  9. CLPanel.java • How it works • CLPanel inherits from JPanel and can be implemented in either a JFrame or a JInternalFrame like in ElVis. • Has all the communication and GUI code. • Has an I/O loop that first reads the user’s input and then looks for the program’s response, sent via the servlet. • If the user closes the CLPanel window, it will send an exit byte (ASCII code 25) down the line so that everything else is informed.

  10. CLTerm In Action

  11. Conclusion • End result and advantages • Successfully integrated a solution for Java clients to talk to command line programs. • Minimal changes to the existing infrastructure. • CLTerm is appropriate for larger applications given its encapsulated nature. • CLPanel lets Java developers incorporate this panel into their own applications. • CLPanel is a class which can be instantiated multiple times in the same application: multiple windows/connections in the same app. • Can also run as an Applet in a browser. • Opportunity to expand PPL Fusion Grid Services.

  12. CLTerm Demo!

More Related