| | |
| | | * |
| | | * |
| | | * Copyright 2008-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2012 ForgeRock AS |
| | | * Portions Copyright 2011-2013 ForgeRock AS |
| | | */ |
| | | |
| | | package org.opends.quicksetup.util; |
| | |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Map; |
| | | import java.util.List; |
| | | import java.util.logging.Level; |
| | | import java.util.logging.Logger; |
| | | import java.io.BufferedReader; |
| | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | // do nothing |
| | | } |
| | | stopped = !installation.getStatus().isServerRunning(); |
| | | LOG.log(Level.INFO, |
| | |
| | | /** |
| | | * 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. |
| | | *@throws org.opends.quicksetup.ApplicationException if something goes wrong. |
| | | */ |
| | | public OperationOutput startServer() throws ApplicationException { |
| | | return startServer(true, false); |
| | | public void startServer() throws ApplicationException { |
| | | 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) |
| | | public void startServer(boolean suppressOutput) |
| | | throws ApplicationException |
| | | { |
| | | return startServer(true, suppressOutput); |
| | | startServer(true, suppressOutput); |
| | | } |
| | | |
| | | /** |
| | |
| | | * connect to the server after starting to verify that it is listening. |
| | | * @param suppressOutput 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. |
| | | */ |
| | | private OperationOutput startServer(boolean verify, boolean suppressOutput) |
| | | private void startServer(boolean verify, boolean suppressOutput) |
| | | throws ApplicationException |
| | | { |
| | | OperationOutput output = new OperationOutput(); |
| | | |
| | | if (suppressOutput && !StandardOutputSuppressor.isSuppressed()) { |
| | | StandardOutputSuppressor.suppress(); |
| | | } |
| | |
| | | LOG.log(Level.WARNING, "Started ID could not be found"); |
| | | } |
| | | |
| | | // Collect any messages found in the output |
| | | List<Message> errors = errReader.getMessages(); |
| | | if (errors != null) { |
| | | for(Message error : errors) { |
| | | output.addErrorMessage(error); |
| | | } |
| | | } |
| | | List<Message> messages = outputReader.getMessages(); |
| | | if (messages != null) { |
| | | for (Message msg : messages) { |
| | | |
| | | // NOTE: this may not be the best place to drop these. |
| | | // However upon startup the server seems to log all messages, |
| | | // regardless of whether or not they signal an error condition, |
| | | // to its error log. |
| | | |
| | | output.addErrorMessage(msg); |
| | | } |
| | | } |
| | | |
| | | // Check if something wrong occurred reading the starting of the server |
| | | ApplicationException ex = errReader.getException(); |
| | | if (ex == null) |
| | |
| | | // 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) |
| | | { |
| | | /* |
| | |
| | | } |
| | | catch (Throwable t) |
| | | { |
| | | // do nothing |
| | | } |
| | | } |
| | | } |
| | |
| | | } |
| | | catch (Throwable t) |
| | | { |
| | | // do nothing |
| | | } |
| | | } |
| | | } |
| | |
| | | application.setNotifyListeners(true); |
| | | } |
| | | } |
| | | return output; |
| | | } |
| | | |
| | | /** |
| | |
| | | { |
| | | private ApplicationException ex; |
| | | |
| | | private List<Message> messages = new ArrayList<Message>(); |
| | | |
| | | private boolean isFinished; |
| | | |
| | | private boolean startedIdFound; |
| | |
| | | isFirstLine = false; |
| | | } |
| | | LOG.log(Level.INFO, "server: " + line); |
| | | if (line.toLowerCase().indexOf("=" + startedId) != -1) |
| | | if (line.toLowerCase().contains("=" + startedId)) |
| | | { |
| | | isFinished = true; |
| | | startedIdFound = true; |
| | | } |
| | | |
| | | messages.add(Message.raw(line)); |
| | | |
| | | line = reader.readLine(); |
| | | } |
| | | } catch (Throwable t) |
| | |
| | | return ex; |
| | | } |
| | | |
| | | public List<Message> getMessages() { |
| | | return messages; |
| | | } |
| | | |
| | | /** |
| | | * Returns <CODE>true</CODE> if the server starting process finished |
| | | * (successfully or not) and <CODE>false</CODE> otherwise. |