Exemplo n.º 1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldConsultUnsatisfiedDependencyHandlerOnFailingDependencyClasses()
        public virtual void ShouldConsultUnsatisfiedDependencyHandlerOnFailingDependencyClasses()
        {
            // GIVEN
            KernelContext context = mock(typeof(KernelContext));
            KernelExtensionFailureStrategy handler = mock(typeof(KernelExtensionFailureStrategy));
            Dependencies dependencies = new Dependencies();               // that hasn't got anything.
            UninitializableKernelExtensionFactory extensionFactory = new UninitializableKernelExtensionFactory();
            GlobalKernelExtensions extensions = new GlobalKernelExtensions(context, iterable(extensionFactory), dependencies, handler);

            // WHEN
            LifeSupport life = new LifeSupport();

            life.Add(extensions);
            try
            {
                life.Start();

                // THEN
                verify(handler).handle(eq(extensionFactory), any(typeof(System.ArgumentException)));
            }
            finally
            {
                life.Shutdown();
            }
        }
Exemplo n.º 2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Override public org.neo4j.kernel.lifecycle.Lifecycle newInstance(@SuppressWarnings("unused") org.neo4j.kernel.impl.spi.KernelContext context, final Dependencies dependencies)
//JAVA TO C# CONVERTER WARNING: 'final' parameters are ignored unless the option to convert to C# 7.2 'in' parameters is selected:
        public override Lifecycle NewInstance(KernelContext context, Dependencies dependencies)
        {
            FileSystemAbstraction fileSystem = dependencies.FileSystem();
            Config       config       = dependencies.Config();
            Monitors     monitoring   = dependencies.Monitoring();
            LogService   logService   = dependencies.Logger();
            JobScheduler jobScheduler = dependencies.JobScheduler();

            return(new LifecycleAdapterAnonymousInnerClass(this, fileSystem, config, monitoring, logService, jobScheduler));
        }
Exemplo n.º 3
0
 public EventReporterBuilder(Config config, MetricRegistry registry, Log logger, KernelContext kernelContext, LifeSupport life, FileSystemAbstraction fileSystem, JobScheduler scheduler, ConnectorPortRegister portRegister)
 {
     this._config        = config;
     this._registry      = registry;
     this._logger        = logger;
     this._kernelContext = kernelContext;
     this._life          = life;
     this._fileSystem    = fileSystem;
     this._scheduler     = scheduler;
     this._portRegister  = portRegister;
 }
 private void LogDependencyException(KernelContext context, Logger dbmsLog, string message)
 {
     // We can for instance get unsatisfied dependency exceptions when the kernel extension is created as part of a consistency check run.
     // In such cases, we will be running in a TOOL context, and we ignore such exceptions since they are harmless.
     // Tools only read, and don't run queries, so there is no need for these advanced pieces of infrastructure.
     if (context.DatabaseInfo() != DatabaseInfo.TOOL)
     {
         // If we are not in a "TOOL" context, then we log this at the "DBMS" level, since it might be important for correctness.
         dbmsLog.Log(message);
     }
 }
