Refine search
SlaveComputer c = getComputer(); if (c == null) { listener.error("Issue with creating launcher for agent " + name + ". Computer has been disconnected"); return new Launcher.DummyLauncher(listener); } else { Slave node = c.getNode(); if (node != this) { String message = "Issue with creating launcher for agent " + name + ". Computer has been reconnected"; final Channel channel = c.getChannel(); if (channel == null) { reportLauncherCreateError("The agent has not been fully initialized yet", "No remoting channel to the agent OR it has not been fully initialized yet", listener); return new Launcher.DummyLauncher(listener); reportLauncherCreateError("The agent is being disconnected", "Remoting channel is either in the process of closing down or has closed down", listener); return new Launcher.DummyLauncher(listener); final Boolean isUnix = c.isUnix(); if (isUnix == null) {
boolean shouldBeOnline = isOnlineScheduled(); LOGGER.log(Level.FINE, "Checking computer {0} against schedule. online = {1}, shouldBeOnline = {2}", new Object[]{c.getName(), c.isOnline(), shouldBeOnline}); if (shouldBeOnline && c.isOffline()) { LOGGER.log(INFO, "Trying to launch computer {0} as schedule says it should be on-line at " + "this point in time", new Object[]{c.getName()}); if (c.isLaunchSupported()) { Computer.threadPoolForRemoting.submit(new Runnable() { public void run() { } else if (!shouldBeOnline && c.isOnline()) { if (keepUpWhenActive) { if (!c.isIdle() && c.isAcceptingTasks()) { c.setAcceptingTasks(false); LOGGER.log(INFO, "Disabling new jobs for computer {0} as it has finished its scheduled uptime", new Object[]{c.getName()}); return 1; } else if (c.isIdle() && c.isAcceptingTasks()) { Queue.withLock(new Runnable() { @Override } else if (c.isIdle() && !c.isAcceptingTasks()) { Queue.withLock(new Runnable() { @Override new Object[]{c.getName()}); c.disconnect(OfflineCause.create(Messages._SimpleScheduledRetentionStrategy_FinishedUpTime()));
/** * Creates a {@link Channel} from the given stream and sets that to this agent. * * Same as {@link #setChannel(InputStream, OutputStream, OutputStream, Channel.Listener)}, but for * {@link TaskListener}. */ public void setChannel(@Nonnull InputStream in, @Nonnull OutputStream out, @Nonnull TaskListener taskListener, @CheckForNull Channel.Listener listener) throws IOException, InterruptedException { setChannel(in,out,taskListener.getLogger(),listener); }
@GuardedBy("hudson.model.Queue.lock") public long check(SlaveComputer c) { if (c.isOffline() && !c.isConnecting() && c.isLaunchSupported()) c.tryReconnect(); return 1; }
public void run() { try { c.connect(true).get(); if (c.isOnline()) { LOGGER.log(INFO, "Launched computer {0} per schedule", new Object[]{c.getName()}); } if (keepUpWhenActive && c.isOnline() && !c.isAcceptingTasks()) { LOGGER.log(INFO, "Enabling new jobs for computer {0} as it has started its scheduled uptime", new Object[]{c.getName()}); c.setAcceptingTasks(true); } } catch (InterruptedException | ExecutionException e) { } } });
@Override public void run() { if (c.isIdle()) { LOGGER.log(INFO, "Disconnecting computer {0} as it has finished its scheduled uptime", new Object[]{c.getName()}); c.disconnect(OfflineCause .create(Messages._SimpleScheduledRetentionStrategy_FinishedUpTime())); } else { c.setAcceptingTasks(false); } } });
@Override public void afterDisconnect(SlaveComputer computer, TaskListener listener) { try { JIDefaultAuthInfoImpl auth = createAuth(); JISession session = JISession.createSession(auth); session.setGlobalSocketTimeout(60000); SWbemServices services = WMI.connect(session, computer.getName()); Win32Service slaveService = services.getService("hudsonslave"); if(slaveService!=null) { listener.getLogger().println(Messages.ManagedWindowsServiceLauncher_StoppingService()); slaveService.StopService(); } } catch (UnknownHostException e) { e.printStackTrace(listener.error(e.getMessage())); } catch (JIException e) { e.printStackTrace(listener.error(e.getMessage())); } }
Process _proc = null; try { listener.getLogger().println(hudson.model.Messages.Slave_Launching(getTimestamp())); if (getCommand().trim().length() == 0) { listener.getLogger().println(Messages.CommandLauncher_NoLaunchCommand()); return; listener.getLogger().println("$ " + getCommand()); new StreamCopyThread("stderr copier for remote agent on " + computer.getDisplayName(), proc.getErrorStream(), listener.getLogger()).start(); computer.setChannel(proc.getInputStream(), proc.getOutputStream(), listener.getLogger(), new Channel.Listener() { @Override public void onClosed(Channel channel, IOException cause) { LOGGER.info("slave agent launched for " + computer.getDisplayName()); } catch (InterruptedException e) { e.printStackTrace(listener.error(Messages.ComputerLauncher_abortedLaunch())); msg = " : " + msg; msg = hudson.model.Messages.Slave_UnableToLaunch(computer.getDisplayName(), msg); LOGGER.log(Level.SEVERE, msg, e); e.printStackTrace(listener.error(msg));
Process _proc = null; try { Slave node = computer.getNode(); if (node == null) { throw new AbortException("Cannot launch commands on deleted nodes"); listener.getLogger().println("$ " + getCommand()); pb.environment().put("WORKSPACE", StringUtils.defaultString(computer.getAbsoluteRemoteFs(), node.getRemoteFS())); //path for local slave log new StreamCopyThread("stderr copier for remote agent on " + computer.getDisplayName(), proc.getErrorStream(), listener.getLogger()).start(); computer.setChannel(proc.getInputStream(), proc.getOutputStream(), listener.getLogger(), new Channel.Listener() { @Override public void onClosed(Channel channel, IOException cause) { LOGGER.info("agent launched for " + computer.getDisplayName()); } catch (InterruptedException e) { Functions.printStackTrace(e, listener.error(Messages.ComputerLauncher_abortedLaunch())); msg = hudson.model.Messages.Slave_UnableToLaunch(computer.getDisplayName(), msg); LOGGER.log(Level.SEVERE, msg, e); Functions.printStackTrace(e, listener.error(msg));
@Override public void launch(SlaveComputer computer, TaskListener listener) { listener.getLogger().println("Launching " + computer.getDisplayName()); try { if (!(computer instanceof DockerComputerSingle)) { throw new IllegalStateException(computer.getName() + " not instance of DockerComputerSingle"); } provisionWithWait((DockerComputerSingle) computer, listener); } catch (Throwable e) { LOG.error("Can't launch ", e); listener.error("Can't launch " + e.getMessage()); Throwables.propagate(e); } }
@Override @SuppressFBWarnings("NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE") public void afterDisconnect(SlaveComputer computer, TaskListener listener) { final Slave node = computer.getNode(); if (node != null) { try { Jenkins.getInstance().removeNode(node); } catch (IOException e) { e.printStackTrace(listener.error(e.getMessage())); } } else { listener.getLogger().printf("Could not remove node for %s as it appears to have been removed already%n", computer); } } };
@Override public void launch(SlaveComputer computer, final TaskListener listener) { try { Slave node = computer.getNode(); if (node == null) { throw new AbortException("Cannot launch commands on deleted nodes"); listener.getLogger().println("$ " + cmd); ProcessBuilder pb = new ProcessBuilder(Util.tokenize(cmd)); final EnvVars cookie = EnvVars.createCookie(); new StreamCopyThread("stderr copier for remote agent on " + computer.getDisplayName(), proc.getErrorStream(), listener.getLogger()).start(); computer.setChannel(proc.getInputStream(), proc.getOutputStream(), listener.getLogger(), new Channel.Listener() { @Override public void onClosed(Channel channel, IOException cause) { LOGGER.log(Level.INFO, "agent launched for {0}", computer.getName()); } catch (Exception x) { LOGGER.log(Level.WARNING, null, x);
PrintStream log = taskListener.getLogger(); Slave node = getNode(); if (node == null) { // Node has been disabled/removed during the connection throw new IOException("Node "+nodeName+" has been deleted during the channel setup"); String remoteFS = node.getRemoteFS(); if (Util.isRelativePath(remoteFS)) { remoteFS = channel.call(new AbsolutePath(remoteFS));
@Override public void launch(@Nonnull SlaveComputer computer, TaskListener listener) throws IOException, InterruptedException { Slave n = computer.getNode(); if (!(n instanceof JCloudsSlave)) { LOGGER.warning(getClass().getSimpleName() + " used to launch incompatible computer type " + computer.getClass()); return; } JCloudsSlave node = (JCloudsSlave) n; Integer configuredTimeout = node.getSlaveOptions().getStartTimeout(); if (configuredTimeout == null) throw new NullPointerException(); long timeout = node.getCreatedTime() + configuredTimeout; do { launcher(computer).launch(computer, listener); if (computer.isOnline()) return; listener.getLogger().println("Launcher failed to bring the node online. Retrying ..."); Thread.sleep(2000); } while (System.currentTimeMillis() < timeout); listener.getLogger().println("Launcher failed to bring the node online within timeout."); }
@Override @GuardedBy("hudson.model.Queue.lock") public long check(final SlaveComputer c) { if (c.isOffline() && c.isLaunchSupported()) { final HashMap<Computer, Integer> availableComputers = new HashMap<>(); for (Computer o : Jenkins.get().getComputers()) { Node checkedNode = c.getNode(); if (needExecutor && checkedNode != null && checkedNode.canTake(item) == null) { demandMilliseconds = System.currentTimeMillis() - item.buildableStartMilliseconds; new Object[]{c.getName(), Util.getTimeSpanString(demandMilliseconds)}); c.connect(false); } else if (c.isIdle()) { final long idleMilliseconds = System.currentTimeMillis() - c.getIdleStartMilliseconds(); if (idleMilliseconds > idleDelay * 1000 * 60 /*MINS->MILLIS*/) { new Object[]{c.getName(), Util.getTimeSpanString(idleMilliseconds)}); c.disconnect(new OfflineCause.IdleOfflineCause()); } else {
boolean shouldAcceptTasks = c.isAcceptingTasks(); c.setAcceptingTasks(false); try { if (isIdleForTooLong(c)) { Node compNode = c.getNode(); if (compNode == null) { return 0; if (c.isOffline() && !c.isConnecting() && c.isLaunchSupported()) c.tryReconnect(); c.setAcceptingTasks(shouldAcceptTasks);
public RetentionStrategy getRetentionStrategy() { Slave n = getNode(); return n==null ? RetentionStrategy.NOOP : n.getRetentionStrategy(); }
public InstallerGui(SlaveInstaller installer, SlaveComputer sc) { this.installer = installer; final Slave node = sc.getNode(); if (node == null) { throw new IllegalStateException("The configration has change and the node for computer " + sc.getName() + " is removed"); } // TODO: missing null check this.slaveRoot = node.getRootPath(); this.jnlpMac = sc.getJnlpMac(); }
args.add("-workDir"); if (workDirPath == null) { Slave node = computer.getNode(); if (node == null) { args.add(node.getRemoteFS()); } else { args.add(workDirPath);
@CheckForNull @Override public T getNode() { return (T) super.getNode(); }