org.apache.ignite.igfs.secondary.local

## Class LocalIgfsSecondaryFileSystem

- java.lang.Object
- - org.apache.ignite.igfs.secondary.local.LocalIgfsSecondaryFileSystem

All Implemented Interfaces:
  IgfsSecondaryFileSystem, LifecycleAware

    public class LocalIgfsSecondaryFileSystem
    extends Object
    implements IgfsSecondaryFileSystem, LifecycleAware

Secondary file system which delegates to local file system.

### Constructor Summary

Constructors
Constructor and Description
`LocalIgfsSecondaryFileSystem()`

### Method Summary

All Methods Instance Methods Concrete Methods
`Collection<IgfsBlockLocation>` `affinity(IgfsPath path, long start, long len, long maxLen)` Get affinity block locations for data blocks of the file.
`OutputStream` `append(IgfsPath path, int bufSize, boolean create, Map<String,String> props)` Opens an output stream to an existing file for appending data.
`OutputStream` `create(IgfsPath path, boolean overwrite)` Creates a file and opens it for writing.
`OutputStream` `create(IgfsPath path, int bufSize, boolean overwrite, int replication, long blockSize, Map<String,String> props)` Creates a file and opens it for writing.
`boolean` `delete(IgfsPath path, boolean recursive)` Deletes file.
`boolean` `exists(IgfsPath path)` Checks if the specified path exists.
`String` `getWorkDirectory()` Get work directory.
`IgfsFile` `info(IgfsPath path)` Gets file information for the specified path.
`Collection<IgfsFile>` `listFiles(IgfsPath path)` Lists files under the specified path.
`Collection<IgfsPath>` `listPaths(IgfsPath path)` Lists file paths under the specified path.
`void` `mkdirs(IgfsPath path)` Creates directories under specified path.
`void` `mkdirs(IgfsPath path, Map<String,String> props)` Creates directories under specified path with the specified properties.
`IgfsSecondaryFileSystemPositionedReadable` `open(IgfsPath path, int bufSize)` Opens a file for reading.
`void` `rename(IgfsPath src, IgfsPath dest)` Renames/moves a file.
`void` `setTimes(IgfsPath path, long modificationTime, long accessTime)` Set times for the given path.
`void` `setWorkDirectory(String workDir)` Set work directory.
`void` `start()` Starts grid component, called on grid start.
`void` `stop()` Stops grid component, called on grid shutdown.
`IgfsFile` `update(IgfsPath path, Map<String,String> props)` Updates file information for the specified path.
`long` `usedSpaceSize()` Gets used space in bytes.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### LocalIgfsSecondaryFileSystem

    public LocalIgfsSecondaryFileSystem()

### Method Detail

#### exists

    public boolean exists(IgfsPath path)

Checks if the specified path exists.

Specified by:
  `exists` in interface `IgfsSecondaryFileSystem`
Parameters:
  `path` - Path to check for existence.
Returns:
  `True` if such file exists, otherwise - `false`.

#### update

    @Nullable
    public IgfsFile update(IgfsPath path,
                                     Map<String,String> props)

Updates file information for the specified path. Existent properties, not listed in the passed collection, will not be affected. Other properties will be added or overwritten. Passed properties with `null` values will be removed from the stored properties or ignored if they don't exist in the file info.

When working in `DUAL_SYNC` or `DUAL_ASYNC` modes with Hadoop secondary file system only the following properties will be updated on the secondary file system:

- `usrName` - file owner name;
- `grpName` - file owner group;
- `permission` - Unix-style string representing file permissions.

Specified by:
  `update` in interface `IgfsSecondaryFileSystem`
Parameters:
  `path` - File path to set properties for.
  `props` - Properties to update.
Returns:
  File information for specified path or `null` if such path does not exist.

#### rename

    public void rename(IgfsPath src,
                       IgfsPath dest)

Renames/moves a file.

You are free to rename/move data files as you wish, but directories can be only renamed. You cannot move the directory between different parent directories.

Examples:

- "/work/file.txt" => "/home/project/Presentation Scenario.txt"
- "/work" => "/work-2012.bkp"
- "/work" => "/backups/work" - such operation is restricted for directories.

Specified by:
  `rename` in interface `IgfsSecondaryFileSystem`
Parameters:
  `src` - Source file path to rename.
  `dest` - Destination file path. If destination path is a directory, then source file will be placed into destination directory with original name.

#### delete

    public boolean delete(IgfsPath path,
                          boolean recursive)

Deletes file.

Specified by:
  `delete` in interface `IgfsSecondaryFileSystem`
Parameters:
  `path` - File path to delete.
  `recursive` - Delete non-empty directories recursively.
Returns:
  `True` in case of success, `false` otherwise.

#### mkdirs

    public void mkdirs(IgfsPath path)

Creates directories under specified path.

Specified by:
  `mkdirs` in interface `IgfsSecondaryFileSystem`
Parameters:
  `path` - Path of directories chain to create.

#### mkdirs

    public void mkdirs(IgfsPath path,
                       @Nullable
                       Map<String,String> props)

Creates directories under specified path with the specified properties.

