Пример #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldDefaultTimeoutToTwentyMinutes() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldDefaultTimeoutToTwentyMinutes()
        {
            OnlineBackupContextFactory    handler           = new OnlineBackupContextFactory(_homeDir, _configDir);
            OnlineBackupContext           context           = handler.CreateContext("--backup-dir=/", "--name=mybackup");
            OnlineBackupRequiredArguments requiredArguments = context.RequiredArguments;

            assertEquals(MINUTES.toMillis(20), requiredArguments.Timeout);
        }
Пример #2
0
        public static string NanosToString(long nanos)
        {
            Debug.Assert(nanos >= 0);
            long          nanoSeconds = nanos;
            StringBuilder timeString  = new StringBuilder();

            long days = DAYS.convert(nanoSeconds, NANOSECONDS);

            if (days > 0)
            {
                nanoSeconds -= DAYS.toNanos(days);
                timeString.Append(days).Append('d');
            }
            long hours = HOURS.convert(nanoSeconds, NANOSECONDS);

            if (hours > 0)
            {
                nanoSeconds -= HOURS.toNanos(hours);
                timeString.Append(hours).Append('h');
            }
            long minutes = MINUTES.convert(nanoSeconds, NANOSECONDS);

            if (minutes > 0)
            {
                nanoSeconds -= MINUTES.toNanos(minutes);
                timeString.Append(minutes).Append('m');
            }
            long seconds = SECONDS.convert(nanoSeconds, NANOSECONDS);

            if (seconds > 0)
            {
                nanoSeconds -= SECONDS.toNanos(seconds);
                timeString.Append(seconds).Append('s');
            }
            long milliseconds = MILLISECONDS.convert(nanoSeconds, NANOSECONDS);

            if (milliseconds > 0)
            {
                nanoSeconds -= MILLISECONDS.toNanos(milliseconds);
                timeString.Append(milliseconds).Append("ms");
            }
            long microseconds = MICROSECONDS.convert(nanoSeconds, NANOSECONDS);

            if (microseconds > 0)
            {
                nanoSeconds -= MICROSECONDS.toNanos(microseconds);
                timeString.Append(microseconds).Append("μs");
            }
            if (nanoSeconds > 0 || timeString.Length == 0)
            {
                timeString.Append(nanoSeconds).Append("ns");
            }
            return(timeString.ToString());
        }
Пример #3
0
        public string GetTime()
        {
            string m = MINUTES.ToString(), s = SECONDS.ToString();   //Задаём переменные

            if (MINUTES < 10)
            {
                m = "0" + m;                                         //Делаем минуты 0X, еслли там однозначное число
            }
            if (SECONDS < 10)
            {
                s = "0" + s;                               //Делаем секунды 0X, еслли там однозначное число
            }
            return("00:" + m + ":" + s);                   //Выводим оставшееся время на экран
        }
