示例#1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldNotStartIfCurrentlyRunning() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldNotStartIfCurrentlyRunning()
        {
            // given
            CoreStateDownloader coreStateDownloader = mock(typeof(CoreStateDownloader));
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.causalclustering.core.state.CommandApplicationProcess applicationProcess = mock(org.neo4j.causalclustering.core.state.CommandApplicationProcess.class);
            CommandApplicationProcess applicationProcess = mock(typeof(CommandApplicationProcess));

            when(coreStateDownloader.DownloadSnapshot(any())).thenReturn(false);

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.logging.Log log = mock(org.neo4j.logging.Log.class);
            Log       log     = mock(typeof(Log));
            NoTimeout timeout = new NoTimeout();
            PersistentSnapshotDownloader persistentSnapshotDownloader = new PersistentSnapshotDownloader(_catchupAddressProvider, applicationProcess, coreStateDownloader, log, timeout, () => _dbHealth, new Monitors());

            Thread thread = new Thread(persistentSnapshotDownloader);

            // when
            thread.Start();
            AwaitOneIteration(timeout);
            persistentSnapshotDownloader.Run();
            persistentSnapshotDownloader.Stop();
            thread.Join();

            // then
            verify(applicationProcess, times(1)).pauseApplier(OPERATION_NAME);
            verify(applicationProcess, times(1)).resumeApplier(OPERATION_NAME);
        }
示例#2
0
        public virtual Optional <JobHandle> ScheduleDownload(CatchupAddressProvider addressProvider)
        {
            lock (this)
            {
                if (_stopped)
                {
                    return(null);
                }

                if (_currentJob == null || _currentJob.hasCompleted())
                {
                    _currentJob = new PersistentSnapshotDownloader(addressProvider, _applicationProcess, _downloader, _log, _downloaderPauseStrategy, _dbHealth, _monitors);
                    _jobHandle  = _jobScheduler.schedule(Group.DOWNLOAD_SNAPSHOT, _currentJob);
                    return(_jobHandle);
                }
                return(_jobHandle);
            }
        }
示例#3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldPauseAndResumeApplicationProcessIfDownloadIsSuccessful() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldPauseAndResumeApplicationProcessIfDownloadIsSuccessful()
        {
            // given
            CoreStateDownloader coreStateDownloader = mock(typeof(CoreStateDownloader));

            when(coreStateDownloader.DownloadSnapshot(any())).thenReturn(true);
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.causalclustering.core.state.CommandApplicationProcess applicationProcess = mock(org.neo4j.causalclustering.core.state.CommandApplicationProcess.class);
            CommandApplicationProcess applicationProcess = mock(typeof(CommandApplicationProcess));
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.logging.Log log = mock(org.neo4j.logging.Log.class);
            Log log = mock(typeof(Log));
            PersistentSnapshotDownloader persistentSnapshotDownloader = new PersistentSnapshotDownloader(_catchupAddressProvider, applicationProcess, coreStateDownloader, log, new NoTimeout(), () => _dbHealth, new Monitors());

            // when
            persistentSnapshotDownloader.Run();

            // then
            verify(applicationProcess, times(1)).pauseApplier(OPERATION_NAME);
            verify(applicationProcess, times(1)).resumeApplier(OPERATION_NAME);
            verify(coreStateDownloader, times(1)).downloadSnapshot(any());
            assertTrue(persistentSnapshotDownloader.HasCompleted());
        }
示例#4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldEventuallySucceed()
        public virtual void ShouldEventuallySucceed()
        {
            // given
            CoreStateDownloader coreStateDownloader = new EventuallySuccessfulDownloader(this, 3);

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.causalclustering.core.state.CommandApplicationProcess applicationProcess = mock(org.neo4j.causalclustering.core.state.CommandApplicationProcess.class);
            CommandApplicationProcess applicationProcess = mock(typeof(CommandApplicationProcess));
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.logging.Log log = mock(org.neo4j.logging.Log.class);
            Log       log     = mock(typeof(Log));
            NoTimeout timeout = new NoTimeout();
            PersistentSnapshotDownloader persistentSnapshotDownloader = new PersistentSnapshotDownloader(_catchupAddressProvider, applicationProcess, coreStateDownloader, log, timeout, () => _dbHealth, new Monitors());

            // when
            persistentSnapshotDownloader.Run();

            // then
            verify(applicationProcess, times(1)).pauseApplier(OPERATION_NAME);
            verify(applicationProcess, times(1)).resumeApplier(OPERATION_NAME);
            assertEquals(3, timeout.CurrentCount());
            assertTrue(persistentSnapshotDownloader.HasCompleted());
        }