//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)); }
//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: 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); }
//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))); }
internal override ProgressiveState <Key> rotate(bool force, RotationStrategy strategy, RotationTimerFactory timerFactory, System.Action <Headers.Builder> headers) { return(state); }
internal NeedsCreation(KeyFormat <Key> keys, ActiveState.Factory stateFactory, RotationStrategy rotation, VersionContextSupplier versionContextSupplier) : base(keys, stateFactory, versionContextSupplier) { this.Rotation = rotation; }
// state transitions //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 virtual ProgressiveState <Key> Initialize(RotationStrategy rotation) { throw new System.InvalidOperationException("Cannot initialize in state: " + StateName()); }
//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);
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldNotPickCorruptStoreFile() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldNotPickCorruptStoreFile() { // given Store store = CreateTestStore(); RotationStrategy rotation = store.RotationStrategy; // when File[] files = new File[10]; { Pair <File, KeyValueStoreFile> file = rotation.Create(EMPTY_DATA_PROVIDER, 1); files[0] = file.First(); for (int txId = 2, i = 1; i < Files.Length; txId <<= 1, i++) { KeyValueStoreFile old = file.Other(); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final int data = txId; int data = txId; file = rotation.Next(file.First(), Headers.HeadersBuilder().put(TX_ID, (long)txId).headers(), data((Entry)(key, value) => { key.putByte(0, ( sbyte )'f'); key.putByte(1, ( sbyte )'o'); key.putByte(2, ( sbyte )'o'); value.putInt(0, data); })); old.Dispose(); files[i] = file.First(); } file.Other().Dispose(); } // Corrupt the last files using (StoreChannel channel = _resourceManager.fileSystem().open(files[9], OpenMode.READ_WRITE)) { // ruin the header channel.Position(16); ByteBuffer value = ByteBuffer.allocate(16); value.put(( sbyte )0); value.flip(); channel.WriteAll(value); } using (StoreChannel channel = _resourceManager.fileSystem().open(files[8], OpenMode.READ_WRITE)) { // ruin the header channel.Position(32); ByteBuffer value = ByteBuffer.allocate(16); value.put(( sbyte )17); value.flip(); channel.WriteAll(value); } using (StoreChannel channel = _resourceManager.fileSystem().open(files[7], OpenMode.READ_WRITE)) { // ruin the header channel.Position(32 + 32 + 32 + 16); ByteBuffer value = ByteBuffer.allocate(16); value.putLong(0); value.putLong(0); value.flip(); channel.WriteAll(value); } // then using (Lifespan life = new Lifespan()) { life.Add(store); assertEquals(64L, store.Headers().get(TX_ID).longValue()); } }