Search in sources :

Example 51 with ColumnFormatter

use of com.sun.enterprise.util.ColumnFormatter in project Payara by payara.

the class ListDomainsCommand method executeCommand.

@Override
protected int executeCommand() throws CommandException, CommandValidationException {
    try {
        File domainsDirFile = ok(domainDirParam) ? new File(domainDirParam) : DomainDirs.getDefaultDomainsDir();
        DomainConfig domainConfig = new DomainConfig(null, domainsDirFile.getAbsolutePath());
        DomainsManager manager = new PEDomainsManager();
        String[] domainsList = manager.listDomains(domainConfig);
        // no prompting for passwords
        programOpts.setInteractive(false);
        if (domainsList.length > 0) {
            if (longOpt) {
                String[] headings = { "DOMAIN", "ADMIN_HOST", "ADMIN_PORT", "RUNNING", "RESTART_REQUIRED" };
                ColumnFormatter cf = header ? new ColumnFormatter(headings) : new ColumnFormatter();
                for (String dn : domainsList) {
                    DomainInfo di = getStatus(dn);
                    cf.addRow(new Object[] { dn, di.adminAddr.getHost(), di.adminAddr.getPort(), di.status, di.restartRequired });
                }
                logger.info(cf.toString());
            } else {
                for (String dn : domainsList) {
                    logger.info(getStatus(dn).statusMsg);
                }
            }
        } else {
            logger.fine(STRINGS.get("NoDomainsToList"));
        }
    } catch (Exception ex) {
        throw new CommandException(ex.getLocalizedMessage());
    }
    return 0;
}
Also used : PEDomainsManager(com.sun.enterprise.admin.servermgmt.pe.PEDomainsManager) DomainsManager(com.sun.enterprise.admin.servermgmt.DomainsManager) File(java.io.File) PEDomainsManager(com.sun.enterprise.admin.servermgmt.pe.PEDomainsManager) ColumnFormatter(com.sun.enterprise.util.ColumnFormatter) IOException(java.io.IOException) DomainException(com.sun.enterprise.admin.servermgmt.DomainException) DomainConfig(com.sun.enterprise.admin.servermgmt.DomainConfig)

Example 52 with ColumnFormatter

use of com.sun.enterprise.util.ColumnFormatter in project Payara by payara.

the class InstanceInfo method format.

// ///////////////////////////////////////////////////////////////////////
// //////  static formatting stuff below   ///////////////////////////////
// ///////////////////////////////////////////////////////////////////////
public static String format(List<InstanceInfo> infos) {
    String[] headings = { NAME, HOST, PORT, PID, CLUSTER, STATE };
    ColumnFormatter cf = new ColumnFormatter(headings);
    for (InstanceInfo info : infos) {
        cf.addRow(new Object[] { info.getName(), info.getHost(), info.getPort(), formatPid(info), info.getDisplayCluster(), info.getDisplayState() });
    }
    return cf.toString();
}
Also used : ColumnFormatter(com.sun.enterprise.util.ColumnFormatter)

Example 53 with ColumnFormatter

use of com.sun.enterprise.util.ColumnFormatter in project Payara by payara.

the class BaseGetNotifierConfigurationCommand method listConfiguration.

/**
 * @param configuration the configuration to print
 * @return A column formatted string representing the configuration
 * @see #getNotifierConfiguration(PayaraNotifierConfiguration)
 */
protected String listConfiguration(C configuration) {
    Map<String, Object> configMap = getNotifierConfiguration(configuration);
    Iterator<Entry<String, Object>> configIterator = configMap.entrySet().iterator();
    List<String> headers = new ArrayList<>(2);
    List<Object> values = new ArrayList<>(2);
    while (configIterator.hasNext()) {
        Entry<String, Object> entry = configIterator.next();
        headers.add(entry.getKey());
        values.add(entry.getValue());
    }
    ColumnFormatter columnFormatter = new ColumnFormatter(headers.toArray(new String[0]));
    columnFormatter.addRow(values.toArray());
    return columnFormatter.toString();
}
Also used : Entry(java.util.Map.Entry) ArrayList(java.util.ArrayList) ColumnFormatter(com.sun.enterprise.util.ColumnFormatter)

Aggregations

ColumnFormatter (com.sun.enterprise.util.ColumnFormatter)53 Properties (java.util.Properties)24 HashMap (java.util.HashMap)22 ActionReport (org.glassfish.api.ActionReport)22 Config (com.sun.enterprise.config.serverbeans.Config)21 ServiceHandle (org.glassfish.hk2.api.ServiceHandle)8 ArrayList (java.util.ArrayList)7 PayaraNotifier (fish.payara.internal.notification.PayaraNotifier)5 MonitoringService (com.sun.enterprise.config.serverbeans.MonitoringService)3 AMXConfiguration (fish.payara.admin.amx.config.AMXConfiguration)2 MonitoredAttribute (fish.payara.jmx.monitoring.configuration.MonitoredAttribute)2 MonitoringServiceConfiguration (fish.payara.jmx.monitoring.configuration.MonitoringServiceConfiguration)2 BaseHealthCheck (fish.payara.nucleus.healthcheck.preliminary.BaseHealthCheck)2 NotifierConfigurationType (fish.payara.nucleus.notification.configuration.NotifierConfigurationType)2 LogNotifierConfiguration (fish.payara.nucleus.notification.log.LogNotifierConfiguration)2 BaseNotifierService (fish.payara.nucleus.notification.service.BaseNotifierService)2 File (java.io.File)2 TaggedJobExecution (com.ibm.jbatch.spi.TaggedJobExecution)1 DomainConfig (com.sun.enterprise.admin.servermgmt.DomainConfig)1 DomainException (com.sun.enterprise.admin.servermgmt.DomainException)1