| | |
| | | import static org.opends.server.messages.ToolMessages.*; |
| | | import org.opends.server.config.ConfigException; |
| | | import org.opends.server.config.ConfigEntry; |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.loggers.Error.logError; |
| | | import org.opends.server.loggers.StartupErrorLogger; |
| | | import static org.opends.server.loggers.ErrorLogger.logError; |
| | | import org.opends.server.loggers.ThreadFilterTextErrorLogPublisher; |
| | | import org.opends.server.loggers.TextWriter; |
| | | import org.opends.server.loggers.ErrorLogger; |
| | | import static org.opends.server.messages.MessageHandler.getMessage; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | import org.opends.server.util.StaticUtils; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.core.CoreConfigManager; |
| | | import org.opends.server.core.LockFileManager; |
| | |
| | | */ |
| | | public class RebuildIndex |
| | | { |
| | | private static DN publisherDN = null; |
| | | |
| | | /** |
| | | * Processes the command-line arguments and invokes the rebuild process. |
| | | * |
| | |
| | | */ |
| | | public static void main(String[] args) |
| | | { |
| | | int retCode = mainRebuildIndex(args); |
| | | |
| | | if(publisherDN != null) |
| | | { |
| | | ErrorLogger.removeErrorLogPublisher(publisherDN); |
| | | } |
| | | |
| | | if(retCode != 0) |
| | | { |
| | | System.exit(retCode); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Processes the command-line arguments and invokes the rebuild process. |
| | | * |
| | | * @param args The command-line arguments provided to this program. |
| | | * |
| | | * @return The error code. |
| | | */ |
| | | public static int mainRebuildIndex(String[] args) |
| | | { |
| | | // Define the command-line arguments that may be used with this program. |
| | | StringArgument configClass = null; |
| | | StringArgument configFile = null; |
| | |
| | | String message = getMessage(msgID, ae.getMessage()); |
| | | |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | System.exit(1); |
| | | return 1; |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | System.err.println(argParser.getUsage()); |
| | | System.exit(1); |
| | | return 1; |
| | | } |
| | | |
| | | |
| | | // If we should just display usage information, then print it and exit. |
| | | if (argParser.usageDisplayed()) |
| | | { |
| | | System.exit(0); |
| | | return 0; |
| | | } |
| | | |
| | | |
| | |
| | | if (numArgs == 0) |
| | | { |
| | | System.out.println(argParser.getUsage()); |
| | | System.exit(1); |
| | | return 1; |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | System.out.println(argParser.getUsage()); |
| | | System.exit(1); |
| | | return 1; |
| | | } |
| | | |
| | | // Perform the initial bootstrap of the Directory Server and process the |
| | |
| | | int msgID = MSGID_SERVER_BOOTSTRAP_ERROR; |
| | | String message = getMessage(msgID, getExceptionMessage(e)); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | System.exit(1); |
| | | return 1; |
| | | } |
| | | |
| | | try |
| | |
| | | int msgID = MSGID_CANNOT_LOAD_CONFIG; |
| | | String message = getMessage(msgID, ie.getMessage()); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | System.exit(1); |
| | | return 1; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | int msgID = MSGID_CANNOT_LOAD_CONFIG; |
| | | String message = getMessage(msgID, getExceptionMessage(e)); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | System.exit(1); |
| | | return 1; |
| | | } |
| | | |
| | | |
| | |
| | | int msgID = MSGID_CANNOT_LOAD_SCHEMA; |
| | | String message = getMessage(msgID, ce.getMessage()); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | System.exit(1); |
| | | return 1; |
| | | } |
| | | catch (InitializationException ie) |
| | | { |
| | | int msgID = MSGID_CANNOT_LOAD_SCHEMA; |
| | | String message = getMessage(msgID, ie.getMessage()); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | System.exit(1); |
| | | return 1; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | int msgID = MSGID_CANNOT_LOAD_SCHEMA; |
| | | String message = getMessage(msgID, getExceptionMessage(e)); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | System.exit(1); |
| | | return 1; |
| | | } |
| | | |
| | | |
| | |
| | | int msgID = MSGID_CANNOT_INITIALIZE_CORE_CONFIG; |
| | | String message = getMessage(msgID, ce.getMessage()); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | System.exit(1); |
| | | return 1; |
| | | } |
| | | catch (InitializationException ie) |
| | | { |
| | | int msgID = MSGID_CANNOT_INITIALIZE_CORE_CONFIG; |
| | | String message = getMessage(msgID, ie.getMessage()); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | System.exit(1); |
| | | return 1; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | int msgID = MSGID_CANNOT_INITIALIZE_CORE_CONFIG; |
| | | String message = getMessage(msgID, getExceptionMessage(e)); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | System.exit(1); |
| | | return 1; |
| | | } |
| | | |
| | | |
| | |
| | | int msgID = MSGID_CANNOT_INITIALIZE_CRYPTO_MANAGER; |
| | | String message = getMessage(msgID, ce.getMessage()); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | System.exit(1); |
| | | return 1; |
| | | } |
| | | catch (InitializationException ie) |
| | | { |
| | | int msgID = MSGID_CANNOT_INITIALIZE_CRYPTO_MANAGER; |
| | | String message = getMessage(msgID, ie.getMessage()); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | System.exit(1); |
| | | return 1; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | int msgID = MSGID_CANNOT_INITIALIZE_CRYPTO_MANAGER; |
| | | String message = getMessage(msgID, getExceptionMessage(e)); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | System.exit(1); |
| | | return 1; |
| | | } |
| | | |
| | | |
| | | |
| | | // FIXME -- Install a custom logger to capture information about the state |
| | | // of the verify process. |
| | | StartupErrorLogger startupLogger = new StartupErrorLogger(); |
| | | startupLogger.initializeErrorLogger(null); |
| | | addErrorLogger(startupLogger); |
| | | try |
| | | { |
| | | publisherDN = DN.decode("cn=Custom Logger for RebuildIndex"); |
| | | ThreadFilterTextErrorLogPublisher publisher = |
| | | new ThreadFilterTextErrorLogPublisher(Thread.currentThread(), |
| | | new TextWriter.STDOUT()); |
| | | ErrorLogger.addErrorLogPublisher(publisherDN, publisher); |
| | | |
| | | } |
| | | catch(Exception e) |
| | | { |
| | | System.err.println("Error installing the custom error logger: " + |
| | | StaticUtils.stackTraceToSingleLineString(e)); |
| | | } |
| | | |
| | | // Decode the base DN provided by the user. |
| | | DN rebuildBaseDN = null; |
| | |
| | | de.getErrorMessage()); |
| | | logError(ErrorLogCategory.BACKEND, ErrorLogSeverity.SEVERE_ERROR, message, |
| | | msgID); |
| | | System.exit(1); |
| | | return 1; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | |
| | | getExceptionMessage(e)); |
| | | logError(ErrorLogCategory.BACKEND, ErrorLogSeverity.SEVERE_ERROR, message, |
| | | msgID); |
| | | System.exit(1); |
| | | return 1; |
| | | } |
| | | |
| | | // Get information about the backends defined in the server. |
| | |
| | | String message = getMessage(msgID, baseDNString.getValue()); |
| | | logError(ErrorLogCategory.BACKEND, ErrorLogSeverity.SEVERE_ERROR, |
| | | message, msgID); |
| | | System.exit(1); |
| | | return 1; |
| | | } |
| | | break; |
| | | } |
| | |
| | | String message = getMessage(msgID, baseDNString.getValue()); |
| | | logError(ErrorLogCategory.BACKEND, ErrorLogSeverity.SEVERE_ERROR, message, |
| | | msgID); |
| | | System.exit(1); |
| | | return 1; |
| | | } |
| | | |
| | | if (!(backend instanceof BackendImpl)) |
| | |
| | | String message = getMessage(msgID); |
| | | logError(ErrorLogCategory.BACKEND, ErrorLogSeverity.SEVERE_ERROR, message, |
| | | msgID); |
| | | System.exit(1); |
| | | return 1; |
| | | } |
| | | |
| | | // Initialize the rebuild configuration. |
| | |
| | | String.valueOf(failureReason)); |
| | | logError(ErrorLogCategory.BACKEND, ErrorLogSeverity.SEVERE_ERROR, |
| | | message, msgID); |
| | | return; |
| | | return 1; |
| | | } |
| | | } |
| | | catch (Exception e) |
| | |
| | | getExceptionMessage(e)); |
| | | logError(ErrorLogCategory.BACKEND, ErrorLogSeverity.SEVERE_ERROR, |
| | | message, msgID); |
| | | return; |
| | | return 1; |
| | | } |
| | | |
| | | // Launch the rebuild process. |
| | |
| | | message, msgID); |
| | | } |
| | | } |
| | | |
| | | return 0; |
| | | } |
| | | } |