Ejemplo n.º 1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private org.neo4j.helpers.collection.Pair<java.io.File, KeyValueStoreFile> initialState(DataInitializer<EntryUpdater<Key>> initializer) throws java.io.IOException
            internal virtual Pair <File, KeyValueStoreFile> InitialState(DataInitializer <EntryUpdater <Key> > initializer)
            {
                long version = initializer.InitialVersion();

                using (ActiveState <Key> creation = StateFactory.open(ReadableState.Empty(KeyFormat(), version), null, VersionContextSupplier))
                {
                    try (EntryUpdater <Key> updater = creation.resetter(new ReentrantLock(), () =>
                        {
                        }
                                                                        ))
                        {
                            initializer.Initialize(updater);
                        }
                    return(Rotation.create(KeyFormat().filter(creation.dataProvider()), initializer.InitialVersion()));
                }
            }
Ejemplo n.º 2
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));
            }