Exemplo n.º 5
0
 public override IndexProvider NewInstance(KernelContext context, Dependencies dependencies)
 {
     lock (this)
     {
         if (_indexProvider == null)
         {
             IndexProvider indexProvider = (new NativeLuceneFusionIndexProviderFactory20()).newInstance(context, dependencies);
             this._indexProvider = new TrackingReadersIndexProvider(indexProvider);
         }
         return(_indexProvider);
     }
 }
        public override Lifecycle NewInstance(KernelContext context, Dependencies dependencies)
        {
            Config config    = dependencies.Config;
            bool   ephemeral = config.Get(GraphDatabaseSettings.ephemeral);
            FileSystemAbstraction fileSystemAbstraction = dependencies.FileSystem();
            DirectoryFactory      directoryFactory      = directoryFactory(ephemeral);
            OperationalMode       operationalMode       = context.DatabaseInfo().OperationalMode;
            JobScheduler          scheduler             = dependencies.Scheduler();

            IndexDirectoryStructure.Factory directoryStructureFactory = SubProviderDirectoryStructure(context.Directory());
            TokenHolders tokenHolders = dependencies.TokenHolders();
            Log          log          = dependencies.LogService.getInternalLog(typeof(FulltextIndexProvider));
            AuxiliaryTransactionStateManager auxiliaryTransactionStateManager;

            try
            {
                auxiliaryTransactionStateManager = dependencies.AuxiliaryTransactionStateManager();
            }
            catch (UnsatisfiedDependencyException e)
            {
                string message = "Fulltext indexes failed to register as transaction state providers. This means that, if queried, they will not be able to " +
                                 "uncommitted transactional changes into account. This is fine if the indexes are opened for non-transactional work, such as for " +
                                 "consistency checking. The reason given is: " + e.Message;
                LogDependencyException(context, log.ErrorLogger(), message);
                auxiliaryTransactionStateManager = new NullAuxiliaryTransactionStateManager();
            }

            FulltextIndexProvider provider = new FulltextIndexProvider(Descriptor, directoryStructureFactory, fileSystemAbstraction, config, tokenHolders, directoryFactory, operationalMode, scheduler, auxiliaryTransactionStateManager, log);

            string procedureRegistrationFailureMessage = "Failed to register the fulltext index procedures. The fulltext index provider will be loaded and " +
                                                         "updated like normal, but it might not be possible to query any fulltext indexes. The reason given is: ";

            try
            {
                dependencies.Procedures().registerComponent(typeof(FulltextAdapter), procContext => provider, true);
                dependencies.Procedures().registerProcedure(typeof(FulltextProcedures));
            }
            catch (KernelException e)
            {
                string message = procedureRegistrationFailureMessage + e.getUserMessage(new NonTransactionalTokenNameLookup(tokenHolders));
                // We use the 'warn' logger in this case, because it can occur due to multi-database shenanigans, or due to internal restarts in HA.
                // These scenarios are less serious, and will _probably_ not prevent FTS from working. Hence we only warn about this.
                LogDependencyException(context, log.WarnLogger(), message);
            }
            catch (UnsatisfiedDependencyException e)
            {
                string message = procedureRegistrationFailureMessage + e.Message;
                LogDependencyException(context, log.ErrorLogger(), message);
            }

            return(provider);
        }
Exemplo n.º 7
0
        internal MetricsExtension(KernelContext kernelContext, MetricsKernelExtensionFactory.Dependencies dependencies)
        {
            LogService            logService    = dependencies.LogService();
            Config                configuration = dependencies.Configuration();
            FileSystemAbstraction fileSystem    = dependencies.FileSystemAbstraction();
            JobScheduler          scheduler     = dependencies.Scheduler();

            _logger = logService.GetUserLog(this.GetType());

            MetricRegistry registry = new MetricRegistry();

            _reporter     = (new EventReporterBuilder(configuration, registry, _logger, kernelContext, _life, fileSystem, scheduler, dependencies.PortRegister())).build();
            _metricsBuilt = (new Neo4jMetricsBuilder(registry, _reporter, configuration, logService, kernelContext, dependencies, _life)).build();
        }
Exemplo n.º 8
0
        public override IndexProvider NewInstance(KernelContext context, DEPENDENCIES dependencies)
        {
            PageCache             pageCache   = dependencies.PageCache();
            File                  databaseDir = context.Directory();
            FileSystemAbstraction fs          = dependencies.FileSystem();
            Log      log      = dependencies.LogService.InternalLogProvider.getLog(LoggingClass());
            Monitors monitors = dependencies.Monitors();

            monitors.AddMonitorListener(new LoggingMonitor(log), DescriptorString());
            IndexProvider.Monitor monitor   = monitors.NewMonitor(typeof(IndexProvider.Monitor), DescriptorString());
            Config          config          = dependencies.Config;
            OperationalMode operationalMode = context.DatabaseInfo().OperationalMode;
            RecoveryCleanupWorkCollector recoveryCleanupWorkCollector = dependencies.RecoveryCleanupWorkCollector();

            return(InternalCreate(pageCache, databaseDir, fs, monitor, config, operationalMode, recoveryCleanupWorkCollector));
        }
