Package com.sun.enterprise.util

Examples of com.sun.enterprise.util.ColumnFormatter


                    break;
                case STEP_METRICS:
                    stepMetricsIndex = index;
                    Map<String, Long> metricMap = new HashMap<>();
                    if (stepExecution.getMetrics() != null) {
                        ColumnFormatter cf = new ColumnFormatter(new String[]{"METRICNAME", "VALUE"});
                        for (Metric metric : stepExecution.getMetrics()) {
                            metricMap.put(metric.getType().name(), metric.getValue());
                            cf.addRow(new Object[] {metric.getType().name(), metric.getValue()});
                        }
                        st = new StringTokenizer(cf.toString(), "\n");
                    }
                    data = metricMap;
                    break;
                default:
                    throw new IllegalArgumentException("Unknown header: " + getOutputHeaders()[index]);
View Full Code Here


    @Override
    protected void executeCommand(AdminCommandContext context, Properties extraProps)
        throws Exception {

        ColumnFormatter columnFormatter = new ColumnFormatter(getDisplayHeaders());
        if (isSimpleMode()) {
            extraProps.put("simpleMode", true);
            extraProps.put("listBatchJobs", findSimpleJobInfo(columnFormatter));
        } else {
            extraProps.put("simpleMode", false);
            List<Map<String, Object>> jobExecutions = new ArrayList<>();
            extraProps.put("listBatchJobs", jobExecutions);
            for (JobExecution je : findJobExecutions()) {
                jobExecutions.add(handleJob(je, columnFormatter));
            }
        }
        context.getActionReport().setMessage(columnFormatter.toString());
    }
View Full Code Here

    @Override
    protected void executeCommand(AdminCommandContext context, Properties extraProps)
        throws Exception {

        ColumnFormatter columnFormatter = new ColumnFormatter(getDisplayHeaders());
        List<Map<String, Object>> jobExecutions = new ArrayList<>();
        extraProps.put("listBatchJobExecutions", jobExecutions);
        if (executionId != null) {
            JobOperator jobOperator = BatchRuntime.getJobOperator();
            JobExecution je = jobOperator.getJobExecution(Long.valueOf(executionId));
            if (instanceId != null) {
                JobInstance ji = jobOperator.getJobInstance(Long.valueOf(executionId));
                if (ji.getInstanceId() != Long.valueOf(instanceId)) {
                    throw new RuntimeException("executionid " + executionId
                    + " is not associated with the specified instanceid (" + instanceId + ")"
                    + "; did you mean " + ji.getInstanceId() + " ?");
                }
            }
            try {
                if (glassFishBatchSecurityHelper.isVisibleToThisInstance(((TaggedJobExecution) je).getTagName()))
                    jobExecutions.add(handleJob(je, columnFormatter));
            } catch (Exception ex) {
                logger.log(Level.WARNING, "Exception while getting jobExecution details: " + ex);
                logger.log(Level.FINE, "Exception while getting jobExecution details: ", ex);
            }
        } else if (instanceId != null) {
            for (JobExecution je : getJobExecutionForInstance(Long.valueOf(instanceId))) {
                try {
                    if (glassFishBatchSecurityHelper.isVisibleToThisInstance(((TaggedJobExecution) je).getTagName()))
                        jobExecutions.add(handleJob(je, columnFormatter));
                } catch (Exception ex) {
                    logger.log(Level.WARNING, "Exception while getting jobExecution details: " + ex);
                    logger.log(Level.FINE, "Exception while getting jobExecution details: ", ex);
                }
            }
        } else {
            JobOperator jobOperator = BatchRuntime.getJobOperator();
            Set<String> jobNames = jobOperator.getJobNames();
            if (jobNames != null) {
                for (String jn : jobOperator.getJobNames()) {
                    List<JobInstance> exe = jobOperator.getJobInstances(jn, 0, Integer.MAX_VALUE - 1);
                    if (exe != null) {
                        for (JobInstance ji : exe) {
                            for (JobExecution je : jobOperator.getJobExecutions(ji)) {
                                try {
                                    if (glassFishBatchSecurityHelper.isVisibleToThisInstance(((TaggedJobExecution) je).getTagName()))
                                        jobExecutions.add(handleJob(jobOperator.getJobExecution(je.getExecutionId()), columnFormatter));
                                } catch (Exception ex) {
                                    logger.log(Level.WARNING, "Exception while getting jobExecution details: " + ex);
                                    logger.log(Level.FINE, "Exception while getting jobExecution details: ", ex);
                                }
                            }
                        }
                    }
                }
            }
        }
        if (jobExecutions.size() > 0) {
            context.getActionReport().setMessage(columnFormatter.toString());
        } else {
            throw new RuntimeException("No Job Executions found");
        }

    }
View Full Code Here

                    }
                    break;
                case JOB_PARAMETERS:
                    data = je.getJobParameters() == null ? new Properties() : je.getJobParameters();
                    jobParamIndex = index;
                    ColumnFormatter cf = new ColumnFormatter(new String[]{"KEY", "VALUE"});
                    for (Map.Entry e : ((Properties) data).entrySet())
                        cf.addRow(new String[]{e.getKey().toString(), e.getValue().toString()});
                    st = new StringTokenizer(cf.toString(), "\n");
                    break;
                case STEP_COUNT:
                    long exeId = executionId == null ? je.getExecutionId() : Long.valueOf(executionId);
                    data = jobOperator.getStepExecutions(exeId) == null
                        ? 0 : jobOperator.getStepExecutions(exeId).size();
