Esempio n. 1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private void writeAndVerify(StreamToDiskProvider writerProvider, java.io.File file) throws Exception
        private void WriteAndVerify(StreamToDiskProvider writerProvider, File file)
        {
            using (StoreFileStream acquire = writerProvider.Acquire(file.Name, 16))
            {
                acquire.Write(_data);
            }
            assertTrue("Streamed file created.", _fs.fileExists(file));
            assertEquals(_data.Length, _fs.getFileSize(file));
        }
Esempio n. 2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldNotAppendToFileWhenRetryingWithNewFile() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldNotAppendToFileWhenRetryingWithNewFile()
        {
            // given
            string fileName               = "foo";
            string copyFileName           = "bar";
            string unfinishedContent      = "abcd";
            string finishedContent        = "abcdefgh";
            IEnumerator <string> contents = Iterators.iterator(unfinishedContent, finishedContent);

            // and
            TestCatchupServerHandler halfWayFailingServerhandler = new TestCatchupServerHandlerAnonymousInnerClass(this, _logProvider, TestDirectory, _fsa, fileName, copyFileName, contents);

            Server halfWayFailingServer = null;

            try
            {
                // when
                ListenSocketAddress listenAddress = new ListenSocketAddress("localhost", PortAuthority.allocatePort());
                halfWayFailingServer = (new CatchupServerBuilder(halfWayFailingServerhandler)).listenAddress(listenAddress).build();
                halfWayFailingServer.Start();

                CatchupAddressProvider addressProvider = CatchupAddressProvider.fromSingleAddress(new AdvertisedSocketAddress(listenAddress.Hostname, listenAddress.Port));

                StoreId storeId     = halfWayFailingServerhandler.StoreId;
                File    databaseDir = TestDirectory.databaseDir();
                StreamToDiskProvider streamToDiskProvider = new StreamToDiskProvider(databaseDir, _fsa, new Monitors());

                // and
                _subject.copyStoreFiles(addressProvider, storeId, streamToDiskProvider, () => _defaultTerminationCondition, _targetLocation);

                // then
                assertEquals(FileContent(new File(databaseDir, fileName)), finishedContent);

                // and
                File fileCopy = new File(databaseDir, copyFileName);

                ByteBuffer buffer = ByteBuffer.wrap(new sbyte[finishedContent.Length]);
                using (StoreChannel storeChannel = _fsa.create(fileCopy))
                {
                    storeChannel.read(buffer);
                }
                assertEquals(finishedContent, new string( buffer.array(), Charsets.UTF_8 ));
            }
            finally
            {
                halfWayFailingServer.Stop();
                halfWayFailingServer.Shutdown();
            }
        }
Esempio n. 3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldLetPageCacheHandleRecordStoresAndNativeLabelScanStoreFiles() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldLetPageCacheHandleRecordStoresAndNativeLabelScanStoreFiles()
        {
            // GIVEN
            Monitors             monitors       = new Monitors();
            StreamToDiskProvider writerProvider = new StreamToDiskProvider(_directory.databaseDir(), _fs, monitors);

            // WHEN
            foreach (StoreType type in StoreType.values())
            {
                if (type.RecordStore)
                {
//JAVA TO C# CONVERTER TODO TASK: Method reference constructor syntax is not converted by Java to C# Converter:
                    File[] files = _directory.databaseLayout().file(type.DatabaseFile).toArray(File[] ::new);
                    foreach (File file in files)
                    {
                        WriteAndVerify(writerProvider, file);
                    }
                }
            }
            WriteAndVerify(writerProvider, _directory.databaseLayout().labelScanStore());
        }
Esempio n. 4
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public void copy(org.neo4j.causalclustering.catchup.CatchupAddressProvider addressProvider, org.neo4j.causalclustering.identity.StoreId expectedStoreId, org.neo4j.io.layout.DatabaseLayout destinationLayout, boolean rotateTransactionsManually) throws StoreCopyFailedException
        public virtual void Copy(CatchupAddressProvider addressProvider, StoreId expectedStoreId, DatabaseLayout destinationLayout, bool rotateTransactionsManually)
        {
            try
            {
                long lastFlushedTxId;
                StreamToDiskProvider streamToDiskProvider = new StreamToDiskProvider(destinationLayout.DatabaseDirectory(), _fs, _monitors);
                lastFlushedTxId = _storeCopyClient.copyStoreFiles(addressProvider, expectedStoreId, streamToDiskProvider, () => new MaximumTotalTime(_config.get(CausalClusteringSettings.store_copy_max_retry_time_per_request).Seconds, TimeUnit.SECONDS), destinationLayout.DatabaseDirectory());

                _log.info("Store files need to be recovered starting from: %d", lastFlushedTxId);

                CatchupResult catchupResult = PullTransactions(addressProvider.Primary(), expectedStoreId, destinationLayout, lastFlushedTxId, true, true, rotateTransactionsManually);
                if (catchupResult != SUCCESS_END_OF_STREAM)
                {
                    throw new StoreCopyFailedException("Failed to pull transactions: " + catchupResult);
                }
            }
            catch (Exception e) when(e is CatchupAddressResolutionException || e is IOException)
            {
                throw new StoreCopyFailedException(e);
            }
        }