public void Optimize(IDirectoryProvider provider) { IOptimizerStrategy optimizerStrategy = searchFactoryImplementor.GetOptimizerStrategy(provider); dpStatistics[provider].OptimizationForced = true; optimizerStrategy.OptimizationForced(); }
private void CleanUp(SearchException originalException) { // Release all readers and writers, then release locks SearchException raisedException = originalException; foreach (IndexReader reader in readers.Values) { try { reader.Close(); } catch (IOException e) { if (raisedException != null) { log.Error("Subsequent Exception while closing IndexReader", e); } else { raisedException = new SearchException("Exception while closing IndexReader", e); } } } readers.Clear(); // TODO release lock of all indexes that do not need optimization early // don't optimize if there is a failure if (raisedException == null) { foreach (IDirectoryProvider provider in lockedProviders) { var stats = dpStatistics[provider]; if (!stats.OptimizationForced) { IOptimizerStrategy optimizerStrategy = searchFactoryImplementor.GetOptimizerStrategy(provider); optimizerStrategy.AddTransaction(stats.Operations); try { optimizerStrategy.Optimize(this); } catch (SearchException e) { raisedException = new SearchException("Exception whilst optimizing directoryProvider: " + provider.Directory, e); break; // No point in continuing } } } } foreach (IndexWriter writer in writers.Values) { try { writer.Close(); } catch (IOException e) { if (raisedException != null) { log.Error("Subsequent Exception while closing IndexWriter", e); } else { raisedException = new SearchException("Exception while closing IndexWriter", e); } } } foreach (IDirectoryProvider provider in lockedProviders) { object syncLock = searchFactoryImplementor.GetLockableDirectoryProviders()[provider]; Monitor.Exit(syncLock); } writers.Clear(); lockedProviders.Clear(); dpStatistics.Clear(); if (raisedException != null) { throw raisedException; } }
public void SetStrategy(IOptimizerStrategy optimizer) { _optimizer = optimizer; }
public OptimizerContext(IOptimizerStrategy optimizer) { _optimizer = optimizer; }
public void AddOptimizerStrategy(IDirectoryProvider provider, IOptimizerStrategy optimizerStrategy) { dirProviderOptimizerStrategy[provider] = optimizerStrategy; }