Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IGNITE-13581 Capture Data Change implementation #8909

Merged
merged 160 commits into from
Jun 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
160 commits
Select commit Hold shift + click to select a range
fd5118a
IGNITE-14360 Refactor FileLockHolder for reusage
nizhikov Mar 20, 2021
229e666
IGNITE-13596 Flag to distinguish DataRecord on primary and backup added.
nizhikov Jan 27, 2021
4c1d9b4
IGNITE-13596 Flag to distinguish DataRecord on primary and backup added.
nizhikov Jan 27, 2021
23484a8
IGNITE-13581 Capture Data Change implementation.
nizhikov Jan 27, 2021
ad41707
IGNITE-13581 CDC Implementation
nizhikov Mar 20, 2021
d05fb92
IGNITE-13581 CDC Implementation
nizhikov Mar 20, 2021
a9b7812
IGNITE-13581 CDC Implementation
nizhikov Mar 20, 2021
44e68ef
IGNITE-13581 Code review fixes.
nizhikov Mar 21, 2021
59cef3b
IGNITE-13581 Mark new configuration properties with the @IgniteExperi…
nizhikov Mar 21, 2021
cd25780
IGNITE-13581 Code review fixes.
nizhikov Mar 22, 2021
6a2461d
Merge branch 'ignite-cdc' into IGNITE-13581
nizhikov Mar 23, 2021
5e423c2
IGNITE-13581 Code review fixes.
nizhikov Mar 23, 2021
228bfef
IGNITE-13581 Code review fixes.
nizhikov Mar 23, 2021
ce391b6
IGNITE-13581 Usage of built-in WalIterator filter
nizhikov Mar 23, 2021
e0d32f2
IGNITE-14353 Ability to specify postfix for IgniteLogger instead of n…
nizhikov Mar 23, 2021
702f923
IGNITE-14353 Ability to specify postfix for IgniteLogger instead of n…
nizhikov Mar 23, 2021
da84342
IGNITE-14353 Ability to specify postfix for IgniteLogger instead of n…
nizhikov Mar 23, 2021
0e50b61
IGNITE-14353 Ability to specify postfix for IgniteLogger instead of n…
nizhikov Mar 23, 2021
b70b9bd
Merge branch 'IGNITE-14353' into IGNITE-13581
nizhikov Mar 23, 2021
642bc8a
IGNITE-13581 Usage of logger file postfix
nizhikov Mar 23, 2021
7e09976
IGNITE-13581 Usage of logger file postfix
nizhikov Mar 23, 2021
5ee86ab
Merge branch 'IGNITE-14353' into IGNITE-13581
nizhikov Mar 23, 2021
055bb30
IGNITE-13581 Usage of logger file postfix
nizhikov Mar 25, 2021
cbbe16b
IGNITE-13581 CDC configuration introduced.
nizhikov Mar 25, 2021
3d42ff1
IGNITE-13581 CDC configuration introduced.
nizhikov Mar 25, 2021
1dcbb02
IGNITE-13581 CDC id removed
nizhikov Mar 25, 2021
13a7302
Merge branch 'ignite-cdc' into IGNITE-13581
nizhikov Mar 25, 2021
4928a1a
IGNITE-13581 code review fixes.
nizhikov Mar 26, 2021
cc25b42
IGNITE-13581 code review fixes.
nizhikov Mar 26, 2021
d841284
Merge branch 'ignite-cdc' into IGNITE-13581
nizhikov Mar 26, 2021
25ad196
Merge branch 'ignite-cdc' into IGNITE-13581
nizhikov Mar 26, 2021
697384f
IGNITE-13581 Reusage of Ignite node lock mechanism
nizhikov Mar 30, 2021
7dda359
IGNITE-14435 Tests fix
nizhikov Mar 30, 2021
9d9a55e
Merge branch 'ignite-cdc' into IGNITE-13581
nizhikov Mar 31, 2021
a413cab
IGNITE-13581 code style fix.
nizhikov Mar 31, 2021
18c96c5
IGNITE-13581 code review fix.
nizhikov Mar 31, 2021
a984df0
IGNITE-13581 code review fix.
nizhikov Mar 31, 2021
d0d593f
IGNITE-13581 revert unnecessary changes.
nizhikov Mar 31, 2021
1c02afd
IGNITE-13581 revert unnecessary changes.
nizhikov Mar 31, 2021
6fc984e
IGNITE-13581 minor refactoring.
nizhikov Mar 31, 2021
4095981
IGNITE-13581 minor refactoring.
nizhikov Mar 31, 2021
81ad577
Merge branch 'ignite-cdc' into IGNITE-13581
nizhikov Apr 1, 2021
741d6a1
Merge branch 'ignite-cdc' into IGNITE-13581
nizhikov Apr 1, 2021
1a5b3e3
IGNITE-13581 stop impl.
nizhikov Apr 2, 2021
e63bc51
IGNITE-13581 stop impl.
nizhikov Apr 2, 2021
875eb3f
IGNITE-13581 generics removed.
nizhikov Apr 2, 2021
15c921c
IGNITE-13581 tests update.
nizhikov Apr 2, 2021
9c3a9fe
IGNITE-13581 tests update.
nizhikov Apr 2, 2021
b829cf3
IGNITE-13581 tests update.
nizhikov Apr 5, 2021
289e622
IGNITE-13581 tests update.
nizhikov Apr 6, 2021
02a233e
IGNITE-13581 tests update.
nizhikov Apr 7, 2021
19a8719
IGNITE-13581 tests update.
nizhikov Apr 7, 2021
de17023
IGNITE-13581 tests update.
nizhikov Apr 9, 2021
d0540ee
IGNITE-13581 tests update.
nizhikov Apr 10, 2021
6adfc51
IGNITE-13581 tests update.
nizhikov Apr 12, 2021
3ec791e
Bug reproducer
nizhikov Apr 12, 2021
8448173
IGNITE-14516 Always log to not archived segment
nizhikov Apr 12, 2021
7c50bd4
IGNITE-14516 Always log to not archived segment
nizhikov Apr 12, 2021
3815d11
IGNITE-14516 Always log to not archived segment
nizhikov Apr 12, 2021
341e15d
IGNITE-14516 Always log to not archived segment
nizhikov Apr 12, 2021
ce617ed
IGNITE-14516 Always log to not archived segment
nizhikov Apr 12, 2021
d870aea
IGNITE-14516 Always log to not archived segment
nizhikov Apr 13, 2021
3931cc5
Merge branch 'ignite-cdc' into IGNITE-13581
nizhikov Apr 13, 2021
b74df48
Merge branch 'IGNITE-14516' into IGNITE-13581
nizhikov Apr 13, 2021
fd39933
IGNITE-13581 tests update.
nizhikov Apr 13, 2021
483903c
IGNITE-13581 tests update.
nizhikov Apr 13, 2021
9f28650
Merge branch 'IGNITE-14516' into IGNITE-13581
nizhikov Apr 13, 2021
bce81a4
IGNITE-13581 tests update.
nizhikov Apr 14, 2021
92171a2
IGNITE-14516 review fix.
nizhikov Apr 14, 2021
d6c3688
IGNITE-14516 review fix.
nizhikov Apr 14, 2021
c90f933
IGNITE-14516 review fix.
nizhikov Apr 14, 2021
c076e09
Merge branch 'IGNITE-14516' into IGNITE-13581
nizhikov Apr 14, 2021
4d95157
IGNITE-14516 review fix.
nizhikov Apr 14, 2021
1d7aa66
IGNITE-14516 review fix.
nizhikov Apr 14, 2021
dace359
IGNITE-14516 review fix.
nizhikov Apr 14, 2021
e61ff1d
Merge branch 'master' into IGNITE-14516
nizhikov Apr 14, 2021
5970187
IGNITE-14516 review fix.
nizhikov Apr 14, 2021
46b8f1d
IGNITE-14516 review fix.
nizhikov Apr 14, 2021
393d620
IGNITE-14516 review fix.
nizhikov Apr 14, 2021
718f5fb
IGNITE-14516 review fix.
nizhikov Apr 14, 2021
f44e3e1
IGNITE-14516 review fix.
nizhikov Apr 15, 2021
e347942
IGNITE-14516 review fix.
nizhikov Apr 15, 2021
295571d
IGNITE-14516 review fix.
nizhikov Apr 15, 2021
61fce8c
IGNITE-14516 review fix.
nizhikov Apr 15, 2021
35fbad5
Merge branch 'IGNITE-14516' into IGNITE-13581
nizhikov Apr 15, 2021
bbc0963
IGNITE-14516 review fix.
nizhikov Apr 15, 2021
1d26d31
IGNITE-14516 review fix.
nizhikov Apr 15, 2021
f1d5237
IGNITE-14516 review fix.
nizhikov Apr 15, 2021
a9df687
Merge branch 'IGNITE-14516' into IGNITE-13581
nizhikov Apr 15, 2021
76cb3be
IGNITE-14516 review fix.
nizhikov Apr 15, 2021
9bf4704
IGNITE-14516 review fix.
nizhikov Apr 16, 2021
0511d35
Merge branch 'master' into IGNITE-13581
nizhikov Apr 20, 2021
cc0c032
IGNITE-14509 Minor fix.
nizhikov Apr 21, 2021
a92b312
IGNITE-13581 Code review fixes
nizhikov Apr 28, 2021
8d21a13
Merge branch 'master' into IGNITE-13581
nizhikov Apr 28, 2021
485fddb
Merge branch 'ignite-cdc' into IGNITE-13581
nizhikov Apr 28, 2021
f922c02
IGNITE-13581 Code review fixes
nizhikov Apr 28, 2021
e03336c
IGNITE-13581 Code review fixes
nizhikov Apr 28, 2021
6fb1dc4
IGNITE-13581 Code review fixes
nizhikov Apr 28, 2021
de0bb63
Merge branch 'master' into IGNITE-13581
nizhikov May 10, 2021
453ce3a
Merge branch 'ignite-cdc' into IGNITE-13581
nizhikov May 14, 2021
868231c
IGNITE-13581 Update
nizhikov May 14, 2021
084f5d6
IGNITE-13581 Update
nizhikov May 14, 2021
d068513
Merge branch 'ignite-cdc' into IGNITE-13581
nizhikov May 14, 2021
630f52a
IGNITE-14353 Ability to specify application name for IgniteLogger
nizhikov May 17, 2021
21c3064
Merge branch 'ignite-cdc' into IGNITE-13581
nizhikov May 17, 2021
6d1eff2
Merge branch 'IGNITE-14353-fix' into IGNITE-13581
nizhikov May 17, 2021
1190906
IGNITE-13581 Update
nizhikov May 18, 2021
e678a39
IGNITE-13581 Update
nizhikov May 18, 2021
cd02d8d
IGNITE-13581 Update
nizhikov May 18, 2021
a7391d5
IGNITE-13581 Update
nizhikov May 18, 2021
ed036d0
Merge branch 'ignite-cdc' into IGNITE-13581
nizhikov May 20, 2021
e062ba6
IGNITE-13581 Code review fixes.
nizhikov May 20, 2021
c2eac49
IGNITE-13581 Code review fixes.
nizhikov May 20, 2021
08ab360
IGNITE-13581 Code review fixes.
nizhikov May 21, 2021
6b3ecaf
IGNITE-13581 Code review fixes.
nizhikov May 21, 2021
6b9034f
IGNITE-13581 Code review fixes.
nizhikov May 21, 2021
6c7557b
IGNITE-13581 Code review fixes.
nizhikov May 21, 2021
1b94a63
IGNITE-13581 Code review fixes.
nizhikov May 21, 2021
8edd0d4
IGNITE-13581 Code review fixes.
nizhikov May 22, 2021
d49b521
IGNITE-13581 Code review fixes.
nizhikov May 22, 2021
e71f075
IGNITE-13581 Code review fixes.
nizhikov May 24, 2021
1fa9585
IGNITE-13581 Code review fixes.
nizhikov May 24, 2021
3f17e58
Merge branch 'master' into IGNITE-13581
nizhikov May 25, 2021
c635575
IGNITE-13581 Code review fixes.
nizhikov May 26, 2021
4e100aa
Merge branch 'ignite-cdc' into IGNITE-13581
nizhikov May 26, 2021
7bafeac
IGNITE-13581 Code review fixes.
nizhikov May 26, 2021
31a2fb9
IGNITE-13581 Code review fixes.
nizhikov May 26, 2021
0346f4c
IGNITE-13581 Code review fixes.
nizhikov May 26, 2021
8adbcc3
IGNITE-13581 Code review fixes.
nizhikov May 27, 2021
74e7df0
IGNITE-13581 Code review fixes.
nizhikov May 27, 2021
66a4f74
Merge branch 'master' of https://github.com/apache/ignite into IGNITE…
nizhikov May 27, 2021
91574e2
IGNITE-13581 Code review fixes.
nizhikov May 28, 2021
ec9b3d3
IGNITE-13581 Code review fixes.
nizhikov May 28, 2021
cd68a23
IGNITE-13581 Code review fixes.
nizhikov May 28, 2021
48f1158
IGNITE-13581 Code review fixes.
nizhikov Jun 1, 2021
3868d91
IGNITE-13581 Code review fixes.
nizhikov Jun 1, 2021
53b16ea
IGNITE-13581 Code review fixes.
nizhikov Jun 1, 2021
fe86506
Merge branch 'ignite-cdc' into IGNITE-13581
nizhikov Jun 1, 2021
9ea41bf
IGNITE-13581 Code review fixes.
nizhikov Jun 1, 2021
e2ab584
IGNITE-13581 Code review fixes.
nizhikov Jun 1, 2021
c9b0c7e
IGNITE-13581 Code review fixes.
nizhikov Jun 2, 2021
20cd0e4
IGNITE-13581 Code review fixes.
nizhikov Jun 2, 2021
39b11eb
IGNITE-13581 Code review fixes.
nizhikov Jun 2, 2021
93b7044
IGNITE-13581 Code review fixes.
nizhikov Jun 3, 2021
a5939b5
IGNITE-13581 Code review fixes.
nizhikov Jun 3, 2021
bed071d
IGNITE-13581 Code review fixes.
nizhikov Jun 3, 2021
b596744
IGNITE-13581 Code review fixes.
nizhikov Jun 3, 2021
18870ac
IGNITE-13581 Code review fixes.
nizhikov Jun 3, 2021
892f323
IGNITE-13581 Code review fixes.
nizhikov Jun 3, 2021
8e980e4
IGNITE-13581 Code review fixes.
nizhikov Jun 3, 2021
9d6a5e2
IGNITE-13581: WIP
nizhikov Jun 4, 2021
d217d6d
IGNITE-13581: WIP
nizhikov Jun 4, 2021
f390a09
IGNITE-14742 WIP
nizhikov Jun 4, 2021
55fff84
IGNITE-13581: WIP
nizhikov Jun 4, 2021
1f34d7f
IGNITE-13581: Code review fixes.
nizhikov Jun 4, 2021
d692dcf
Merge branch 'ignite-cdc' into IGNITE-13581
nizhikov Jun 6, 2021
d05838c
IGNITE-14823: Initial implementation.
nizhikov Jun 7, 2021
f723205
IGNITE-13581: Code review fixes.
nizhikov Jun 7, 2021
208639c
IGNITE-13581: Code review fixes.
nizhikov Jun 7, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions bin/ignite-cdc.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env bash

