org.apache.ignite.internal.processors.igfs

## Class IgfsImpl

- java.lang.Object
- - org.apache.ignite.internal.processors.igfs.IgfsImpl

All Implemented Interfaces:
  Igfs, IgniteFs, IgfsEx, IgniteAsyncSupport

    public final class IgfsImpl
    extends Object
    implements IgfsEx

Cache-based IGFS implementation.

### Field Summary

### Fields inherited from interface org.apache.ignite.IgniteFs

`IGFS_SCHEME, PROP_PREFER_LOCAL_WRITES`

### Fields inherited from interface org.apache.ignite.igfs.Igfs

`PROP_GROUP_NAME, PROP_PERMISSION, PROP_USER_NAME`

### Method Summary

Methods
`Collection<IgfsBlockLocation>` `affinity(IgfsPath path, long start, long len)` Gets affinity block locations for data blocks of the file, i.e. the nodes, on which the blocks are stored.
`Collection<IgfsBlockLocation>` `affinity(IgfsPath path, long start, long len, long maxLen)` Get affinity block locations for data blocks of the file.
`IgfsOutputStream` `append(IgfsPath path, boolean create)` Opens an output stream to an existing file for appending data.
`IgfsOutputStream` `append(IgfsPath path, int bufSize, boolean create, Map<String,String> props)` Opens an output stream to an existing file for appending data.
`IgniteInternalFuture<?>` `awaitDeletesAsync()` Asynchronously await for all entries existing in trash to be removed.
`String` `clientLogDirectory()` Gets client file system log directory.
`void` `clientLogDirectory(String logDir)` Sets client file system log directory.
`IgfsConfiguration` `configuration()` Gets IGFS configuration.
`IgfsContext` `context()`
`IgfsOutputStream` `create(IgfsPath path, boolean overwrite)` Creates a file and opens it for writing.
`IgfsOutputStream` `create(IgfsPath path, int bufSize, boolean overwrite, IgniteUuid affKey, int replication, long blockSize, Map<String,String> props)` Creates a file and opens it for writing.
`IgfsOutputStream` `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` `evictExclude(IgfsPath path, boolean primary)` Whether this path is excluded from evictions.
`<T,R> R` `execute(Class<? extends IgfsTask<T,R>> taskCls, IgfsRecordResolver rslvr, Collection<IgfsPath> paths, boolean skipNonExistentFiles, long maxRangeSize, T arg)` Executes IGFS task with overridden maximum range length (see `IgfsConfiguration.getMaximumTaskRangeLength()` for more information).
`<T,R> R` `execute(Class<? extends IgfsTask<T,R>> taskCls, IgfsRecordResolver rslvr, Collection<IgfsPath> paths, T arg)` Executes IGFS task.
`<T,R> R` `execute(IgfsTask<T,R> task, IgfsRecordResolver rslvr, Collection<IgfsPath> paths, boolean skipNonExistentFiles, long maxRangeLen, T arg)` Executes IGFS task with overridden maximum range length (see `IgfsConfiguration.getMaximumTaskRangeLength()` for more information).
`<T,R> R` `execute(IgfsTask<T,R> task, IgfsRecordResolver rslvr, Collection<IgfsPath> paths, T arg)` Executes IGFS task.
`boolean` `exists(IgfsPath path)` Checks if the specified path exists in the file system.
`void` `format()` Formats the file system removing all existing entries from it.
`<R> IgniteFuture<R>` `future()` Gets and resets future for previous asynchronous operation.
`Boolean` `globalSampling()` Get sampling state.
`void` `globalSampling(Boolean val)` Enables, disables or clears sampling flag.
`IgfsStatus` `globalSpace()` Gets global space counters.
`long` `groupBlockSize()` Gets group block size, i.e. block size multiplied by group size in affinity mapper.
`IgfsFile` `info(IgfsPath path)` Gets file information for the specified path.
`boolean` `isAsync()`
`boolean` `isProxy(URI path)` Check whether the given path is proxy path.
`Collection<IgfsFile>` `listFiles(IgfsPath path)` Lists files under the specified path.
`Collection<IgfsPath>` `listPaths(IgfsPath path)` Lists file paths under the specified path.
`IgfsLocalMetrics` `localMetrics()` Get local metrics.
`IgfsMetrics` `metrics()` Gets metrics snapshot for this file system.
`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.
`String` `name()` Gets IGFS name.
`IgniteUuid` `nextAffinityKey()` Get next affinity key.
`IgfsInputStreamAdapter` `open(IgfsPath path)` Opens a file for reading.
`IgfsInputStreamAdapter` `open(IgfsPath path, int bufSize)` Opens a file for reading.
`IgfsInputStreamAdapter` `open(IgfsPath path, int bufSize, int seqReadsBeforePrefetch)` Opens a file for reading.
`Map<String,String>` `properties()` Gets the implementation specific properties of file system.
`IgfsPaths` `proxyPaths()` Get handshake message.
`void` `rename(IgfsPath src, IgfsPath dest)` Renames/moves a file.
`void` `resetMetrics()` Resets metrics for this file system.
`void` `setTimes(IgfsPath path, long accessTime, long modificationTime)` Sets last access time and last modification time for a given path.
`long` `size(IgfsPath path)` Determines size of the file denoted by provided path.
`void` `stop()` Stops IGFS cleaning all used resources.
`IgfsPathSummary` `summary(IgfsPath path)` Gets summary (total number of files, total number of directories and total length) for a given path.
`IgfsFile` `update(IgfsPath path, Map<String,String> props)` Updates file information for the specified path.
`long` `usedSpaceSize()` Gets used space in bytes.
`IgniteFs` `withAsync()` Gets component with asynchronous mode enabled.

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

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

### Method Detail

#### stop

    public void stop()

Stops IGFS cleaning all used resources.

Specified by:
  `stop` in interface `IgfsEx`

#### context

    public IgfsContext context()

Specified by:
  `context` in interface `IgfsEx`
Returns:
  IGFS context.

#### name

    @Nullable
    public String name()

Gets IGFS name.

Specified by:
  `name` in interface `IgniteFs`
Returns:
  IGFS name, or `null` for default file system.

#### configuration

    public IgfsConfiguration configuration()

Gets IGFS configuration.

Specified by:
  `configuration` in interface `IgniteFs`
Returns:
  IGFS configuration.

#### proxyPaths

    public IgfsPaths proxyPaths()

Get handshake message.

Specified by:
  `proxyPaths` in interface `IgfsEx`
Returns:
  Handshake message.

#### clientLogDirectory

    public String clientLogDirectory()

Gets client file system log directory.

Specified by:
  `clientLogDirectory` in interface `IgfsEx`
Returns:
  Client file system log directory or `null` in case no client connections have been created yet.

#### clientLogDirectory

    public void clientLogDirectory(String logDir)

Sets client file system log directory.

Specified by:
  `clientLogDirectory` in interface `IgfsEx`
Parameters:
  `logDir` - Client file system log directory.

#### globalSpace

    public IgfsStatus globalSpace()
                           throws IgniteCheckedException

Gets global space counters.

Specified by:
  `globalSpace` in interface `IgfsEx`
Returns:
  Tuple in which first component is used space on all nodes, second is available space on all nodes.
Throws:
  `IgniteCheckedException` - If task execution failed.

#### globalSampling

    public void globalSampling(@Nullable
                      Boolean val)
                        throws IgniteCheckedException

Enables, disables or clears sampling flag.

Specified by:
  `globalSampling` in interface `IgfsEx`
Parameters:
  `val` - `True` to turn on sampling, `false` to turn it off, `null` to clear sampling state.
Throws:
  `IgniteCheckedException` - If failed.

#### globalSampling

    @Nullable
    public Boolean globalSampling()

Get sampling state.

Specified by:
  `globalSampling` in interface `IgfsEx`
Returns:
  `True` in case sampling is enabled, `false` otherwise, or `null` in case sampling flag is not set.

#### localMetrics

    public IgfsLocalMetrics localMetrics()

Get local metrics.

Specified by:
  `localMetrics` in interface `IgfsEx`
Returns:
  Local metrics.

#### groupBlockSize

    public long groupBlockSize()

Gets group block size, i.e. block size multiplied by group size in affinity mapper.

Specified by:
  `groupBlockSize` in interface `IgfsEx`
Returns:
  Group block size.

#### exists

    public boolean exists(IgfsPath path)

Checks if the specified path exists in the file system.

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

#### info

    public IgfsFile info(IgfsPath path)

Gets file information for the specified path.

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

#### summary

    public IgfsPathSummary summary(IgfsPath path)

Gets summary (total number of files, total number of directories and total length) for a given path.

Specified by:
  `summary` in interface `IgniteFs`
Parameters:
  `path` - Path to get information for.
Returns:
  Summary object.

#### update

    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 only the following properties will be propagated to the secondary file system:

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

Specified by:
  `update` in interface `Igfs`
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 `Igfs`
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 `Igfs`
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 `Igfs`
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 `Igfs`
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 `Igfs`
Parameters:
  `path` - Path to list files under.
Returns:
  List of files under the specified path.

#### listFiles

    public Collection<IgfsFile> listFiles(IgfsPath path)

Lists files under the specified path.

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

#### usedSpaceSize

    public long usedSpaceSize()

Gets used space in bytes.

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

#### properties

    public Map<String,String> properties()

Gets the implementation specific properties of file system.

Specified by:
  `properties` in interface `Igfs`
Returns:
  Map of properties.

#### open

    public IgfsInputStreamAdapter open(IgfsPath path)

Opens a file for reading.

Specified by:
  `open` in interface `IgniteFs`
Specified by:
  `open` in interface `IgfsEx`
Parameters:
  `path` - File path to read.
Returns:
  File input stream to read data from.

#### open

    public IgfsInputStreamAdapter open(IgfsPath path,
                              int bufSize)

Opens a file for reading.

Specified by:
  `open` in interface `Igfs`
Specified by:
  `open` in interface `IgniteFs`
Specified by:
  `open` in interface `IgfsEx`
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.

#### open

    public IgfsInputStreamAdapter open(IgfsPath path,
                              int bufSize,
                              int seqReadsBeforePrefetch)

Opens a file for reading.

Specified by:
  `open` in interface `IgniteFs`
Specified by:
  `open` in interface `IgfsEx`
Parameters:
  `path` - File path to read.
  `bufSize` - Read buffer size (bytes) or `zero` to use default value.
  `seqReadsBeforePrefetch` - Amount of sequential reads before prefetch is started.
Returns:
  File input stream to read data from.

#### create

    public IgfsOutputStream create(IgfsPath path,
                          boolean overwrite)

Creates a file and opens it for writing.

Specified by:
  `create` in interface `Igfs`
Specified by:
  `create` in interface `IgniteFs`
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 IgfsOutputStream 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 `Igfs`
Specified by:
  `create` in interface `IgniteFs`
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.

#### create

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

Creates a file and opens it for writing.

Specified by:
  `create` in interface `IgniteFs`
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.
  `affKey` - Affinity key used to store file blocks. If not `null`, the whole file will be stored on node where `affKey` resides.
  `replication` - Replication factor.
  `blockSize` - Block size.
  `props` - File properties to set.
Returns:
  File output stream to write data to.

#### append

    public IgfsOutputStream append(IgfsPath path,
                          boolean create)

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

Specified by:
  `append` in interface `IgniteFs`
Parameters:
  `path` - File path to append.
  `create` - Create file if it doesn't exist yet.
Returns:
  File output stream to append data to.

#### append

    public IgfsOutputStream 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 `Igfs`
Specified by:
  `append` in interface `IgniteFs`
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.

#### setTimes

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

Sets last access time and last modification time for a given path. If argument is `null`, corresponding time will not be changed.

Specified by:
  `setTimes` in interface `IgniteFs`
Parameters:
  `path` - Path to update.
  `accessTime` - Optional last access time to set. Value `-1` does not update access time.
  `modificationTime` - Optional last modification time to set. Value `-1` does not update modification time.

#### affinity

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

Gets affinity block locations for data blocks of the file, i.e. the nodes, on which the blocks are stored.

Specified by:
  `affinity` in interface `IgniteFs`
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.
Returns:
  Affinity block locations.

#### affinity

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

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 `IgniteFs`
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.

#### metrics

    public IgfsMetrics metrics()

Gets metrics snapshot for this file system.

Specified by:
  `metrics` in interface `IgniteFs`
Returns:
  Metrics.

#### resetMetrics

    public void resetMetrics()

Resets metrics for this file system.

Specified by:
  `resetMetrics` in interface `IgniteFs`

#### size

    public long size(IgfsPath path)

Determines size of the file denoted by provided path. In case if path is a directory, then total size of all containing entries will be calculated recursively.

Specified by:
  `size` in interface `IgniteFs`
Parameters:
  `path` - File system path.
Returns:
  Total size.

#### format

    public void format()

Formats the file system removing all existing entries from it.

Supports asynchronous execution (see `IgniteAsyncSupport`).

Specified by:
  `format` in interface `IgniteFs`

#### awaitDeletesAsync

    public IgniteInternalFuture<?> awaitDeletesAsync()
                                              throws IgniteCheckedException

Asynchronously await for all entries existing in trash to be removed.

Specified by:
  `awaitDeletesAsync` in interface `IgfsEx`
Returns:
  Future which will be completed when all entries existed in trash by the time of invocation are removed.
Throws:
  `IgniteCheckedException` - If failed.

#### execute

    public <T,R> R execute(IgfsTask<T,R> task,
                  @Nullable
                  IgfsRecordResolver rslvr,
                  Collection<IgfsPath> paths,
                  @Nullable
                  T arg)

Executes IGFS task.

Supports asynchronous execution (see `IgniteAsyncSupport`).

Specified by:
  `execute` in interface `IgniteFs`
Parameters:
  `task` - Task to execute.
  `rslvr` - Optional resolver to control split boundaries.
  `paths` - Collection of paths to be processed within this task.
  `arg` - Optional task argument.
Returns:
  Task result.

#### execute

    public <T,R> R execute(IgfsTask<T,R> task,
                  @Nullable
                  IgfsRecordResolver rslvr,
                  Collection<IgfsPath> paths,
                  boolean skipNonExistentFiles,
                  long maxRangeLen,
                  @Nullable
                  T arg)

Executes IGFS task with overridden maximum range length (see `IgfsConfiguration.getMaximumTaskRangeLength()` for more information).

Supports asynchronous execution (see `IgniteAsyncSupport`).

Specified by:
  `execute` in interface `IgniteFs`
Parameters:
  `task` - Task to execute.
  `rslvr` - Optional resolver to control split boundaries.
  `paths` - Collection of paths to be processed within this task.
  `skipNonExistentFiles` - Whether to skip non existent files. If set to `true` non-existent files will be ignored. Otherwise an exception will be thrown.
  `maxRangeLen` - Optional maximum range length. If `0`, then by default all consecutive IGFS blocks will be included.
  `arg` - Optional task argument.
Returns:
  Task result.

#### execute

    public <T,R> R execute(Class<? extends IgfsTask<T,R>> taskCls,
                  @Nullable
                  IgfsRecordResolver rslvr,
                  Collection<IgfsPath> paths,
                  @Nullable
                  T arg)

Executes IGFS task.

Supports asynchronous execution (see `IgniteAsyncSupport`).

Specified by:
  `execute` in interface `IgniteFs`
Parameters:
  `taskCls` - Task class to execute.
  `rslvr` - Optional resolver to control split boundaries.
  `paths` - Collection of paths to be processed within this task.
  `arg` - Optional task argument.
Returns:
  Task result.

#### execute

    public <T,R> R execute(Class<? extends IgfsTask<T,R>> taskCls,
                  @Nullable
                  IgfsRecordResolver rslvr,
                  Collection<IgfsPath> paths,
                  boolean skipNonExistentFiles,
                  long maxRangeSize,
                  @Nullable
                  T arg)

Executes IGFS task with overridden maximum range length (see `IgfsConfiguration.getMaximumTaskRangeLength()` for more information).

Supports asynchronous execution (see `IgniteAsyncSupport`).

Specified by:
  `execute` in interface `IgniteFs`
Parameters:
  `taskCls` - Task class to execute.
  `rslvr` - Optional resolver to control split boundaries.
  `paths` - Collection of paths to be processed within this task.
  `skipNonExistentFiles` - Whether to skip non existent files. If set to `true` non-existent files will be ignored. Otherwise an exception will be thrown.
  `maxRangeSize` - Maximum range length.
  `arg` - Optional task argument.
Returns:
  Task result.

#### evictExclude

    public boolean evictExclude(IgfsPath path,
                       boolean primary)

Whether this path is excluded from evictions.

Specified by:
  `evictExclude` in interface `IgfsEx`
Parameters:
  `path` - Path.
  `primary` - Whether the mode is PRIMARY.
Returns:
  `True` if path is excluded from evictions.

#### withAsync

    public IgniteFs withAsync()

Gets component with asynchronous mode enabled.

Specified by:
  `withAsync` in interface `IgniteFs`
Specified by:
  `withAsync` in interface `IgniteAsyncSupport`
Returns:
  Component with asynchronous mode enabled.

#### isAsync

    public boolean isAsync()

Specified by:
  `isAsync` in interface `IgniteAsyncSupport`
Returns:
  `True` if asynchronous mode is enabled.

#### future

    public <R> IgniteFuture<R> future()

Gets and resets future for previous asynchronous operation.

Specified by:
  `future` in interface `IgniteAsyncSupport`
Returns:
  Future for previous asynchronous operation.

#### nextAffinityKey

    public IgniteUuid nextAffinityKey()

Get next affinity key.

Specified by:
  `nextAffinityKey` in interface `IgfsEx`
Returns:
  Next affinity key.

#### isProxy

    public boolean isProxy(URI path)

Check whether the given path is proxy path.

Specified by:
  `isProxy` in interface `IgfsEx`
Parameters:
  `path` - Path.
Returns:
  `True` if proxy.

2015 Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Fabric | : ver. 1.0.0-RC1
Release Date | : February 17 2015