Ejemplo n.º 1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void pruningStrategyShouldBeDynamic() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void PruningStrategyShouldBeDynamic()
        {
            CheckPointer          checkPointer = GetInstanceFromDb(typeof(CheckPointer));
            Config                config       = GetInstanceFromDb(typeof(Config));
            FileSystemAbstraction fs           = GetInstanceFromDb(typeof(FileSystemAbstraction));

            LogFiles logFiles = LogFilesBuilder.builder(Db.databaseLayout(), fs).withLogVersionRepository(new SimpleLogVersionRepository()).withLastCommittedTransactionIdSupplier(() => 1).withTransactionIdStore(new SimpleTransactionIdStore()).build();

            // Force transaction log rotation
            WriteTransactionsAndRotateTwice();

            // Checkpoint to make sure strategy is evaluated
            checkPointer.ForceCheckPoint(_triggerInfo);

            // Make sure file is still there since we have disable pruning
            assertThat(CountTransactionLogs(logFiles), @is(3));

            // Change pruning to true
            config.UpdateDynamicSetting(keep_logical_logs.name(), "false", "test");

            // Checkpoint to make sure strategy is evaluated
            checkPointer.ForceCheckPoint(_triggerInfo);

            // Make sure file is removed
            assertThat(CountTransactionLogs(logFiles), @is(2));
        }
Ejemplo n.º 2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test(timeout = TEST_TIMEOUT) public void notifyWhenWholeStoreDirectoryRemoved() throws java.io.IOException, InterruptedException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void NotifyWhenWholeStoreDirectoryRemoved()
        {
            assumeFalse(SystemUtils.IS_OS_WINDOWS);

            string       fileName     = TestDirectory.databaseLayout().metadataStore().Name;
            FileWatcher  fileWatcher  = GetFileWatcher(_database);
            CheckPointer checkpointer = GetCheckpointer(_database);

            ModificationEventListener modificationListener = new ModificationEventListener(fileName);

            fileWatcher.AddFileWatchEventListener(modificationListener);
            do
            {
                CreateNode(_database);
                ForceCheckpoint(checkpointer);
            } while (!modificationListener.AwaitModificationNotification());
            fileWatcher.RemoveFileWatchEventListener(modificationListener);

            string storeDirectoryName = TestDirectory.databaseLayout().databaseDirectory().Name;
            DeletionLatchEventListener eventListener = new DeletionLatchEventListener(storeDirectoryName);

            fileWatcher.AddFileWatchEventListener(eventListener);
            FileUtils.deleteRecursively(TestDirectory.databaseLayout().databaseDirectory());

            eventListener.AwaitDeletionNotification();

            _logProvider.rawMessageMatcher().assertContains("'" + storeDirectoryName + "' which belongs to the store was deleted while database was running.");
        }
Ejemplo n.º 3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test(timeout = TEST_TIMEOUT) public void doNotMonitorTransactionLogFiles() throws InterruptedException, java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void DoNotMonitorTransactionLogFiles()
        {
            assumeFalse(SystemUtils.IS_OS_WINDOWS);

            FileWatcher  fileWatcher   = GetFileWatcher(_database);
            CheckPointer checkpointer  = GetCheckpointer(_database);
            string       metadataStore = TestDirectory.databaseLayout().metadataStore().Name;
            ModificationEventListener modificationEventListener = new ModificationEventListener(metadataStore);

            fileWatcher.AddFileWatchEventListener(modificationEventListener);

            do
            {
                CreateNode(_database);
                ForceCheckpoint(checkpointer);
            } while (!modificationEventListener.AwaitModificationNotification());

            string fileName = TransactionLogFiles.DEFAULT_NAME + ".0";
            DeletionLatchEventListener deletionListener = new DeletionLatchEventListener(fileName);

            fileWatcher.AddFileWatchEventListener(deletionListener);
            DeleteFile(TestDirectory.storeDir(), fileName);
            deletionListener.AwaitDeletionNotification();

            AssertableLogProvider.LogMatcher logMatcher = AssertableLogProvider.inLog(typeof(DefaultFileDeletionEventListener)).info(containsString(fileName));
            _logProvider.assertNone(logMatcher);
        }
Ejemplo n.º 4
0
 public StoreCopyServer(NeoStoreDataSource dataSource, CheckPointer checkPointer, FileSystemAbstraction fileSystem, File databaseDirectory, Monitor monitor)
 {
     this._dataSource        = dataSource;
     this._checkPointer      = checkPointer;
     this._fileSystem        = fileSystem;
     this._databaseDirectory = getCanonicalFile(databaseDirectory);
     this._monitor           = monitor;
 }
