//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testTimer()
        public virtual void TestTimer()
        {
            // GIVEN
            FakeClock fakeClock = Clocks.fakeClock(10000, TimeUnit.MILLISECONDS);

            // WHEN
            RotationTimerFactory timerFactory = new RotationTimerFactory(fakeClock, 1000);

            RotationTimerFactory.RotationTimer timer        = timerFactory.CreateTimer();
            RotationTimerFactory.RotationTimer anotherTimer = timerFactory.CreateTimer();

            // THEN
            assertFalse(timer.TimedOut);
            assertEquals(0, timer.ElapsedTimeMillis);
            assertNotSame("Factory should construct different timers", timer, anotherTimer);

            // WHEN
            fakeClock = Clocks.fakeClock();
            RotationTimerFactory fakeTimerFactory = new RotationTimerFactory(fakeClock, 1000);

            RotationTimerFactory.RotationTimer fakeTimer = fakeTimerFactory.CreateTimer();
            fakeClock.Forward(1001, TimeUnit.MILLISECONDS);

            assertTrue(fakeTimer.TimedOut);
            assertEquals(1001, fakeTimer.ElapsedTimeMillis);
        }
示例#2
0
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: public AbstractKeyValueStore(org.neo4j.io.fs.FileSystemAbstraction fs, org.neo4j.io.pagecache.PageCache pages, org.neo4j.io.layout.DatabaseLayout databaseLayout, RotationMonitor monitor, org.neo4j.logging.Logger logger, RotationTimerFactory timerFactory, org.neo4j.io.pagecache.tracing.cursor.context.VersionContextSupplier versionContextSupplier, int keySize, int valueSize, HeaderField<?>... headerFields)
        public AbstractKeyValueStore(FileSystemAbstraction fs, PageCache pages, DatabaseLayout databaseLayout, RotationMonitor monitor, Logger logger, RotationTimerFactory timerFactory, VersionContextSupplier versionContextSupplier, int keySize, int valueSize, params HeaderField <object>[] headerFields)
        {
            this._fs       = fs;
            this.KeySize   = keySize;
            this.ValueSize = valueSize;
            Rotation rotation = this.GetType().getAnnotation(typeof(Rotation));

            if (monitor == null)
            {
                monitor = RotationMonitor.NONE;
            }
            this._format               = new Format(this, headerFields);
            this._logger               = logger;
            this.RotationStrategy      = rotation.value().create(fs, pages, _format, monitor, databaseLayout);
            this._rotationTimerFactory = timerFactory;
            this.State = new DeadState.Stopped <Key>(_format, this.GetType().getAnnotation(typeof(State)).value(), versionContextSupplier);
        }
示例#3
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: ProgressiveState<Key> rotate(boolean force, RotationStrategy strategy, RotationTimerFactory timerFactory, System.Action<Headers.Builder> headers) throws java.io.IOException
                internal override ProgressiveState <Key> rotate(bool force, RotationStrategy strategy, RotationTimerFactory timerFactory, System.Action <Headers.Builder> headers)
                {
                    return(new Prepared <Key>(_outerInstance.state.rotate(force, strategy, timerFactory, headers)));
                }
示例#4
0
 internal override ProgressiveState <Key> rotate(bool force, RotationStrategy strategy, RotationTimerFactory timerFactory, System.Action <Headers.Builder> headers)
 {
     return(state);
 }
示例#5
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: ActiveState<Key> rotate(boolean force, RotationStrategy strategy, RotationTimerFactory timerFactory, System.Action<Headers.Builder> headersUpdater) throws java.io.IOException
            internal override ActiveState <Key> Rotate(bool force, RotationStrategy strategy, RotationTimerFactory timerFactory, System.Action <Headers.Builder> headersUpdater)
            {
                if (!force)
                {
                    RotationTimerFactory.RotationTimer rotationTimer = timerFactory.CreateTimer();
                    for (long expected = Threshold - PreState.store.version(), sleep = 10; PreState.applied() < expected; sleep = Math.Min(sleep * 2, 100))
                    {
                        if (rotationTimer.TimedOut)
                        {
                            throw new RotationTimeoutException(Threshold, PreState.store.version(), rotationTimer.ElapsedTimeMillis);
                        }
                        try
                        {
                            Thread.Sleep(sleep);
                        }
                        catch (InterruptedException e)
                        {
                            throw ( InterruptedIOException )(new InterruptedIOException("Rotation was interrupted.")).initCause(e);
                        }
                    }
                }
                Pair <File, KeyValueStoreFile> next = strategy.Next(File(), UpdateHeaders(headersUpdater), KeyFormat().filter(PreState.dataProvider()));

                return(PostState.create(ReadableState.Store(PreState.keyFormat(), next.Other()), next.First(), PreState.versionContextSupplier));
            }
示例#6
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: abstract ProgressiveState<Key> rotate(boolean force, RotationStrategy strategy, RotationTimerFactory timerFactory, System.Action<Headers.Builder> headersUpdater) throws java.io.IOException;
        internal abstract ProgressiveState <Key> Rotate(bool force, RotationStrategy strategy, RotationTimerFactory timerFactory, System.Action <Headers.Builder> headersUpdater);
示例#7
0
 internal RotationTimer(RotationTimerFactory outerInstance, long startTimeNanos, long deadlineNanos)
 {
     this._outerInstance = outerInstance;
     this.StartTimeNanos = startTimeNanos;
     this.DeadlineNanos  = deadlineNanos;
 }