View Full Code Here

    @Override
    protected void executeCommand(AdminCommandContext context, Properties extraProps)
        throws Exception {

        ColumnFormatter columnFormatter = new ColumnFormatter(getDisplayHeaders());
        List<Map<String, Object>> jobExecutions = new ArrayList<>();
        extraProps.put("listBatchJobSteps", jobExecutions);
        for (StepExecution je : findStepExecutions()) {
            try {
                jobExecutions.add(handleJob(je, columnFormatter));
            } catch (Exception ex) {
                logger.log(Level.WARNING, "Exception while getting jobExecution details: " + ex);
                logger.log(Level.FINE, "Exception while getting jobExecution details ", ex);
            }
        }
        context.getActionReport().setMessage(columnFormatter.toString());
    }
View Full Code Here

                    break;
                case STEP_METRICS:
                    stepMetricsIndex = index;
                    Map<String, Long> metricMap = new HashMap<>();
                    if (stepExecution.getMetrics() != null) {
                        ColumnFormatter cf = new ColumnFormatter(new String[]{"METRICNAME", "VALUE"});
                        for (Metric metric : stepExecution.getMetrics()) {
                            metricMap.put(metric.getType().name(), metric.getValue());
                            cf.addRow(new Object[] {metric.getType().name(), metric.getValue()});
                        }
                        st = new StringTokenizer(cf.toString(), "\n");
                    }
                    data = metricMap;
                    break;
                default:
                    throw new IllegalArgumentException("Unknown header: " + getOutputHeaders()[index]);
View Full Code Here

    @Override
    protected void executeCommand(AdminCommandContext context, Properties extraProps)
        throws Exception {

        ColumnFormatter columnFormatter = new ColumnFormatter(getDisplayHeaders());
        if (isSimpleMode()) {
            extraProps.put("simpleMode", true);
            extraProps.put("listBatchJobs", findSimpleJobInfo(columnFormatter));
        } else {
            extraProps.put("simpleMode", false);
            List<Map<String, Object>> jobExecutions = new ArrayList<>();
            extraProps.put("listBatchJobs", jobExecutions);
            for (JobExecution je : findJobExecutions()) {
                try {
                    if (glassFishBatchSecurityHelper.isVisibleToThisInstance(((TaggedJobExecution) je).getTagName()))
                        jobExecutions.add(handleJob(je, columnFormatter));
                } catch (Exception ex) {
                    logger.log(Level.WARNING, "Exception while getting jobExecution details: " + ex);
                    logger.log(Level.FINE, "Exception while getting jobExecution details ", ex);
                }
            }
        }
        context.getActionReport().setMessage(columnFormatter.toString());
    }
View Full Code Here

        final ActionReport report = context.getActionReport();
        String header_name = localStrings.getLocalString("list.loggers.header.name", "Logger Name");
        String header_subsystem = localStrings.getLocalString("list.loggers.header.subsystem", "Subsystem");
        String header_description = localStrings.getLocalString("list.loggers.header.description", "Logger Description");
       
        ColumnFormatter colFormatter = new ColumnFormatter(new String[]{header_name, header_subsystem, header_description});
               
        // An option to specify client locale should be supported. However, it probably
        // should not be specific to this command. For now, localize using the default locale.
        Locale locale = Locale.getDefault();

        try {
            Set<String> loggers = loggerInfoMetadataService.getLoggerNames();
            // The following Map & List are used to hold the REST data
            Map<String, String> loggerSubsystems = new HashMap<String, String>();
            Map<String, String> loggerDescriptions = new HashMap<String, String>();
            List<String> loggerList = new ArrayList<String>(loggers);
            Collections.sort(loggerList);
            for (String logger : loggers) {
                String subsystem = loggerInfoMetadataService.getSubsystem(logger);
                String desc = loggerInfoMetadataService.getDescription(logger, locale);
                boolean published = loggerInfoMetadataService.isPublished(logger);
                if (subsystem == null) subsystem = UNKNOWN;
                if (desc == null) desc = UNKNOWN;
                if (published || listInternalLoggers) {
                    colFormatter.addRow(new Object[]{logger, subsystem, desc});
                    loggerSubsystems.put(logger, subsystem);
                    loggerDescriptions.put(logger, desc); //Needed for REST xml and JSON output
                    loggerList.add(logger); //Needed for REST xml and JSON output                                   
                }
            }
           
            report.appendMessage(colFormatter.toString());
            report.appendMessage(System.getProperty("line.separator"));
           
            // Populate the extraProperties data structure for REST...
            Properties restData = new Properties();
            restData.put("loggerSubsystems", loggerSubsystems);
View Full Code Here

    @Override
    protected void executeCommand(AdminCommandContext context, Properties extraProps)
        throws Exception {

        ColumnFormatter columnFormatter = new ColumnFormatter(getDisplayHeaders());
        List<Map<String, Object>> jobExecutions = new ArrayList<>();
        extraProps.put("listBatchJobSteps", jobExecutions);
        for (StepExecution je : findStepExecutions()) {
            jobExecutions.add(handleJob(je, columnFormatter));
        }
        context.getActionReport().setMessage(columnFormatter.toString());
    }
View Full Code Here

                    break;
                case STEP_METRICS:
                    stepMetricsIndex = index;
                    Map<String, Long> metricMap = new HashMap<>();
                    if (stepExecution.getMetrics() != null) {
                        ColumnFormatter cf = new ColumnFormatter(new String[]{"METRICNAME", "VALUE"});
                        for (Metric metric : stepExecution.getMetrics()) {
                            metricMap.put(metric.getName().name(), metric.getValue());
                            cf.addRow(new Object[] {metric.getName().name(), metric.getValue()});
                        }
                        st = new StringTokenizer(cf.toString(), "\n");
                    }
                    data = metricMap;
                    break;
                default:
                    throw new IllegalArgumentException("Unknown header: " + getOutputHeaders()[index]);
View Full Code Here

TOP

Related Classes of com.sun.enterprise.util.ColumnFormatter

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.