Ejemplo n.º 5
0
 public CheckPointScheduler(CheckPointer checkPointer, IOLimiter ioLimiter, JobScheduler scheduler, long recurringPeriodMillis, DatabaseHealth health)
 {
     this._checkPointer          = checkPointer;
     this._ioLimiter             = ioLimiter;
     this._scheduler             = scheduler;
     this._recurringPeriodMillis = recurringPeriodMillis;
     this._health = health;
 }
Ejemplo n.º 6
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private static void generateTransactionsAndRotate(org.neo4j.kernel.internal.GraphDatabaseAPI database, int logFilesToGenerate, boolean checkpoint) throws java.io.IOException
        private static void GenerateTransactionsAndRotate(GraphDatabaseAPI database, int logFilesToGenerate, bool checkpoint)
        {
            DependencyResolver resolver     = database.DependencyResolver;
            LogFiles           logFiles     = resolver.ResolveDependency(typeof(TransactionLogFiles));
            CheckPointer       checkpointer = resolver.ResolveDependency(typeof(CheckPointer));

            while (logFiles.HighestLogVersion < logFilesToGenerate)
            {
                logFiles.LogFile.rotate();
                GenerateTransaction(database);
                if (checkpoint)
                {
                    checkpointer.ForceCheckPoint(new SimpleTriggerInfo("testForcedCheckpoint"));
                }
            }
        }
Ejemplo n.º 7
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldUseEventBasedReportingCorrectly() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldUseEventBasedReportingCorrectly()
        {
            // GIVEN
            AddNodes(100);

            // WHEN
            CheckPointer checkPointer = _db.DependencyResolver.resolveDependency(typeof(CheckPointer));

            checkPointer.CheckPointIfNeeded(new SimpleTriggerInfo("test"));

            // wait for the file to be written before shutting down the cluster
            File metricFile = metricsCsv(_outputPath, CheckPointingMetrics.CHECK_POINT_DURATION);

            long result = readLongValueAndAssert(metricFile, (newValue, currentValue) => newValue >= 0);

            // THEN
            assertThat(result, greaterThanOrEqualTo(0L));
        }
Ejemplo n.º 8
0
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: public org.neo4j.com.Response<?> copyStore(StoreWriter writer)
            public override Response <object> CopyStore(StoreWriter writer)
            {
                NeoStoreDataSource neoStoreDataSource = Original.DependencyResolver.resolveDependency(typeof(NeoStoreDataSource));

                TransactionIdStore transactionIdStore = Original.DependencyResolver.resolveDependency(typeof(TransactionIdStore));

                LogicalTransactionStore logicalTransactionStore = Original.DependencyResolver.resolveDependency(typeof(LogicalTransactionStore));

                CheckPointer checkPointer = Original.DependencyResolver.resolveDependency(typeof(CheckPointer));

                RequestContext requestContext = (new StoreCopyServer(neoStoreDataSource, checkPointer, Fs, OriginalDir, (new Monitors()).newMonitor(typeof(StoreCopyServer.Monitor)))).flushStoresAndStreamStoreFiles("test", writer, IncludeLogs);

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.storageengine.api.StoreId storeId = original.getDependencyResolver().resolveDependency(org.neo4j.kernel.impl.storageengine.impl.recordstorage.RecordStorageEngine.class).getStoreId();
                StoreId storeId = Original.DependencyResolver.resolveDependency(typeof(RecordStorageEngine)).StoreId;

                ResponsePacker responsePacker = new ResponsePacker(logicalTransactionStore, transactionIdStore, () => storeId);

                Response = spy(responsePacker.PackTransactionStreamResponse(requestContext, null));
                return(Response);
            }
Ejemplo n.º 9
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test(timeout = TEST_TIMEOUT) public void notifyAboutStoreFileDeletion() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void NotifyAboutStoreFileDeletion()
        {
            assumeFalse(SystemUtils.IS_OS_WINDOWS);

            string       fileName     = TestDirectory.databaseLayout().metadataStore().Name;
            FileWatcher  fileWatcher  = GetFileWatcher(_database);
            CheckPointer checkpointer = GetCheckpointer(_database);
            DeletionLatchEventListener deletionListener = new DeletionLatchEventListener(fileName);

            fileWatcher.AddFileWatchEventListener(deletionListener);

            do
            {
                CreateNode(_database);
                ForceCheckpoint(checkpointer);
            } while (!deletionListener.AwaitModificationNotification());

            DeleteFile(TestDirectory.storeDir(), fileName);
            deletionListener.AwaitDeletionNotification();

            _logProvider.rawMessageMatcher().assertContains("'" + fileName + "' which belongs to the store was deleted while database was running.");
        }
