| | |
| | | * Copyright 2008-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2012-2015 ForgeRock AS |
| | | */ |
| | | |
| | | package org.opends.guitools.controlpanel.task; |
| | | |
| | | import static org.opends.messages.AdminToolMessages.*; |
| | |
| | | |
| | | import javax.swing.SwingUtilities; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.opends.guitools.controlpanel.datamodel.AbstractIndexDescriptor; |
| | | import org.opends.guitools.controlpanel.datamodel.BackendDescriptor; |
| | | import org.opends.guitools.controlpanel.datamodel.ControlPanelInfo; |
| | |
| | | import org.opends.guitools.controlpanel.datamodel.VLVIndexDescriptor; |
| | | import org.opends.guitools.controlpanel.ui.ProgressDialog; |
| | | import org.opends.guitools.controlpanel.util.Utilities; |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.opends.server.tools.RebuildIndex; |
| | | |
| | | /** |
| | | * The class that is used when a set of indexes must be rebuilt. |
| | | * |
| | | */ |
| | | public class RebuildIndexTask extends IndexTask |
| | | { |
| | |
| | | boolean canLaunch = true; |
| | | if (state == State.RUNNING && runningOnSameServer(taskToBeLaunched)) |
| | | { |
| | | // All the operations are incompatible if they apply to this |
| | | // backend. |
| | | Set<String> backends = |
| | | new TreeSet<String>(taskToBeLaunched.getBackends()); |
| | | // All the operations are incompatible if they apply to this backend. |
| | | Set<String> backends = new TreeSet<>(taskToBeLaunched.getBackends()); |
| | | backends.retainAll(getBackends()); |
| | | if (backends.size() > 0) |
| | | if (!backends.isEmpty()) |
| | | { |
| | | incompatibilityReasons.add(getIncompatibilityMessage(this, |
| | | taskToBeLaunched)); |
| | | incompatibilityReasons.add(getIncompatibilityMessage(this, taskToBeLaunched)); |
| | | canLaunch = false; |
| | | } |
| | | } |
| | |
| | | for (final String baseDN : baseDNs) |
| | | { |
| | | ArrayList<String> arguments = getCommandLineArguments(baseDN); |
| | | |
| | | String[] args = new String[arguments.size()]; |
| | | |
| | | arguments.toArray(args); |
| | | String[] args = arguments.toArray(new String[arguments.size()]); |
| | | |
| | | final List<String> displayArgs = getObfuscatedCommandLineArguments( |
| | | getCommandLineArguments(baseDN)); |
| | |
| | | |
| | | private boolean rebuildAll() |
| | | { |
| | | boolean rebuildAll = true; |
| | | Set<BackendDescriptor> backends = new HashSet<BackendDescriptor>(); |
| | | for (AbstractIndexDescriptor index : indexes) |
| | | { |
| | |
| | | } |
| | | for (BackendDescriptor backend : backends) |
| | | { |
| | | Set<AbstractIndexDescriptor> allIndexes = |
| | | new HashSet<AbstractIndexDescriptor>(); |
| | | Set<AbstractIndexDescriptor> allIndexes = new HashSet<>(); |
| | | allIndexes.addAll(backend.getIndexes()); |
| | | allIndexes.addAll(backend.getVLVIndexes()); |
| | | for (AbstractIndexDescriptor index : allIndexes) |
| | | { |
| | | if (!ignoreIndex(index)) |
| | | if (!ignoreIndex(index) |
| | | && !indexExists(index)) |
| | | { |
| | | boolean found = false; |
| | | for (AbstractIndexDescriptor indexToRebuild : indexes) |
| | | { |
| | | if (indexToRebuild.equals(index)) |
| | | { |
| | | found = true; |
| | | break; |
| | | } |
| | | } |
| | | if (!found) |
| | | { |
| | | rebuildAll = false; |
| | | break; |
| | | } |
| | | return false; |
| | | } |
| | | } |
| | | } |
| | | return rebuildAll; |
| | | return true; |
| | | } |
| | | |
| | | private boolean indexExists(AbstractIndexDescriptor index) |
| | | { |
| | | for (AbstractIndexDescriptor indexToRebuild : indexes) |
| | | { |
| | | if (indexToRebuild.equals(index)) |
| | | { |
| | | return true; |
| | | } |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | private boolean ignoreIndex(AbstractIndexDescriptor index) |
| | | { |
| | | boolean ignoreIndex = false; |
| | | if (index instanceof IndexDescriptor) |
| | | { |
| | | for (String name : INDEXES_NOT_TO_SPECIFY) |
| | | { |
| | | if (name.equalsIgnoreCase(index.getName())) |
| | | { |
| | | ignoreIndex = true; |
| | | break; |
| | | return true; |
| | | } |
| | | } |
| | | } |
| | | return ignoreIndex; |
| | | return false; |
| | | } |
| | | } |