RebuildIndex.java revision 4abbc080225761b99a4086c0d26ba1e6cd57517f
/*
* 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
* 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
*
*
* Copyright 2006-2009 Sun Microsystems, Inc.
*/
/**
* This program provides a utility to rebuild the contents of the indexes
* of a Directory Server backend. This will be a process that is
* intended to run separate from Directory Server and not internally within the
* server process (e.g., via the tasks interface).
*/
public class RebuildIndex extends TaskTool
{
/**
* Processes the command-line arguments and invokes the rebuild process.
*
* @param args The command-line arguments provided to this program.
*/
{
if(retCode != 0)
{
}
}
/**
* Processes the command-line arguments and invokes the rebuild process.
*
* @param args The command-line arguments provided to this
* program.
* @param initializeServer Indicates whether to initialize the server.
* @param outStream The output stream to use for standard output, or
* {@code null} if standard output is not needed.
* @param errStream The output stream to use for standard error, or
* {@code null} if standard error is not needed.
*
* @return The error code.
*/
{
}
{
}
else
{
}
{
}
else
{
}
// Define the command-line arguments that may be used with this program.
// Create the command-line argument parser for use with this program.
createArgParser("org.opends.server.tools.RebuildIndex",
// Initialize all the command-line argument types and register them with the
// parser.
try
{
true, INFO_CONFIGCLASS_PLACEHOLDER.get(),
configClass.setHidden(true);
null,
configFile.setHidden(true);
false, true, true,
false, true, INFO_REBUILDINDEX_TEMP_DIR_PLACEHOLDER.get(),
"import-tmp",
}
catch (ArgumentException ae)
{
return 1;
}
// Parse the command-line arguments provided to this program.
try
{
}
catch (ArgumentException ae)
{
return 1;
}
// If we should just display usage or version information,
// then print it and exit.
if (argParser.usageOrVersionDisplayed())
{
return 0;
}
// If no arguments were provided, then display usage information and exit.
if (numArgs == 0)
{
return 1;
}
{
return 1;
}
{
return 1;
}
}
/**
* {@inheritDoc}
*/
protected int processLocal(boolean initializeServer,
PrintStream err) {
// Perform the initial bootstrap of the Directory Server and process the
// configuration.
if (initializeServer)
{
try
{
}
catch (Exception e)
{
getExceptionMessage(e));
return 1;
}
try
{
configFile.getValue());
}
catch (InitializationException ie)
{
return 1;
}
catch (Exception e)
{
return 1;
}
// Initialize the Directory Server schema elements.
try
{
}
catch (ConfigException ce)
{
return 1;
}
catch (InitializationException ie)
{
return 1;
}
catch (Exception e)
{
return 1;
}
// Initialize the Directory Server core configuration.
try
{
}
catch (ConfigException ce)
{
ce.getMessage());
return 1;
}
catch (InitializationException ie)
{
ie.getMessage());
return 1;
}
catch (Exception e)
{
getExceptionMessage(e));
return 1;
}
// Initialize the Directory Server crypto manager.
try
{
}
catch (ConfigException ce)
{
ce.getMessage());
return 1;
}
catch (InitializationException ie)
{
ie.getMessage());
return 1;
}
catch (Exception e)
{
getExceptionMessage(e));
return 1;
}
try
{
}
catch(Exception e)
{
}
}
// Decode the base DN provided by the user.
try
{
}
catch (DirectoryException de)
{
return 1;
}
catch (Exception e)
{
return 1;
}
// Get information about the backends defined in the server.
DN[] baseDNArray;
for (int i=0; i < numBackends; i++)
{
{
{
{
backend = b;
}
else
{
return 1;
}
break;
}
}
}
{
return 1;
}
if (!(backend instanceof BackendImpl))
{
return 1;
}
// Initialize the rebuild configuration.
{
}
// Acquire an exclusive lock for the backend.
//TODO: Find a way to do this with the server online.
try
{
{
return 1;
}
}
catch (Exception e)
{
return 1;
}
// Launch the rebuild process.
int returnCode = 0;
try
{
}
catch (Exception e)
{
returnCode = 1;
}
finally
{
// Release the shared lock on the backend.
try
{
{
}
}
catch (Exception e)
{
}
}
return returnCode;
}
/**
* {@inheritDoc}
*/
// NYI.
return null;
}
/**
* {@inheritDoc}
*/
{
//
// Required attributes
//
{
}
tmpDirectory.getDefaultValue())) {
}
rebuildAll.getDefaultValue())) {
}
}
/**
* {@inheritDoc}
*/
public String getTaskObjectclass() {
return "ds-task-rebuild";
}
/**
* {@inheritDoc}
*/
public Class getTaskClass() {
return RebuildTask.class;
}
}