opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/resources/Resources.properties
@@ -172,12 +172,11 @@ to a newer version. Use of this tool assumes that you have already downloaded an \ OpenDS install package (.zip) file. You can also upgrade your server using \ the Java Web Start version of this tool by visiting the OpenDS web site at opends.org.\n\n\ Usage: {0} {options} where {options} \ include:\n\n\ Usage: {0} {options}\n where {options} include:\n\ -V, --version\n Display Directory Server version information.\n\ -f, --file\n Specifies an existing OpenDS package (.zip) \ file to which the\n current build will be upgraded using the command line \ \n version of this tool\n \n version of this tool\n-?, -H , --help\n Display this usage information.\n upgrade-launcher-launching-gui=Launching graphical upgrade... upgrade-launcher-launching-cli=Launching command line upgrade... upgrade-launcher-gui-launched-failed=\n\nThe graphical upgrade launch \ @@ -848,6 +847,7 @@ progress-downloading=Downloading progress-done=Done. progress-points=..... progress-error=Error. progress-extracting=Extracting {0} progress-configuring=Configuring Directory Server progress-updating-certificates=Configuring Certificates opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/ui/GuiApplication.java
@@ -487,10 +487,9 @@ protected void startServerWithoutConnectionHandlers() throws ApplicationException { try { ServerController control = new ServerController(this); ServerController control = new ServerController(getInstallation()); if (getInstallation().getStatus().isServerRunning()) { control.stopServer(); notifyListeners(formatter.getLineBreak()); control.stopServer(true); } new InProcessServerController(getInstallation()).startServer(true); } catch (IOException e) { opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/upgrader/Upgrader.java
@@ -152,11 +152,15 @@ VERIFYING("summary-upgrade-verifying", 80), RECORDING_HISTORY("summary-upgrade-history", 85), STARTING_SERVER("summary-starting", 90), CLEANUP("summary-upgrade-cleanup", 90), STOPPING_SERVER("summary-stopping", 90), ABORT("summary-upgrade-abort", 95), RECORDING_HISTORY("summary-upgrade-history", 97), CLEANUP("summary-upgrade-cleanup", 99), ABORT("summary-upgrade-abort", 99), FINISHED_WITH_ERRORS("summary-upgrade-finished-with-errors", 100), @@ -736,6 +740,8 @@ formatter.getLineBreak()); LOG.log(Level.INFO, "extraction finished"); } catch (ApplicationException e) { notifyListeners(formatter.getFormattedError() + formatter.getLineBreak()); LOG.log(Level.INFO, "Error extracting build file", e); throw e; } @@ -750,6 +756,8 @@ formatter.getLineBreak()); LOG.log(Level.INFO, "initialization finished"); } catch (ApplicationException e) { notifyListeners(formatter.getFormattedError() + formatter.getLineBreak()); LOG.log(Level.INFO, "Error initializing upgrader", e); throw e; } @@ -766,6 +774,8 @@ formatter.getLineBreak()); LOG.log(Level.INFO, "check for schema customizations finished"); } catch (ApplicationException e) { notifyListeners(formatter.getFormattedError() + formatter.getLineBreak()); LOG.log(Level.INFO, "Error calculating schema customizations", e); throw e; } @@ -782,6 +792,8 @@ formatter.getLineBreak()); LOG.log(Level.INFO, "check for config customizations finished"); } catch (ApplicationException e) { notifyListeners(formatter.getFormattedError() + formatter.getLineBreak()); LOG.log(Level.INFO, "Error calculating config customizations", e); throw e; @@ -797,6 +809,8 @@ formatter.getLineBreak()); LOG.log(Level.INFO, "database backup finished"); } catch (ApplicationException e) { notifyListeners(formatter.getFormattedError() + formatter.getLineBreak()); LOG.log(Level.INFO, "Error backing up databases", e); throw e; } @@ -811,6 +825,8 @@ formatter.getLineBreak()); LOG.log(Level.INFO, "filesystem backup finished"); } catch (ApplicationException e) { notifyListeners(formatter.getFormattedError() + formatter.getLineBreak()); LOG.log(Level.INFO, "Error backing up files", e); throw e; } @@ -826,6 +842,8 @@ formatter.getLineBreak()); LOG.log(Level.INFO, "componnet upgrade finished"); } catch (ApplicationException e) { notifyListeners(formatter.getFormattedError() + formatter.getLineBreak()); LOG.log(Level.INFO, "Error upgrading components", e); throw e; @@ -865,6 +883,8 @@ formatter.getLineBreak()); LOG.log(Level.INFO, "custom schema application finished"); } catch (ApplicationException e) { notifyListeners(formatter.getFormattedError() + formatter.getLineBreak()); LOG.log(Level.INFO, "Error applying schema customizations", e); throw e; @@ -883,6 +903,8 @@ formatter.getLineBreak()); LOG.log(Level.INFO, "custom config application finished"); } catch (ApplicationException e) { notifyListeners(formatter.getFormattedError() + formatter.getLineBreak()); LOG.log(Level.INFO, "Error applying configuration customizations", e); throw e; @@ -924,6 +946,8 @@ formatter.getLineBreak()); LOG.log(Level.INFO, "upgrade verification complete"); } catch (ApplicationException e) { notifyListeners(formatter.getFormattedError() + formatter.getLineBreak()); LOG.log(Level.INFO, "Error verifying upgrade", e); throw e; } @@ -933,24 +957,32 @@ // verified at this point to in the unlikely event of an error, // we call this a warning instead of an error. try { ServerController control = getServerController(); ServerController control = new ServerController(getInstallation()); boolean serverRunning = getInstallation().getStatus().isServerRunning(); boolean userRequestsStart = getUserData().getStartServer(); if (userRequestsStart && !serverRunning) { try { LOG.log(Level.INFO, "starting server"); control.startServer(); notifyListeners(formatter.getLineBreak()); setCurrentProgressStep(UpgradeProgressStep.STARTING_SERVER); control.startServer(true); notifyListeners(formatter.getFormattedDone() + formatter.getLineBreak()); } catch (ApplicationException e) { notifyListeners(formatter.getFormattedError() + formatter.getLineBreak()); LOG.log(Level.INFO, "error starting server"); this.runWarning = e; } } else if (!userRequestsStart && serverRunning) { try { LOG.log(Level.INFO, "stopping server"); control.stopServer(); notifyListeners(formatter.getLineBreak()); setCurrentProgressStep(UpgradeProgressStep.STOPPING_SERVER); control.stopServer(true); notifyListeners(formatter.getFormattedDone() + formatter.getLineBreak()); } catch (ApplicationException e) { notifyListeners(formatter.getFormattedError() + formatter.getLineBreak()); LOG.log(Level.INFO, "error stopping server"); this.runWarning = e; } @@ -1013,6 +1045,8 @@ Utils.getPath(getInstallation().getHistoryLogFile()) + " for upgrade history" + formatter.getLineBreak()); } catch (ApplicationException e) { notifyListeners(formatter.getFormattedError() + formatter.getLineBreak()); System.err.print("Error cleaning up after upgrade: " + e.getLocalizedMessage()); } @@ -1158,8 +1192,8 @@ // Restart the server after putting the files // back like we found them. getServerController().stopServer(); getServerController().startServer(); getServerController().stopServer(true); getServerController().startServer(true); } catch (IOException e) { LOG.log(Level.INFO, "Error getting backup directory", e); opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/HtmlProgressMessageFormatter.java
@@ -42,6 +42,7 @@ public class HtmlProgressMessageFormatter implements ProgressMessageFormatter { private String doneHtml; private String errorHtml; /** * The line break in HTML. @@ -210,6 +211,20 @@ } /** * Returns the HTML representation of the 'Error' text string. * @return the HTML representation of the 'Error' text string. */ public String getFormattedError() { if (errorHtml == null) { String html = getHtml(getMsg("progress-error")); errorHtml = UIFactory.applyFontToHtml(html, UIFactory.PROGRESS_ERROR_FONT); } return errorHtml; } /** * Returns the HTML representation of the argument text to which we add * points. For instance if we pass as argument 'Configuring Server' the * return value will be 'Configuring Server <B>.....</B>'. opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/InProcessServerController.java
@@ -146,9 +146,14 @@ */ public void stopServer() { LOG.log(Level.INFO, "Shutting down in process server"); StandardOutputSuppressor.suppress(); try { org.opends.server.core.DirectoryServer.shutDown( ServerController.class.getName(), "quicksetup requests shutdown"); } finally { StandardOutputSuppressor.unsuppress(); } } /** @@ -167,58 +172,50 @@ public OperationOutput startServer() throws org.opends.server.types.InitializationException, org.opends.server.config.ConfigException { org.opends.server.config.ConfigException { OperationOutput output = new OperationOutput(); // Bootstrap and start the Directory Server. LOG.log(Level.FINER, "Bootstrapping directory server"); org.opends.server.core.DirectoryServer directoryServer = org.opends.server.core.DirectoryServer.getInstance(); StandardOutputSuppressor.suppress(); directoryServer.bootstrapServer(); String configClass = "org.opends.server.extensions.ConfigFileHandler"; String configPath = Utils.getPath( installation.getCurrentConfigurationFile()); directoryServer.initializeConfiguration(configClass, configPath); try { try { DebugLogPublisher startupDebugPublisher = TextDebugLogPublisher.getStartupTextDebugPublisher( new ServerControllerTextWriter(output) { void storeRecord(String record, OperationOutput output) { void storeRecord(String record, OperationOutput output) { LOG.log(Level.INFO, "server start (debug log): " + record); output.addDebugMessage(record); } }); DebugLogger.removeAllDebugLogPublishers(); DebugLogger.addDebugLogPublisher(DN.NULL_DN, startupDebugPublisher); ErrorLogPublisher startupErrorPublisher = TextErrorLogPublisher.getStartupTextErrorPublisher( new ServerControllerTextWriter(output) { void storeRecord(String record, OperationOutput output) { void storeRecord(String record, OperationOutput output) { LOG.log(Level.INFO, "server start (error log): " + record); output.addErrorMessage(record); } }); ErrorLogger.removeAllErrorLogPublishers(); ErrorLogger.addErrorLogPublisher(DN.NULL_DN, startupErrorPublisher); AccessLogPublisher startupAccessPublisher = TextAccessLogPublisher.getStartupTextAccessPublisher( new ServerControllerTextWriter(output) { void storeRecord(String record, OperationOutput output) { void storeRecord(String record, OperationOutput output) { LOG.log(Level.INFO, "server start (access log): " + record); output.addAccessMessage(record); } }); AccessLogger.removeAllAccessLogPublishers(); AccessLogger.addAccessLogPublisher(DN.NULL_DN, startupAccessPublisher); @@ -227,9 +224,26 @@ e.toString()); } org.opends.server.core.DirectoryServer directoryServer = org.opends.server.core.DirectoryServer.getInstance(); // Bootstrap and start the Directory Server. LOG.log(Level.FINER, "Bootstrapping directory server"); directoryServer.bootstrapServer(); LOG.log(Level.FINER, "Initializing configuration"); String configClass = "org.opends.server.extensions.ConfigFileHandler"; String configPath = Utils.getPath( installation.getCurrentConfigurationFile()); directoryServer.initializeConfiguration(configClass, configPath); LOG.log(Level.FINER, "Invoking start server"); directoryServer.startServer(); } finally { StandardOutputSuppressor.unsuppress(); } return output; } opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/PlainTextProgressMessageFormatter.java
@@ -38,6 +38,7 @@ implements ProgressMessageFormatter { private String doneText; private String errorText; /** * The line break in plain text. @@ -167,6 +168,19 @@ } /** * Returns the plain text representation of the 'Error' text string. * @return the plain text representation of the 'Error' text string. */ public String getFormattedError() { if (errorText == null) { errorText = getMsg("progress-error"); } return errorText; } /** * Returns the plain text representation of the argument text to which we add * points. For instance if we pass as argument 'Configuring Server' the * return value will be 'Configuring Server .....'. @@ -263,7 +277,7 @@ * have something of type: * key=value * * @see ResourceProvider.getMsg(String key) * @see ResourceProvider#getMsg(String key) * @param key the key in the properties file. * @return the value associated to the key in the properties file. * properties file. opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/ProgressMessageFormatter.java
@@ -112,6 +112,12 @@ public String getFormattedDone(); /** * Returns the formatted representation of the 'Error' text string. * @return the formatted representation of the 'Error' text string. */ public String getFormattedError(); /** * Returns the formatted representation of the argument text to which we add * points. For instance if we pass as argument 'Configuring Server' the * return value will be 'Configuring Server .....'. opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/ServerController.java
@@ -60,7 +60,7 @@ * @param application to use for notifications */ public ServerController(Application application) { this(application, application.getInstallation()); wqthis(application, application.getInstallation()); } /** @@ -92,6 +92,24 @@ * @throws org.opends.quicksetup.ApplicationException if something goes wrong. */ public void stopServer() throws ApplicationException { stopServer(false); } /** * This methods stops the server. * * @param suppressOutput boolean indicating that ouput to standard output * streams from the server should be suppressed. * @throws org.opends.quicksetup.ApplicationException * if something goes wrong. */ public void stopServer(boolean suppressOutput) throws ApplicationException { if (suppressOutput && !StandardOutputSuppressor.isSuppressed()) { StandardOutputSuppressor.suppress(); } try { if (application != null) { application.notifyListeners( application.getFormattedProgress( @@ -204,16 +222,36 @@ throw new ApplicationException(ApplicationException.Type.STOP_ERROR, getThrowableMsg("error-stopping-server", e), e); } } finally { if (suppressOutput && StandardOutputSuppressor.isSuppressed()) { StandardOutputSuppressor.unsuppress(); } } } /** * This methods starts the server. * * @return OperationOutput object containing output from the start server * command invocation. * @throws org.opends.quicksetup.ApplicationException if something goes wrong. */ public OperationOutput startServer() throws ApplicationException { return startServer(true); return startServer(true, false); } /** * This methods starts the server. * @param suppressOutput boolean indicating that ouput to standard output * streams from the server should be suppressed. * @return OperationOutput object containing output from the start server * command invocation. * @throws org.opends.quicksetup.ApplicationException if something goes wrong. */ public OperationOutput startServer(boolean suppressOutput) throws ApplicationException { return startServer(true, suppressOutput); } /** @@ -222,12 +260,20 @@ * connect to the server after starting to verify that it is listening. * @return OperationOutput object containing output from the start server * command invocation. * @return boolean indicating that ouput to standard output streams * from the server should be suppressed. * @throws org.opends.quicksetup.ApplicationException if something goes wrong. */ private OperationOutput startServer(boolean verify) private OperationOutput startServer(boolean verify, boolean suppressOuput) throws ApplicationException { OperationOutput output = new OperationOutput(); if (suppressOuput && !StandardOutputSuppressor.isSuppressed()) { StandardOutputSuppressor.suppress(); } try { if (application != null) { application.notifyListeners( application.getFormattedProgress( @@ -394,6 +440,11 @@ getThrowableMsg("error-starting-server", ioe), ioe); } } finally { if (suppressOuput && StandardOutputSuppressor.isSuppressed()) { StandardOutputSuppressor.unsuppress(); } } return output; } opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/ServerHealthChecker.java
@@ -76,7 +76,7 @@ try { control = new InProcessServerController(installation); if (installation.getStatus().isServerRunning()) { new ServerController(installation).stopServer(); new ServerController(installation).stopServer(true); } OperationOutput op = control.startServer(true); errors = op.getErrorMessages(UNHEALTHY_SERVER_LOG_REGEX); opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/StandardOutputSuppressor.java
New file @@ -0,0 +1,108 @@ /* * CDDL HEADER START * * The contents of this file are subject to the terms of the * Common Development and Distribution License, Version 1.0 only * (the "License"). You may not use this file except in compliance * with the License. * * You can obtain a copy of the license at * trunk/opends/resource/legal-notices/OpenDS.LICENSE * or https://OpenDS.dev.java.net/OpenDS.LICENSE. * See the License for the specific language governing permissions * and limitations under the License. * * When distributing Covered Code, include this CDDL HEADER in each * file and include the License file at * trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable, * add the following below this CDDL HEADER, with the fields enclosed * by brackets "[]" replaced with your own identifying information: * Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END * * * Portions Copyright 2007 Sun Microsystems, Inc. */ package org.opends.quicksetup.util; import java.io.OutputStream; import java.io.IOException; import java.io.PrintStream; /** * Tool for suppressing and unsuppressing output to standard * output streams. */ public class StandardOutputSuppressor { static private Token token = null; /** * Object to return to this class for * unsupressing output. */ static private class Token { PrintStream out; PrintStream err; } /** * Suppresses output to the standard output * streams. */ static synchronized public void suppress() { if (token == null) { token = new Token(); token.out = System.out; token.err = System.err; System.out.flush(); System.err.flush(); System.setOut(new PrintStream(new NullOutputStream())); System.setErr(new PrintStream(new NullOutputStream())); } else { throw new IllegalStateException("Standard streams currently suppressed"); } } /** * Unsupresses the standard output streams. Following a call to this * method System.out and System.err will point to the descriptor prior * to calling <code>suppress()</code>. */ static synchronized public void unsuppress() { if (token != null) { System.setOut(token.out); System.setErr(token.err); token = null; } else { throw new IllegalStateException( "Standard streams not currently suppressed"); } } /** * Checks whether or not this class has suppressed standard out streams. * @return boolean where true indicates output is suppressed */ static public boolean isSuppressed() { return token != null; } /** * PrintWriter for suppressing stream. */ static private class NullOutputStream extends OutputStream { /** * {@inheritDoc} */ public void write(int b) throws IOException { // do nothing; } } }