KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > proactive > core > process > lsf > RLoginProcess


1 /*
2 * ################################################################
3 *
4 * ProActive: The Java(TM) library for Parallel, Distributed,
5 * Concurrent computing with Security and Mobility
6 *
7 * Copyright (C) 1997-2002 INRIA/University of Nice-Sophia Antipolis
8 * Contact: proactive-support@inria.fr
9 *
10 * This library is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public
12 * License as published by the Free Software Foundation; either
13 * version 2.1 of the License, or any later version.
14 *
15 * This library is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Lesser General Public License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with this library; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
23 * USA
24 *
25 * Initial developer(s): The ProActive Team
26 * http://www.inria.fr/oasis/ProActive/contacts.html
27 * Contributor(s):
28 *
29 * ################################################################
30 */

31 package org.objectweb.proactive.core.process.lsf;
32
33 import org.objectweb.proactive.core.process.SimpleExternalProcess;
34 import org.objectweb.proactive.core.process.AbstractExternalProcessDecorator;
35 import org.objectweb.proactive.core.process.ExternalProcess;
36
37 /**
38  * <p>
39  * The RloginProcess class is able to start any class, of the ProActive library,
40  * using rlogin command.
41  * </p><p>
42  * For instance:
43  * </p><pre>
44  * ...............
45  * PrunSubProcess lsf = new PrunSubProcess(new SimpleExternalProcess("ls -lsa"));
46  * RLoginProcess p = new RLoginProcess(lsf, false);
47  * p.setHostname("cluster_front_end_name");
48  * p.startProcess();
49  * ...............
50  * </pre>
51  * @author ProActive Team
52  * @version 1.0, 2002/09/20
53  * @since ProActive 0.9.4
54  */

55
56 public class RLoginProcess extends AbstractExternalProcessDecorator {
57   
58   private boolean exitAfterCommand;
59   //
60
// -- CONSTRUCTORS -----------------------------------------------
61
//
62

63   /**
64    * Creates a new RloginProcess
65    * Used with XML Descriptors
66    */

67   public RLoginProcess() {
68     super();
69     setCompositionType(SEND_TO_OUTPUT_STREAM_COMPOSITION);
70   }
71   
72   /**
73    * Creates a new RloginProcess
74    * @param targetProcess The target process associated to this process. The target process
75    * represents the process that will be launched after logging remote host with rlogin
76    */

77   public RLoginProcess(ExternalProcess targetProcess) {
78     this(targetProcess, false);
79   }
80   
81   
82   /**
83    * Creates a new RloginProcess
84    * @param targetProcess The target process associated to this process. The target process
85    * represents the process that will be launched after logging remote host with rlogin
86    * @param exitAfterCommand If true the process will finished once rlogin command is performed. The default value is false
87    */

88   public RLoginProcess(ExternalProcess targetProcess, boolean exitAfterCommand) {
89     super(targetProcess, SEND_TO_OUTPUT_STREAM_COMPOSITION);
90     this.exitAfterCommand = exitAfterCommand;
91   }
92
93     
94     
95   //
96
// -- PUBLIC METHODS -----------------------------------------------
97
//
98
/**
99      * Method setExitAfterCommand
100      * @param b If true the process will finished once rlogin command is performed. The default vaule is false
101      */

102   public void setExitAfterCommand(boolean b) {
103     exitAfterCommand = b;
104   }
105     
106     
107     /**
108      * Returns the value of the boolean telling that the process will finished after rlogin command or will wait
109      * for another command to be pushed once logging on the remote host
110      * @return boolean
111      */

112   public boolean getExitAfterCommand() {
113     return exitAfterCommand;
114   }
115     
116   public static void main(String JavaDoc[] args) {
117     try {
118       LSFBSubProcess lsf = new LSFBSubProcess(new SimpleExternalProcess("ls -lsa"));
119       RLoginProcess p = new RLoginProcess(lsf, false);
120       p.setHostname("galere1");
121       p.startProcess();
122     } catch (Exception JavaDoc e) {
123       e.printStackTrace();
124     }
125   }
126
127
128   //
129
// -- PROTECTED METHODS -----------------------------------------------
130
//
131

132   protected String JavaDoc internalBuildCommand() {
133     return buildEnvironmentCommand()+buildRLoginCommand();
134   }
135   
136   
137   protected String JavaDoc buildRLoginCommand() {
138     return "rlogin "+hostname+" ";
139   }
140   
141   
142   protected void internalStartProcess(String JavaDoc command) throws java.io.IOException JavaDoc {
143     
144     super.internalStartProcess(command);
145     if (exitAfterCommand) {
146       outputMessageSink.setMessage(null);
147     }
148   }
149
150
151   //
152
// -- PRIVATE METHODS -----------------------------------------------
153
//
154

155 }
156
Popular Tags