//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test(expected = IllegalStateException.class) public void createIdGeneratorMustRefuseOverwritingExistingFile() throws java.io.IOException //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void CreateIdGeneratorMustRefuseOverwritingExistingFile() { IdGeneratorImpl.createGenerator(_fs, IdGeneratorFile(), 0, false); IdGenerator idGenerator = new IdGeneratorImpl(_fs, IdGeneratorFile(), 1008, 1000, false, IdType.NODE, () => 0L); try { IdGeneratorImpl.createGenerator(_fs, IdGeneratorFile(), 0, true); } finally { CloseIdGenerator(idGenerator); // verify that id generator is ok StoreChannel fileChannel = _fs.open(IdGeneratorFile(), OpenMode.READ_WRITE); ByteBuffer buffer = ByteBuffer.allocate(9); fileChannel.ReadAll(buffer); buffer.flip(); assertEquals(( sbyte )0, buffer.get()); assertEquals(0L, buffer.Long); buffer.flip(); int readCount = fileChannel.read(buffer); if (readCount != -1 && readCount != 0) { fail("Id generator header not ok read 9 + " + readCount + " bytes from file"); } fileChannel.close(); File file = IdGeneratorFile(); if (file.exists()) { assertTrue(file.delete()); } } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private static ByteBuffer readLong(org.neo4j.io.fs.StoreChannel readChannel) throws java.io.IOException private static ByteBuffer ReadLong(StoreChannel readChannel) { ByteBuffer readBuffer = allocate(8); readChannel.ReadAll(readBuffer); readBuffer.flip(); return(readBuffer); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private String readFailure(java.io.File failureFile) throws java.io.IOException private string ReadFailure(File failureFile) { using (StoreChannel channel = _fs.open(failureFile, OpenMode.READ)) { sbyte[] data = new sbyte[( int )channel.size()]; channel.ReadAll(ByteBuffer.wrap(data)); return(UTF8.decode(WithoutZeros(data))); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private boolean isFailed(java.io.File failureFile) throws java.io.IOException private bool IsFailed(File failureFile) { using (StoreChannel channel = _fs.open(failureFile, OpenMode.READ)) { sbyte[] data = new sbyte[( int )channel.size()]; channel.ReadAll(ByteBuffer.wrap(data)); channel.close(); return(!AllZero(data)); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private ByteBuffer readFile(java.io.File file) throws java.io.IOException private ByteBuffer ReadFile(File file) { using (StoreChannel channel = FileSystemRule.get().open(file, OpenMode.READ)) { ByteBuffer buffer = ByteBuffer.allocate(( int )channel.size()); channel.ReadAll(buffer); buffer.flip(); return(buffer); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void createShouldClearExistingFile() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void CreateShouldClearExistingFile() { // given sbyte[] someBytes = FileWithContent(); // when Populator.create(); // then using (StoreChannel r = fs.open(IndexFile, OpenMode.READ)) { sbyte[] firstBytes = new sbyte[someBytes.Length]; r.ReadAll(ByteBuffer.wrap(firstBytes)); assertNotEquals("Expected previous file content to have been cleared but was still there", someBytes, firstBytes); } Populator.close(true); }
/// <summary> /// Store failure in failure file for index with the given id /// </summary> /// <param name="failure"> message describing the failure that needs to be stored </param> /// <exception cref="IOException"> if the failure could not be stored </exception> //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public synchronized void storeIndexFailure(String failure) throws java.io.IOException public virtual void StoreIndexFailure(string failure) { lock (this) { File failureFile = failureFile(); using (StoreChannel channel = _fs.open(failureFile, OpenMode.READ_WRITE)) { sbyte[] existingData = new sbyte[( int )channel.size()]; channel.ReadAll(ByteBuffer.wrap(existingData)); channel.Position(LengthOf(existingData)); sbyte[] data = UTF8.encode(failure); channel.WriteAll(ByteBuffer.wrap(data, 0, Math.Min(data.Length, MAX_FAILURE_SIZE))); channel.Force(true); channel.close(); } } }
private static void VerifyFileIsFullOfLongIntegerOnes(StoreChannel channel) { try { long claimedSize = channel.size(); ByteBuffer buffer = allocate(( int )claimedSize); channel.ReadAll(buffer); buffer.flip(); for (int position = 0; position < claimedSize; position += 8) { long value = buffer.getLong(position); assertEquals(1, value); } } catch (IOException e) { throw new Exception(e); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public void readAll(ByteBuffer dst) throws java.io.IOException public override void ReadAll(ByteBuffer dst) { @delegate.ReadAll(dst); }