Package org.apache.ignite.cdc
Interface CdcConsumer
-
public interface CdcConsumer
Consumer of WAL data change events. This consumer will receive data change events duringCdcMain
application 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,LoggerResource
annotation:public class ChangeDataCaptureConsumer implements ChangeDataCaptureConsumer { @LoggerResource private IgniteLogger log; ... }
Note, consumption of theCdcEvent
will 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,CdcConsumer
receive 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 boolean
alive()
Checks that consumer still alive.void
onCacheChange(Iterator<CdcCacheEvent> cacheEvents)
Handles caches changes(create, edit) events.void
onCacheDestroy(Iterator<Integer> caches)
Handles cache destroy events.boolean
onEvents(Iterator<CdcEvent> events)
Handles entry changes events.void
onMappings(Iterator<TypeMapping> mappings)
Handles new mappings from type name to id.void
onTypes(Iterator<BinaryType> types)
Handles new binary types.void
start(MetricRegistry mreg)
Starts the consumer.void
stop()
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 returntrue
then current offset will be stored and ongoing notifications after CDC application fail/restart will be started from it.- Parameters:
events
- Entry change events.- Returns:
True
if 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 determineCdcConsumer
errors in caseCdcEvent
is rare or source cluster is down.- Returns:
True
in case consumer alive,false
otherwise.
-
-