Search in sources :

Example 6 with CompactFileState

use of org.smartdata.model.CompactFileState in project SSM by Intel-bigdata.

the class SmartFileSystem method getFileLinkStatus.

@Override
public FileStatus getFileLinkStatus(final Path f) throws IOException {
    FileStatus fileStatus = super.getFileLinkStatus(f);
    if (fileStatus.getLen() == 0) {
        Path target = getLinkTarget(f);
        FileState fileState = smartDFSClient.getFileState(getPathName(target));
        if (fileState instanceof CompactFileState) {
            fileStatus = getFileStatus(target);
        }
    } else {
        Path target = getLinkTarget(f);
        FileState fileState = smartDFSClient.getFileState(getPathName(target));
        if (fileState instanceof CompressionFileState) {
            fileStatus = getFileStatus(target);
        }
    }
    return fileStatus;
}
Also used : Path(org.apache.hadoop.fs.Path) CompactFileState(org.smartdata.model.CompactFileState) FileState(org.smartdata.model.FileState) CompressionFileState(org.smartdata.model.CompressionFileState) FileStatus(org.apache.hadoop.fs.FileStatus) LocatedFileStatus(org.apache.hadoop.fs.LocatedFileStatus) HdfsNamedFileStatus(org.apache.hadoop.hdfs.protocol.HdfsNamedFileStatus) HdfsFileStatus(org.apache.hadoop.hdfs.protocol.HdfsFileStatus) HdfsLocatedFileStatus(org.apache.hadoop.hdfs.protocol.HdfsLocatedFileStatus) CompressionFileState(org.smartdata.model.CompressionFileState) CompactFileState(org.smartdata.model.CompactFileState)

Example 7 with CompactFileState

use of org.smartdata.model.CompactFileState in project SSM by Intel-bigdata.

the class SmartFileSystem method getFileBlockLocations.

@Override
public BlockLocation[] getFileBlockLocations(Path p, final long start, final long len) throws IOException {
    BlockLocation[] blockLocations = super.getFileBlockLocations(p, start, len);
    if (blockLocations.length == 0) {
        FileState fileState = smartDFSClient.getFileState(getPathName(p));
        if (fileState instanceof CompactFileState) {
            FileContainerInfo fileContainerInfo = ((CompactFileState) fileState).getFileContainerInfo();
            String containerFile = fileContainerInfo.getContainerFilePath();
            long offset = fileContainerInfo.getOffset();
            blockLocations = super.getFileBlockLocations(new Path(containerFile), offset + start, len);
            for (BlockLocation blockLocation : blockLocations) {
                blockLocation.setOffset(blockLocation.getOffset() - offset);
            }
        }
    }
    return blockLocations;
}
Also used : Path(org.apache.hadoop.fs.Path) CompactFileState(org.smartdata.model.CompactFileState) FileState(org.smartdata.model.FileState) CompressionFileState(org.smartdata.model.CompressionFileState) BlockLocation(org.apache.hadoop.fs.BlockLocation) FileContainerInfo(org.smartdata.model.FileContainerInfo) CompactFileState(org.smartdata.model.CompactFileState)

Example 8 with CompactFileState

use of org.smartdata.model.CompactFileState in project SSM by Intel-bigdata.

the class SmartFileSystem method listStatus.

@Override
public FileStatus[] listStatus(Path p) throws IOException {
    FileStatus[] oldStatus = super.listStatus(p);
    ArrayList<FileStatus> newStatus = new ArrayList<>(oldStatus.length);
    for (FileStatus status : oldStatus) {
        if (oldStatus == null) {
            newStatus.add(null);
            continue;
        }
        if (status.getLen() == 0) {
            FileState fileState = smartDFSClient.getFileState(getPathName(status.getPath()));
            if (fileState instanceof CompactFileState) {
                long len = ((CompactFileState) fileState).getFileContainerInfo().getLength();
                newStatus.add(new FileStatus(len, status.isDirectory(), status.getReplication(), status.getBlockSize(), status.getModificationTime(), status.getAccessTime(), status.getPermission(), status.getOwner(), status.getGroup(), status.isSymlink() ? status.getSymlink() : null, status.getPath()));
            } else {
                newStatus.add(status);
            }
        } else {
            FileState fileState = smartDFSClient.getFileState(getPathName(status.getPath()));
            if (fileState instanceof CompressionFileState) {
                long len = ((CompressionFileState) fileState).getOriginalLength();
                newStatus.add(new FileStatus(len, status.isDirectory(), status.getReplication(), status.getBlockSize(), status.getModificationTime(), status.getAccessTime(), status.getPermission(), status.getOwner(), status.getGroup(), status.isSymlink() ? status.getSymlink() : null, status.getPath()));
            } else {
                newStatus.add(status);
            }
        }
    }
    return newStatus.toArray(new FileStatus[oldStatus.length]);
}
Also used : CompactFileState(org.smartdata.model.CompactFileState) FileState(org.smartdata.model.FileState) CompressionFileState(org.smartdata.model.CompressionFileState) FileStatus(org.apache.hadoop.fs.FileStatus) LocatedFileStatus(org.apache.hadoop.fs.LocatedFileStatus) HdfsNamedFileStatus(org.apache.hadoop.hdfs.protocol.HdfsNamedFileStatus) HdfsFileStatus(org.apache.hadoop.hdfs.protocol.HdfsFileStatus) HdfsLocatedFileStatus(org.apache.hadoop.hdfs.protocol.HdfsLocatedFileStatus) ArrayList(java.util.ArrayList) CompressionFileState(org.smartdata.model.CompressionFileState) CompactFileState(org.smartdata.model.CompactFileState)

