Search in sources :

Example 1 with CrailBlockLocation

use of org.apache.crail.CrailBlockLocation in project incubator-crail by apache.

the class CrailHDFS method getFileBlockLocations.

@Override
public BlockLocation[] getFileBlockLocations(Path path, long start, long len) throws AccessControlException, FileNotFoundException, UnresolvedLinkException, IOException {
    try {
        CrailBlockLocation[] _locations = dfs.lookup(path.toUri().getRawPath()).get().asFile().getBlockLocations(start, len);
        BlockLocation[] locations = new BlockLocation[_locations.length];
        for (int i = 0; i < locations.length; i++) {
            locations[i] = new BlockLocation();
            locations[i].setOffset(_locations[i].getOffset());
            locations[i].setLength(_locations[i].getLength());
            locations[i].setNames(_locations[i].getNames());
            locations[i].setHosts(_locations[i].getHosts());
            locations[i].setTopologyPaths(_locations[i].getTopology());
        }
        return locations;
    } catch (Exception e) {
        throw new IOException(e);
    }
}
Also used : CrailBlockLocation(org.apache.crail.CrailBlockLocation) IOException(java.io.IOException) BlockLocation(org.apache.hadoop.fs.BlockLocation) CrailBlockLocation(org.apache.crail.CrailBlockLocation) URISyntaxException(java.net.URISyntaxException) UnresolvedLinkException(org.apache.hadoop.fs.UnresolvedLinkException) ParentNotDirectoryException(org.apache.hadoop.fs.ParentNotDirectoryException) FileAlreadyExistsException(org.apache.hadoop.fs.FileAlreadyExistsException) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) AccessControlException(org.apache.hadoop.security.AccessControlException) UnsupportedFileSystemException(org.apache.hadoop.fs.UnsupportedFileSystemException)

Example 2 with CrailBlockLocation

use of org.apache.crail.CrailBlockLocation in project incubator-crail by apache.

the class CrailFsck method getLocations.

public void getLocations(String filename, long offset, long length) throws Exception {
    System.out.println("getLocations, filename " + filename + ", offset " + offset + ", len " + length);
    CrailConfiguration conf = new CrailConfiguration();
    CrailStore fs = CrailStore.newInstance(conf);
    CrailBlockLocation[] locations = fs.lookup(filename).get().getBlockLocations(offset, length);
    for (int i = 0; i < locations.length; i++) {
        System.out.println("location " + i + " : " + locations[i].toString());
    }
    fs.close();
}
Also used : CrailBlockLocation(org.apache.crail.CrailBlockLocation) CrailStore(org.apache.crail.CrailStore) CrailConfiguration(org.apache.crail.conf.CrailConfiguration)

Example 3 with CrailBlockLocation

use of org.apache.crail.CrailBlockLocation in project incubator-crail by apache.

the class CrailHadoopFileSystem method getFileBlockLocations.

@Override
public BlockLocation[] getFileBlockLocations(FileStatus file, long start, long len) throws IOException {
    try {
        CrailBlockLocation[] _locations = dfs.lookup(file.getPath().toUri().getRawPath()).get().asFile().getBlockLocations(start, len);
        BlockLocation[] locations = new BlockLocation[_locations.length];
        for (int i = 0; i < locations.length; i++) {
            locations[i] = new BlockLocation();
            locations[i].setOffset(_locations[i].getOffset());
            locations[i].setLength(_locations[i].getLength());
            locations[i].setNames(_locations[i].getNames());
            locations[i].setHosts(_locations[i].getHosts());
            locations[i].setTopologyPaths(_locations[i].getTopology());
        }
        return locations;
    } catch (Exception e) {
        throw new IOException(e);
    }
}
Also used : CrailBlockLocation(org.apache.crail.CrailBlockLocation) IOException(java.io.IOException) BlockLocation(org.apache.hadoop.fs.BlockLocation) CrailBlockLocation(org.apache.crail.CrailBlockLocation) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException)

Example 4 with CrailBlockLocation

use of org.apache.crail.CrailBlockLocation in project incubator-crail by apache.

the class CrailHadoopFileSystem method getFileBlockLocations.

@Override
public BlockLocation[] getFileBlockLocations(Path path, long start, long len) throws IOException {
    try {
        CrailBlockLocation[] _locations = dfs.lookup(path.toUri().getRawPath()).get().asFile().getBlockLocations(start, len);
        BlockLocation[] locations = new BlockLocation[_locations.length];
        for (int i = 0; i < locations.length; i++) {
            locations[i] = new BlockLocation();
            locations[i].setOffset(_locations[i].getOffset());
            locations[i].setLength(_locations[i].getLength());
            locations[i].setNames(_locations[i].getNames());
            locations[i].setHosts(_locations[i].getHosts());
            locations[i].setTopologyPaths(_locations[i].getTopology());
        }
        return locations;
    } catch (Exception e) {
        throw new IOException(e);
    }
}
Also used : CrailBlockLocation(org.apache.crail.CrailBlockLocation) IOException(java.io.IOException) BlockLocation(org.apache.hadoop.fs.BlockLocation) CrailBlockLocation(org.apache.crail.CrailBlockLocation) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException)

Aggregations

CrailBlockLocation (org.apache.crail.CrailBlockLocation)4 FileNotFoundException (java.io.FileNotFoundException)3 IOException (java.io.IOException)3 BlockLocation (org.apache.hadoop.fs.BlockLocation)3 URISyntaxException (java.net.URISyntaxException)1 CrailStore (org.apache.crail.CrailStore)1 CrailConfiguration (org.apache.crail.conf.CrailConfiguration)1 FileAlreadyExistsException (org.apache.hadoop.fs.FileAlreadyExistsException)1 ParentNotDirectoryException (org.apache.hadoop.fs.ParentNotDirectoryException)1 UnresolvedLinkException (org.apache.hadoop.fs.UnresolvedLinkException)1 UnsupportedFileSystemException (org.apache.hadoop.fs.UnsupportedFileSystemException)1 AccessControlException (org.apache.hadoop.security.AccessControlException)1