Exemplo n.º 9
0
        public override Lifecycle NewInstance(KernelContext context, Dependencies deps)
        {
            JobScheduler scheduler = deps.JobScheduler();
            DatabaseAvailabilityGuard databaseAvailabilityGuard = deps.AvailabilityGuard();
            PageCache             pageCache         = deps.PageCache();
            FileSystemAbstraction fs                = deps.FileSystemAbstraction();
            LogService            logService        = deps.LogService();
            NeoStoreDataSource    dataSourceManager = deps.DataSource;
            Log      log      = logService.GetInternalLog(typeof(PageCacheWarmer));
            Monitors monitors = deps.Monitors();
            PageCacheWarmerMonitor monitor = monitors.NewMonitor(typeof(PageCacheWarmerMonitor));

            monitors.AddMonitorListener(new PageCacheWarmerLoggingMonitor(log));
            Config config = deps.Config();

            return(new PageCacheWarmerKernelExtension(scheduler, databaseAvailabilityGuard, pageCache, fs, dataSourceManager, log, monitor, config));
        }
 public override Lifecycle NewInstance(KernelContext context, UnproxyableDependencies dependencies)
 {
     return(null);
 }
Exemplo n.º 11
0
 /// <summary>
 /// Create a new instance of this kernel extension.
 /// </summary>
 /// <param name="context"> the context the extension should be created for </param>
 /// <param name="dependencies"> deprecated </param>
 /// <returns> the <seealso cref="Lifecycle"/> for the extension </returns>
 public abstract Lifecycle NewInstance(KernelContext context, DEPENDENCIES dependencies);
Exemplo n.º 12
0
 public override Lifecycle NewInstance(KernelContext context, Dependencies dependencies)
 {
     dependencies.Procedures().registerComponent(typeof(MyCoreAPI), ctx => new MyCoreAPI(dependencies.GraphDatabaseAPI, dependencies.TxBridge(), dependencies.LogService().getUserLog(typeof(MyCoreAPI))), true);
     return(new LifecycleAdapter());
 }
Exemplo n.º 13
0
 public override Lifecycle NewInstance(KernelContext context, Dependencies dependencies)
 {
     return(new MetricsExtension(context, dependencies));
 }
Exemplo n.º 14
0
 public override Lifecycle NewInstance(KernelContext context, TestingDependencies dependencies)
 {
     return(new TestingExtension(dependencies.JobScheduler()));
 }
Exemplo n.º 15
0
 public override Lifecycle NewInstance(KernelContext context, Dependencies dependencies)
 {
     return(new LuceneKernelExtension(context.Directory(), dependencies.Config, dependencies.getIndexStore, dependencies.FileSystem(), dependencies.IndexProviders, context.DatabaseInfo().OperationalMode));
 }
Exemplo n.º 16
0
 public override Lifecycle NewInstance(KernelContext context, Dependencies dependencies)
 {
     dependencies.Procedures().registerComponent(typeof(SomeService), ctx => new SomeService(), true);
     return(new LifecycleAdapter());
 }
Exemplo n.º 17
0
        public override Lifecycle NewInstance(KernelContext context, Dependencies dependencies)
        {
            IndexProviders indexProviders = dependencies.IndexProviders;

            return(new Extension(indexProviders));
        }
Exemplo n.º 18
0
        public override Lifecycle NewInstance(KernelContext kernelContext, UdcKernelExtensionFactory.Dependencies dependencies)
        {
            Config config = dependencies.Config();

            return(new UdcKernelExtension(config, dependencies.DataSourceManager(), dependencies.UsageData(), new Timer("Neo4j UDC Timer", true)));
        }