Example 9 with CompactFileState

use of org.smartdata.model.CompactFileState in project SSM by Intel-bigdata.

the class SmartDFSClient method listCorruptFileBlocks.

@Override
public CorruptFileBlocks listCorruptFileBlocks(String path, String cookie) throws IOException {
    CorruptFileBlocks corruptFileBlocks = super.listCorruptFileBlocks(path, cookie);
    FileState fileState = getFileState(path);
    if (fileState instanceof CompactFileState) {
        corruptFileBlocks = super.listCorruptFileBlocks(((CompactFileState) fileState).getFileContainerInfo().getContainerFilePath(), cookie);
    }
    return corruptFileBlocks;
}
Also used : NormalFileState(org.smartdata.model.NormalFileState) CompactFileState(org.smartdata.model.CompactFileState) FileState(org.smartdata.model.FileState) CompressionFileState(org.smartdata.model.CompressionFileState) CorruptFileBlocks(org.apache.hadoop.hdfs.protocol.CorruptFileBlocks) CompactFileState(org.smartdata.model.CompactFileState)

Example 10 with CompactFileState

use of org.smartdata.model.CompactFileState in project SSM by Intel-bigdata.

the class SmartDFSClient method getBlockSize.

@Override
public long getBlockSize(String f) throws IOException {
    long blockSize = super.getBlockSize(f);
    FileState fileState = getFileState(f);
    if (fileState instanceof CompactFileState) {
        blockSize = super.getBlockSize(((CompactFileState) fileState).getFileContainerInfo().getContainerFilePath());
    }
    return blockSize;
}
Also used : NormalFileState(org.smartdata.model.NormalFileState) CompactFileState(org.smartdata.model.CompactFileState) FileState(org.smartdata.model.FileState) CompressionFileState(org.smartdata.model.CompressionFileState) CompactFileState(org.smartdata.model.CompactFileState)

Aggregations

CompactFileState (org.smartdata.model.CompactFileState)19 CompressionFileState (org.smartdata.model.CompressionFileState)15 FileState (org.smartdata.model.FileState)14 NormalFileState (org.smartdata.model.NormalFileState)8 ArrayList (java.util.ArrayList)5 Gson (com.google.gson.Gson)3 IOException (java.io.IOException)3 Path (org.apache.hadoop.fs.Path)3 HdfsFileStatus (org.apache.hadoop.hdfs.protocol.HdfsFileStatus)3 FileContainerInfo (org.smartdata.model.FileContainerInfo)3 TypeToken (com.google.gson.reflect.TypeToken)2 BlockLocation (org.apache.hadoop.fs.BlockLocation)2 FileStatus (org.apache.hadoop.fs.FileStatus)2 LocatedFileStatus (org.apache.hadoop.fs.LocatedFileStatus)2 HdfsLocatedFileStatus (org.apache.hadoop.hdfs.protocol.HdfsLocatedFileStatus)2 HdfsNamedFileStatus (org.apache.hadoop.hdfs.protocol.HdfsNamedFileStatus)2 LocatedBlocks (org.apache.hadoop.hdfs.protocol.LocatedBlocks)2 CompactFileStateProto (org.smartdata.protocol.ClientServerProto.CompactFileStateProto)2 CompressionFileStateProto (org.smartdata.protocol.ClientServerProto.CompressionFileStateProto)2 S3FileStateProto (org.smartdata.protocol.ClientServerProto.S3FileStateProto)2