Package org.apache.ignite.cdc
Interface CdcConsumer
-
public interface CdcConsumerConsumer of WAL data change events. This consumer will receive data change events duringCdcMainapplication invocation. The lifecycle of the consumer is the following:- Start of the consumer
start(MetricRegistry). - Notification of the consumer by the
onEvents(Iterator)call. - Stop of the consumer
stop().
IgniteLogger, please, use,LoggerResourceannotation:public class ChangeDataCaptureConsumer implements ChangeDataCaptureConsumer { @LoggerResource private IgniteLogger log; ... }Note, consumption of theCdcEventwill be started from the last saved offset. The offset of consumptions is saved on the disk every timeonEvents(Iterator)returnstrue. Note, order of notifications are following: Note,CdcConsumerreceive notifications on each running CDC application(node).- See Also:
CdcMain,CdcEvent,CacheEntryVersion
- Start of the consumer
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default booleanalive()Checks that consumer still alive.voidonCacheChange(Iterator<CdcCacheEvent> cacheEvents)Handles caches changes(create, edit) events.voidonCacheDestroy(Iterator<Integer> caches)Handles cache destroy events.booleanonEvents(Iterator<CdcEvent> events)Handles entry changes events.voidonMappings(Iterator<TypeMapping> mappings)Handles new mappings from type name to id.voidonTypes(Iterator<BinaryType> types)Handles new binary types.voidstart(MetricRegistry mreg)Starts the consumer.voidstop()Stops the consumer.
-
-
-
Method Detail
-
start
void start(MetricRegistry mreg)
Starts the consumer.- Parameters:
mreg- Metric registry for consumer specific metrics.
-
onEvents
boolean onEvents(Iterator<CdcEvent> events)
Handles entry changes events. If this method returntruethen current offset will be stored and ongoing notifications after CDC application fail/restart will be started from it.- Parameters:
events- Entry change events.- Returns:
Trueif current offset should be saved on the disk to continue from it in case any failures or restart.
-
onTypes
void onTypes(Iterator<BinaryType> types)
Handles new binary types. State of the types processing will be stored after method invocation and ongoing notifications after CDC application fail/restart will be continued for newly created/updates types. Note, unlikeonEvents(Iterator)this method MUST process all types or CDC will fail. Because, in time of invocationonEvents(Iterator)all changed types must be available on destionation.- Parameters:
types- Binary types iterator.- See Also:
IgniteBinary,IgniteBinary.type(int),IgniteBinary.type(Class),IgniteBinary.type(String),IgniteBinary.types()
-
onMappings
void onMappings(Iterator<TypeMapping> mappings)
Handles new mappings from type name to id. State of the types processing will be stored after method invocation and ongoing notifications after CDC application fail/restart will be continued for newly created/updates mappings.- Parameters:
mappings- Binary mapping iterator.- See Also:
IgniteBinary,IgniteBinary.typeId(String),BinaryIdMapper
-
onCacheChange
void onCacheChange(Iterator<CdcCacheEvent> cacheEvents)
Handles caches changes(create, edit) events. State of cache processing will be stored after method invocation and ongoing notifications after CDC application fail/restart will be continued for newly changed caches.- Parameters:
cacheEvents- Cache change events.- See Also:
Ignite.createCache(String),Ignite.getOrCreateCache(String),CdcCacheEvent
-
onCacheDestroy
void onCacheDestroy(Iterator<Integer> caches)
Handles cache destroy events. State of cache processing will be stored after method invocation and ongoing notifications after CDC application fail/restart will be continued for newly changed caches.- Parameters:
caches- Destroyed caches.- See Also:
Ignite.destroyCache(String),CdcCacheEvent,CacheView.cacheId()
-
stop
void stop()
Stops the consumer. This method can be invoked only afterstart(MetricRegistry).
-
alive
default 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.
-
-