Search in sources :

Example 16 with IgfsBlockLocation

use of org.apache.ignite.igfs.IgfsBlockLocation in project ignite by apache.

the class IgniteHadoopFileSystem method getFileBlockLocations.

/**
 * {@inheritDoc}
 */
@Override
public BlockLocation[] getFileBlockLocations(Path path, long start, long len) throws IOException {
    A.notNull(path, "path");
    IgfsPath igfsPath = convert(path);
    enterBusy();
    try {
        long now = System.currentTimeMillis();
        List<IgfsBlockLocation> affinity = new ArrayList<>(rmtClient.affinity(igfsPath, start, len));
        BlockLocation[] arr = new BlockLocation[affinity.size()];
        for (int i = 0; i < arr.length; i++) arr[i] = convert(affinity.get(i));
        if (LOG.isDebugEnabled())
            LOG.debug("Fetched file locations [path=" + path + ", fetchTime=" + (System.currentTimeMillis() - now) + ", locations=" + Arrays.asList(arr) + ']');
        return arr;
    } finally {
        leaveBusy();
    }
}
Also used : IgfsPath(org.apache.ignite.igfs.IgfsPath) ArrayList(java.util.ArrayList) IgfsBlockLocation(org.apache.ignite.igfs.IgfsBlockLocation) BlockLocation(org.apache.hadoop.fs.BlockLocation) IgfsBlockLocation(org.apache.ignite.igfs.IgfsBlockLocation) HadoopIgfsEndpoint(org.apache.ignite.internal.processors.hadoop.igfs.HadoopIgfsEndpoint)

Example 17 with IgfsBlockLocation

use of org.apache.ignite.igfs.IgfsBlockLocation in project ignite by apache.

the class IgniteHadoopFileSystem method getFileBlockLocations.

/**
 * {@inheritDoc}
 */
@Override
public BlockLocation[] getFileBlockLocations(FileStatus status, long start, long len) throws IOException {
    A.notNull(status, "status");
    enterBusy();
    try {
        IgfsPath path = convert(status.getPath());
        long now = System.currentTimeMillis();
        List<IgfsBlockLocation> affinity = new ArrayList<>(rmtClient.affinity(path, start, len));
        BlockLocation[] arr = new BlockLocation[affinity.size()];
        for (int i = 0; i < arr.length; i++) arr[i] = convert(affinity.get(i));
        if (LOG.isDebugEnabled())
            LOG.debug("Fetched file locations [path=" + path + ", fetchTime=" + (System.currentTimeMillis() - now) + ", locations=" + Arrays.asList(arr) + ']');
        return arr;
    } catch (FileNotFoundException ignored) {
        return EMPTY_BLOCK_LOCATIONS;
    } finally {
        leaveBusy();
    }
}
Also used : IgfsPath(org.apache.ignite.igfs.IgfsPath) ArrayList(java.util.ArrayList) FileNotFoundException(java.io.FileNotFoundException) IgfsBlockLocation(org.apache.ignite.igfs.IgfsBlockLocation) BlockLocation(org.apache.hadoop.fs.BlockLocation) IgfsBlockLocation(org.apache.ignite.igfs.IgfsBlockLocation)

Aggregations

IgfsBlockLocation (org.apache.ignite.igfs.IgfsBlockLocation)17 IgfsPath (org.apache.ignite.igfs.IgfsPath)10 ClusterNode (org.apache.ignite.cluster.ClusterNode)6 IgfsFile (org.apache.ignite.igfs.IgfsFile)6 ArrayList (java.util.ArrayList)3 UUID (java.util.UUID)3 IgniteFileSystem (org.apache.ignite.IgniteFileSystem)3 OutputStream (java.io.OutputStream)2 HashMap (java.util.HashMap)2 BlockLocation (org.apache.hadoop.fs.BlockLocation)2 FSDataOutputStream (org.apache.hadoop.fs.FSDataOutputStream)2 Path (org.apache.hadoop.fs.Path)2 IgniteException (org.apache.ignite.IgniteException)2 IgfsOutputStream (org.apache.ignite.igfs.IgfsOutputStream)2 HadoopIgfsEndpoint (org.apache.ignite.internal.processors.hadoop.igfs.HadoopIgfsEndpoint)2 IgniteUuid (org.apache.ignite.lang.IgniteUuid)2 Nullable (org.jetbrains.annotations.Nullable)2 File (java.io.File)1 FileNotFoundException (java.io.FileNotFoundException)1 FileOutputStream (java.io.FileOutputStream)1