//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)); }
internal Updater(Lock @lock, ReadableState <Key> store, ConcurrentMap <Key, ChangeEntry> changes, AtomicLong changeCounter, long version) : base(@lock) { this.ChangeCounter = changeCounter; this.Store = store; this.Changes = changes; this.Version = version; }
private ConcurrentMapState(Prototype <Key> prototype, ReadableState <Key> store, File file, VersionContextSupplier versionContextSupplier) : base(store, versionContextSupplier) { this._previousVersion = store.Version(); this._versionContextSupplier = versionContextSupplier; this._file = file; this._hasTrackedChanges = prototype.HasTrackedChanges; this._changes = prototype.Changes; this._highestAppliedVersion = prototype.HighestAppliedVersion; this._appliedChanges = prototype.AppliedChanges; }
internal ConcurrentMapState(ReadableState <Key> store, File file, VersionContextSupplier versionContextSupplier) : base(store, versionContextSupplier) { this._previousVersion = store.Version(); this._file = file; this._versionContextSupplier = versionContextSupplier; this._highestAppliedVersion = new AtomicLong(_previousVersion); this._changes = new ConcurrentDictionary <Key, ChangeEntry>(); this._appliedChanges = new AtomicLong(); _hasTrackedChanges = new AtomicBoolean(); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: ActiveState<Key> start(DataInitializer<EntryUpdater<Key>> initializer) throws java.io.IOException internal override ActiveState <Key> Start(DataInitializer <EntryUpdater <Key> > initializer) { if (initializer == null) { throw new System.InvalidOperationException("Store needs to be created, and no initializer is given."); } Pair <File, KeyValueStoreFile> created = InitialState(initializer); return(StateFactory.open(ReadableState.Store(KeyFormat(), created.Other()), created.First(), VersionContextSupplier)); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: ProgressiveState<Key> initialize(RotationStrategy rotation) throws java.io.IOException internal override ProgressiveState <Key> Initialize(RotationStrategy rotation) { Pair <File, KeyValueStoreFile> opened = rotation.Open(); if (opened == null) { return(new NeedsCreation <Key>(KeyFormat(), StateFactory, rotation, VersionContextSupplier)); } return(new Prepared <Key>(StateFactory.open(ReadableState.Store(KeyFormat(), opened.Other()), opened.First(), VersionContextSupplier))); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private static <Key> DataProvider dataProvider(ReadableState<Key> store, java.util.concurrent.ConcurrentMap<Key, ChangeEntry> changes) throws java.io.IOException private static DataProvider DataProvider <Key>(ReadableState <Key> store, ConcurrentMap <Key, ChangeEntry> changes) { if (changes.Empty) { return(store.DataProvider()); } else { KeyFormat <Key> keys = store.KeyFormat(); return(new KeyValueMerger(store.DataProvider(), new UpdateProvider(SortedUpdates(keys, changes)), keys.KeySize(), keys.ValueSize())); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private static <Key> boolean performLookup(ReadableState<Key> store, org.neo4j.io.pagecache.tracing.cursor.context.VersionContext versionContext, java.util.concurrent.ConcurrentMap<Key,ChangeEntry> changes, Key key, ValueSink sink) throws java.io.IOException private static bool PerformLookup <Key>(ReadableState <Key> store, VersionContext versionContext, ConcurrentMap <Key, ChangeEntry> changes, Key key, ValueSink sink) { ChangeEntry change = changes.get(key); if (change != null) { if (change.Version > versionContext.LastClosedTransactionId()) { versionContext.MarkAsDirty(); } sink.Value(new BigEndianByteArrayBuffer(change.Data)); return(true); } return(store.Lookup(key, sink)); }
//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())); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("SynchronizationOnLocalVariableOrMethodParameter") static <Key> void applyUpdate(ReadableState<Key> store, java.util.concurrent.ConcurrentMap<Key, ChangeEntry> changes, Key key, ValueUpdate update, boolean reset, long version) throws java.io.IOException //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: internal static void ApplyUpdate <Key>(ReadableState <Key> store, ConcurrentMap <Key, ChangeEntry> changes, Key key, ValueUpdate update, bool reset, long version) { ChangeEntry value = changes.get(key); if (value == null) { ChangeEntry newEntry = ChangeEntry.Of(new sbyte[store.KeyFormat().valueSize()], version); lock ( newEntry ) { value = changes.putIfAbsent(key, newEntry); if (value == null) { BigEndianByteArrayBuffer buffer = new BigEndianByteArrayBuffer(newEntry.Data); if (!reset) { PreviousValue lookup = new PreviousValue(newEntry.Data); if (!store.Lookup(key, lookup)) { buffer.Clear(); } } update.Update(buffer); return; } } } lock ( value ) { BigEndianByteArrayBuffer target = new BigEndianByteArrayBuffer(value.Data); value.Version = version; if (reset) { target.Clear(); } update.Update(target); } }
protected internal abstract ActiveState <Key> Create(ReadableState <Key> sub, File file, VersionContextSupplier versionContextSupplier);
protected internal override ActiveState <Key> Create(ReadableState <Key> sub, File file, VersionContextSupplier versionContextSupplier) { return(new ConcurrentMapState <Key>(this, sub, file, versionContextSupplier)); }
public <Key> ActiveState <Key> open(ReadableState <Key> store, File file, VersionContextSupplier versionContextSupplier) { return(new ConcurrentMapState <>(store, file, versionContextSupplier)); }
public ActiveState(ReadableState <Key> store, VersionContextSupplier versionContextSupplier) { this.Store = store; this.VersionContextSupplier = versionContextSupplier; }