Ejemplo n.º 10
0
        private void PrepareDatabase(Label label)
        {
            GenerateData(label);

            using (Transaction transaction = Database.beginTx())
            {
                for (int i = 0; i < 10; i++)
                {
                    Database.schema().indexFor(label).on(PROPERTY_PREFIX + i).create();
                }
                transaction.Success();
            }

            using (Transaction ignored = Database.beginTx())
            {
                Database.schema().awaitIndexesOnline(1, TimeUnit.MINUTES);
            }

            _checkPointer    = ResolveDependency(typeof(CheckPointer));
            _indexingService = ResolveDependency(typeof(IndexingService));
            _fileSystem      = ResolveDependency(typeof(FileSystemAbstraction));
        }
Ejemplo n.º 11
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test(timeout = TEST_TIMEOUT) public void doNotNotifyAboutLuceneIndexFilesDeletion() throws InterruptedException, java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void DoNotNotifyAboutLuceneIndexFilesDeletion()
        {
            DependencyResolver dependencyResolver = (( GraphDatabaseAPI )_database).DependencyResolver;
            FileWatcher        fileWatcher        = GetFileWatcher(_database);
            CheckPointer       checkPointer       = dependencyResolver.ResolveDependency(typeof(CheckPointer));

            string propertyStoreName = TestDirectory.databaseLayout().propertyStore().Name;
            AccumulativeDeletionEventListener accumulativeListener = new AccumulativeDeletionEventListener();
            ModificationEventListener         modificationListener = new ModificationEventListener(propertyStoreName);

            fileWatcher.AddFileWatchEventListener(modificationListener);
            fileWatcher.AddFileWatchEventListener(accumulativeListener);

            string labelName    = "labelName";
            string propertyName = "propertyName";
            Label  testLabel    = Label.label(labelName);

            CreateIndexes(_database, propertyName, testLabel);
            do
            {
                CreateNode(_database, propertyName, testLabel);
                ForceCheckpoint(checkPointer);
            } while (!modificationListener.AwaitModificationNotification());

            fileWatcher.RemoveFileWatchEventListener(modificationListener);
            ModificationEventListener afterRemovalListener = new ModificationEventListener(propertyStoreName);

            fileWatcher.AddFileWatchEventListener(afterRemovalListener);

            DropAllIndexes(_database);
            do
            {
                CreateNode(_database, propertyName, testLabel);
                ForceCheckpoint(checkPointer);
            } while (!afterRemovalListener.AwaitModificationNotification());

            accumulativeListener.AssertDoesNotHaveAnyDeletions();
        }
Ejemplo n.º 12
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test(timeout = TEST_TIMEOUT) public void notifyAboutExplicitIndexFolderRemoval() throws InterruptedException, java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void NotifyAboutExplicitIndexFolderRemoval()
        {
            string monitoredDirectory = GetExplicitIndexDirectory(TestDirectory.databaseLayout());

            FileWatcher  fileWatcher  = GetFileWatcher(_database);
            CheckPointer checkPointer = GetCheckpointer(_database);
            DeletionLatchEventListener deletionListener = new DeletionLatchEventListener(monitoredDirectory);
            string metadataStore = TestDirectory.databaseLayout().metadataStore().Name;
            ModificationEventListener modificationEventListener = new ModificationEventListener(metadataStore);

            fileWatcher.AddFileWatchEventListener(deletionListener);
            fileWatcher.AddFileWatchEventListener(modificationEventListener);

            do
            {
                CreateNode(_database);
                ForceCheckpoint(checkPointer);
            } while (!modificationEventListener.AwaitModificationNotification());

            DeleteStoreDirectory(_storeDir, monitoredDirectory);
            deletionListener.AwaitDeletionNotification();

            _logProvider.rawMessageMatcher().assertContains("'" + monitoredDirectory + "' which belongs to the store was deleted while database was running.");
        }
Ejemplo n.º 13
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private void checkpoint(org.neo4j.graphdb.GraphDatabaseService db) throws java.io.IOException
        private void Checkpoint(GraphDatabaseService db)
        {
            CheckPointer checkPointer = checkPointer(db);

            checkPointer.ForceCheckPoint(new SimpleTriggerInfo("test"));
        }
Ejemplo n.º 14
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private static void forceCheckpoint(org.neo4j.kernel.impl.transaction.log.checkpoint.CheckPointer checkPointer) throws java.io.IOException
        private static void ForceCheckpoint(CheckPointer checkPointer)
        {
            checkPointer.ForceCheckPoint(new SimpleTriggerInfo("testForceCheckPoint"));
        }