Skip to content

Commit

Permalink
mirror changes from hdfs2
Browse files Browse the repository at this point in the history
  • Loading branch information
chrislusf committed Jul 30, 2020
1 parent a6d0f96 commit 703057b
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package seaweed.hdfs;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.*;
import org.apache.hadoop.fs.permission.AclEntry;
import org.apache.hadoop.fs.permission.AclStatus;
import org.apache.hadoop.fs.permission.FsPermission;
import org.apache.hadoop.security.AccessControlException;
import org.apache.hadoop.security.UserGroupInformation;
import org.apache.hadoop.util.Progressable;
import org.slf4j.Logger;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package seaweed.hdfs;

import org.apache.hadoop.fs.PositionedReadable;
import org.apache.hadoop.fs.Seekable;

import java.io.BufferedInputStream;
import java.io.FilterInputStream;
import java.io.IOException;
import java.io.InputStream;

class BufferedSeaweedInputStream extends FilterInputStream implements Seekable, PositionedReadable {

SeaweedInputStream t;

protected BufferedSeaweedInputStream(InputStream in, int bufferSize) {
super(new BufferedInputStream(in, bufferSize));
t = (SeaweedInputStream)in;
}

@Override
public int read(long position, byte[] buffer, int offset, int length) throws IOException {
return this.t.read(position,buffer,offset,length);
}

@Override
public void readFully(long position, byte[] buffer, int offset, int length) throws IOException {
this.t.readFully(position,buffer,offset,length);
}

@Override
public void readFully(long position, byte[] buffer) throws IOException {
this.t.readFully(position,buffer);
}

@Override
public void seek(long pos) throws IOException {
this.t.seek(pos);
}

@Override
public long getPos() throws IOException {
return this.t.getPos();
}

@Override
public boolean seekToNewSource(long targetPos) throws IOException {
return this.t.seekToNewSource(targetPos);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public FSDataInputStream open(Path path, int bufferSize) throws IOException {

try {
InputStream inputStream = seaweedFileSystemStore.openFileForRead(path, statistics, bufferSize);
return new FSDataInputStream(inputStream);
return new FSDataInputStream(new BufferedSeaweedInputStream(inputStream, 16 * 1024 * 1024));
} catch (Exception ex) {
LOG.warn("open path: {} bufferSize:{}", path, bufferSize, ex);
return null;
Expand Down

0 comments on commit 703057b

Please sign in to comment.