org.apache.ignite.internal.processors.igfs

## Class IgfsDataManager

- java.lang.Object
- - org.apache.ignite.internal.processors.igfs.IgfsManager
  - - org.apache.ignite.internal.processors.igfs.IgfsDataManager

    public class IgfsDataManager
    extends IgfsManager

Cache based file's data container.

### Field Summary

### Fields inherited from class org.apache.ignite.internal.processors.igfs.IgfsManager

`igfsCtx, log`

### Constructor Summary

Constructors
Constructor and Description
`IgfsDataManager()`

### Method Summary

Methods
`Collection<IgfsBlockLocation>` `affinity(IgfsFileInfo info, long start, long len)` Resolve affinity nodes for specified part of file.
`Collection<IgfsBlockLocation>` `affinity(IgfsFileInfo info, long start, long len, long maxLen)` Resolve affinity nodes for specified part of file.
`ClusterNode` `affinityNode(Object affinityKey)` Maps affinity key to node.
`IgfsBlockKey` `blockKey(long blockIdx, IgfsFileInfo fileInfo)`
`void` `cleanBlocks(IgfsFileInfo fileInfo, IgfsFileAffinityRange range, boolean cleanNonColocated)` Tries to remove blocks affected by fragmentizer.
`IgniteInternalFuture<byte[]>` `dataBlock(IgfsFileInfo fileInfo, IgfsPath path, long blockIdx, IgfsSecondaryFileSystemPositionedReadable secReader)` Get data block for specified file ID and block index.
`IgniteInternalFuture<Object>` `delete(IgfsFileInfo fileInfo)` Delete file's data from data cache.
`long` `groupBlockSize()` Gets group block size (block size * group size).
`List<Long>` `listLocalDataBlocks(IgfsFileInfo fileInfo)` Get list of local data blocks of the given file.
`long` `maxSpaceSize()`
`IgniteUuid` `nextAffinityKey(IgniteUuid prevAffKey)` Generates next affinity key for local node based on current topology.
`protected void` `onKernalStart0()`
`protected void` `onKernalStop0(boolean cancel)`
`long` `spaceSize()`
`void` `spreadBlocks(IgfsFileInfo fileInfo, IgfsFileAffinityRange range)` Moves all colocated blocks in range to non-colocated keys.
`protected void` `start0()` Start manager implementation.
`byte[]` `storeDataBlocks(IgfsFileInfo fileInfo, long reservedLen, byte[] remainder, int remainderLen, ByteBuffer data, boolean flush, IgfsFileAffinityRange affinityRange, IgfsFileWorkerBatch batch)` Store data blocks in file.
`byte[]` `storeDataBlocks(IgfsFileInfo fileInfo, long reservedLen, byte[] remainder, int remainderLen, DataInput in, int len, boolean flush, IgfsFileAffinityRange affinityRange, IgfsFileWorkerBatch batch)` Store data blocks in file.
`void` `writeClose(IgfsFileInfo fileInfo)` Notifies data manager that no further writes will be performed on stream.
`IgniteInternalFuture<Boolean>` `writeStart(IgfsFileInfo fileInfo)` Registers write future in igfs data manager.

### Methods inherited from class org.apache.ignite.internal.processors.igfs.IgfsManager

`kernalStartInfo, kernalStopInfo, onKernalStart, onKernalStop, start, startInfo, stop, stop0, stopInfo`

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

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

### Constructor Detail

#### IgfsDataManager

    public IgfsDataManager()

### Method Detail

#### start0

    protected void start0()
                   throws IgniteCheckedException

Start manager implementation.

Overrides:
  `start0` in class `IgfsManager`
Throws:
  `IgniteCheckedException`

#### onKernalStart0

    protected void onKernalStart0()
                           throws IgniteCheckedException

Overrides:
  `onKernalStart0` in class `IgfsManager`
Throws:
  `IgniteCheckedException` - If failed.

#### onKernalStop0

    protected void onKernalStop0(boolean cancel)

Overrides:
  `onKernalStop0` in class `IgfsManager`

#### spaceSize

    public long spaceSize()

Returns:
  Number of bytes used to store files.

#### maxSpaceSize

    public long maxSpaceSize()

Returns:
  Maximum number of bytes for IGFS data cache.

#### nextAffinityKey

    public IgniteUuid nextAffinityKey(@Nullable
                             IgniteUuid prevAffKey)

Generates next affinity key for local node based on current topology. If previous affinity key maps on local node, return previous affinity key to prevent unnecessary file map growth.

Parameters:
  `prevAffKey` - Affinity key of previous block.
Returns:
  Affinity key.

#### affinityNode

    public ClusterNode affinityNode(Object affinityKey)

Maps affinity key to node.

Parameters:
  `affinityKey` - Affinity key to map.
Returns:
  Primary node for this key.

#### listLocalDataBlocks

    public List<Long> listLocalDataBlocks(IgfsFileInfo fileInfo)
                                   throws IgniteCheckedException

Get list of local data blocks of the given file.

Parameters:
  `fileInfo` - File info.
Returns:
  List of local data block indices.
Throws:
  `IgniteCheckedException` - If failed.

#### dataBlock

    @Nullable
    public IgniteInternalFuture<byte[]> dataBlock(IgfsFileInfo fileInfo,
                                                  IgfsPath path,
                                                  long blockIdx,
                                                  @Nullable
                                                  IgfsSecondaryFileSystemPositionedReadable secReader)
                                           throws IgniteCheckedException

