Search in sources :

Example 21 with Computer

use of hudson.model.Computer in project support-core-plugin by jenkinsci.

the class FileDescriptorLimit method addContents.

private void addContents(@NonNull Container container, @NonNull final Node node) {
    Computer c = node.toComputer();
    if (c == null) {
        return;
    }
    if (c instanceof SlaveComputer && !Boolean.TRUE.equals(((SlaveComputer) c).isUnix())) {
        return;
    }
    if (!node.createLauncher(TaskListener.NULL).isUnix()) {
        return;
    }
    String name;
    if (node instanceof Jenkins) {
        name = "master";
    } else {
        name = "slave/" + node.getNodeName();
    }
    container.add(new Content("nodes/" + name + "/file-descriptors.txt") {

        @Override
        public void writeTo(OutputStream os) throws IOException {
            PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(os, "utf-8")));
            out.println(node.getDisplayName());
            out.println("======");
            out.println();
            try {
                out.println(getUlimit(node));
            } catch (IOException e) {
                SupportLogFormatter.printStackTrace(e, out);
            } finally {
                out.flush();
            }
        }
    });
}
Also used : SlaveComputer(hudson.slaves.SlaveComputer) Jenkins(jenkins.model.Jenkins) Content(com.cloudbees.jenkins.support.api.Content) OutputStream(java.io.OutputStream) Computer(hudson.model.Computer) SlaveComputer(hudson.slaves.SlaveComputer) OutputStreamWriter(java.io.OutputStreamWriter) IOException(java.io.IOException) PrintWriter(java.io.PrintWriter) BufferedWriter(java.io.BufferedWriter)

Example 22 with Computer

use of hudson.model.Computer in project support-core-plugin by jenkinsci.

the class ProcFilesRetriever method addUnixContents.

protected void addUnixContents(@NonNull Container container, @NonNull final Node node) {
    Computer c = node.toComputer();
    if (c == null || c.isOffline()) {
        return;
    }
    // fast path bailout for Windows
    if (!Boolean.TRUE.equals(c.isUnix())) {
        return;
    }
    SystemPlatform nodeSystemPlatform = getSystemPlatform(node);
    if (!SystemPlatform.LINUX.equals(nodeSystemPlatform)) {
        return;
    }
    String name;
    if (node instanceof Jenkins) {
        name = "master";
    } else {
        name = "slave/" + node.getNodeName();
    }
    for (Map.Entry<String, String> procDescriptor : getFilesToRetrieve().entrySet()) {
        container.add(new FilePathContent("nodes/" + name + "/proc/" + procDescriptor.getValue(), new FilePath(c.getChannel(), procDescriptor.getKey())));
    }
    afterAddUnixContents(container, node, name);
}
Also used : Jenkins(jenkins.model.Jenkins) FilePath(hudson.FilePath) FilePathContent(com.cloudbees.jenkins.support.api.FilePathContent) Computer(hudson.model.Computer) SystemPlatform(com.cloudbees.jenkins.support.util.SystemPlatform) Map(java.util.Map) WeakHashMap(java.util.WeakHashMap)

Example 23 with Computer

use of hudson.model.Computer in project selenium_java by sergueik.

the class BuildDetailsImpl method resolveBuildNode.

private BuildNode resolveBuildNode(final Node node) {
    String address = "UNKNOWN";
    String hostname = "UNKNOWN";
    try {
        final InetAddress iaddr = InetAddress.getLocalHost();
        address = iaddr.getHostAddress();
        hostname = iaddr.getHostName();
    } catch (final UnknownHostException e) {
        LOGGER.log(Level.SEVERE, "An error occurred while trying to resolve the master's network name and address: " + e.getMessage(), e);
    }
    final Computer computer = node.toComputer();
    final BuildNode retval = new BuildNodeImpl(address, hostname, computer.getDisplayName(), String.format("%s/%s", hostname, computer.getUrl()), node.getNodeName(), node.getNodeDescription(), node.getLabelString());
    return retval;
}
Also used : UnknownHostException(java.net.UnknownHostException) Computer(hudson.model.Computer) InetAddress(java.net.InetAddress) BuildNode(org.jenkins.plugins.audit2db.model.BuildNode)

Example 24 with Computer

use of hudson.model.Computer in project sonar-scanner-jenkins by SonarSource.

the class SonarRunnerBuilder method computeJdkToUse.

private void computeJdkToUse(Run<?, ?> build, FilePath workspace, TaskListener listener, EnvVars env) throws IOException, InterruptedException {
    JDK jdkToUse = getJdkToUse(getProject(build));
    if (jdkToUse != null) {
        Computer computer = workspace.toComputer();
        // just in case we are not in a build
        if (computer != null) {
            jdkToUse = jdkToUse.forNode(computer.getNode(), listener);
        }
        jdkToUse.buildEnvVars(env);
    }
}
Also used : JDK(hudson.model.JDK) Computer(hudson.model.Computer)

Example 25 with Computer

use of hudson.model.Computer in project sonar-scanner-jenkins by SonarSource.

the class BuilderUtils method getBuildTool.

@CheckForNull
public static <T extends ToolInstallation & EnvironmentSpecific<T> & NodeSpecific<T>> T getBuildTool(@Nullable T tool, EnvVars env, TaskListener listener, FilePath workspace) throws IOException, InterruptedException {
    Computer computer = workspace.toComputer();
    if (computer == null) {
        return null;
    }
    Node node = computer.getNode();
    if (tool == null || node == null) {
        return null;
    }
    T t = tool.forNode(node, listener);
    t = t.forEnvironment(env);
    return t;
}
Also used : Node(hudson.model.Node) Computer(hudson.model.Computer) CheckForNull(javax.annotation.CheckForNull)

Aggregations

Computer (hudson.model.Computer)26 IOException (java.io.IOException)10 Node (hudson.model.Node)8 Executor (hudson.model.Executor)6 AbortException (hudson.AbortException)4 FilePath (hudson.FilePath)4 Jenkins (jenkins.model.Jenkins)4 EnvVars (hudson.EnvVars)3 VirtualChannel (hudson.remoting.VirtualChannel)3 PrintWriter (java.io.PrintWriter)3 Test (org.junit.Test)3 Content (com.cloudbees.jenkins.support.api.Content)2 SlaveComputer (hudson.slaves.SlaveComputer)2 WorkspaceList (hudson.slaves.WorkspaceList)2 InterruptedIOException (java.io.InterruptedIOException)2 ArrayList (java.util.ArrayList)2 Folder (com.cloudbees.hudson.plugins.folder.Folder)1 FileContent (com.cloudbees.jenkins.support.api.FileContent)1 FilePathContent (com.cloudbees.jenkins.support.api.FilePathContent)1 PrintedContent (com.cloudbees.jenkins.support.api.PrintedContent)1