hudson.slaves.ComputerLauncher Java Examples
The following examples show how to use
hudson.slaves.ComputerLauncher.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DockerSlave.java From yet-another-docker-plugin with MIT License | 6 votes |
public DockerSlave(String slaveName, String nodeDescription, ComputerLauncher launcher, String containerId, DockerSlaveTemplate dockerSlaveTemplate, String cloudId, ProvisioningActivity.Id provisioningId) throws IOException, Descriptor.FormException { super(slaveName, nodeDescription, //description dockerSlaveTemplate.getRemoteFs(), dockerSlaveTemplate.getNumExecutors(), dockerSlaveTemplate.getMode(), dockerSlaveTemplate.getLabelString(), launcher, dockerSlaveTemplate.getRetentionStrategyCopy(), dockerSlaveTemplate.getNodeProperties() ); this.displayName = slaveName; // initial value this.containerId = containerId; this.cloudId = cloudId; setDockerSlaveTemplate(dockerSlaveTemplate); this.provisioningId = provisioningId; }
Example #2
Source File: ECSSlave.java From amazon-ecs-plugin with MIT License | 6 votes |
public ECSSlave(@Nonnull ECSCloud cloud, @Nonnull String name, ECSTaskTemplate template, @Nonnull ComputerLauncher launcher) throws Descriptor.FormException, IOException { super( name, "ECS Agent", template.makeRemoteFSRoot(name), 1, Mode.EXCLUSIVE, template.getLabel(), launcher, cloud.getRetainAgents() ? new CloudRetentionStrategy(cloud.getRetentionTimeout()) : new OnceRetentionStrategy(cloud.getRetentionTimeout()), Collections.emptyList() ); this.cloud = cloud; this.template = template; }
Example #3
Source File: DockerComputerConnector.java From docker-plugin with MIT License | 6 votes |
@Nonnull public final ComputerLauncher createLauncher(@Nonnull final DockerAPI api, @Nonnull final String containerId, @Nonnull String workdir, @Nonnull TaskListener listener) throws IOException, InterruptedException { final InspectContainerResponse inspect; try(final DockerClient client = api.getClient()) { inspect = client.inspectContainerCmd(containerId).exec(); } final ComputerLauncher launcher = createLauncher(api, workdir, inspect, listener); final Boolean running = inspect.getState().getRunning(); if (Boolean.FALSE.equals(running)) { listener.error("Container {} is not running. {}", containerId, inspect.getState().getStatus()); throw new IOException("Container is not running."); } return new DockerDelegatingComputerLauncher(launcher, api, containerId); }
Example #4
Source File: ProvisionIntegrationTest.java From ec2-spot-jenkins-plugin with Apache License 2.0 | 6 votes |
@Test public void should_not_keep_planned_node_if_configured_so_jenkins_will_overprovision() throws Exception { ComputerLauncher computerLauncher = mock(ComputerLauncher.class); ComputerConnector computerConnector = mock(ComputerConnector.class); when(computerConnector.launch(anyString(), any(TaskListener.class))).thenReturn(computerLauncher); final EC2FleetCloud cloud = spy(new EC2FleetCloud(null, null, "credId", null, "region", null, "fId", "momo", null, computerConnector, false, false, 0, 0, 10, 1, false, false, false, 0, 0, false, 10, false)); j.jenkins.clouds.add(cloud); mockEc2ApiToDescribeInstancesWhenModified(InstanceStateName.Running); getQueueTaskFutures(1); tryUntil(new Runnable() { @Override public void run() { j.jenkins.getLabelAtom("momo").nodeProvisioner.suggestReviewNow(); verify(cloud, atLeast(2)).provision(any(Label.class), anyInt()); } }); }
Example #5
Source File: ParallelsDesktopVM.java From jenkins-parallels with MIT License | 5 votes |
@DataBoundConstructor public ParallelsDesktopVM(String vmid, String labels, String remoteFS, ComputerLauncher launcher) { this.vmid = vmid; this.labels = labels; this.remoteFS = remoteFS; this.launcher = launcher; }
Example #6
Source File: DockerFunctions.java From yet-another-docker-plugin with MIT License | 5 votes |
/** * Only this plugin specific launchers. */ public static List<Descriptor<ComputerLauncher>> getDockerComputerLauncherDescriptors() { List<Descriptor<ComputerLauncher>> launchers = new ArrayList<>(); launchers.add(getInstance().getDescriptor(DockerComputerSSHLauncher.class)); launchers.add(getInstance().getDescriptor(DockerComputerJNLPLauncher.class)); launchers.add(getInstance().getDescriptor(DockerComputerIOLauncher.class)); return launchers; }
Example #7
Source File: KubernetesSlave.java From kubernetes-plugin with Apache License 2.0 | 5 votes |
protected KubernetesSlave(String name, @Nonnull PodTemplate template, String nodeDescription, String cloudName, String labelStr, ComputerLauncher computerLauncher, RetentionStrategy rs) throws Descriptor.FormException, IOException { super(name, null, computerLauncher); setNodeDescription(nodeDescription); setNumExecutors(1); setMode(template.getNodeUsageMode() != null ? template.getNodeUsageMode() : Node.Mode.NORMAL); setLabelString(labelStr); setRetentionStrategy(rs); setNodeProperties(template.getNodeProperties()); this.cloudName = cloudName; this.template = template; }
Example #8
Source File: ParallelsDesktopCloud.java From jenkins-parallels with MIT License | 5 votes |
@DataBoundConstructor public ParallelsDesktopCloud(String name, String remoteFS, ComputerLauncher pdLauncher, boolean useConnectorAsBuilder, List<ParallelsDesktopVM> vms) { super(name); this.remoteFS = remoteFS; if (vms == null) this.vms = Collections.emptyList(); else this.vms = vms; this.pdLauncher = pdLauncher; this.useConnectorAsBuilder = useConnectorAsBuilder; }
Example #9
Source File: ParallelsDesktopConnectorSlave.java From jenkins-parallels with MIT License | 5 votes |
@DataBoundConstructor public ParallelsDesktopConnectorSlave(ParallelsDesktopCloud owner, String name, String remoteFS, ComputerLauncher launcher, boolean useAsBuilder) throws IOException, Descriptor.FormException { super(name, "", remoteFS, 1, Mode.NORMAL, "", launcher, useAsBuilder ? new RetentionStrategy.Always() : new RetentionStrategy.Demand(1, 1), new ArrayList<NodeProperty<?>>()); this.owner = owner; this.useAsBuilder = useAsBuilder; }
Example #10
Source File: DockerComputerSSHConnector.java From docker-plugin with MIT License | 5 votes |
@Override protected ComputerLauncher createLauncher(DockerAPI api, String workdir, InspectContainerResponse inspect, TaskListener listener) throws IOException, InterruptedException { if ("exited".equals(inspect.getState().getStatus())) { // Something went wrong // FIXME report error "somewhere" visible to end user. LOGGER.error("Failed to launch docker SSH agent :" + inspect.getState().getExitCode()); throw new IOException("Failed to launch docker SSH agent. Container exited with status " + inspect.getState().getExitCode()); } LOGGER.debug("container created {}", inspect); final InetSocketAddress address = getBindingForPort(api, inspect, port); // Wait until sshd has started // TODO we could (also) have a more generic mechanism relying on healthcheck (inspect State.Health.Status) final PortUtils.ConnectionCheck connectionCheck = PortUtils.connectionCheck( address ); final PortUtils.ConnectionCheckSSH connectionCheckSSH = connectionCheck.useSSH(); final Integer maxNumRetriesOrNull = getMaxNumRetries(); if ( maxNumRetriesOrNull!=null ) { connectionCheck.withRetries( maxNumRetriesOrNull ); } final Integer retryWaitTimeOrNull = getRetryWaitTime(); if ( retryWaitTimeOrNull!=null ) { connectionCheck.withEveryRetryWaitFor( retryWaitTimeOrNull, TimeUnit.SECONDS ); } final Integer sshTimeoutSeconds = getLaunchTimeoutSeconds(); if( sshTimeoutSeconds != null) { connectionCheckSSH.withSSHTimeout(sshTimeoutSeconds, TimeUnit.SECONDS); } final long timestampBeforeConnectionCheck = System.nanoTime(); if (!connectionCheck.execute() || !connectionCheckSSH.execute()) { final long timestampAfterConnectionCheckEnded = System.nanoTime(); final long nanosecondsElapsed = timestampAfterConnectionCheckEnded - timestampBeforeConnectionCheck; final long secondsElapsed = TimeUnit.NANOSECONDS.toSeconds(nanosecondsElapsed); final long millisecondsElapsed = TimeUnit.NANOSECONDS.toMillis(nanosecondsElapsed) - TimeUnit.SECONDS.toMillis(secondsElapsed); throw new IOException("SSH service hadn't started after " + secondsElapsed + " seconds and " + millisecondsElapsed + " milliseconds." + "Try increasing the number of retries (currently " + maxNumRetriesOrNull + ") and/or the retry wait time (currently " + retryWaitTimeOrNull + ") to allow for containers taking longer to start."); } return sshKeyStrategy.getSSHLauncher(address, this); }
Example #11
Source File: DockerComputerSSHConnector.java From docker-plugin with MIT License | 5 votes |
@Override public ComputerLauncher getSSHLauncher(InetSocketAddress address, DockerComputerSSHConnector connector) throws IOException { final InstanceIdentity id = InstanceIdentity.get(); final String pem = PEMEncodable.create(id.getPrivate()).encode(); return new DockerSSHLauncher(address.getHostString(), address.getPort(), user, pem, connector.getJvmOptions(), connector.getJavaPath(), connector.getPrefixStartSlaveCmd(), connector.getSuffixStartSlaveCmd(), connector.getLaunchTimeoutSeconds(), connector.getMaxNumRetries(), connector.getRetryWaitTime(), new NonVerifyingKeyVerificationStrategy() ); }
Example #12
Source File: DockerComputerSSHConnector.java From docker-plugin with MIT License | 5 votes |
@Override public ComputerLauncher getSSHLauncher(InetSocketAddress address, DockerComputerSSHConnector connector) throws IOException { return new SSHLauncher(address.getHostString(), address.getPort(), getCredentialsId(), connector.getJvmOptions(), connector.getJavaPath(), connector.getPrefixStartSlaveCmd(), connector.getSuffixStartSlaveCmd(), connector.getLaunchTimeoutSeconds(), connector.getMaxNumRetries(), connector.getRetryWaitTime(), sshHostKeyVerificationStrategy ); }
Example #13
Source File: HudsonTestCase.java From jenkins-test-harness with MIT License | 5 votes |
/** * Creates a {@link ComputerLauncher} for launching a slave locally. * * @param env * Environment variables to add to the slave process. Can be null. */ public ComputerLauncher createComputerLauncher(EnvVars env) throws URISyntaxException, IOException { int sz = jenkins.getNodes().size(); return new SimpleCommandLauncher( String.format("\"%s/bin/java\" %s %s -jar \"%s\"", System.getProperty("java.home"), SLAVE_DEBUG_PORT>0 ? " -Xdebug -Xrunjdwp:transport=dt_socket,server=y,address="+(SLAVE_DEBUG_PORT+sz): "", "-Djava.awt.headless=true", new File(jenkins.getJnlpJars("slave.jar").getURL().toURI()).getAbsolutePath()), env); }
Example #14
Source File: JenkinsRule.java From jenkins-test-harness with MIT License | 5 votes |
/** * Creates a launcher for starting a local agent. * * @param env * Environment variables to add to the slave process. Can be null. */ public ComputerLauncher createComputerLauncher(EnvVars env) throws URISyntaxException, IOException { int sz = jenkins.getNodes().size(); return new SimpleCommandLauncher( String.format("\"%s/bin/java\" %s %s -jar \"%s\"", System.getProperty("java.home"), SLAVE_DEBUG_PORT>0 ? " -Xdebug -Xrunjdwp:transport=dt_socket,server=y,address="+(SLAVE_DEBUG_PORT+sz): "", "-Djava.awt.headless=true", new File(jenkins.getJnlpJars("slave.jar").getURL().toURI()).getAbsolutePath()), env); }
Example #15
Source File: ProvisionIntegrationTest.java From ec2-spot-jenkins-plugin with Apache License 2.0 | 5 votes |
@Test public void should_not_convert_planned_to_node_if_state_is_not_running_and_check_state_enabled() throws Exception { ComputerLauncher computerLauncher = mock(ComputerLauncher.class); ComputerConnector computerConnector = mock(ComputerConnector.class); when(computerConnector.launch(anyString(), any(TaskListener.class))).thenReturn(computerLauncher); EC2FleetCloud cloud = new EC2FleetCloud(null, null, "credId", null, "region", null, "fId", "momo", null, computerConnector, false, false, 0, 0, 10, 1, true, false, false, 0, 0, false, 2, false); j.jenkins.clouds.add(cloud); mockEc2ApiToDescribeInstancesWhenModified(InstanceStateName.Pending); List<QueueTaskFuture> rs = getQueueTaskFutures(1); triggerSuggestReviewNow("momo"); Assert.assertEquals(0, j.jenkins.getNodes().size()); tryUntil(new Runnable() { @Override public void run() { Assert.assertEquals(ImmutableSet.of("master", "momo"), labelsToNames(j.jenkins.getLabels())); Assert.assertEquals(1, j.jenkins.getLabelAtom("momo").nodeProvisioner.getPendingLaunches().size()); Assert.assertEquals(0, j.jenkins.getNodes().size()); } }); cancelTasks(rs); }
Example #16
Source File: ProvisionIntegrationTest.java From ec2-spot-jenkins-plugin with Apache License 2.0 | 5 votes |
@Test public void should_keep_planned_node_until_node_will_not_be_online_so_jenkins_will_not_request_overprovision() throws Exception { ComputerLauncher computerLauncher = mock(ComputerLauncher.class); ComputerConnector computerConnector = mock(ComputerConnector.class); when(computerConnector.launch(anyString(), any(TaskListener.class))).thenReturn(computerLauncher); EC2FleetCloud cloud = spy(new EC2FleetCloud(null, null, "credId", null, "region", null, "fId", "momo", null, computerConnector, false, false, 0, 0, 10, 1, false, false, false, 300, 15, false, 2, false)); // provide init state cloud.setStats(new FleetStateStats("", 0, "active", Collections.<String>emptySet(), Collections.<String, Double>emptyMap())); j.jenkins.clouds.add(cloud); mockEc2ApiToDescribeInstancesWhenModified(InstanceStateName.Running); List<QueueTaskFuture> rs = getQueueTaskFutures(1); final String labelString = "momo"; triggerSuggestReviewNow(labelString); Thread.sleep(TimeUnit.MINUTES.toMillis(2)); verify(cloud, times(1)).provision(any(Label.class), anyInt()); cancelTasks(rs); }
Example #17
Source File: ProvisionIntegrationTest.java From ec2-spot-jenkins-plugin with Apache License 2.0 | 5 votes |
@Test public void should_add_planned_if_capacity_required_but_not_described_yet() throws Exception { ComputerLauncher computerLauncher = mock(ComputerLauncher.class); ComputerConnector computerConnector = mock(ComputerConnector.class); when(computerConnector.launch(anyString(), any(TaskListener.class))).thenReturn(computerLauncher); mockEc2ApiToDescribeFleetNotInstanceWhenModified(); EC2FleetCloud cloud = new EC2FleetCloud(null, null, "credId", null, "region", null, "fId", "momo", null, computerConnector, false, false, 0, 0, 10, 1, false, false, false, 0, 0, false, 2, false); j.jenkins.clouds.add(cloud); List<QueueTaskFuture> rs = getQueueTaskFutures(1); triggerSuggestReviewNow("momo"); Assert.assertEquals(0, j.jenkins.getNodes().size()); tryUntil(new Runnable() { @Override public void run() { Assert.assertEquals(0, j.jenkins.getNodes().size()); Assert.assertEquals(2, j.jenkins.getLabels().size()); Assert.assertEquals(1, j.jenkins.getLabelAtom("momo").nodeProvisioner.getPendingLaunches().size()); } }); cancelTasks(rs); }
Example #18
Source File: LocalComputerConnector.java From ec2-spot-jenkins-plugin with Apache License 2.0 | 5 votes |
@Override public ComputerLauncher launch(@Nonnull String host, TaskListener listener) throws IOException { System.out.println("Creating computer launcher"); try { return j.createComputerLauncher(null); } catch (URISyntaxException e) { throw new RuntimeException(e); } }
Example #19
Source File: DockerTransientNode.java From docker-plugin with MIT License | 5 votes |
public DockerTransientNode(@Nonnull String nodeName, String containerId, String workdir, ComputerLauncher launcher) throws Descriptor.FormException, IOException { super(nodeName, workdir, launcher); this.containerId = containerId; setNumExecutors(1); setMode(Mode.EXCLUSIVE); setRetentionStrategy(new DockerOnceRetentionStrategy(10)); }
Example #20
Source File: NoOpDelegatingComputerLauncher.java From yet-another-docker-plugin with MIT License | 4 votes |
public NoOpDelegatingComputerLauncher(ComputerLauncher core) { super(core); }
Example #21
Source File: DockerDelegatingComputerLauncher.java From docker-plugin with MIT License | 4 votes |
public DockerDelegatingComputerLauncher(ComputerLauncher launcher, DockerAPI api, String containerId) { super(launcher); this.api = api; this.containerId = containerId; }
Example #22
Source File: DockerComputerAttachConnector.java From docker-plugin with MIT License | 4 votes |
@Override protected ComputerLauncher createLauncher(DockerAPI api, String workdir, InspectContainerResponse inspect, TaskListener listener) throws IOException, InterruptedException { return new DockerAttachLauncher(api, inspect.getId(), getUser(), workdir, getJavaExe(), getJvmArgsString(), getEntryPointCmdString()); }
Example #23
Source File: DockerComputerJNLPConnector.java From docker-plugin with MIT License | 4 votes |
@Override protected ComputerLauncher createLauncher(final DockerAPI api, final String workdir, final InspectContainerResponse inspect, TaskListener listener) throws IOException, InterruptedException { return new JNLPLauncher(); }
Example #24
Source File: DockerSlave.java From docker-plugin with MIT License | 4 votes |
private DockerSlave(@Nonnull String name, String remoteFS, ComputerLauncher launcher) throws Descriptor.FormException, IOException { super(name, remoteFS, launcher); }
Example #25
Source File: DockerSlaveConfig.java From yet-another-docker-plugin with MIT License | 4 votes |
public ComputerLauncher getLauncher() { return launcher; }
Example #26
Source File: DockerSlaveConfig.java From yet-another-docker-plugin with MIT License | 4 votes |
@DataBoundSetter public void setLauncher(ComputerLauncher launcher) { this.launcher = launcher; }
Example #27
Source File: DockerComputerJNLPLauncher.java From yet-another-docker-plugin with MIT License | 4 votes |
@Override public ComputerLauncher getLauncher() { return new JNLPLauncher(); }
Example #28
Source File: DockerComputerLauncher.java From yet-another-docker-plugin with MIT License | 4 votes |
public void setLauncher(ComputerLauncher launcher) { this.launcher = launcher; }
Example #29
Source File: DockerComputerLauncher.java From yet-another-docker-plugin with MIT License | 4 votes |
protected DockerComputerLauncher(ComputerLauncher launcher) { super(launcher); }
Example #30
Source File: DockerComputerIOLauncher.java From yet-another-docker-plugin with MIT License | 4 votes |
@Override public ComputerLauncher getLauncher() { return this; }