Package com.sun.grid.jgdi.util

Examples of com.sun.grid.jgdi.util.OutputTable$PropertyColumn


    //-secl
    @OptionAnnotation(value = "-secl", min = 0)
    public void showEventClientList(final OptionInfo oi) throws JGDIException {
        List<EventClient> evcl = jgdi.getEventClientList();
        if (!evcl.isEmpty()) {
            OutputTable table = new OutputTable(com.sun.grid.jgdi.configuration.EventClient.class);
            try {
                table.addCol("id", "ID", 8, OutputTable.Column.RIGHT);
                table.addCol("name", "NAME", 15, OutputTable.Column.LEFT);
                table.addCol("host", "HOST", 24, OutputTable.Column.LEFT);
            } catch (IntrospectionException ex) {
                ex.printStackTrace();
            }
            table.printHeader(out);
            out.write("--------------------------------------------------\n");
            for (EventClient evc : evcl) {
                table.printRow(out, (Object) evc);
            }
        } else {
            err.println(getErrorMessage("NoObjectFound", oi.getOd().getOption()));
            setExitCode(getCustomExitCode("NoObjectFound", oi.getOd().getOption()));
        }
View Full Code Here


        return ret;
    }

    private static OutputTable createHostTable() throws IntrospectionException {

        OutputTable ret = new OutputTable(HostInfo.class);

        ret.addCol("hostname", "HOSTNAME", 23);
        ret.addCol("arch", "ARCH", 13);
        ret.addCol("NumberOfProcessors", "NCPU", 4, OutputTable.Column.RIGHT);
        ret.addCol("loadAvg", "LOAD", 5, OutputTable.Column.RIGHT);
        ret.addCol("memTotal", "MEMTOT", 7, OutputTable.Column.RIGHT);
        ret.addCol("memUsed", "MEMUSE", 7, OutputTable.Column.RIGHT);
        ret.addCol("swapTotal", "SWAPTO", 7, OutputTable.Column.RIGHT);
        ret.addCol("swapUsed", "SWAPUS", 7, OutputTable.Column.RIGHT);

        return ret;
    }
View Full Code Here

        return ret;
    }

    private static OutputTable createHostQueueTable() throws IntrospectionException {
        OutputTable ret = new OutputTable(QueueInfo.class);
        ret.addCol("qname", "qname", 20);
        ret.addCol("qType", "qtype", 5);

        Calc slotCalc = new Calc() {

            public Object getValue(Object obj) {
                StringBuilder ret = new StringBuilder();
                QueueInfo qi = (QueueInfo) obj;
                // ret.append(qi.getReservedSlots());
                // ret.append('/');
                ret.append(qi.getUsedSlots());
                ret.append('/');
                ret.append(qi.getTotalSlots());
                return ret.toString();
            }
        };
        ret.addCol("usedSlots", "used/tot.", 9, slotCalc);
        ret.addCol("state", "state", 5);

        return ret;
    }
