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 shouldListExpectedFilesCorrectly() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldListExpectedFilesCorrectly()
        {
            // given (setup) required runtime subject dependencies
            NeoStoreDataSource  neoStoreDataSource  = GetNeoStoreDataSource(_graphDb);
            SimpleCatchupClient simpleCatchupClient = new SimpleCatchupClient(_graphDb, _fsa, _catchupClient, _catchupServer, _temporaryDirectory, _logProvider);

            // when
            PrepareStoreCopyResponse prepareStoreCopyResponse = simpleCatchupClient.RequestListOfFilesFromServer();

            simpleCatchupClient.Close();

            // then
            ListOfDownloadedFilesMatchesServer(neoStoreDataSource, prepareStoreCopyResponse.Files);

            // and downloaded files are identical to source
            IList <File> expectedCountStoreFiles = ListServerExpectedNonReplayableFiles(neoStoreDataSource);

            foreach (File storeFileSnapshot in expectedCountStoreFiles)
            {
                FileContentEquals(DatabaseFileToClientFile(storeFileSnapshot), storeFileSnapshot);
            }

            // and
            AssertTransactionIdMatches(prepareStoreCopyResponse.LastTransactionId());

            //and
            assertTrue("Expected an empty set of ids. Found size " + prepareStoreCopyResponse.IndexIds.size(), prepareStoreCopyResponse.IndexIds.Empty);
        }
Exemplo n.º 2
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: long copyStoreFiles(org.neo4j.causalclustering.catchup.CatchupAddressProvider catchupAddressProvider, org.neo4j.causalclustering.identity.StoreId expectedStoreId, StoreFileStreamProvider storeFileStreamProvider, System.Func<TerminationCondition> requestWiseTerminationCondition, java.io.File destDir) throws StoreCopyFailedException
        internal virtual long CopyStoreFiles(CatchupAddressProvider catchupAddressProvider, StoreId expectedStoreId, StoreFileStreamProvider storeFileStreamProvider, System.Func <TerminationCondition> requestWiseTerminationCondition, File destDir)
        {
            try
            {
                PrepareStoreCopyResponse prepareStoreCopyResponse = PrepareStoreCopy(catchupAddressProvider.Primary(), expectedStoreId, storeFileStreamProvider);
                CopyFilesIndividually(prepareStoreCopyResponse, expectedStoreId, catchupAddressProvider, storeFileStreamProvider, requestWiseTerminationCondition, destDir);
                CopyIndexSnapshotIndividually(prepareStoreCopyResponse, expectedStoreId, catchupAddressProvider, storeFileStreamProvider, requestWiseTerminationCondition);
                return(prepareStoreCopyResponse.LastTransactionId());
            }
            catch (Exception e) when(e is CatchupAddressResolutionException || e is CatchUpClientException)
            {
                throw new StoreCopyFailedException(e);
            }
        }
Exemplo n.º 3
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private void copyFilesIndividually(PrepareStoreCopyResponse prepareStoreCopyResponse, org.neo4j.causalclustering.identity.StoreId expectedStoreId, org.neo4j.causalclustering.catchup.CatchupAddressProvider addressProvider, StoreFileStreamProvider storeFileStream, System.Func<TerminationCondition> terminationConditions, java.io.File destDir) throws StoreCopyFailedException
        private void CopyFilesIndividually(PrepareStoreCopyResponse prepareStoreCopyResponse, StoreId expectedStoreId, CatchupAddressProvider addressProvider, StoreFileStreamProvider storeFileStream, System.Func <TerminationCondition> terminationConditions, File destDir)
        {
            StoreCopyClientMonitor storeCopyClientMonitor = _monitors.newMonitor(typeof(StoreCopyClientMonitor));

            storeCopyClientMonitor.StartReceivingStoreFiles();
            long lastTransactionId = prepareStoreCopyResponse.LastTransactionId();

            foreach (File file in prepareStoreCopyResponse.Files)
            {
                storeCopyClientMonitor.StartReceivingStoreFile(Paths.get(destDir.ToString(), file.Name).ToString());
                PersistentCallToSecondary(new GetStoreFileRequest(expectedStoreId, file, lastTransactionId), filesCopyAdaptor(storeFileStream, _log), addressProvider, terminationConditions());
                storeCopyClientMonitor.FinishReceivingStoreFile(Paths.get(destDir.ToString(), file.Name).ToString());
            }
            storeCopyClientMonitor.FinishReceivingStoreFiles();
        }
Exemplo n.º 4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void transactionIdGetsTransmitted()
        public virtual void TransactionIdGetsTransmitted()
        {
            // given
            long transactionId = long.MaxValue;

            // when a transaction id is serialised
            PrepareStoreCopyResponse prepareStoreCopyResponse = PrepareStoreCopyResponse.Success(new File[0], LongSets.immutable.empty(), transactionId);

            SendToChannel(prepareStoreCopyResponse, _embeddedChannel);

            // then it can be deserialised
            PrepareStoreCopyResponse readPrepareStoreCopyResponse = _embeddedChannel.readInbound();

            assertEquals(prepareStoreCopyResponse.LastTransactionId(), readPrepareStoreCopyResponse.LastTransactionId());
        }
Exemplo n.º 5
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private void copyIndexSnapshotIndividually(PrepareStoreCopyResponse prepareStoreCopyResponse, org.neo4j.causalclustering.identity.StoreId expectedStoreId, org.neo4j.causalclustering.catchup.CatchupAddressProvider addressProvider, StoreFileStreamProvider storeFileStream, System.Func<TerminationCondition> terminationConditions) throws StoreCopyFailedException
        private void CopyIndexSnapshotIndividually(PrepareStoreCopyResponse prepareStoreCopyResponse, StoreId expectedStoreId, CatchupAddressProvider addressProvider, StoreFileStreamProvider storeFileStream, System.Func <TerminationCondition> terminationConditions)
        {
            StoreCopyClientMonitor storeCopyClientMonitor = _monitors.newMonitor(typeof(StoreCopyClientMonitor));
            long         lastTransactionId = prepareStoreCopyResponse.LastTransactionId();
            LongIterator indexIds          = prepareStoreCopyResponse.IndexIds.longIterator();

            storeCopyClientMonitor.StartReceivingIndexSnapshots();
            while (indexIds.hasNext())
            {
                long indexId = indexIds.next();
                storeCopyClientMonitor.StartReceivingIndexSnapshot(indexId);
                PersistentCallToSecondary(new GetIndexFilesRequest(expectedStoreId, indexId, lastTransactionId), filesCopyAdaptor(storeFileStream, _log), addressProvider, terminationConditions());
                storeCopyClientMonitor.FinishReceivingIndexSnapshot(indexId);
            }
            storeCopyClientMonitor.FinishReceivingIndexSnapshots();
        }