Exemple #1
0
        /// <summary>
        /// Instantiate a graph database given configuration, dependencies, and a custom implementation of {@link org
        /// .neo4j.kernel.impl.factory.GraphDatabaseFacade}.
        /// </summary>
        /// <param name="storeDir"> the directory where the Neo4j data store is located </param>
        /// <param name="config"> configuration </param>
        /// <param name="dependencies"> the dependencies required to construct the <seealso cref="GraphDatabaseFacade"/> </param>
        /// <param name="graphDatabaseFacade"> the already created facade which needs initialisation </param>
        /// <returns> the initialised <seealso cref="GraphDatabaseFacade"/> </returns>
//JAVA TO C# CONVERTER WARNING: 'final' parameters are ignored unless the option to convert to C# 7.2 'in' parameters is selected:
//ORIGINAL LINE: public org.neo4j.kernel.impl.factory.GraphDatabaseFacade initFacade(java.io.File storeDir, org.neo4j.kernel.configuration.Config config, final Dependencies dependencies, final org.neo4j.kernel.impl.factory.GraphDatabaseFacade graphDatabaseFacade)
        public virtual GraphDatabaseFacade InitFacade(File storeDir, Config config, Dependencies dependencies, GraphDatabaseFacade graphDatabaseFacade)
        {
            PlatformModule        platform = CreatePlatform(storeDir, config, dependencies);
            AbstractEditionModule edition  = _editionFactory.apply(platform);

            dependencies.AvailabilityGuardInstaller()(edition.GetGlobalAvailabilityGuard(platform.Clock, platform.Logging, platform.Config));

            platform.Life.add(new VmPauseMonitorComponent(config, platform.Logging.getInternalLog(typeof(VmPauseMonitorComponent)), platform.JobScheduler));

            Procedures procedures = SetupProcedures(platform, edition, graphDatabaseFacade);

            platform.Dependencies.satisfyDependency(new NonTransactionalDbmsOperations(procedures));

            Logger          msgLog          = platform.Logging.getInternalLog(this.GetType()).infoLogger();
            DatabaseManager databaseManager = edition.CreateDatabaseManager(graphDatabaseFacade, platform, edition, procedures, msgLog);

            platform.Life.add(databaseManager);
            platform.Dependencies.satisfyDependency(databaseManager);

            DataCollectorManager dataCollectorManager = new DataCollectorManager(platform.DataSourceManager, platform.JobScheduler, procedures, platform.Monitors, platform.Config);

            platform.Life.add(dataCollectorManager);

            edition.CreateSecurityModule(platform, procedures);
            SecurityProvider securityProvider = edition.SecurityProvider;

            platform.Dependencies.satisfyDependencies(securityProvider.AuthManager());
            platform.Dependencies.satisfyDependencies(securityProvider.UserManagerSupplier());

            platform.Life.add(platform.GlobalKernelExtensions);
            platform.Life.add(CreateBoltServer(platform, edition, databaseManager));
            platform.Dependencies.satisfyDependency(edition.GlobalTransactionCounter());
            platform.Life.add(new PublishPageCacheTracerMetricsAfterStart(platform.Tracers.pageCursorTracerSupplier));
            platform.Life.add(new StartupWaiter(edition.GetGlobalAvailabilityGuard(platform.Clock, platform.Logging, platform.Config), edition.TransactionStartTimeout));
            platform.Dependencies.satisfyDependency(edition.SchemaWriteGuard);
            platform.Life.Last = platform.EventHandlers;

            edition.CreateDatabases(databaseManager, config);

            string activeDatabase = config.Get(GraphDatabaseSettings.active_database);
            GraphDatabaseFacade databaseFacade = databaseManager.GetDatabaseFacade(activeDatabase).orElseThrow(() => new System.InvalidOperationException(string.Format("Database {0} not found. Please check the logs for startup errors.", activeDatabase)));

            Exception error = null;

            try
            {
                platform.Life.start();
            }
//JAVA TO C# CONVERTER WARNING: 'final' catch parameters are not available in C#:
//ORIGINAL LINE: catch (final Throwable throwable)
            catch (Exception throwable)
            {
//JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getName method:
                error = new Exception("Error starting " + this.GetType().FullName + ", " + platform.StoreLayout.storeDirectory(), throwable);
            }
            finally
            {
                if (error != null)
                {
                    try
                    {
                        graphDatabaseFacade.Shutdown();
                    }
                    catch (Exception shutdownError)
                    {
                        error.addSuppressed(shutdownError);
                    }
                }
            }

            if (error != null)
            {
                msgLog.Log("Failed to start database", error);
                throw error;
            }

            return(databaseFacade);
        }