View Full Code Here

        return ret;
    }

    private static OutputTable createHostJobTable(QHostOptions options) throws IntrospectionException {

        OutputTable ret = new OutputTable(JobInfo.class);

        ret.addCol("id", "job-ID ", 7, OutputTable.Column.RIGHT);
        ret.addCol("priority", "prior", 7, OutputTable.POINT_FIVE_FORMAT);
        ret.addCol("name", "name", 10);
        ret.addCol("user", "user", 12);
        ret.addCol("state", "state", 5);
        Calc timeCalc = new Calc() {

            public Object getValue(Object obj) {
                JobInfo ji = (JobInfo) obj;
                return ji.getStartTime();
            }
        };
        ret.addCol("startTime", "submit/start at     ", 19, DEFAULT_DATE_FORMAT, timeCalc);
        if (!options.includeQueue()) {
            ret.addCol("qinstanceName", "queue", 10);
        }
        ret.addCol("masterQueue", "master", 6);
        ret.addCol("taskID", "ja-task-ID", 10, new JaTaskIdCalc() {

            public Object getValue(Object obj) {
                String ret = ((JobInfo) obj).getTaskId();
                if (ret == null) {
                    return "";
View Full Code Here

        return ret;
    }

    public static void print(PrintWriter pw, QueueInstanceSummaryResult result, QueueInstanceSummaryOptions options) {
        OutputTable jobSummaryTable = null;
        OutputTable qiTable = null;
        try {
            jobSummaryTable = createJobSummaryTable(options);
            qiTable = createQueueInstanceSummaryTable();
        } catch (IntrospectionException ex) {
            IllegalStateException ex1 = new IllegalStateException("introspection error");
            ex1.initCause(ex);
            throw ex1;
        }


        boolean hadJobs = false;
        if (!result.getQueueInstanceSummary().isEmpty()) {
            if (options.showFullOutput()) {
                qiTable.printHeader(pw);
            }
        }
        for (QueueInstanceSummary qi : result.getQueueInstanceSummary()) {
            if (options.showFullOutput()) {
                qiTable.printDelimiter(pw, '-');
            }
            if (options.showFullOutput()) {
                qiTable.printRow(pw, qi);
                for (String dom : qi.getResourceDominanceSet()) {
                    for (String name : qi.getResourceNames(dom)) {
                        pw.print("    " + dom + ":" + name + "=");
                        pw.println(qi.getResourceValue(dom, name));
                    }
                }
            }
            for (JobSummary js : qi.getJobList()) {
                if (!hadJobs && !options.showFullOutput()) {
                    jobSummaryTable.printHeader(pw);
                    jobSummaryTable.printDelimiter(pw, '-');
                }
                jobSummaryTable.printRow(pw, js);
                if (options.showRequestedResourcesForJobs()) {
                    printRequestedResources(pw, js);
                }
                hadJobs = true;
            }
        }

        List<JobSummary> jobList = result.getPendingJobs();
        if (!jobList.isEmpty()) {
            if (options.showFullOutput()) {
                pw.println();
                qiTable.printDelimiter(pw, '#');
                pw.println(" - PENDING JOBS - PENDING JOBS - PENDING JOBS - PENDING JOBS - PENDING JOBS");
                qiTable.printDelimiter(pw, '#');
            }

            if (!hadJobs && !options.showFullOutput()) {
                jobSummaryTable.printHeader(pw);
                jobSummaryTable.printDelimiter(pw, '-');
            }
            for (JobSummary js : jobList) {
                jobSummaryTable.printRow(pw, js);
                if (options.showRequestedResourcesForJobs()) {
                    printRequestedResources(pw, js);
                }
                hadJobs = true;
            }
        }

        jobList = result.getErrorJobs();
        if (!jobList.isEmpty()) {
            if (options.showFullOutput()) {
                pw.println();
                qiTable.printDelimiter(pw, '-');
                pw.println("     - ERROR JOBS - ERROR JOBS - ERROR JOBS - ERROR JOBS - ERROR JOBS");
                qiTable.printDelimiter(pw, '#');
            }
            if (!hadJobs && !options.showFullOutput()) {
                jobSummaryTable.printHeader(pw);
                jobSummaryTable.printDelimiter(pw, '-');
            }
            for (JobSummary js : jobList) {
                jobSummaryTable.printRow(pw, js);
                if (options.showRequestedResourcesForJobs()) {
                    printRequestedResources(pw, js);
                }
                hadJobs = true;
            }
        }

        jobList = result.getFinishedJobs();
        if (!jobList.isEmpty()) {
            if (options.showFullOutput()) {
                pw.println();
                qiTable.printDelimiter(pw, '#');
                pw.println("- FINISHED JOBS - FINISHED JOBS - FINISHED JOBS - FINISHED JOBS - FINISHED JOBS");
                qiTable.printDelimiter(pw, '#');
            }
            if (!hadJobs && !options.showFullOutput()) {
                jobSummaryTable.printHeader(pw);
                jobSummaryTable.printDelimiter(pw, '-');
            }
            for (JobSummary js : jobList) {
                jobSummaryTable.printRow(pw, js);
                if (options.showRequestedResourcesForJobs()) {
                    printRequestedResources(pw, js);
                }
                hadJobs = true;
            }
        }

        jobList = result.getZombieJobs();
        if (!jobList.isEmpty()) {
            if (options.showFullOutput()) {
                pw.println();
                qiTable.printDelimiter(pw, '#');
                pw.println("   - ZOMBIE JOBS - ZOMBIE JOBS - ZOMBIE JOBS - ZOMBIE JOBS - ZOMBIE JOBS");
                qiTable.printDelimiter(pw, '#');
            }
            if (!hadJobs && !options.showFullOutput()) {
                jobSummaryTable.printHeader(pw);
                jobSummaryTable.printDelimiter(pw, '-');
            }
View Full Code Here

            }
        }
    }

    public static void print(PrintWriter pw, QHostResult result, QHostOptions options) {
        OutputTable hjTable = null;
        OutputTable hqTable = null;
        OutputTable hiTable = null;

        try {
            hiTable = createHostTable();
            hqTable = createHostQueueTable();
            hjTable = createHostJobTable(options);
        } catch (IntrospectionException ex) {
            IllegalStateException ex1 = new IllegalStateException("   - ZOMBIE JOBS - ZOMBIE JOBS - ZOMBIE JOBS - ZOMBIE JOBS - ZOMBIE JOBS");
            ex1.initCause(ex);
            throw ex1;
        }

        if (!result.getHostInfo().isEmpty()) {
            hiTable.printHeader(pw);
            hiTable.printDelimiter(pw, '-');
        }
        for (HostInfo hi : result.getHostInfo()) {
            hiTable.printRow(pw, hi);
            if (options.getResourceAttributeFilter() != null) {
                for (String dom : hi.getDominanceSet()) {
                    for (String name : hi.getResourceValueNames(dom)) {
                        pw.print("   " + dom + ":" + name + "=");
                        pw.println(hi.getResourceValue(dom, name));
View Full Code Here

        sge_urg = options.showJobUrgency();
        sge_pri = options.showJobPriorities();
        sge_time = !sge_ext;
        sge_time = sge_time | tsk_ext | sge_urg | sge_pri;

        OutputTable table = new OutputTable(JobSummary.class);

        table.addCol("id", "job-ID ", 7, OutputTable.Column.RIGHT);
        table.addCol("priority", "prior", 7);
        if (sge_pri || sge_urg) {
            table.addCol("normalizedUrgency", "nurg", 9);
        }
        if (sge_pri) {
            table.addCol("normalizedRequestedPriority", "npprior", 10);
        }
        if (sge_pri || sge_ext) {
            table.addCol("normalizedTickets", "ntckts", 6);
        }
        if (sge_urg) {
            table.addCol("urgency", "urg", 8);
            table.addCol("rrcontr", "rrcontr", 8);
            table.addCol("wtcontr", "wtcontr", 8);
            table.addCol("wtcontr", "dlcontr", 8);
        }
        if (sge_pri) {
            table.addCol("priority", "ppri", 7);
        }
        table.addCol("name", "name", 10);
        table.addCol("user", "user", 12);
        if (sge_ext) {
            table.addCol("project", "project", 15);
            table.addCol("department", "department", 15);
        }
        table.addCol("state", "state", 5);
        if (sge_time) {

            Calc timeCalc = new Calc() {

                public Object getValue(Object obj) {
                    JobSummary js = (JobSummary) obj;
                    if (js.isRunning()) {
                        return js.getStartTime();
                    } else {
                        return js.getSubmitTime();
                    }
                }
            };
            table.addCol("submitTime", "submit/start at     ", 19, DEFAULT_DATE_FORMAT, timeCalc);
        }
        if (sge_urg) {
            table.addCol("deadline", "deadline", 15);
        }
        if (sge_ext) {
            table.addCol("cpuUsage", "cpu", 8, new CpuUsageCalc());
            table.addCol("memUsage", "mem", 7, OutputTable.Column.RIGHT, new MemUsageCalc());
            table.addCol("ioUsage", "io", 7, OutputTable.Column.RIGHT, new IOUsageCalc());
            table.addCol("tickets", "tckts", 8, new TicketCalc(sge_ext) {

                public long getValue(JobSummary js) {
                    return js.getTickets();
                }
            });
            table.addCol("overrideTickets", "ovrts", 8, new TicketCalc(sge_ext) {

                public long getValue(JobSummary js) {
                    return js.getOverrideTickets();
                }
            });
            table.addCol("otickets", "otckt", 8, new TicketCalc(sge_ext) {

                public long getValue(JobSummary js) {
                    return js.getOtickets();
                }
            });
            table.addCol("ftickets", "ftckt", 8, new TicketCalc(sge_ext) {

                public long getValue(JobSummary js) {
                    return js.getFtickets();
                }
            });
            table.addCol("stickets", "stckt", 8, new TicketCalc(sge_ext) {

                public long getValue(JobSummary js) {
                    return js.getStickets();
                }
            });

            table.addCol("share", "share", 8, new ShareCalc(sge_ext));
        }
        //table.addCol("queueAssigned", "qs", 5);
        if (!options.showFullOutput()) {
            table.addCol("queue", "queue", 30);
        }
        // if (options.showPEJobs()) {
        if (options.showExtendedSubTaskInfo()) {
            table.addCol("masterQueue", "master", 8, OutputTable.Column.LEFT);
        } else {
            table.addCol("slots", "slots", 8, OutputTable.Column.RIGHT);
        }
        table.addCol("ja-taskId", "ja-task-ID", 10, new JaTaskIdCalc());


        if (tsk_ext) {
            Calc fixedValue = new Calc() {

                public Object getValue(Object obj) {
                    return "   NA ";
                }
            };
            table.addCol("taskId", "task-ID ", 7, fixedValue);
            table.addCol("state", "state", 6, new StatCalc());
            // TODO retrieve values from first task
            table.addCol("cpuUsage", "cpu", 8, fixedValue);
            table.addCol("memUsage", "mem", 7, OutputTable.Column.RIGHT, fixedValue);
            table.addCol("ioUsage", "io", 7, OutputTable.Column.RIGHT, fixedValue);
            table.addCol("stat", "stat", 5, fixedValue);
            table.addCol("failed", "failed", 7, fixedValue);
        }
        return table;
    }
View Full Code Here

    }
    private static final DateFormat DEFAULT_DATE_FORMAT = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");

    private static OutputTable createQueueInstanceSummaryTable() throws IntrospectionException {

        OutputTable ret = new OutputTable(QueueInstanceSummary.class);

        ret.addCol("name", "queuename", 30);
        ret.addCol("queueType", "qtype", 5);

        Calc slotCalc = new Calc() {

            public Object getValue(Object obj) {

                QueueInstanceSummary qi = (QueueInstanceSummary) obj;

                StringBuilder ret = new StringBuilder();
                ret.append(qi.getReservedSlots());
                ret.append('/');
                ret.append(qi.getUsedSlots());
                ret.append('/');
                ret.append(qi.getTotalSlots());
                return ret.toString();
            }
        };

        ret.addCol("totalSlots", "resv/used/tot.", 14, slotCalc);

        Calc loadAvgCalc = new Calc() {

            public Object getValue(Object obj) {

                QueueInstanceSummary qi = (QueueInstanceSummary) obj;
                if (qi.isHasLoadValueFromObject()) {
                    return new Double(qi.getLoadAvg());
                } else {
                    return "-NA-";
                }
            }
        };

        ret.addCol("load_avg", "load_avg", 8, new DecimalFormat("####0.00"), loadAvgCalc);
        ret.addCol("arch", "arch", 13);
        ret.addCol("state", "states", 6);

        return ret;
    }
View Full Code Here

TOP

Related Classes of com.sun.grid.jgdi.util.OutputTable$PropertyColumn

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.