/** * @deprecated since 2009-04-13. * Use {@link #forProcess(String, ExecutorService, InputStream, OutputStream, OutputStream, Proc)} */ @Deprecated public static Channel forProcess(String name, ExecutorService execService, InputStream in, OutputStream out, Proc proc) throws IOException { return forProcess(name,execService,in,out,null,proc); }
/** * Launches a new JVM with the given classpath and system properties, establish a communication channel, * and return a {@link Channel} to it. * * @param displayName * Human readable name of what this JVM represents. For example "Selenium grid" or "Hadoop". * This token is used for messages to {@code listener}. * @param listener * The progress of the launcher and the failure information will be sent here. Must not be null. * @param workDir * If non-null, the new JVM will have this directory as the working directory. This must be a local path. * @param classpath * The classpath of the new JVM. Can be null if you just need {@code agent.jar} (and everything else * can be sent over the channel.) But if you have jars that are known to be necessary by the new JVM, * setting it here will improve the classloading performance (by avoiding remote class file transfer.) * Classes in this classpath will also take precedence over any other classes that's sent via the channel * later, so it's also useful for making sure you get the version of the classes you want. * @param systemProperties * If the new JVM should have a certain system properties set. Can be null. * * @return * never null * @since 1.300 */ public static Channel newJVM(String displayName, TaskListener listener, FilePath workDir, ClasspathBuilder classpath, Map<String,String> systemProperties) throws IOException { JVMBuilder vmb = new JVMBuilder(); vmb.systemProperties(systemProperties); return newJVM(displayName,listener,vmb,workDir,classpath); }
serverSocket.close(); return forProcess("Channel to "+displayName, Computer.threadPoolForRemoting, new BufferedInputStream(SocketChannelStream.in(s)), new BufferedOutputStream(SocketChannelStream.out(s)),null,p);
/** * Launches a new JVM with the given classpath and system properties, establish a communication channel, * and return a {@link Channel} to it. * * @param displayName * Human readable name of what this JVM represents. For example "Selenium grid" or "Hadoop". * This token is used for messages to {@code listener}. * @param listener * The progress of the launcher and the failure information will be sent here. Must not be null. * @param workDir * If non-null, the new JVM will have this directory as the working directory. This must be a local path. * @param classpath * The classpath of the new JVM. Can be null if you just need {@code slave.jar} (and everything else * can be sent over the channel.) But if you have jars that are known to be necessary by the new JVM, * setting it here will improve the classloading performance (by avoiding remote class file transfer.) * Classes in this classpath will also take precedence over any other classes that's sent via the channel * later, so it's also useful for making sure you get the version of the classes you want. * @param systemProperties * If the new JVM should have a certain system properties set. Can be null. * * @return * never null * @since 1.300 */ public static Channel newJVM(String displayName, TaskListener listener, FilePath workDir, ClasspathBuilder classpath, Map<String,String> systemProperties) throws IOException { JVMBuilder vmb = new JVMBuilder(); vmb.systemProperties(systemProperties); return newJVM(displayName,listener,vmb,workDir,classpath); }
VirtualChannel start(TaskListener listener, String rootPassword) throws IOException, InterruptedException { final int uid = LIBC.geteuid(); if(uid==0) // already running as root return newLocalChannel(); String javaExe = System.getProperty("java.home") + "/bin/java"; File slaveJar = Which.jarFile(Launcher.class); ArgumentListBuilder args = new ArgumentListBuilder().add(javaExe); if(slaveJar.isFile()) args.add("-jar").add(slaveJar); else // in production code this never happens, but during debugging this is convenient args.add("-cp").add(slaveJar).add(hudson.remoting.Launcher.class.getName()); if(rootPassword==null) { // try sudo, in the hope that the user has the permission to do so without password return new LocalLauncher(listener).launchChannel( args.prepend(sudoExe()).toCommandArray(), listener.getLogger(), null, Collections.<String, String>emptyMap()); } else { // try sudo with the given password. Also run in pfexec so that we can elevate the privileges Process proc = sudoWithPass(args); return Channels.forProcess(args.toStringWithQuote(), Computer.threadPoolForRemoting, proc, listener.getLogger() ); } } }
/** * Launches a new JVM with the given classpath and system properties, establish a communication channel, * and return a {@link Channel} to it. * * @param displayName * Human readable name of what this JVM represents. For example "Selenium grid" or "Hadoop". * This token is used for messages to {@code listener}. * @param listener * The progress of the launcher and the failure information will be sent here. Must not be null. * @param workDir * If non-null, the new JVM will have this directory as the working directory. This must be a local path. * @param classpath * The classpath of the new JVM. Can be null if you just need {@code agent.jar} (and everything else * can be sent over the channel.) But if you have jars that are known to be necessary by the new JVM, * setting it here will improve the classloading performance (by avoiding remote class file transfer.) * Classes in this classpath will also take precedence over any other classes that's sent via the channel * later, so it's also useful for making sure you get the version of the classes you want. * @param systemProperties * If the new JVM should have a certain system properties set. Can be null. * * @return * never null * @since 1.300 */ public static Channel newJVM(String displayName, TaskListener listener, FilePath workDir, ClasspathBuilder classpath, Map<String,String> systemProperties) throws IOException { JVMBuilder vmb = new JVMBuilder(); vmb.systemProperties(systemProperties); return newJVM(displayName,listener,vmb,workDir,classpath); }
/** * @deprecated since 2009-04-13. * Use {@link #forProcess(String, ExecutorService, InputStream, OutputStream, OutputStream, Proc)} */ public static Channel forProcess(String name, ExecutorService execService, InputStream in, OutputStream out, Proc proc) throws IOException { return forProcess(name,execService,in,out,null,proc); }
/** * Launches a new JVM with the given classpath and system properties, establish a communication channel, * and return a {@link Channel} to it. * * @param displayName * Human readable name of what this JVM represents. For example "Selenium grid" or "Hadoop". * This token is used for messages to {@code listener}. * @param listener * The progress of the launcher and the failure information will be sent here. Must not be null. * @param workDir * If non-null, the new JVM will have this directory as the working directory. This must be a local path. * @param classpath * The classpath of the new JVM. Can be null if you just need {@code slave.jar} (and everything else * can be sent over the channel.) But if you have jars that are known to be necessary by the new JVM, * setting it here will improve the classloading performance (by avoiding remote class file transfer.) * Classes in this classpath will also take precedence over any other classes that's sent via the channel * later, so it's also useful for making sure you get the version of the classes you want. * @param systemProperties * If the new JVM should have a certain system properties set. Can be null. * * @return * never null * @since 1.300 */ public static Channel newJVM(String displayName, TaskListener listener, FilePath workDir, ClasspathBuilder classpath, Map<String,String> systemProperties) throws IOException { JVMBuilder vmb = new JVMBuilder(); vmb.systemProperties(systemProperties); return newJVM(displayName,listener,vmb,workDir,classpath); }
/** * @deprecated since 2009-04-13. * Use {@link #forProcess(String, ExecutorService, InputStream, OutputStream, OutputStream, Proc)} */ public static Channel forProcess(String name, ExecutorService execService, InputStream in, OutputStream out, Proc proc) throws IOException { return forProcess(name,execService,in,out,null,proc); }
/** * Launches a new JVM with the given classpath and system properties, establish a communication channel, * and return a {@link Channel} to it. * * @param displayName * Human readable name of what this JVM represents. For example "Selenium grid" or "Hadoop". * This token is used for messages to {@code listener}. * @param listener * The progress of the launcher and the failure information will be sent here. Must not be null. * @param workDir * If non-null, the new JVM will have this directory as the working directory. This must be a local path. * @param classpath * The classpath of the new JVM. Can be null if you just need {@code slave.jar} (and everything else * can be sent over the channel.) But if you have jars that are known to be necessary by the new JVM, * setting it here will improve the classloading performance (by avoiding remote class file transfer.) * Classes in this classpath will also take precedence over any other classes that's sent via the channel * later, so it's also useful for making sure you get the version of the classes you want. * @param systemProperties * If the new JVM should have a certain system properties set. Can be null. * * @return * never null * @since 1.300 */ public static Channel newJVM(String displayName, TaskListener listener, FilePath workDir, ClasspathBuilder classpath, Map<String,String> systemProperties) throws IOException { JVMBuilder vmb = new JVMBuilder(); vmb.systemProperties(systemProperties); return newJVM(displayName,listener,vmb,workDir,classpath); }
/** * @deprecated since 2009-04-13. * Use {@link #forProcess(String, ExecutorService, InputStream, OutputStream, OutputStream, Proc)} */ public static Channel forProcess(String name, ExecutorService execService, InputStream in, OutputStream out, Proc proc) throws IOException { return forProcess(name,execService,in,out,null,proc); }
/** * Launches a new JVM with the given classpath and system properties, * establish a communication channel, and return a {@link Channel} to it. * * @param displayName Human readable name of what this JVM represents. For * example "Selenium grid" or "Hadoop". This token is used for messages to * {@code listener}. * @param listener The progress of the launcher and the failure information * will be sent here. Must not be null. * @param workDir If non-null, the new JVM will have this directory as the * working directory. This must be a local path. * @param classpath The classpath of the new JVM. Can be null if you just * need {@code slave.jar} (and everything else can be sent over the * channel.) But if you have jars that are known to be necessary by the new * JVM, setting it here will improve the classloading performance (by * avoiding remote class file transfer.) Classes in this classpath will also * take precedence over any other classes that's sent via the channel later, * so it's also useful for making sure you get the version of the classes * you want. * @param systemProperties If the new JVM should have a certain system * properties set. Can be null. * * @return never null * @since 1.300 */ public static Channel newJVM(String displayName, TaskListener listener, FilePath workDir, ClasspathBuilder classpath, Map<String, String> systemProperties) throws IOException { JVMBuilder vmb = new JVMBuilder(); vmb.systemProperties(systemProperties); return newJVM(displayName, listener, vmb, workDir, classpath); }
/** * @deprecated since 2009-04-13. Use * {@link #forProcess(String, ExecutorService, InputStream, OutputStream, OutputStream, Proc)} */ public static Channel forProcess(String name, ExecutorService execService, InputStream in, OutputStream out, Proc proc) throws IOException { return forProcess(name, execService, in, out, null, proc); }
/** * Launches Hub in a separate JVM. * */ public static Channel createSeleniumGridVM(TaskListener listener) throws IOException { JVMBuilder vmb = new JVMBuilder(); vmb.systemProperties(null); return Channels.newJVM("Selenium Grid", listener, vmb, new FilePath(Jenkins.getInstance().getRootDir()), new ClasspathBuilder().add(findStandAloneServerJar()).add(findHtmlUnitDriverJar())); }
/** * @deprecated since 2009-04-13. * Use {@link #forProcess(String, ExecutorService, InputStream, OutputStream, OutputStream, Proc)} */ @Deprecated public static Channel forProcess(String name, ExecutorService execService, InputStream in, OutputStream out, Proc proc) throws IOException { return forProcess(name,execService,in,out,null,proc); }
serverSocket.close(); return forProcess("Channel to "+displayName, Computer.threadPoolForRemoting, new BufferedInputStream(SocketChannelStream.in(s)), new BufferedOutputStream(SocketChannelStream.out(s)),null,p);
serverSocket.close(); return forProcess("Channel to "+displayName, Computer.threadPoolForRemoting, new BufferedInputStream(new SocketInputStream(s)), new BufferedOutputStream(new SocketOutputStream(s)),null,p);
serverSocket.close(); return forProcess("Channel to " + displayName, Computer.threadPoolForRemoting, new BufferedInputStream(new SocketInputStream(s)), new BufferedOutputStream(new SocketOutputStream(s)), null, p);
serverSocket.close(); return forProcess("Channel to "+displayName, Computer.threadPoolForRemoting, new BufferedInputStream(new SocketInputStream(s)), new BufferedOutputStream(new SocketOutputStream(s)),null,p);
serverSocket.close(); return forProcess("Channel to "+displayName, Computer.threadPoolForRemoting, new BufferedInputStream(new SocketInputStream(s)), new BufferedOutputStream(new SocketOutputStream(s)),null,p);