Skip to content

Commit

Permalink
Merge pull request neo4j#3618 from chrisvest/2.2-no-native-mmap
Browse files Browse the repository at this point in the history
Make the PageCache the only way to map files into memory.
  • Loading branch information
davidegrohmann committed Dec 5, 2014
2 parents 1983466 + 706f111 commit bba3395
Show file tree
Hide file tree
Showing 9 changed files with 11 additions and 78 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,8 @@

import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.MappedByteBuffer;
import java.nio.channels.FileChannel;
import java.nio.channels.FileLock;

import org.neo4j.io.fs.StoreChannel;

public class AbstractStoreChannel implements StoreChannel
{
@Override
Expand All @@ -53,12 +49,6 @@ public void writeAll( ByteBuffer src ) throws IOException
throw new UnsupportedOperationException();
}

@Override
public MappedByteBuffer map( FileChannel.MapMode mode, long position, long size ) throws IOException
{
throw new UnsupportedOperationException();
}

@Override
public int read( ByteBuffer dst, long position ) throws IOException
{
Expand Down
4 changes: 0 additions & 4 deletions community/io/src/main/java/org/neo4j/io/fs/StoreChannel.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@

import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.MappedByteBuffer;
import java.nio.channels.FileChannel;
import java.nio.channels.FileLock;
import java.nio.channels.GatheringByteChannel;
import java.nio.channels.InterruptibleChannel;
Expand Down Expand Up @@ -58,8 +56,6 @@ public interface StoreChannel
*/
void writeAll( ByteBuffer src ) throws IOException;

MappedByteBuffer map( FileChannel.MapMode mode, long position, long size ) throws IOException;

/**
* @see java.nio.channels.FileChannel#read(java.nio.ByteBuffer, long)
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.MappedByteBuffer;
import java.nio.channels.FileChannel;
import java.nio.channels.FileLock;

Expand Down Expand Up @@ -51,12 +50,6 @@ public int write( ByteBuffer src, long position ) throws IOException
return channel.write( src, position );
}

@Override
public MappedByteBuffer map( FileChannel.MapMode mode, long position, long size ) throws IOException
{
return channel.map( mode, position, size );
}

@Override
public long write( ByteBuffer[] srcs, int offset, int length ) throws IOException
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@

import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.MappedByteBuffer;
import java.nio.channels.FileChannel;
import java.nio.channels.FileLock;

import org.neo4j.adversaries.Adversary;
Expand Down Expand Up @@ -68,13 +66,6 @@ public void writeAll( ByteBuffer src ) throws IOException
delegate.writeAll( src );
}

@Override
public MappedByteBuffer map( FileChannel.MapMode mode, long position, long size ) throws IOException
{
adversary.injectFailure( IOException.class );
return delegate.map( mode, position, size );
}

@Override
public long write( ByteBuffer[] srcs, int offset, int length ) throws IOException
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@

import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.MappedByteBuffer;
import java.nio.channels.FileChannel;
import java.nio.channels.FileLock;

import org.neo4j.io.fs.StoreChannel;
Expand Down Expand Up @@ -61,11 +59,6 @@ public void writeAll( ByteBuffer src, long position ) throws IOException
delegate.writeAll( src, position );
}

public MappedByteBuffer map( FileChannel.MapMode mode, long position, long size ) throws IOException
{
return delegate.map( mode, position, size );
}

public StoreChannel truncate( long size ) throws IOException
{
delegate.truncate( size );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@

import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.MappedByteBuffer;
import java.nio.channels.FileChannel;
import java.nio.channels.FileLock;

import org.neo4j.io.fs.StoreChannel;
Expand Down Expand Up @@ -139,12 +137,6 @@ public void writeAll( ByteBuffer src ) throws IOException
inner.writeAll( src );
}

@Override
public MappedByteBuffer map( FileChannel.MapMode mapMode, long l, long l1 ) throws IOException
{
return inner.map( mapMode, l, l1 );
}

@Override
public boolean isOpen()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,29 +19,29 @@
*/
package org.neo4j.io.fs;

import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;

import java.io.File;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.ClosedByInterruptException;
import java.nio.channels.ClosedChannelException;
import java.nio.channels.FileChannel;
import java.util.Arrays;

import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.neo4j.function.Factory;
import org.neo4j.graphdb.mockfs.EphemeralFileSystemAbstraction;
import org.neo4j.test.TargetDirectory;

import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

@RunWith( Parameterized.class )
public class FileSystemAbstractionInterruptionTest
{
Expand Down Expand Up @@ -192,12 +192,6 @@ public void ch_write_ByteBuffer_position() throws IOException
chan( true ).write( ByteBuffer.allocate( 1 ), 1 );
}

@Test(expected = ClosedByInterruptException.class)
public void ch_map() throws IOException
{
chan( true ).map( FileChannel.MapMode.READ_ONLY, 0, 10 );
}

@Test(expected = ClosedByInterruptException.class)
public void ch_read_ByteBuffer() throws IOException
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@

import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.MappedByteBuffer;
import java.nio.channels.FileChannel;
import java.nio.channels.FileLock;

import org.neo4j.io.fs.StoreChannel;
Expand Down Expand Up @@ -68,12 +66,6 @@ public void writeAll( ByteBuffer src ) throws IOException
delegateChannel.writeAll( src );
}

@Override
public MappedByteBuffer map( FileChannel.MapMode mode, long position, long size ) throws IOException
{
throw new UnsupportedOperationException( "Not needed" );
}

@Override
public int read( ByteBuffer dst, long position ) throws IOException
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
import java.io.File;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.MappedByteBuffer;
import java.nio.channels.FileChannel;
import java.nio.channels.FileLock;

import org.neo4j.io.fs.StoreChannel;
Expand Down Expand Up @@ -152,12 +150,6 @@ public int write( ByteBuffer byteBuffer, long l ) throws IOException
return writtenInThisCall;
}

@Override
public MappedByteBuffer map( FileChannel.MapMode mode, long position, long size ) throws IOException
{
return inner.map( mode, position, size );
}

@Override
public boolean isOpen()
{
Expand Down

0 comments on commit bba3395

Please sign in to comment.