Get data block for specified file ID and block index.

Parameters:
  `fileInfo` - File info.
  `path` - Path reading from.
  `blockIdx` - Block index.
  `secReader` - Optional secondary file system reader.
Returns:
  Requested data block or `null` if nothing found.
Throws:
  `IgniteCheckedException` - If failed.

#### writeStart

    public IgniteInternalFuture<Boolean> writeStart(IgfsFileInfo fileInfo)

Registers write future in igfs data manager.

Parameters:
  `fileInfo` - File info of file opened to write.
Returns:
  Future that will be completed when all ack messages are received or when write failed.

#### writeClose

    public void writeClose(IgfsFileInfo fileInfo)

Notifies data manager that no further writes will be performed on stream.

Parameters:
  `fileInfo` - File info being written.

#### storeDataBlocks

    @Nullable
    public byte[] storeDataBlocks(IgfsFileInfo fileInfo,
                                  long reservedLen,
                                  @Nullable
                                  byte[] remainder,
                                  int remainderLen,
                                  ByteBuffer data,
                                  boolean flush,
                                  IgfsFileAffinityRange affinityRange,
                                  @Nullable
                                  IgfsFileWorkerBatch batch)
                           throws IgniteCheckedException

Store data blocks in file.
Note! If file concurrently deleted we'll get lost blocks.

Parameters:
  `fileInfo` - File info.
  `reservedLen` - Reserved length.
  `remainder` - Remainder.
  `remainderLen` - Remainder length.
  `data` - Data to store.
  `flush` - Flush flag.
  `affinityRange` - Affinity range to update if file write can be colocated.
  `batch` - Optional secondary file system worker batch.
Returns:
  Remainder if data did not fill full block.
Throws:
  `IgniteCheckedException` - If failed.

#### storeDataBlocks

    @Nullable
    public byte[] storeDataBlocks(IgfsFileInfo fileInfo,
                                  long reservedLen,
                                  @Nullable
                                  byte[] remainder,
                                  int remainderLen,
                                  DataInput in,
                                  int len,
                                  boolean flush,
                                  IgfsFileAffinityRange affinityRange,
                                  @Nullable
                                  IgfsFileWorkerBatch batch)
                           throws IgniteCheckedException,
                                  IOException

Store data blocks in file.
Note! If file concurrently deleted we'll got lost blocks.

Parameters:
  `fileInfo` - File info.
  `reservedLen` - Reserved length.
  `remainder` - Remainder.
  `remainderLen` - Remainder length.
  `in` - Data to store.
  `len` - Data length to store.
  `flush` - Flush flag.
  `affinityRange` - File affinity range to update if file cal be colocated.
  `batch` - Optional secondary file system worker batch.
Returns:
  Remainder of data that did not fit the block if `flush` flag is `false`.
Throws:
  `IgniteCheckedException` - If failed.
  `IOException` - If store failed.

#### delete

    public IgniteInternalFuture<Object> delete(IgfsFileInfo fileInfo)

Delete file's data from data cache.

Parameters:
  `fileInfo` - File details to remove data for.
Returns:
  Delete future that will be completed when file is actually erased.

#### blockKey

    public IgfsBlockKey blockKey(long blockIdx,
                        IgfsFileInfo fileInfo)

Parameters:
  `blockIdx` - Block index.
  `fileInfo` - File info.
Returns:
  Block key.

#### cleanBlocks

    public void cleanBlocks(IgfsFileInfo fileInfo,
                   IgfsFileAffinityRange range,
                   boolean cleanNonColocated)

Tries to remove blocks affected by fragmentizer. If `cleanNonColocated` is `true`, will remove non-colocated blocks as well.

Parameters:
  `fileInfo` - File info to clean up.
  `range` - Range to clean up.
  `cleanNonColocated` - `True` if all blocks should be cleaned.

#### spreadBlocks

    public void spreadBlocks(IgfsFileInfo fileInfo,
                    IgfsFileAffinityRange range)

Moves all colocated blocks in range to non-colocated keys.

Parameters:
  `fileInfo` - File info to move data for.
  `range` - Range to move.

#### affinity

    public Collection<IgfsBlockLocation> affinity(IgfsFileInfo info,
                                         long start,
                                         long len)
                                           throws IgniteCheckedException

Resolve affinity nodes for specified part of file.

Parameters:
  `info` - File info to resolve affinity nodes for.
  `start` - Start position in the file.
  `len` - File part length to get affinity for.
Returns:
  Affinity blocks locations.
Throws:
  `IgniteCheckedException` - If failed.

#### affinity

    public Collection<IgfsBlockLocation> affinity(IgfsFileInfo info,
                                         long start,
                                         long len,
                                         long maxLen)
                                           throws IgniteCheckedException

Resolve affinity nodes for specified part of file.

Parameters:
  `info` - File info to resolve affinity nodes for.
  `start` - Start position in the file.
  `len` - File part length to get affinity for.
  `maxLen` - Maximum block length.
Returns:
  Affinity blocks locations.
Throws:
  `IgniteCheckedException` - If failed.

#### groupBlockSize

    public long groupBlockSize()

Gets group block size (block size * group size).

Returns:
  Group block size.

2015 Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Fabric | : ver. 1.2.0-incubating
Release Date | : June 16 2015