Exemple #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Before public void setup() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void Setup()
        {
            _logProvider   = new DuplicatingLogProvider(_assertableLogProvider, FormattedLogProvider.withDefaultLogLevel(Level.DEBUG).toOutputStream(System.out));
            _serverHandler = new TestCatchupServerHandler(_logProvider, TestDirectory, _fsa);
            _serverHandler.addFile(_fileA);
            _serverHandler.addFile(_fileB);
            _serverHandler.addIndexFile(_indexFileA);
            WriteContents(_fsa, Relative(_fileA.Filename), _fileA.Content);
            WriteContents(_fsa, Relative(_fileB.Filename), _fileB.Content);
            WriteContents(_fsa, Relative(_indexFileA.Filename), _indexFileA.Content);

            ListenSocketAddress listenAddress = new ListenSocketAddress("localhost", PortAuthority.allocatePort());

            _catchupServer = (new CatchupServerBuilder(_serverHandler)).listenAddress(listenAddress).build();
            _catchupServer.start();

            CatchUpClient catchUpClient = (new CatchupClientBuilder()).build();

            catchUpClient.Start();

            ConstantTimeTimeoutStrategy storeCopyBackoffStrategy = new ConstantTimeTimeoutStrategy(1, TimeUnit.MILLISECONDS);

            Monitors monitors = new Monitors();

            _subject = new StoreCopyClient(catchUpClient, monitors, _logProvider, storeCopyBackoffStrategy);
        }
Exemple #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldSetLastPulledTransactionId() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldSetLastPulledTransactionId()
        {
            // given
            long    lastFlushedTxId           = 12;
            StoreId wantedStoreId             = new StoreId(1, 2, 3, 4);
            AdvertisedSocketAddress localhost = new AdvertisedSocketAddress("127.0.0.1", 1234);
            CatchupAddressProvider  catchupAddressProvider = CatchupAddressProvider.fromSingleAddress(localhost);

            StoreCopyClient storeCopyClient = mock(typeof(StoreCopyClient));

            when(storeCopyClient.CopyStoreFiles(eq(catchupAddressProvider), eq(wantedStoreId), any(typeof(StoreFileStreamProvider)), any(), any())).thenReturn(lastFlushedTxId);

            TxPullClient txPullClient = mock(typeof(TxPullClient));

            when(txPullClient.PullTransactions(eq(localhost), eq(wantedStoreId), anyLong(), any())).thenReturn(new TxPullRequestResult(SUCCESS_END_OF_STREAM, 13));

            TransactionLogCatchUpWriter writer = mock(typeof(TransactionLogCatchUpWriter));

            RemoteStore remoteStore = new RemoteStore(NullLogProvider.Instance, mock(typeof(FileSystemAbstraction)), null, storeCopyClient, txPullClient, Factory(writer), Config.defaults(), new Monitors());

            // when
            remoteStore.Copy(catchupAddressProvider, wantedStoreId, DatabaseLayout.of(new File("destination")), true);

            // then
            long previousTxId = lastFlushedTxId - 1;               // the interface is defined as asking for the one preceding

            verify(txPullClient).pullTransactions(eq(localhost), eq(wantedStoreId), eq(previousTxId), any());
        }
Exemple #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldCloseDownTxLogWriterIfTxStreamingFails() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldCloseDownTxLogWriterIfTxStreamingFails()
        {
            // given
            StoreId                     storeId                = new StoreId(1, 2, 3, 4);
            StoreCopyClient             storeCopyClient        = mock(typeof(StoreCopyClient));
            TxPullClient                txPullClient           = mock(typeof(TxPullClient));
            TransactionLogCatchUpWriter writer                 = mock(typeof(TransactionLogCatchUpWriter));
            CatchupAddressProvider      catchupAddressProvider = CatchupAddressProvider.fromSingleAddress(null);

            RemoteStore remoteStore = new RemoteStore(NullLogProvider.Instance, mock(typeof(FileSystemAbstraction)), null, storeCopyClient, txPullClient, Factory(writer), Config.defaults(), new Monitors());

            doThrow(typeof(CatchUpClientException)).when(txPullClient).pullTransactions(Null, eq(storeId), anyLong(), any());

            // when
            try
            {
                remoteStore.Copy(catchupAddressProvider, storeId, DatabaseLayout.of(new File(".")), true);
            }
            catch (StoreCopyFailedException)
            {
                // expected
            }

            // then
            verify(writer).close();
        }
Exemple #4
0
 public RemoteStore(LogProvider logProvider, FileSystemAbstraction fs, PageCache pageCache, StoreCopyClient storeCopyClient, TxPullClient txPullClient, TransactionLogCatchUpFactory transactionLogFactory, Config config, Monitors monitors)
 {
     this._logProvider     = logProvider;
     this._storeCopyClient = storeCopyClient;
     this._txPullClient    = txPullClient;
     this._fs                    = fs;
     this._pageCache             = pageCache;
     this._transactionLogFactory = transactionLogFactory;
     this._config                = config;
     this._monitors              = monitors;
     this._log                   = logProvider.getLog(this.GetType());
     this._commitStateHelper     = new CommitStateHelper(pageCache, fs, config);
 }
Exemple #5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldCopyStoreFilesAndPullTransactions() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldCopyStoreFilesAndPullTransactions()
        {
            // given
            StoreId         storeId         = new StoreId(1, 2, 3, 4);
            StoreCopyClient storeCopyClient = mock(typeof(StoreCopyClient));
            TxPullClient    txPullClient    = mock(typeof(TxPullClient));

            when(txPullClient.PullTransactions(any(), any(), anyLong(), any())).thenReturn(new TxPullRequestResult(SUCCESS_END_OF_STREAM, 13));
            TransactionLogCatchUpWriter writer = mock(typeof(TransactionLogCatchUpWriter));

            RemoteStore remoteStore = new RemoteStore(NullLogProvider.Instance, mock(typeof(FileSystemAbstraction)), null, storeCopyClient, txPullClient, Factory(writer), Config.defaults(), new Monitors());

            // when
            AdvertisedSocketAddress localhost = new AdvertisedSocketAddress("127.0.0.1", 1234);
            CatchupAddressProvider  catchupAddressProvider = CatchupAddressProvider.fromSingleAddress(localhost);

            remoteStore.Copy(catchupAddressProvider, storeId, DatabaseLayout.of(new File("destination")), true);

            // then
            verify(storeCopyClient).copyStoreFiles(eq(catchupAddressProvider), eq(storeId), any(typeof(StoreFileStreamProvider)), any(), any());
            verify(txPullClient).pullTransactions(eq(localhost), eq(storeId), anyLong(), any());
        }
Exemple #6
0
 public CatchUpResponseAdaptorAnonymousInnerClass(StoreCopyClient outerInstance)
 {
     this.outerInstance = outerInstance;
 }