public override void Compose(Composition composition)
        {
            base.Compose(composition);

            // populators are not a collection: one cannot remove ours, and can only add more
            // the container can inject IEnumerable<IIndexPopulator> and get them all
            composition.Register <MemberIndexPopulator>(Lifetime.Singleton);
            composition.Register <ContentIndexPopulator>(Lifetime.Singleton);
            composition.Register <PublishedContentIndexPopulator>(Lifetime.Singleton);
            composition.Register <MediaIndexPopulator>(Lifetime.Singleton);

            composition.Register <IndexRebuilder>(Lifetime.Singleton);
            composition.RegisterUnique <IUmbracoIndexesCreator, UmbracoIndexesCreator>();
            composition.RegisterUnique <IPublishedContentValueSetBuilder>(factory =>
                                                                          new ContentValueSetBuilder(
                                                                              factory.GetInstance <PropertyEditorCollection>(),
                                                                              factory.GetInstance <UrlSegmentProviderCollection>(),
                                                                              factory.GetInstance <IUserService>(),
                                                                              true));
            composition.RegisterUnique <IContentValueSetBuilder>(factory =>
                                                                 new ContentValueSetBuilder(
                                                                     factory.GetInstance <PropertyEditorCollection>(),
                                                                     factory.GetInstance <UrlSegmentProviderCollection>(),
                                                                     factory.GetInstance <IUserService>(),
                                                                     false));
            composition.RegisterUnique <IValueSetBuilder <IMedia>, MediaValueSetBuilder>();
            composition.RegisterUnique <IValueSetBuilder <IMember>, MemberValueSetBuilder>();

            //We want to manage Examine's AppDomain shutdown sequence ourselves so first we'll disable Examine's default behavior
            //and then we'll use MainDom to control Examine's shutdown - this MUST be done in Compose ie before ExamineManager
            //is instantiated, as the value is used during instantiation
            ExamineManager.DisableDefaultHostingEnvironmentRegistration();
        }
        /// <summary>
        /// Called during the initialize operation of the boot manager process
        /// </summary>
        public void Initialize()
        {
            //We want to manage Examine's appdomain shutdown sequence ourselves so first we'll disable Examine's default behavior
            //and then we'll use MainDom to control Examine's shutdown
            ExamineManager.DisableDefaultHostingEnvironmentRegistration();

            //we want to tell examine to use a different fs lock instead of the default NativeFSFileLock which could cause problems if the appdomain
            //terminates and in some rare cases would only allow unlocking of the file if IIS is forcefully terminated. Instead we'll rely on the simplefslock
            //which simply checks the existence of the lock file
            DirectoryTracker.DefaultLockFactory = d =>
            {
                var simpleFsLockFactory = new NoPrefixSimpleFsLockFactory(d);
                return(simpleFsLockFactory);
            };

            //This is basically a hack for this item: http://issues.umbraco.org/issue/U4-5976
            // when Examine initializes it will try to rebuild if the indexes are empty, however in many cases not all of Examine's
            // event handlers will be assigned during bootup when the rebuilding starts which is a problem. So with the examine 0.1.58.2941 build
            // it has an event we can subscribe to in order to cancel this rebuilding process, but what we'll do is cancel it and postpone the rebuilding until the
            // boot process has completed. It's a hack but it works.
            ExamineManager.Instance.BuildingEmptyIndexOnStartup += OnInstanceOnBuildingEmptyIndexOnStartup;

            //let's deal with shutting down Examine with MainDom
            var examineShutdownRegistered = _appCtx.MainDom.Register(() =>
            {
                using (_profilingLogger.TraceDuration <ExamineStartup>("Examine shutting down"))
                {
                    //Due to the way Examine's own IRegisteredObject works, we'll first run it with immediate=false and then true so that
                    //it's correct subroutines are executed (otherwise we'd have to run this logic manually ourselves)
                    ExamineManager.Instance.Stop(false);
                    ExamineManager.Instance.Stop(true);
                }
            });

            if (examineShutdownRegistered)
            {
                _profilingLogger.Logger.Debug <ExamineStartup>("Examine shutdown registered with MainDom");
            }
            else
            {
                _profilingLogger.Logger.Debug <ExamineStartup>("Examine shutdown not registered, this appdomain is not the MainDom");

                //if we could not register the shutdown examine ourselves, it means we are not maindom! in this case all of examine should be disabled
                //from indexing anything on startup!!
                _disableExamineIndexing = true;
                Suspendable.ExamineEvents.SuspendIndexers();
            }
        }
示例#3
0
        public override void Compose(Composition composition)
        {
            if (ConfigurationManager.AppSettings["examine:ElasticSearch.Debug"] == "True")
            {
                if (ElasticSearchConfig.DebugConnectionConfiguration == null)
                {
                    ElasticSearchConfig.DebugConnectionConfiguration = new ElasticSearchConfig();
                }
            }

            base.Compose(composition);
            //composition.Register(typeof(ElasticIndexCreator));
            composition.Components().Remove <ExamineComponent>();
            composition.Register <Novicell.Examine.ElasticSearch.Populators.ContentIndexPopulator>(Lifetime.Singleton);

            composition.Register <Novicell.Examine.ElasticSearch.Populators.PublishedContentIndexPopulator>(
                Lifetime.Singleton);

            composition.Register <Novicell.Examine.ElasticSearch.Populators.MediaIndexPopulator>(Lifetime.Singleton);
            // the container can inject IEnumerable<IIndexPopulator> and get them all
            composition.Register <Novicell.Examine.ElasticSearch.Populators.MemberIndexPopulator>(Lifetime.Singleton);

            composition.Register <IndexRebuilder>(Lifetime.Singleton);

            //   composition.RegisterUnique<IUmbracoIndexesCreator, UmbracoIndexesCreator>();
            composition.RegisterUnique <ElasticIndexCreator>();

            composition.RegisterUnique <IPublishedContentValueSetBuilder>(factory =>
                                                                          new ContentValueSetBuilder(
                                                                              factory.GetInstance <PropertyEditorCollection>(),
                                                                              factory.GetInstance <UrlSegmentProviderCollection>(),
                                                                              factory.GetInstance <IUserService>(),
                                                                              true));
            composition.RegisterUnique <IContentValueSetBuilder>(factory =>
                                                                 new ContentValueSetBuilder(
                                                                     factory.GetInstance <PropertyEditorCollection>(),
                                                                     factory.GetInstance <UrlSegmentProviderCollection>(),
                                                                     factory.GetInstance <IUserService>(),
                                                                     false));
            composition.RegisterUnique <IValueSetBuilder <IMedia>, MediaValueSetBuilder>();
            composition.RegisterUnique <IValueSetBuilder <IMember>, MemberValueSetBuilder>();


            //We want to manage Examine's AppDomain shutdown sequence ourselves so first we'll disable Examine's default behavior
            //and then we'll use MainDom to control Examine's shutdown - this MUST be done in Compose ie before ExamineManager
            //is instantiated, as the value is used during instantiation
            ExamineManager.DisableDefaultHostingEnvironmentRegistration();
        }