| | |
| | | import javax.naming.NamingException; |
| | | import java.util.ArrayList; |
| | | import java.util.Map; |
| | | import java.util.List; |
| | | import java.io.BufferedReader; |
| | | import java.io.InputStreamReader; |
| | | import java.io.IOException; |
| | |
| | | |
| | | /** |
| | | * 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 void startServer() throws ApplicationException { |
| | | startServer(true); |
| | | public OperationOutput startServer() throws ApplicationException { |
| | | return startServer(true); |
| | | } |
| | | |
| | | /** |
| | | * This methods starts the server. |
| | | * @param verify boolean indicating whether this method will attempt to |
| | | * connect to the server after starting to verify that it is listening. |
| | | * @return OperationOutput object containing output from the start server |
| | | * command invocation. |
| | | * @throws org.opends.quicksetup.ApplicationException if something goes wrong. |
| | | */ |
| | | private void startServer(boolean verify) throws ApplicationException { |
| | | private OperationOutput startServer(boolean verify) |
| | | throws ApplicationException |
| | | { |
| | | OperationOutput output = new OperationOutput(); |
| | | application.notifyListeners( |
| | | application.getFormattedProgress( |
| | | application.getMsg("progress-starting")) + |
| | |
| | | StartReader errReader = new StartReader(err, startedId, true); |
| | | StartReader outputReader = new StartReader(out, startedId, false); |
| | | |
| | | while (!errReader.isFinished() && !outputReader.isFinished()) |
| | | while (!errReader.isFinished() || !outputReader.isFinished()) |
| | | { |
| | | try |
| | | { |
| | |
| | | { |
| | | } |
| | | } |
| | | |
| | | // Collect any errors found in the output |
| | | List<String> errors = errReader.getErrors(); |
| | | if (outputReader.getErrors() != null) { |
| | | if (errors == null) { |
| | | errors = new ArrayList<String>(); |
| | | } |
| | | errors.addAll(outputReader.getErrors()); |
| | | } |
| | | output.setErrors(errors); |
| | | |
| | | // Check if something wrong occurred reading the starting of the server |
| | | ApplicationException ex = errReader.getException(); |
| | | if (ex == null) |
| | |
| | | } |
| | | if (ex != null) |
| | | { |
| | | // This is meaningless right now since we throw |
| | | // the exception below, but in case we change out |
| | | // minds later or add the ability to return exceptions |
| | | // in the output only instead of throwing... |
| | | output.setException(ex); |
| | | throw ex; |
| | | |
| | | } else if (verify) |
| | |
| | | throw new ApplicationException(ApplicationException.Type.START_ERROR, |
| | | application.getThrowableMsg("error-starting-server", ioe), ioe); |
| | | } |
| | | return output; |
| | | } |
| | | |
| | | /** |
| | |
| | | { |
| | | private ApplicationException ex; |
| | | |
| | | private List<String> errors; |
| | | |
| | | private boolean isFinished; |
| | | |
| | | private boolean isFirstLine; |
| | |
| | | { |
| | | isFinished = true; |
| | | } |
| | | |
| | | // Collect lines that would seem to indicate all is |
| | | // not well with the server |
| | | if (line.indexOf("severity=SEVERE_ERROR") != -1) { |
| | | if (errors == null) { |
| | | errors = new ArrayList<String>(); |
| | | } |
| | | errors.add(line); |
| | | } |
| | | |
| | | line = reader.readLine(); |
| | | } |
| | | } catch (IOException ioe) |
| | |
| | | return ex; |
| | | } |
| | | |
| | | public List<String> getErrors() { |
| | | return errors; |
| | | } |
| | | |
| | | /** |
| | | * Returns <CODE>true</CODE> if the server starting process finished |
| | | * (successfully or not) and <CODE>false</CODE> otherwise. |