00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 package org.objectweb.proactive.core.runtime;
00032
00033 import java.io.File;
00034 import java.io.IOException;
00035 import java.net.URL;
00036
00037 import org.apache.log4j.Logger;
00038 import org.apache.log4j.PropertyConfigurator;
00039 import org.objectweb.proactive.core.ProActiveException;
00040 import org.objectweb.proactive.core.config.ProActiveConfiguration;
00041 import org.objectweb.proactive.core.util.UrlBuilder;
00042 import org.objectweb.proactive.core.util.log.Loggers;
00043 import org.objectweb.proactive.core.util.log.ProActiveLogger;
00044
00045
00060 public class StartRuntime {
00061
00062
00063
00064 static Logger logger = ProActiveLogger.getLogger(Loggers.RUNTIME);
00065 protected String defaultRuntimeURL;
00066 protected String nodeURL;
00067 protected String creatorID;
00068 protected ProActiveRuntime proActiveRuntime;
00069
00070
00071 protected String nodeNumber;
00072 protected String vmName;
00073 protected int nodenumber;
00074 protected String protocolId;
00075
00076 protected StartRuntime() {
00077 }
00078
00079 private StartRuntime(String[] args) {
00080 if (args.length != 0) {
00081 this.nodeURL = args[0];
00082 this.creatorID = args[0].trim();
00083
00084
00085 this.defaultRuntimeURL = UrlBuilder.removeUsername(args[1]);
00086
00087
00088 this.nodeNumber = args[2];
00089
00090
00091 this.nodenumber = (new Integer(nodeNumber)).intValue();
00092 this.protocolId = args[3];
00093 this.vmName = args[4];
00094 }
00095 }
00096
00097 public static void main(String[] args) {
00098 if ("true".equals(System.getProperty("log4j.defaultInitOverride")) &&
00099 (System.getProperty("log4j.configuration") != null)) {
00100
00101 try {
00102 String log4jConfiguration = System.getProperty(
00103 "log4j.configuration");
00104 File f = new File(log4jConfiguration);
00105 PropertyConfigurator.configure(new URL(f.getPath()));
00106 } catch (IOException e) {
00107 System.out.println(
00108 "Error : incorrect path for log4j configuration : " +
00109 System.getProperty("log4j.configuration"));
00110 }
00111 }
00112
00113 ProActiveConfiguration.load();
00114
00115 try {
00116 logger.info("**** Starting jvm on " +
00117 UrlBuilder.getHostNameorIP(java.net.InetAddress.getLocalHost()));
00118
00119 if (logger.isDebugEnabled()) {
00120 logger.debug("**** Starting jvm with classpath " +
00121 System.getProperty("java.class.path"));
00122 logger.debug("**** with bootclasspath " +
00123 System.getProperty("sun.boot.class.path"));
00124 }
00125 } catch (java.net.UnknownHostException e) {
00126 e.printStackTrace();
00127 }
00128
00129 new StartRuntime(args).run();
00130 }
00131
00137 private void run() {
00138 ProActiveRuntimeImpl impl = (ProActiveRuntimeImpl) ProActiveRuntimeImpl.getProActiveRuntime();
00139 impl.getVMInformation().setCreationProtocolID(protocolId);
00140
00141 if (defaultRuntimeURL != null) {
00142 ProActiveRuntime PART;
00143 try {
00144 PART = RuntimeFactory.getRuntime(defaultRuntimeURL,
00145 UrlBuilder.getProtocol(defaultRuntimeURL));
00146 register(PART);
00147 impl.setParent(PART);
00148 } catch (ProActiveException e) {
00149 e.printStackTrace();
00150
00151 System.exit(0);
00152 }
00153 }
00154 }
00155
00161 private void register(ProActiveRuntime PART) {
00162 try {
00163 proActiveRuntime = RuntimeFactory.getProtocolSpecificRuntime(System.getProperty(
00164 "proactive.communication.protocol") + ":");
00165
00166 PART.register(proActiveRuntime, proActiveRuntime.getURL(),
00167 creatorID,
00168 System.getProperty("proactive.communication.protocol") + ":",
00169 vmName);
00170 } catch (ProActiveException e) {
00171 e.printStackTrace();
00172
00173
00174 System.exit(0);
00175 }
00176 }
00177 }