Rebuild on startup working

Gets indexes rebuilding at startup, gets indexes rebuilding with published content which required some updates to the content service/repo to pass in a more robust filter when paging. Added more tasks to fix up more of the examine parts like the local storage sync which currently just throws exceptions.
This commit is contained in:
Shannon
2016-04-29 00:50:26 +02:00
parent 734f5f35dc
commit 209e9373d0
32 changed files with 270 additions and 132 deletions

View File

@@ -173,18 +173,10 @@ namespace Umbraco.Web
base.Complete(afterComplete);
//TODO: Fix this - we need to manually perform re-indexing on startup when necessary Examine lib no longer does this
////Ok, now that everything is complete we'll check if we've stored any references to index that need rebuilding and run them
//// (see the initialize method for notes) - we'll ensure we remove the event handler too in case examine manager doesn't actually
//// initialize during startup, in which case we want it to rebuild the indexes itself.
//ExamineManager.Instance.BuildingEmptyIndexOnStartup -= OnInstanceOnBuildingEmptyIndexOnStartup;
//if (IndexesToRebuild.Any())
//{
// foreach (var indexer in IndexesToRebuild)
// {
// indexer.RebuildIndex();
// }
//}
//rebuild any empty indexes
//TODO: Do we want to make this optional? otherwise the only way to disable this on startup
// would be to implement a custom WebBootManager and override this method
RebuildIndexes(true);
//Now ensure webapi is initialized after everything
GlobalConfiguration.Configuration.EnsureInitialized();
@@ -422,23 +414,6 @@ namespace Umbraco.Web
else
{
//We are using a custom action here so we can check the examine settings value first, we don't want to
// put that check into the CreateIndexesOnColdBoot method because developers may choose to use this
// method directly and they will be in charge of this check if they need it
Action rebuildIndexes = () =>
{
//TODO: Fix this - we need to manually perform re-indexing on startup when necessary Examine lib no longer does this
////If the developer has explicitly opted out of rebuilding indexes on startup then we
//// should adhere to that and not do it, this means that if they are load balancing things will be
//// out of sync if they are auto-scaling but there's not much we can do about that.
//if (ExamineSettings.Instance.RebuildOnAppStart == false) return;
foreach (var indexer in GetIndexesForColdBoot())
{
indexer.RebuildIndex();
}
};
ServerMessengerResolver.Current.SetServerMessenger(new BatchedDatabaseServerMessenger(
ApplicationContext,
true,
@@ -454,7 +429,7 @@ namespace Umbraco.Web
//rebuild indexes if the server is not synced
// NOTE: This will rebuild ALL indexes including the members, if developers want to target specific
// indexes then they can adjust this logic themselves.
rebuildIndexes
() => RebuildIndexes(false)
}
}));
}
@@ -518,7 +493,7 @@ namespace Umbraco.Web
SiteDomainHelperResolver.Current = new SiteDomainHelperResolver(Container, typeof(SiteDomainHelper));
// ain't that a bit dirty? YES
PublishedCache.XmlPublishedCache.PublishedContentCache.UnitTesting = _isForTesting;
PublishedContentCache.UnitTesting = _isForTesting;
ThumbnailProvidersResolver.Current = new ThumbnailProvidersResolver(
Container, ProfilingLogger.Logger,
@@ -557,44 +532,24 @@ namespace Umbraco.Web
GlobalConfiguration.Configuration.Services.Replace(typeof(IHttpControllerSelector),
new NamespaceHttpControllerSelector(GlobalConfiguration.Configuration));
}
/// <summary>
/// The method used to create indexes on a cold boot
/// </summary>
/// <remarks>
/// A cold boot is when the server determines it will not (or cannot) process instructions in the cache table and
/// will rebuild it's own caches itself.
/// </remarks>
public static IEnumerable<BaseIndexProvider> GetIndexesForColdBoot()
protected virtual void RebuildIndexes(bool onlyEmptyIndexes)
{
// NOTE: This is IMPORTANT! ... we don't want to rebuild any index that is already flagged to be re-indexed
// on startup based on our _indexesToRebuild variable and how Examine auto-rebuilds when indexes are empty.
// This callback is used above for the DatabaseServerMessenger startup options.
if (ApplicationContext.IsConfigured == false || ApplicationContext.DatabaseContext.IsDatabaseConfigured == false)
{
return;
}
// all indexes
IEnumerable<BaseIndexProvider> indexes = ExamineManager.Instance.IndexProviderCollection;
foreach (var indexer in ExamineManager.Instance.IndexProviders)
{
if (onlyEmptyIndexes == false || indexer.Value.IsIndexNew())
{
indexer.Value.RebuildIndex();
}
}
//TODO: Fix this - we need to manually perform re-indexing on startup when necessary Examine lib no longer does this
//// except those that are already flagged
//// and are processed in Complete()
//if (IndexesToRebuild.Any())
// indexes = indexes.Except(IndexesToRebuild);
// return
foreach (var index in indexes)
yield return index;
}
//TODO: Fix this - we need to manually perform re-indexing on startup when necessary Examine lib no longer does this
//private void OnInstanceOnBuildingEmptyIndexOnStartup(object sender, BuildingEmptyIndexOnStartupEventArgs args)
//{
// //store the indexer that needs rebuilding because it's empty for when the boot process
// // is complete and cancel this current event so the rebuild process doesn't start right now.
// args.Cancel = true;
// IndexesToRebuild.Add((BaseIndexProvider)args.Indexer);
//}
}
}