예제 #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void pullRotatesWhenThresholdCrossedAndExplicitlySet() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void PullRotatesWhenThresholdCrossedAndExplicitlySet()
        {
            // given
            Config config = Config.defaults();

            config.Augment(GraphDatabaseSettings.logical_log_rotation_threshold, "1M");                 // 1 mebibyte

            // and
            Org.Neo4j.Storageengine.Api.StoreId storeId = SimulateStoreCopy();

            // and
            long fromTxId = BASE_TX_ID;
            TransactionLogCatchUpWriter subject = new TransactionLogCatchUpWriter(_databaseLayout, _fs, _pageCache, config, NullLogProvider.Instance, fromTxId, PartOfStoreCopyConflict, false, true);

            // when a bunch of transactions received
            LongStream.range(fromTxId, _manyTransactions).mapToObj(TransactionLogCatchUpWriterTest.tx).map(tx => new TxPullResponse(ToCasualStoreId(storeId), tx)).forEach(subject.onTxReceived);
            subject.Close();

            // then there was a rotation
            LogFilesBuilder logFilesBuilder = LogFilesBuilder.activeFilesBuilder(_databaseLayout, _fs, _pageCache);
            LogFiles        logFiles        = logFilesBuilder.Build();

            assertNotEquals(logFiles.LowestLogVersion, logFiles.HighestLogVersion);
            VerifyTransactionsInLog(logFiles, fromTxId, _manyTransactions);
            VerifyCheckpointInLog(logFiles, PartOfStoreCopyConflict);
        }
예제 #2
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private static void transactions1M(org.neo4j.causalclustering.discovery.Cluster<?> cluster) throws Exception
        private static void Transactions1M <T1>(Cluster <T1> cluster)
        {
            int  numberOfTransactions = 500;
            long sizeOfTransaction    = (ByteUnit.mebiBytes(1) / numberOfTransactions) + 1;

            for (int txId = 0; txId < numberOfTransactions; txId++)
            {
                cluster.CoreTx((coreGraphDatabase, transaction) =>
                {
                    Node node         = coreGraphDatabase.createNode();
                    string longString = LongStream.range(0, sizeOfTransaction).map(l => l % 10).mapToObj(long?.toString).collect(joining(""));
                    node.setProperty("name", longString);
                    coreGraphDatabase.createNode().createRelationshipTo(node, RelationshipType.withName("KNOWS"));
                    transaction.success();
                });
            }
        }
예제 #3
0
        private static void Transactions1M(GraphDatabaseService db)
        {
            int  numberOfTransactions = 500;
            long sizeOfTransaction    = (ByteUnit.mebiBytes(1) / numberOfTransactions) + 1;

            for (int txId = 0; txId < numberOfTransactions; txId++)
            {
                using (Transaction tx = Db.beginTx())
                {
                    Node   node       = Db.createNode();
                    string longString = LongStream.range(0, sizeOfTransaction).map(l => l % 10).mapToObj(long?.toString).collect(joining(""));
                    node.SetProperty("name", longString);
                    Db.createNode().createRelationshipTo(node, RelationshipType.withName("KNOWS"));
                    tx.Success();
                }
            }
        }
예제 #4
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: void prepareIndex(GBPTree<KEY,VALUE> index, java.util.TreeSet<long> dataInIndex, java.util.Queue<long> toRemove, java.util.Queue<long> toAdd, java.util.Random random) throws java.io.IOException
            internal virtual void PrepareIndex(GBPTree <KEY, VALUE> index, SortedSet <long> dataInIndex, LinkedList <long> toRemove, LinkedList <long> toAdd, Random random)
            {
                IList <long> fullRange       = LongStream.range(MinRange, MaxRange).boxed().collect(Collectors.toList());
                IList <long> rangeOutOfOrder = ShuffleToNewList(fullRange, random);

                using (Writer <KEY, VALUE> writer = index.Writer())
                {
                    foreach (long?key in rangeOutOfOrder)
                    {
                        bool addForRemoval = random.NextDouble() > WritePercentage;
                        if (addForRemoval)
                        {
                            writer.Put(key(key), outerInstance.value(key.Value));
                            dataInIndex.Add(key);
                            toRemove.AddLast(key);
                        }
                        else
                        {
                            toAdd.AddLast(key);
                        }
                    }
                }
            }
예제 #5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void concurrentLuceneIndexSnapshotUseDifferentSnapshots() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ConcurrentLuceneIndexSnapshotUseDifferentSnapshots()
        {
            Label label = Label.label("testLabel");

            Database.withSetting(GraphDatabaseSettings.default_schema_provider, GraphDatabaseSettings.SchemaIndex.NATIVE20.providerName());
            PrepareDatabase(label);

            ForceCheckpoint(_checkPointer);
            ResourceIterator <File> firstCheckpointSnapshot = _indexingService.snapshotIndexFiles();

            GenerateData(label);
            RemoveOldNodes(LongStream.range(1, 20));
            UpdateOldNodes(LongStream.range(30, 40));

            ForceCheckpoint(_checkPointer);
            ResourceIterator <File> secondCheckpointSnapshot = _indexingService.snapshotIndexFiles();

            GenerateData(label);
            RemoveOldNodes(LongStream.range(50, 60));
            UpdateOldNodes(LongStream.range(70, 80));

            ForceCheckpoint(_checkPointer);
            ResourceIterator <File> thirdCheckpointSnapshot = _indexingService.snapshotIndexFiles();

            ISet <string> firstSnapshotFileNames  = GetFileNames(firstCheckpointSnapshot);
            ISet <string> secondSnapshotFileNames = GetFileNames(secondCheckpointSnapshot);
            ISet <string> thirdSnapshotFileNames  = GetFileNames(thirdCheckpointSnapshot);

            CompareSnapshotFiles(firstSnapshotFileNames, secondSnapshotFileNames, _fileSystem);
            CompareSnapshotFiles(secondSnapshotFileNames, thirdSnapshotFileNames, _fileSystem);
            CompareSnapshotFiles(thirdSnapshotFileNames, firstSnapshotFileNames, _fileSystem);

            firstCheckpointSnapshot.Close();
            secondCheckpointSnapshot.Close();
            thirdCheckpointSnapshot.Close();
        }
예제 #6
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void mustHaveLogFilesToPruneIfStrategyFindsFiles()
        public virtual void MustHaveLogFilesToPruneIfStrategyFindsFiles()
        {
            when(_factory.strategyFromConfigValue(eq(_fs), eq(_logFiles), eq(_clock), anyString())).thenReturn(upTo => LongStream.range(3, upTo));
            when(_logFiles.HighestLogVersion).thenReturn(4L);
            LogPruning pruning = new LogPruningImpl(_fs, _logFiles, _logProvider, _factory, _clock, _config);

            assertTrue(pruning.MightHaveLogsToPrune());
        }
예제 #7
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void mustDeleteLogFilesThatCanBePruned()
        public virtual void MustDeleteLogFilesThatCanBePruned()
        {
            when(_factory.strategyFromConfigValue(eq(_fs), eq(_logFiles), eq(_clock), anyString())).thenReturn(upTo => LongStream.range(3, upTo));
            LogPruning pruning = new LogPruningImpl(_fs, _logFiles, _logProvider, _factory, _clock, _config);

            pruning.PruneLogs(5);
            InOrder order = inOrder(_fs);

            order.verify(_fs).deleteFile(new File("3"));
            order.verify(_fs).deleteFile(new File("4"));
            // Log file 5 is not deleted; it's the lowest version expected to remain after pruning.
            verifyNoMoreInteractions(_fs);
        }