#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

export MAIN_CLASS="org.apache.ignite.startup.cmdline.ChangeDataCaptureCommandLineStartup"

if [ "${IGNITE_HOME:-}" = "" ];
then IGNITE_HOME_TMP="$(dirname "$(cd "$(dirname "$0")"; "pwd")")";
else IGNITE_HOME_TMP=${IGNITE_HOME};
fi
nizhikov marked this conversation as resolved.
Show resolved Hide resolved

${IGNITE_HOME_TMP}/bin/ignite.sh "$@"
Mmuzaf marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.ignite.cache;

import java.io.Serializable;
import java.util.Map;
import org.apache.ignite.internal.processors.cache.CacheConflictResolutionManager;
import org.apache.ignite.internal.processors.cache.IgniteInternalCache;
import org.apache.ignite.internal.processors.cache.version.GridCacheVersionManager;
import org.apache.ignite.lang.IgniteExperimental;

/**
* Entry event order.
* Two concurrent updates of the same entry can be ordered based on {@link CacheEntryVersion} comparsion.
* Greater value means that event occurs later.
*
* @see CacheConflictResolutionManager
* @see GridCacheVersionManager#dataCenterId(byte)
*/
@IgniteExperimental
public interface CacheEntryVersion extends Comparable<CacheEntryVersion>, Serializable {
nizhikov marked this conversation as resolved.
Show resolved Hide resolved
/**
* Order of the update. Value is an incremental counter value. Scope of counter is node.
* @return Version order.
*/
public long order();

/** @return Node order on which this version was assigned. */
public int nodeOrder();
nizhikov marked this conversation as resolved.
Show resolved Hide resolved

/**
* Cluster id is a value to distinguish updates in case user wants to aggregate and sort updates from several
* Ignite clusters. {@code clusterId} id can be set for the node using
* {@link GridCacheVersionManager#dataCenterId(byte)}.
*
* @return Cluster id.
*/
public byte clusterId();

/** @return Topology version plus number of seconds from the start time of the first grid node. */
public int topologyVersion();

/**
* If source of the update is "local" cluster then {@code this} will be returned.
* If updated comes from the other cluster using {@link IgniteInternalCache#putAllConflict(Map)} then
* @return Replication version.
* @see IgniteInternalCache#putAllConflict(Map)
* @see IgniteInternalCache#removeAllConflict(Map)
*/
public CacheEntryVersion otherClusterVersion();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.ignite.cdc;

import org.apache.ignite.configuration.DataStorageConfiguration;
import org.apache.ignite.internal.cdc.ChangeDataCapture;
import org.apache.ignite.lang.IgniteExperimental;

/**
* This class defines {@link ChangeDataCapture} runtime configuration.
* Configuration is passed to {@link ChangeDataCapture} constructor.
*/
@IgniteExperimental
public class ChangeDataCaptureConfiguration {
/** */
private static final int DFLT_LOCK_TIMEOUT = 1000;

/** */
private static final long DFLT_CHECK_FREQ = 1000L;

/** */
private static final boolean DFLT_KEEP_BINARY = true;
nizhikov marked this conversation as resolved.
Show resolved Hide resolved

/** Change Data Capture consumer. */
private ChangeDataCaptureConsumer consumer;

/** Keep binary flag.<br>Default value {@code true}. */
private boolean keepBinary = DFLT_KEEP_BINARY;

/**
* {@link ChangeDataCapture} acquire file lock on startup to ensure exclusive consumption.
* This property specifies amount of time to wait for lock acquisition.<br>
* Default is {@code 1000 ms}.
*/
private long lockTimeout = DFLT_LOCK_TIMEOUT;

/**
* CDC application periodically scans {@link DataStorageConfiguration#getChangeDataCaptureWalPath()} folder to find new WAL segments.
* This frequency specify amount of time application sleeps between subsequent checks when no new files available.
* Default is {@code 1000 ms}.
*/
private long checkFreq = DFLT_CHECK_FREQ;

/** @return CDC consumer. */
public ChangeDataCaptureConsumer getConsumer() {
return consumer;
}

/** @param consumer CDC consumer. */
public void setConsumer(ChangeDataCaptureConsumer consumer) {
this.consumer = consumer;
}

/** @return keep binary value. */
public boolean isKeepBinary() {
return keepBinary;
}

/** @param keepBinary keep binary value. */
public void setKeepBinary(boolean keepBinary) {
this.keepBinary = keepBinary;
}

/** @return Amount of time to wait for lock acquisition. */
public long getLockTimeout() {
return lockTimeout;
}

/** @param lockTimeout Amount of time to wait for lock acquisition. */
public void setLockTimeout(long lockTimeout) {
this.lockTimeout = lockTimeout;
}

/** @return Amount of time application sleeps between subsequent checks when no new files available. */
public long getCheckFrequency() {
return checkFreq;
}

/**
* @param checkFreq Amount of time application sleeps between subsequent checks when no new
* files available.
*/
public void setCheckFrequency(long checkFreq) {
this.checkFreq = checkFreq;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.ignite.cdc;

import java.util.Iterator;
import org.apache.ignite.IgniteLogger;
import org.apache.ignite.cache.CacheEntryVersion;
import org.apache.ignite.internal.cdc.ChangeDataCapture;
import org.apache.ignite.lang.IgniteExperimental;
import org.apache.ignite.resources.LoggerResource;

/**
* Consumer of WAL data change events.
* This consumer will receive data change events during {@link ChangeDataCapture} application invocation.
* The lifecycle of the consumer is the following:
* <ul>
* <li>Start of the consumer {@link #start()}.</li>
* <li>Notification of the consumer by the {@link #onEvents(Iterator)} call.</li>
* <li>Stop of the consumer {@link #stop()}.</li>
* </ul>
*
* In case consumer implementation wants to user {@link IgniteLogger}, please, use, {@link LoggerResource} annotation:
* <pre> {@code
* public class ChangeDataCaptureConsumer implements ChangeDataCaptureConsumer {
* @LoggerReource
* private IgniteLogger log;
*
* ...
* }
* }</pre>
*
* Note, consumption of the {@link ChangeDataCaptureEvent} will be started from the last saved offset.
* The offset of consumptions is saved on the disk every time {@link #onEvents(Iterator)} returns {@code true}.
*
* @see ChangeDataCapture
* @see ChangeDataCaptureEvent
* @see CacheEntryVersion
*/
@IgniteExperimental
public interface ChangeDataCaptureConsumer {
/**
* Starts the consumer.
*/
public void start();

/**
* Handles entry changes events.
* If this method return {@code true} then current offset will be stored
* and ongoing notifications after CDC application fail/restart will be started from it.
*
* @param events Entry change events.
* @return {@code True} if current offset should be saved on the disk
* to continue from it in case any failures or restart.
*/
public boolean onEvents(Iterator<ChangeDataCaptureEvent> events);

/**
* Stops the consumer.
* This methods can be invoked only after {@link #start()}.
*/
public void stop();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.ignite.cdc;

import java.io.Serializable;
import org.apache.ignite.cache.CacheEntryVersion;
import org.apache.ignite.cache.affinity.Affinity;
import org.apache.ignite.internal.cdc.ChangeDataCapture;
import org.apache.ignite.lang.IgniteExperimental;
import org.apache.ignite.spi.systemview.view.CacheView;
import org.jetbrains.annotations.Nullable;

/**
* Event of single entry change.
* Instance presents new value of modified entry.
*
* @see ChangeDataCapture
* @see ChangeDataCaptureConsumer
*/
@IgniteExperimental
public interface ChangeDataCaptureEvent extends Serializable {
/**
* @return Key for the changed entry.
*/
public Object key();

/**
* @return Value for the changed entry or {@code null} in case of entry removal.
*/
@Nullable public Object value();

/**
* @return {@code True} if event fired on primary node for partition containing this entry.
* @see <a href="
* https://ignite.apache.org/docs/latest/configuring-caches/configuring-backups#configuring-partition-backups">
* Configuring partition backups.</a>
*/
public boolean primary();

/**
* Ignite split dataset into smaller chunks to distribute them across the cluster.
* {@link ChangeDataCaptureConsumer} implementations can use {@link #partition()} to split changes processing
* in the same way as it done for the cache.
*
* @return Partition number.
* @see Affinity#partition(Object)
* @see Affinity#partitions()
* @see <a href="https://ignite.apache.org/docs/latest/data-modeling/data-partitioning">Data partitioning</a>
* @see <a href="https://ignite.apache.org/docs/latest/data-modeling/affinity-collocation">Affinity collocation</a>
*/
public int partition();
nizhikov marked this conversation as resolved.
Show resolved Hide resolved

/**
* @return Version of the entry.
*/
public CacheEntryVersion version();

/**
* @return Cache ID.
* @see org.apache.ignite.internal.util.typedef.internal.CU#cacheId(String)
* @see CacheView#cacheId()
*/
public int cacheId();
}
Loading