Specified by:
  `mkdirs` in interface `IgfsSecondaryFileSystem`
Parameters:
  `path` - Path of directories chain to create.
  `props` - Metadata properties to set on created directories.

#### listPaths

    public Collection<IgfsPath> listPaths(IgfsPath path)

Lists file paths under the specified path.

Specified by:
  `listPaths` in interface `IgfsSecondaryFileSystem`
Parameters:
  `path` - Path to list files under.
Returns:
  List of paths under the specified path.

#### listFiles

    public Collection<IgfsFile> listFiles(IgfsPath path)

Lists files under the specified path.

Specified by:
  `listFiles` in interface `IgfsSecondaryFileSystem`
Parameters:
  `path` - Path to list files under.
Returns:
  List of files under the specified path.

#### open

    public IgfsSecondaryFileSystemPositionedReadable open(IgfsPath path,
                                                          int bufSize)

Opens a file for reading.

Specified by:
  `open` in interface `IgfsSecondaryFileSystem`
Parameters:
  `path` - File path to read.
  `bufSize` - Read buffer size (bytes) or `zero` to use default value.
Returns:
  File input stream to read data from.

#### create

    public OutputStream create(IgfsPath path,
                               boolean overwrite)

Creates a file and opens it for writing.

Specified by:
  `create` in interface `IgfsSecondaryFileSystem`
Parameters:
  `path` - File path to create.
  `overwrite` - Overwrite file if it already exists. Note: you cannot overwrite an existent directory.
Returns:
  File output stream to write data to.

#### create

    public OutputStream create(IgfsPath path,
                               int bufSize,
                               boolean overwrite,
                               int replication,
                               long blockSize,
                               @Nullable
                               Map<String,String> props)

Creates a file and opens it for writing.

Specified by:
  `create` in interface `IgfsSecondaryFileSystem`
Parameters:
  `path` - File path to create.
  `bufSize` - Write buffer size (bytes) or `zero` to use default value.
  `overwrite` - Overwrite file if it already exists. Note: you cannot overwrite an existent directory.
  `replication` - Replication factor.
  `blockSize` - Block size.
  `props` - File properties to set.
Returns:
  File output stream to write data to.

#### append

    public OutputStream append(IgfsPath path,
                               int bufSize,
                               boolean create,
                               @Nullable
                               Map<String,String> props)

Opens an output stream to an existing file for appending data.

Specified by:
  `append` in interface `IgfsSecondaryFileSystem`
Parameters:
  `path` - File path to append.
  `bufSize` - Write buffer size (bytes) or `zero` to use default value.
  `create` - Create file if it doesn't exist yet.
  `props` - File properties to set only in case it file was just created.
Returns:
  File output stream to append data to.

#### info

    public IgfsFile info(IgfsPath path)

Gets file information for the specified path.

Specified by:
  `info` in interface `IgfsSecondaryFileSystem`
Parameters:
  `path` - Path to get information for.
Returns:
  File information for specified path or `null` if such path does not exist.

#### usedSpaceSize

    public long usedSpaceSize()

Gets used space in bytes.

Specified by:
  `usedSpaceSize` in interface `IgfsSecondaryFileSystem`
Returns:
  Used space in bytes.

#### setTimes

    public void setTimes(IgfsPath path,
                         long modificationTime,
                         long accessTime)
                  throws IgniteException

Set times for the given path.

Specified by:
  `setTimes` in interface `IgfsSecondaryFileSystem`
Parameters:
  `path` - Path.
  `modificationTime` - Modification time.
  `accessTime` - Access time.
Throws:
  `IgniteException` - If failed.

#### start

    public void start()
               throws IgniteException

Starts grid component, called on grid start.

Specified by:
  `start` in interface `LifecycleAware`
Throws:
  `IgniteException` - If failed.

#### stop

    public void stop()
              throws IgniteException

Stops grid component, called on grid shutdown.

Specified by:
  `stop` in interface `LifecycleAware`
Throws:
  `IgniteException` - If failed.

#### affinity

    public Collection<IgfsBlockLocation> affinity(IgfsPath path,
                                                  long start,
                                                  long len,
                                                  long maxLen)
                                           throws IgniteException

Get affinity block locations for data blocks of the file. In case `maxLen` parameter is set and particular block location length is greater than this value, block locations will be split into smaller chunks.

Specified by:
  `affinity` in interface `IgfsSecondaryFileSystem`
Parameters:
  `path` - File path to get affinity for.
  `start` - Position in the file to start affinity resolution from.
  `len` - Size of data in the file to resolve affinity for.
  `maxLen` - Maximum length of a single returned block location length.
Returns:
  Affinity block locations.
Throws:
  `IgniteException` - In case of error.
  `IgfsPathNotFoundException` - If path doesn't exist.

#### getWorkDirectory

    @Nullable
    public String getWorkDirectory()

Get work directory.

Returns:
  Work directory.

#### setWorkDirectory

    public void setWorkDirectory(@Nullable
                                 String workDir)

Set work directory.

Parameters:
  `workDir` - Work directory.

2018 Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Fabric | : ver. 2.6.0
Release Date | : July 10 2018