From: <ju...@us...> - 2007-10-11 13:07:29
|
Revision: 5246 http://smartfrog.svn.sourceforge.net/smartfrog/?rev=5246&view=rev Author: julgui Date: 2007-10-11 06:06:41 -0700 (Thu, 11 Oct 2007) Log Message: ----------- Improved diagnostics messages. Modified Paths: -------------- trunk/core/smartfrog/src/org/smartfrog/SFSystem.java trunk/core/smartfrog/src/org/smartfrog/sfcore/common/ConfigurationDescriptor.java trunk/core/smartfrog/src/org/smartfrog/sfcore/common/Diagnostics.java trunk/core/smartfrog/src/org/smartfrog/sfcore/common/Logger.java trunk/core/smartfrog/src/org/smartfrog/sfcore/common/OptionSet.java trunk/core/smartfrog/src/org/smartfrog/sfcore/logging/LogImpl.java Modified: trunk/core/smartfrog/src/org/smartfrog/SFSystem.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/SFSystem.java 2007-10-10 10:01:40 UTC (rev 5245) +++ trunk/core/smartfrog/src/org/smartfrog/SFSystem.java 2007-10-11 13:06:41 UTC (rev 5246) @@ -95,7 +95,8 @@ /** * root process. Will be null after termination. */ - private ProcessCompound rootProcess; + private ProcessCompound rootProcess = null; + public static final String HEADLESS_MODE_MESSAGE = "Running in headless mode"; /** @@ -283,7 +284,8 @@ * Shows the version info of the SmartFrog system. */ private static void showVersionInfo(){ - sfLog().out(Version.versionString()+System.getProperty("line.separator")+Version.copyright()); + String lineS = System.getProperty("line.separator"); + sfLog().out(lineS+Version.versionString()+lineS+Version.copyright()+lineS); } /** @@ -409,19 +411,22 @@ exitWith("Failed to initialize SmartFrog", ExitCodes.EXIT_ERROR_CODE_GENERAL); } - setRootProcess(null); - + //SmartFrog version info showVersionInfo(); + logInitStatus(); + //read command line options OptionSet opts = new OptionSet(args); + //engage headless mode + maybeGoHeadless(opts); + maybeShowDiagnostics(opts); if (opts.errorString != null) { exitWith(opts.errorString, ExitCodes.EXIT_ERROR_CODE_GENERAL); } - //engage headless mode - maybeGoHeadless(opts); + try { setRootProcess(runSmartFrog(opts.cfgDescriptors,opts.terminateOnDeploymentFailure)); } catch (SmartFrogException sfex) { @@ -482,6 +487,15 @@ } } + public void logInitStatus() { + //SmartFrog security warning messages + logSecurityStatus(); + //Notify special properties status + Logger.logStatus(); + //SmartFrog network status checks + logNetworkStatus(); + } + protected void exitWithException(Exception sfex, int errorcode) { if (Logger.logStackTrace){ printStackTrace(sfex); @@ -512,13 +526,15 @@ } } - private void maybeGoNoExitCodeOptionSet(OptionSet opts) { - if (opts.headless) { - sfLog().info(HEADLESS_MODE_MESSAGE); - System.setProperty("java.awt.headless", "true"); - } - } +// Was this used? - Julio - if not, then remove. +// private void maybeGoNoExitCodeOptionSet(OptionSet opts) { +// if (opts.headless) { +// sfLog().info(HEADLESS_MODE_MESSAGE); +// System.setProperty("java.awt.headless", "true"); +// } +// } + /** * Prints StackTrace * @param thr Throwable @@ -606,6 +622,7 @@ /** * initialise the system. Turn security on, read properties from an ini file * and then look at stack tracing. + * To print init status messages call {@link org.smartfrog.SFSystem#logInitStatus()} after. * This method is idempotent and synchronised; you can only init the system once. * @throws SmartFrogException * @throws SFGeneralSecurityException @@ -618,26 +635,31 @@ // Read init properties readPropertiesFromIniFile(); sfLog(); - notifySecurityStatus(); - // Init logging properties + // Init special static properties Logger.init(); + //Notifies any possible problem with security init. + checkSecurityStatus(); + alreadySystemInit = true; + } + } - //Test local networking: checks localhost NIC - if (Logger.testNetwork) { - StringBuffer result = new StringBuffer(); - boolean failed = Diagnostics.doReportLocalNetwork(result); - if (failed) { - if (sfLog().isWarnEnabled()) { sfLog().warn(result.toString()); } - } else { - if (sfLog().isDebugEnabled()) { sfLog().debug(result.toString()); } - } + private static void logNetworkStatus() {//Test local networking: checks localhost NIC + if (Logger.testNetwork) { + StringBuffer result = new StringBuffer(); + boolean failed = Diagnostics.doReportLocalNetwork(result); + if (failed) { + if (sfLog().isWarnEnabled()) { sfLog().warn(result.toString()); } + } else { + if (sfLog().isDebugEnabled()) { sfLog().debug(result.toString()); } } - alreadySystemInit = true; } } - public static void notifySecurityStatus() throws SFGeneralSecurityException { + /** + * Throws exception if secury is required and not enabled. + */ + public static void checkSecurityStatus() throws SFGeneralSecurityException { // Notify status of Security if (!SFSecurity.isSecurityOn()){ String securityRequired = System.getProperty(SFSecurityProperties.propSecurityRequired,"false"); @@ -646,12 +668,21 @@ //we need security, but it is not enabled throw new SFGeneralSecurityException(MessageUtil.formatMessage(ERROR_NO_SECURITY_BUT_REQUIRED)); } + } + } + + /** + * Prints messages about security status + * @throws SFGeneralSecurityException + */ + public static void logSecurityStatus() { + // Notify warning message about Security status + if (!SFSecurity.isSecurityOn()){ if (sfLog().isWarnEnabled()) { sfLog().warn(MessageUtil.formatMessage(WARN_NO_SECURITY)); } - } - // if this property is set the a sec manager is created + // if this property is set then a security manager is created, here we provide debug information about it. String secPro = System.getProperty(SmartFrogCoreProperty.codebase); if (secPro!=null ) { if (sfLog().isDebugEnabled()) sfLog().debug("Using java security policy: "+secPro); Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/common/ConfigurationDescriptor.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/common/ConfigurationDescriptor.java 2007-10-10 10:01:40 UTC (rev 5245) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/common/ConfigurationDescriptor.java 2007-10-11 13:06:41 UTC (rev 5246) @@ -591,7 +591,7 @@ * ex. foo * ex. "HOST localhost:foo" * ex. 'HOST localhost:foo' - * - ACTION: possible actions: DEPLOY, TERMINATE, DETACH, DETaTERM, PING, PARSE, DIAGNOSTICS, UPDATE, LOAD + * - ACTION: possible actions: DEPLOY, TERMINATE, DETACH, DETaTERM, PING, PARSE, DIAGNOSTICS, UPDATE, LOAD, DUMP * - url: description used by ACTION * ex. /home/sf/foo.sf * ex. "c:\sf\foo.sf" @@ -737,7 +737,7 @@ * - name: name where to apply ACTION * ex. "foo" * ex. "HOST localhost:foo" - * - action: possible actions: DEPLOY, TERMINATE, DETACH, DETaTERM, PING, PARSE, DIAGNOSTICS, UPDATE, LOAD + * - action: possible actions: DEPLOY, TERMINATE, DETACH, DETaTERM, PING, PARSE, DIAGNOSTICS, UPDATE, LOAD, DUMP * - descriptionURL: description used by ACTION * ex. "/home/sf/foo.sf" * ex. "c:\sf\foo.sf" Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/common/Diagnostics.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/common/Diagnostics.java 2007-10-10 10:01:40 UTC (rev 5245) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/common/Diagnostics.java 2007-10-11 13:06:41 UTC (rev 5246) @@ -297,11 +297,11 @@ header(out, "Locale information"); doReportLocale(out); + doReportPrim(out, prim); + header(out, "Thread Dump"); doReportThreadDump(out); - doReportPrim(out, prim); - header(out, "System properties"); doReportSystemProperties(out); @@ -542,7 +542,14 @@ out.append("* SF codebase: ");out.append(nameP);out.append("\n"); } + nameP =System.getProperty("java.awt.headless"); + if ((nameP!=null)&& !nameP.equals("")){ + out.append("* Headless: true");out.append("\n"); + } else { + out.append("* Headless: false");out.append("\n"); + } + } /** Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/common/Logger.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/common/Logger.java 2007-10-10 10:01:40 UTC (rev 5245) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/common/Logger.java 2007-10-11 13:06:41 UTC (rev 5246) @@ -100,7 +100,11 @@ } catch (Exception ex){ if (SFSystem.sfLog().isErrorEnabled()) { SFSystem.sfLog().error(ex); } } + + initialized = true; + } + public static void logStatus() { if (logStackTrace&&(SFSystem.sfLog().isWarnEnabled())) { SFSystem.sfLog().warn(MessageUtil.formatMessage(MSG_WARNING_STACKTRACE_ENABLED)); } @@ -108,8 +112,6 @@ if (logLiveness && (SFSystem.sfLog().isWarnEnabled())) { SFSystem.sfLog().warn(MessageUtil.formatMessage(MSG_WARNING_LIVENESS_ENABLED)); } - - initialized = true; } /** Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/common/OptionSet.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/common/OptionSet.java 2007-10-10 10:01:40 UTC (rev 5245) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/common/OptionSet.java 2007-10-11 13:06:41 UTC (rev 5246) @@ -21,6 +21,7 @@ package org.smartfrog.sfcore.common; import java.util.Vector; +import java.util.Arrays; import org.smartfrog.Version; import java.io.LineNumberReader; @@ -147,8 +148,10 @@ * @param args arguments to create from */ public OptionSet(String[] args) { - int i = 0; - + int i = 0; + if (SFSystem.sfLog().isDebugEnabled()) { + SFSystem.sfLog().debug("Command Line args: "+ Arrays.toString(args)); + } while ((i < args.length) && (errorString == null)) { try { String currentArg = args[i]; Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/logging/LogImpl.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/logging/LogImpl.java 2007-10-10 10:01:40 UTC (rev 5245) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/logging/LogImpl.java 2007-10-11 13:06:41 UTC (rev 5246) @@ -317,7 +317,7 @@ private void loadStartUpLoggers(String name, Object configurationClass, String configurationCodeBase, Vector loggersConfiguration) throws RemoteException, SmartFrogLogException { if (configurationClass instanceof String) { localLog = loadLogger(name, (ComponentDescription)loggersConfiguration.firstElement(), new Integer(currentLogLevel), (String)configurationClass, configurationCodeBase); - if (localLog.isDebugEnabled()) localLog.debug("Logger registered: "+ localLog.getClass().toString()); + if (localLog.isTraceEnabled()) localLog.trace("Logger registered: "+ localLog.getClass().toString()); } else if (configurationClass instanceof Vector) { String className = null; ComponentDescription loggerConfiguration = null; @@ -334,8 +334,8 @@ } else { register("localLog"+i, logger); } - if (isDebugEnabled()) { - debug("Logger registered: "+logger.getClass().toString()); + if (isTraceEnabled()) { + trace("Logger registered: "+logger.getClass().toString()); } } catch (Exception ex) { if (i ==0) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |