org.apache.ignite.internal.cdc

## Class CdcConsumerState

- java.lang.Object
- - org.apache.ignite.internal.cdc.CdcConsumerState

    public class CdcConsumerState
    extends Object

Change Data Capture Consumer state. Each time `CdcConsumer.onEvents(Iterator)` returns `true` current offset in WAL segment and `DataEntry` index inside `DataRecord` saved to file. This allows to the `CdcConsumer` to continue consumption of the `CdcEvent` from the last saved offset in case of fail or restart.

See Also:
  `CdcConsumer.onEvents(Iterator)`, `CdcMain`

### Field Summary

Fields
`static String` `CACHES_STATE_FILE_NAME`
`static String` `CDC_MODE_FILE_NAME` The file stores state of CDC mode.
`static String` `MAPPINGS_STATE_FILE_NAME`
`static String` `TYPES_STATE_FILE_NAME`
`static String` `WAL_STATE_FILE_NAME`

### Constructor Summary

Constructors
Constructor and Description
`CdcConsumerState(IgniteLogger log, Path stateDir)`

### Method Summary

All Methods Instance Methods Concrete Methods
`Map<Integer,Long>` `loadCaches()` Loads CDC caches state from file.
`CdcMode` `loadCdcMode()` Loads CDC mode state from file.
`Set<T2<Integer,Byte>>` `loadMappingsState()` Loads types mappings state from file.
`Map<Integer,Long>` `loadTypesState()` Loads CDC types state from file.
`T2<WALPointer,Integer>` `loadWalState()` Loads CDC consumer state from file.
`void` `saveCaches(Map<Integer,Long> cachesState)` Saves caches state to file.
`void` `saveCdcMode(CdcMode mode)` Saves CDC mode state to file.
`void` `saveMappings(Set<T2<Integer,Byte>> mappingsState)` Saves types mappings state to file.
`void` `saveTypes(Map<Integer,Long> typesState)` Saves binary types state to file.
`void` `saveWal(T2<WALPointer,Integer> state)` Saves WAL consumption state to file.

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

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

### Field Detail

#### WAL_STATE_FILE_NAME

    public static final String WAL_STATE_FILE_NAME

See Also:
  Constant Field Values

#### TYPES_STATE_FILE_NAME

    public static final String TYPES_STATE_FILE_NAME

See Also:
  Constant Field Values

#### MAPPINGS_STATE_FILE_NAME

    public static final String MAPPINGS_STATE_FILE_NAME

See Also:
  Constant Field Values

#### CACHES_STATE_FILE_NAME

    public static final String CACHES_STATE_FILE_NAME

See Also:
  Constant Field Values

#### CDC_MODE_FILE_NAME

    public static final String CDC_MODE_FILE_NAME

The file stores state of CDC mode. Content of the file is a `CdcMode` value:

- `CdcMode.CDC_UTILITY_ACTIVE` means that `CdcMain` utility captures data.
- `CdcMode.IGNITE_NODE_ACTIVE` means that `CdcManager` captures data within Ignite node.

See Also:
  Constant Field Values

### Constructor Detail

#### CdcConsumerState

    public CdcConsumerState(IgniteLogger log,
                            Path stateDir)

Parameters:
  `stateDir` - State directory.

### Method Detail

#### saveWal

    public void saveWal(T2<WALPointer,Integer> state)
                 throws IOException

Saves WAL consumption state to file.

Parameters:
  `state` - WAL pointer and index of `DataEntry` inside `DataRecord`.
Throws:
  `IOException`

#### saveTypes

    public void saveTypes(Map<Integer,Long> typesState)
                   throws IOException

Saves binary types state to file.

Parameters:
  `typesState` - State of types.
Throws:
  `IOException`

#### saveMappings

    public void saveMappings(Set<T2<Integer,Byte>> mappingsState)
                      throws IOException

Saves types mappings state to file.

Parameters:
  `mappingsState` - Mappings state.
Throws:
  `IOException`

#### loadWalState

    public T2<WALPointer,Integer> loadWalState()

Loads CDC consumer state from file.

Returns:
  Saved state.

#### loadCaches

    public Map<Integer,Long> loadCaches()

Loads CDC caches state from file.

Returns:
  Saved state.

#### saveCaches

    public void saveCaches(Map<Integer,Long> cachesState)
                    throws IOException

Saves caches state to file.

Parameters:
  `cachesState` - State of caches.
Throws:
  `IOException`

#### loadMappingsState

    public Set<T2<Integer,Byte>> loadMappingsState()

Loads types mappings state from file.

Returns:
  Saved state.

#### loadTypesState

    public Map<Integer,Long> loadTypesState()

Loads CDC types state from file.

Returns:
  Saved state.

#### loadCdcMode

    public CdcMode loadCdcMode()

Loads CDC mode state from file.

Returns:
  CDC mode state.

#### saveCdcMode

    public void saveCdcMode(CdcMode mode)
                     throws IOException

Saves CDC mode state to file.

Parameters:
  `mode` - CDC mode.
Throws:
  `IOException`

${current.year} Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Database and Caching Platform | : ver. 2.16.0
Release Date | : December 15 2023