Search in sources :

Example 1 with PrefilteredPrintedContent

use of com.cloudbees.jenkins.support.api.PrefilteredPrintedContent 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(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 PrefilteredPrintedContent("nodes/{0}/file-descriptors.txt", name) {

        @Override
        protected void printTo(PrintWriter out, ContentFilter filter) {
            out.println(node.getDisplayName());
            out.println("======");
            out.println();
            try {
                out.println(AsyncResultCache.get(node, fileDescriptorCache, new GetUlimit(filter), "file descriptor info", "N/A: Either no connection to node or no cached result"));
            } catch (IOException e) {
                Functions.printStackTrace(e, out);
            } finally {
                out.flush();
            }
        }
    });
}
Also used : SlaveComputer(hudson.slaves.SlaveComputer) Jenkins(jenkins.model.Jenkins) PrefilteredPrintedContent(com.cloudbees.jenkins.support.api.PrefilteredPrintedContent) Computer(hudson.model.Computer) SlaveComputer(hudson.slaves.SlaveComputer) IOException(java.io.IOException) ContentFilter(com.cloudbees.jenkins.support.filter.ContentFilter) PrintWriter(java.io.PrintWriter)

Aggregations

PrefilteredPrintedContent (com.cloudbees.jenkins.support.api.PrefilteredPrintedContent)1 ContentFilter (com.cloudbees.jenkins.support.filter.ContentFilter)1 Computer (hudson.model.Computer)1 SlaveComputer (hudson.slaves.SlaveComputer)1 IOException (java.io.IOException)1 PrintWriter (java.io.PrintWriter)1 Jenkins (jenkins.model.Jenkins)1