46
46
import org .apache .ignite .internal .processors .cache .persistence .wal .WALPointer ;
47
47
import org .apache .ignite .internal .processors .cache .persistence .wal .reader .StandaloneGridKernalContext ;
48
48
import org .apache .ignite .internal .processors .metric .MetricRegistry ;
49
+ import org .apache .ignite .internal .util .lang .RunnableX ;
49
50
import org .apache .ignite .internal .util .typedef .T2 ;
50
51
import org .apache .ignite .plugin .AbstractTestPluginProvider ;
51
52
import org .apache .ignite .plugin .PluginContext ;
@@ -119,7 +120,7 @@ public class CdcIgniteNodeActiveModeTest extends AbstractCdcTest {
119
120
120
121
/** */
121
122
@ Test
122
- public void testCdcMetricsIgniteNodeActiveMode () throws Exception {
123
+ public void testCdcMetrics () throws Exception {
123
124
awaitCdcModeValue (CdcMode .IGNITE_NODE_ACTIVE );
124
125
125
126
IgniteCache <Integer , User > cache = ign .cache (DEFAULT_CACHE_NAME );
@@ -157,25 +158,7 @@ public void testSwitchToCdcUtilityActiveMode() throws Exception {
157
158
158
159
/** */
159
160
@ Test
160
- public void testCdcModeWritesByIgniteNodeOnly () throws Exception {
161
- writeCdcManagerStopCdcRecord ();
162
-
163
- rollSegment ();
164
-
165
- awaitCdcModeValue (CdcMode .CDC_UTILITY_ACTIVE );
166
-
167
- cdcMainFut .cancel ();
168
-
169
- cdcMain = createCdc (new UserCdcConsumer (), ign .configuration ());
170
-
171
- cdcMainFut = runAsync (cdcMain );
172
-
173
- awaitCdcModeValue (CdcMode .IGNITE_NODE_ACTIVE );
174
- }
175
-
176
- /** */
177
- @ Test
178
- public void testSwitchToPreviousSegment () throws Exception {
161
+ public void testSkipsNodeCommittedData () throws Exception {
179
162
List <Integer > expUsers = new ArrayList <>();
180
163
181
164
addData (0 , 1 , null );
@@ -207,7 +190,7 @@ public void testSwitchToPreviousSegment() throws Exception {
207
190
208
191
/** */
209
192
@ Test
210
- public void testCleanOldWals () throws Exception {
193
+ public void testCleanWalsAfterCdcManagerRecord () throws Exception {
211
194
checkCdcSegmentsExists (0 , -1 ); // No segments stored in CDC dir.
212
195
213
196
rollSegment ();
@@ -240,20 +223,13 @@ public void testCleanOldWals() throws Exception {
240
223
241
224
/** */
242
225
@ Test
243
- public void testIteratorSimple () throws Exception {
244
- checkIterator (false );
245
- }
246
-
247
- /** */
248
- @ Test
249
- public void testIteratorWithCdcRestart () throws Exception {
250
- checkIterator (true );
251
- }
226
+ public void testRestoreModeOnRestart () throws Exception {
227
+ RunnableX restartUtil = () -> {
228
+ cdcMainFut .cancel ();
229
+ cdcMain = createCdc (cnsmr , getConfiguration (getTestIgniteInstanceName ()));
230
+ cdcMainFut = runAsync (cdcMain );
231
+ };
252
232
253
- /**
254
- * @param restartCdc Restart cdc.
255
- */
256
- private void checkIterator (boolean restartCdc ) throws Exception {
257
233
List <Integer > expUsers = new ArrayList <>();
258
234
259
235
addData (0 , 1 , null );
@@ -262,13 +238,7 @@ private void checkIterator(boolean restartCdc) throws Exception {
262
238
263
239
addData (2 , 3 , null );
264
240
265
- if (restartCdc ) {
266
- cdcMainFut .cancel ();
267
-
268
- cdcMain = createCdc (cnsmr , getConfiguration (getTestIgniteInstanceName ()));
269
-
270
- cdcMainFut = runAsync (cdcMain );
271
- }
241
+ restartUtil .run ();
272
242
273
243
rollSegment ();
274
244
@@ -279,6 +249,8 @@ private void checkIterator(boolean restartCdc) throws Exception {
279
249
280
250
rollSegment ();
281
251
252
+ restartUtil .run ();
253
+
282
254
awaitCdcModeValue (CdcMode .CDC_UTILITY_ACTIVE );
283
255
284
256
checkConsumerData (expUsers );
@@ -338,7 +310,7 @@ private void awaitCdcModeValue(CdcMode expVal) throws IgniteInterruptedCheckedEx
338
310
ObjectMetric <String > m = GridTestUtils .<StandaloneGridKernalContext >getFieldValue (cdcMain , "kctx" )
339
311
.metric ().registry ("cdc" ).findMetric (CDC_MODE );
340
312
341
- return expVal .name ().equals (m .value ());
313
+ return m != null && expVal .name ().equals (m .value ());
342
314
}
343
315
catch (Exception e ) {
344
316
return false ;
0 commit comments