//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private void readIdBatch0() throws java.io.IOException private void ReadIdBatch0() { if (_stackPosition == 0) { return; } long startPosition = max(_stackPosition - _batchSize * _idEntrySize, 0); int bytesToRead = toIntExact(_stackPosition - startPosition); ByteBuffer readBuffer = ByteBuffer.allocate(bytesToRead); _channel.position(startPosition); _channel.readAll(readBuffer); _stackPosition = startPosition; readBuffer.flip(); int idsRead = bytesToRead / _idEntrySize; for (int i = 0; i < idsRead; i++) { long id = readBuffer.Long; _readFromDisk.enqueue(id); } if (_aggressiveMode) { Truncate(startPosition); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void position() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: internal virtual void Position() { long position = 500; when(_actual.position()).thenReturn(position); assertEquals(position - _offset, _channel.position()); verify(_actual).position(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldBeConsistentAfterConcurrentWritesAndForces() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: internal virtual void ShouldBeConsistentAfterConcurrentWritesAndForces() { ExecutorService executorService = Executors.newCachedThreadPool(); try { for (int attempt = 0; attempt < 100; attempt++) { using (EphemeralFileSystemAbstraction fs = new EphemeralFileSystemAbstraction()) { File aFile = new File("contendedFile"); ICollection <Callable <Void> > workers = new List <Callable <Void> >(); for (int i = 0; i < 100; i++) { workers.Add(() => { try { StoreChannel channel = fs.Open(aFile, OpenMode.READ_WRITE); channel.position(channel.size()); WriteLong(channel, 1); } catch (IOException e) { throw new Exception(e); } return(null); }); workers.Add(() => { StoreChannel channel = fs.Open(aFile, OpenMode.READ_WRITE); channel.force(true); return(null); }); } IList <Future <Void> > futures = executorService.invokeAll(workers); foreach (Future <Void> future in futures) { future.get(); } fs.Crash(); VerifyFileIsFullOfLongIntegerOnes(fs.Open(aFile, OpenMode.READ_WRITE)); } } } finally { executorService.shutdown(); } }
/// <returns> the position of the channel, also taking into account buffer position. </returns> /// <exception cref="IOException"> if underlying channel throws <seealso cref="IOException"/>. </exception> //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public long position() throws java.io.IOException public virtual long Position() { return(ChannelConflict.position() + Buffer.position()); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public long position() throws java.io.IOException public override long Position() { return(@delegate.position() - _offset); }