KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > proactive > core > descriptor > data > VirtualMachineImpl


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.descriptor.data;
32
33 import org.objectweb.proactive.core.process.ExternalProcess;
34
35
36 /**
37  * A <code>VirtualMachine</code> is a conceptual entity that represents
38  * a JVM running a ProActiveRuntime
39  *
40  * @author ProActive Team
41  * @version 1.0, 2002/09/20
42  * @since ProActive 0.9.4
43  *
44  */

45 public class VirtualMachineImpl implements VirtualMachine, java.io.Serializable JavaDoc {
46     //
47
// ----- PRIVATE MEMBERS -----------------------------------------------------------------------------------
48
//
49

50     /** the name of this VirtualMachine */
51     private String JavaDoc name;
52
53     /** number of nodes that will be deployed on this VM. One node is the default */
54     private String JavaDoc nodeNumber = "1";
55
56     /** the acquisition method to use to find the VirtualMachine once created */
57     private String JavaDoc acquisitionMethod;
58
59 // /** the port number used during the acquisition */
60
// private String portNumber;
61

62     /** the process to start in order to create the JVM */
63     private transient ExternalProcess process;
64
65     /** The name of the VirtualNode that created this VirtualMachine */
66     private String JavaDoc creatorId = null;
67
68     //
69
// ----- CONSTRUCTORS -----------------------------------------------------------------------------------
70
//
71

72     /**
73      * Contructs a new intance of VirtualNode
74      */

75     VirtualMachineImpl() {
76     }
77
78     //
79
// ----- PUBLIC METHODS -----------------------------------------------------------------------------------
80
//
81
public void setHostsNumber(String JavaDoc nodeNumber) throws java.io.IOException JavaDoc {
82         if (new Integer JavaDoc(nodeNumber).intValue() < 1) {
83             throw new java.io.IOException JavaDoc(
84                 "Cannot define nodeNumber with a value < 1");
85         }
86         this.nodeNumber = nodeNumber;
87     }
88     
89
90     public String JavaDoc getNodeNumber() {
91         return this.nodeNumber;
92     }
93
94     public void setName(String JavaDoc s) {
95         name = s;
96     }
97
98     public String JavaDoc getName() {
99         return name;
100     }
101
102 // public void setAcquisitionMethod(String s) {
103
// acquisitionMethod = s;
104
// }
105
//
106
// public String getAcquisitionMethod() {
107
// return acquisitionMethod;
108
// }
109

110     
111 // public void setPortNumber(String s) {
112
// portNumber = s;
113
// }
114
//
115
// public String getPortNumber() {
116
// return portNumber;
117
// }
118

119     public void setProcess(ExternalProcess p) {
120         process = p;
121     }
122
123     public ExternalProcess getProcess() {
124         return process;
125     }
126
127     /**
128      * Returns the name of the machine where the process mapped to this virtual machine
129      * was launched.
130      * @return String
131      */

132     public String JavaDoc getHostName() {
133         String JavaDoc hostName = process.getHostname();
134         if (hostName == null) {
135             hostName = "localhost";
136         }
137         return hostName;
138     }
139
140     public void setCreatorId(String JavaDoc creatorId) {
141         this.creatorId = creatorId;
142     }
143
144     public String JavaDoc getCreatorId() {
145         return this.creatorId;
146     }
147 }
148
Popular Tags