Пример #4
0
//JAVA TO C# CONVERTER WARNING: 'final' parameters are ignored unless the option to convert to C# 7.2 'in' parameters is selected:
//ORIGINAL LINE: static String formatInterval(final long l)
        internal static string FormatInterval(long l)
        {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final long hr = MILLISECONDS.toHours(l);
            long hr = MILLISECONDS.toHours(l);
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final long min = MILLISECONDS.toMinutes(l - HOURS.toMillis(hr));
            long min = MILLISECONDS.toMinutes(l - HOURS.toMillis(hr));
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final long sec = MILLISECONDS.toSeconds(l - HOURS.toMillis(hr) - MINUTES.toMillis(min));
            long sec = MILLISECONDS.toSeconds(l - HOURS.toMillis(hr) - MINUTES.toMillis(min));
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final long ms = l - HOURS.toMillis(hr) - MINUTES.toMillis(min) - SECONDS.toMillis(sec);
            long ms = l - HOURS.toMillis(hr) - MINUTES.toMillis(min) - SECONDS.toMillis(sec);

            return(string.Format("{0:D2}:{1:D2}:{2:D2}.{3:D3}", hr, min, sec, ms));
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldNotTimeoutSchemaTransactions()
        internal virtual void ShouldNotTimeoutSchemaTransactions()
        {
            // given
            KernelTransactions       kernelTransactions = mock(typeof(KernelTransactions));
            FakeClock                clock   = new FakeClock(100, MINUTES);
            KernelTransactionMonitor monitor = new KernelTransactionMonitor(kernelTransactions, clock, NullLogService.Instance);
            // a 2 minutes old schema transaction which has a timeout of 1 minute
            KernelTransactionHandle oldSchemaTransaction = mock(typeof(KernelTransactionHandle));

            when(oldSchemaTransaction.SchemaTransaction).thenReturn(true);
            when(oldSchemaTransaction.StartTime()).thenReturn(clock.Millis() - MINUTES.toMillis(2));
            when(oldSchemaTransaction.TimeoutMillis()).thenReturn(MINUTES.toMillis(1));
            when(kernelTransactions.ActiveTransactions()).thenReturn(Iterators.asSet(oldSchemaTransaction));

            // when
            monitor.Run();

            // then
            verify(oldSchemaTransaction, times(1)).SchemaTransaction;
            verify(oldSchemaTransaction, never()).markForTermination(any());
        }
Пример #6
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void upgradedNeoStoreShouldHaveNewUpgradeTimeAndUpgradeId() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void UpgradedNeoStoreShouldHaveNewUpgradeTimeAndUpgradeId()
        {
            // Given
            _fileSystem.deleteFile(_databaseLayout.file(INTERNAL_LOG_FILE));
            PageCache          pageCache          = _pageCacheRule.getPageCache(_fileSystem);
            UpgradableDatabase upgradableDatabase = GetUpgradableDatabase(pageCache);

            // When
            NewUpgrader(upgradableDatabase, _allowMigrateConfig, pageCache).migrateIfNeeded(_databaseLayout);

            // Then
            StoreFactory factory = new StoreFactory(_databaseLayout, _allowMigrateConfig, new DefaultIdGeneratorFactory(_fileSystem), pageCache, _fileSystem, NullLogProvider.Instance, EmptyVersionContextSupplier.EMPTY);

            using (NeoStores neoStores = factory.OpenAllNeoStores())
            {
                assertThat(neoStores.MetaDataStore.UpgradeTransaction, equalTo(neoStores.MetaDataStore.LastCommittedTransaction));
                assertThat(neoStores.MetaDataStore.UpgradeTime, not(equalTo(MetaDataStore.FIELD_NOT_INITIALIZED)));

                long minuteAgo = DateTimeHelper.CurrentUnixTimeMillis() - MINUTES.toMillis(1);
                assertThat(neoStores.MetaDataStore.UpgradeTime, greaterThan(minuteAgo));
            }
        }
Пример #7
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldDelayFreeingOfAggressivelyReusedIdsConsideringTimeAsWell()
        public virtual void ShouldDelayFreeingOfAggressivelyReusedIdsConsideringTimeAsWell()
        {
            // GIVEN
            MockedIdGeneratorFactory actual = new MockedIdGeneratorFactory();
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.time.FakeClock clock = org.neo4j.time.Clocks.fakeClock();
            FakeClock clock = Clocks.fakeClock();
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final long safeZone = MINUTES.toMillis(1);
            long safeZone = MINUTES.toMillis(1);
            ControllableSnapshotSupplier boundaries = new ControllableSnapshotSupplier();
            BufferingIdGeneratorFactory  bufferingIdGeneratorFactory = new BufferingIdGeneratorFactory(actual, t => clock.Millis() - t.snapshotTime() >= safeZone, new CommunityIdTypeConfigurationProvider());

            bufferingIdGeneratorFactory.Initialize(boundaries);

            IdGenerator idGenerator = bufferingIdGeneratorFactory.Open(new File("doesnt-matter"), 10, IdType.StringBlock, () => 0L, int.MaxValue);

            // WHEN
            idGenerator.FreeId(7);
            verifyNoMoreInteractions(actual.Get(IdType.StringBlock));

            // after some maintenance and transaction still not closed
            bufferingIdGeneratorFactory.Maintenance();
            verifyNoMoreInteractions(actual.Get(IdType.StringBlock));

            // although after transactions have all closed
            boundaries.SetMostRecentlyReturnedSnapshotToAllClosed();
            bufferingIdGeneratorFactory.Maintenance();
            // ... the clock would still say "nope" so no interaction
            verifyNoMoreInteractions(actual.Get(IdType.StringBlock));

            // then finally after time has passed as well
            clock.Forward(70, SECONDS);
            bufferingIdGeneratorFactory.Maintenance();

            // THEN
            verify(actual.Get(IdType.StringBlock)).freeId(7);
        }
Пример #8
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void displayDuration()
        internal virtual void DisplayDuration()
        {
            assertThat(duration(MINUTES.toMillis(1) + SECONDS.toMillis(2)), @is("1m 2s"));
            assertThat(duration(42), @is("42ms"));
            assertThat(duration(0), @is("0ms"));
        }