Package org.apache.ignite.internal.cdc
Class WalRecordsConsumer<K,V>
- java.lang.Object
-
- org.apache.ignite.internal.cdc.WalRecordsConsumer<K,V>
-
public class WalRecordsConsumer<K,V> extends Object
- See Also:
CdcMain,CdcConsumer
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classWalRecordsConsumer.DataEntryIteratorIterator overDataEntry.
-
Field Summary
Fields Modifier and Type Field Description static StringEVTS_CNTEvents count metric name.static StringLAST_EVT_TIMELast event time metric name.
-
Constructor Summary
Constructors Constructor Description WalRecordsConsumer(CdcConsumer consumer, IgniteLogger log)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanalive()Checks that consumer still alive.CdcConsumerconsumer()voidonCacheDestroyEvents(Iterator<Integer> caches)Handles destroy cache events.voidonCacheEvents(Iterator<CdcCacheEvent> cacheEvts)Handles new cache events.voidonMappings(Iterator<TypeMapping> mappings)Handles new mappings.booleanonRecords(Iterator<DataEntry> entries, IgniteClosure<DataEntry,CdcEvent> transform, @Nullable IgnitePredicate<? super DataEntry> filter)Handles data entries.voidonTypes(Iterator<BinaryType> types)Handles new binary types.voidstart(MetricRegistryImpl cdcReg, MetricRegistryImpl cdcConsumerReg)Starts the consumer.voidstop()Stops the consumer.StringtoString()
-
-
-
Field Detail
-
EVTS_CNT
public static final String EVTS_CNT
Events count metric name.- See Also:
- Constant Field Values
-
LAST_EVT_TIME
public static final String LAST_EVT_TIME
Last event time metric name.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
WalRecordsConsumer
public WalRecordsConsumer(CdcConsumer consumer, IgniteLogger log)
- Parameters:
consumer- User provided CDC consumer.log- Logger.
-
-
Method Detail
-
onRecords
public boolean onRecords(Iterator<DataEntry> entries, IgniteClosure<DataEntry,CdcEvent> transform, @Nullable @Nullable IgnitePredicate<? super DataEntry> filter)
Handles data entries. If this method returntruethen current offset in WAL andDataEntryindex insideDataRecordwill be stored and WAL iteration will be started from it on CDC application fail/restart.- Parameters:
entries- Data entries iterator.transform- Event transformer.filter- Optional event filter.- Returns:
Trueif current offset in WAL should be commited.
-
onTypes
public void onTypes(Iterator<BinaryType> types)
Handles new binary types.- Parameters:
types- Binary types iterator.
-
onMappings
public void onMappings(Iterator<TypeMapping> mappings)
Handles new mappings.- Parameters:
mappings- Mappings iterator.
-
onCacheEvents
public void onCacheEvents(Iterator<CdcCacheEvent> cacheEvts)
Handles new cache events.- Parameters:
cacheEvts- Cache events iterator.
-
onCacheDestroyEvents
public void onCacheDestroyEvents(Iterator<Integer> caches)
Handles destroy cache events.- Parameters:
caches- Destroyed cache iterator.
-
start
public void start(MetricRegistryImpl cdcReg, MetricRegistryImpl cdcConsumerReg) throws IgniteCheckedException
Starts the consumer.- Parameters:
cdcReg- CDC metric registry.cdcConsumerReg- CDC consumer metric registry.- Throws:
IgniteCheckedException- If failed.
-
stop
public void stop()
Stops the consumer. This methods can be invoked only afterstart(MetricRegistryImpl, MetricRegistryImpl).
-
alive
public boolean alive()
Checks that consumer still alive. This method helps to determineCdcConsumererrors in caseCdcEventis rare or source cluster is down.- Returns:
Truein case consumer alive,falseotherwise.
-
consumer
public CdcConsumer consumer()
- Returns:
- Change Data Capture Consumer.
-
-