hudson.slaves.AbstractCloudComputer Java Examples

The following examples show how to use hudson.slaves.AbstractCloudComputer. 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: DockerCloudRetentionStrategy.java    From yet-another-docker-plugin with MIT License 6 votes vote down vote up
/**
 * While x-stream serialisation buggy, copy implementation.
 */
@Override
@GuardedBy("hudson.model.Queue.lock")
public long check(final AbstractCloudComputer c) {
    final AbstractCloudSlave computerNode = c.getNode();
    if (c.isIdle() && computerNode != null) {
        final long idleMilliseconds = System.currentTimeMillis() - c.getIdleStartMilliseconds();
        if (idleMilliseconds > MINUTES.toMillis(idleMinutes)) {
            LOG.info("Disconnecting {}, after {} min timeout.", c.getName(), idleMinutes);
            try {
                computerNode.terminate();
            } catch (InterruptedException | IOException e) {
                LOG.warn("Failed to terminate {}", c.getName(), e);
            }
        }
    }
    return 1;
}
 
Example #2
Source File: DockerOnceRetentionStrategy.java    From yet-another-docker-plugin with MIT License 6 votes vote down vote up
@Override
@GuardedBy("hudson.model.Queue.lock")
public long check(final AbstractCloudComputer acc) {
    // When the slave is idle we should disable accepting tasks and check to see if it is already trying to
    // terminate. If it's not already trying to terminate then lets terminate manually.
    if (acc.isIdle() && !disabled) {
        final long idleMilliseconds = System.currentTimeMillis() - acc.getIdleStartMilliseconds();
        if (idleMilliseconds > TimeUnit2.MINUTES.toMillis(idleMinutes)) {
            LOG.debug("Disconnecting {}", acc.getName());
            done(acc);
        }
    }

    // Return one because we want to check every minute if idle.
    return 1;
}
 
Example #3
Source File: DockerOnceRetentionStrategy.java    From yet-another-docker-plugin with MIT License 6 votes vote down vote up
protected void done(Executor executor) {
    final AbstractCloudComputer<?> c = (AbstractCloudComputer) executor.getOwner();
    Queue.Executable exec = executor.getCurrentExecutable();
    if (executor instanceof OneOffExecutor) {
        LOG.debug("Not terminating {} because {} was a flyweight task", c.getName(), exec);
        return;
    }

    if (exec instanceof ContinuableExecutable && ((ContinuableExecutable) exec).willContinue()) {
        LOG.debug("not terminating {} because {} says it will be continued", c.getName(), exec);
        return;
    }

    LOG.debug("terminating {} since {} seems to be finished", c.getName(), exec);
    done(c);
}
 
Example #4
Source File: DockerOnceRetentionStrategy.java    From yet-another-docker-plugin with MIT License 6 votes vote down vote up
@SuppressFBWarnings("RV_RETURN_VALUE_IGNORED_BAD_PRACTICE")
protected void done(final AbstractCloudComputer<?> c) {
    c.setAcceptingTasks(false); // just in case
    synchronized (this) {
        if (terminating) {
            return;
        }
        terminating = true;
    }

    Computer.threadPoolForRemoting.submit(() -> {
            try {
                AbstractCloudSlave node = c.getNode();
                if (node != null) {
                    node.terminate();
                }
            } catch (InterruptedException | IOException e) {
                LOG.warn("Failed to terminate " + c.getName(), e);
                synchronized (DockerOnceRetentionStrategy.this) {
                    terminating = false;
                }
            }
        }
    );
}
 
Example #5
Source File: DockerOnceRetentionStrategy.java    From yet-another-docker-plugin with MIT License 5 votes vote down vote up
@Override
public void start(AbstractCloudComputer c) {
    if (c.getNode() instanceof EphemeralNode) {
        throw new IllegalStateException("May not use OnceRetentionStrategy on an EphemeralNode: " + c);
    }
    super.start(c);
}
 
Example #6
Source File: JenkinsConfiguratorCloudSupportTest.java    From configuration-as-code-plugin with MIT License 4 votes vote down vote up
@Override
public AbstractCloudComputer createComputer() {
    return null;
}
 
Example #7
Source File: ParallelsDesktopVMSlave.java    From jenkins-parallels with MIT License 4 votes vote down vote up
@Override
public AbstractCloudComputer createComputer()
{
	return new ParallelsDesktopVMSlaveComputer(this);
}
 
Example #8
Source File: ParallelsDesktopConnectorSlave.java    From jenkins-parallels with MIT License 4 votes vote down vote up
@Override
public AbstractCloudComputer createComputer()
{
	return new ParallelsDesktopConnectorSlaveComputer(this);
}
 
Example #9
Source File: DockerSlaveSingle.java    From yet-another-docker-plugin with MIT License 4 votes vote down vote up
@Override
public AbstractCloudComputer createComputer() {
    return new DockerComputerSingle(this, activityId);
}
 
Example #10
Source File: DockerCloudRetentionStrategy.java    From yet-another-docker-plugin with MIT License 4 votes vote down vote up
/**
 * Try to connect to it ASAP.
 */
@Override
public void start(AbstractCloudComputer c) {
    c.connect(false);
}
 
Example #11
Source File: ECSSlave.java    From amazon-ecs-plugin with MIT License 4 votes vote down vote up
@Override
public AbstractCloudComputer<ECSSlave> createComputer() {
    return new ECSComputer(this);
}