@@ -1221,73 +1221,92 @@ public void testReadEncrypted() throws Exception {
12211221 }
12221222
12231223 /** */
1224- private void CheckDumpReaderDebugLogsGroupName (String [] grpNames ) throws Exception {
1225- String id = "test" ;
1224+ @ Test
1225+ public void testDumpRateLimiter () throws Exception {
1226+ try (IgniteEx ign = startGrid (0 )) {
1227+ ign .cluster ().state (ClusterState .ACTIVE );
12261228
1227- setLoggerDebugLevel ();
1229+ byte [] val = new byte [(int )U .KB ];
1230+ ThreadLocalRandom .current ().nextBytes (val );
12281231
1229- ListeningTestLogger testLog = new ListeningTestLogger ( log ) ;
1232+ int keysCnt = 10 ;
12301233
1231- LogListener errLsnr = LogListener . matches ( "Error consuming partition" ). andMatches ( "grp=" + GRP ). build ();
1232- LogListener cnsmLsnr = LogListener . matches ( "Consuming partition" ). andMatches ( "grp=" + GRP ). build ( );
1234+ for ( int i = 0 ; i < keysCnt ; i ++)
1235+ ign . getOrCreateCache ( DEFAULT_CACHE_NAME ). put ( i , val );
12331236
1234- testLog .registerListener (errLsnr );
1235- testLog .registerListener (cnsmLsnr );
1237+ ign .context ().distributedConfiguration ()
1238+ .property (SNAPSHOT_TRANSFER_RATE_DMS_KEY )
1239+ .propagate (U .KB );
12361240
1237- IgniteEx ign0 = startGrid ( getConfiguration ( id ). setConsistentId ( id ). setGridLogger ( testLog ) );
1241+ IgniteFuture < Void > fut = ign . snapshot (). createDump ( DMP_NAME , null );
12381242
1239- ign0 . cluster ().state ( ClusterState . ACTIVE );
1243+ IgniteSnapshotManager snpMgr = ign . context ().cache (). context (). snapshotMgr ( );
12401244
1241- IgniteCache <Integer , Integer > cache = ign0 .createCache (new CacheConfiguration <Integer , Integer >()
1242- .setName (CACHE_0 )
1243- .setGroupName (GRP )
1244- .setBackups (1 )
1245- .setAffinity (new RendezvousAffinityFunction ().setPartitions (3 ))
1246- );
1245+ assertTrue (GridTestUtils .waitForCondition (() ->
1246+ snpMgr .currentSnapshotTask (CreateDumpFutureTask .class ) != null , 10_000 , 10 ));
12471247
1248- IntStream . range ( 0 , KEYS_CNT ). forEach ( i -> cache . put ( i , i ) );
1248+ CreateDumpFutureTask task = snpMgr . currentSnapshotTask ( CreateDumpFutureTask . class );
12491249
1250- ign0 . snapshot (). createDump ( DMP_NAME , null ). get ( getTestTimeout () );
1250+ List < Long > processedVals = new ArrayList <>( );
12511251
1252- TestDumpConsumer cnsmr = new TestDumpConsumer () {
1253- @ Override public void onPartition (int grp , int part , Iterator <DumpEntry > data ) {
1254- throw new RuntimeException ("trigger error log" );
1255- }
1256- };
1252+ assertTrue (GridTestUtils .waitForCondition (() -> {
1253+ processedVals .add (task .processedSize ());
12571254
1258- assertThrows (null , () -> new DumpReader (
1259- new DumpReaderConfiguration (
1255+ return fut .isDone ();
1256+ }, getTestTimeout (), 100 ));
1257+
1258+ assertTrue ("Expected distinct values: " + processedVals ,
1259+ processedVals .stream ().mapToLong (v -> v ).distinct ().count () >= keysCnt );
1260+
1261+ assertTrue ("Expected sorted values: " + processedVals ,
1262+ F .isSorted (processedVals .stream ().mapToLong (v -> v ).toArray ()));
1263+ }
1264+ }
1265+
1266+ /** */
1267+ @ Test
1268+ public void testConfigOnlySnapshotThrows () throws Exception {
1269+ try (IgniteEx ign = startGrid (0 )) {
1270+ ign .cluster ().state (ClusterState .ACTIVE );
1271+
1272+ IgniteCache <Integer , Integer > c = ign .createCache (DEFAULT_CACHE_NAME );
1273+
1274+ IntStream .range (0 , 10 ).forEach (i -> c .put (i , i ));
1275+
1276+ IgniteSnapshotManager snpMgr = ign .context ().cache ().context ().snapshotMgr ();
1277+
1278+ assertThrows (
1279+ null ,
1280+ () -> {
1281+ snpMgr .createSnapshot (
12601282 DMP_NAME ,
12611283 null ,
1262- ign0 .configuration (),
1263- cnsmr ,
1264- DFLT_THREAD_CNT ,
1265- DFLT_TIMEOUT ,
1266- true ,
1267- true ,
1268- false ,
1269- grpNames ,
12701284 null ,
12711285 false ,
1272- null
1273- ),
1274- testLog
1275- ).run (), RuntimeException .class , "trigger error log" );
1276-
1277- assertTrue ("Log with group name not found" , errLsnr .check ());
1278- assertTrue ("Consuming with group name not found" , cnsmLsnr .check ());
1286+ false ,
1287+ false ,
1288+ false ,
1289+ false ,
1290+ false ,
1291+ true
1292+ );
1293+ },
1294+ IgniteException .class ,
1295+ "Config only supported only for dump"
1296+ );
1297+ }
12791298 }
12801299
12811300 /** */
12821301 @ Test
12831302 public void testDumpReaderDebugLogsGroupName () throws Exception {
1284- CheckDumpReaderDebugLogsGroupName (new String []{GRP });
1303+ checkDumpReaderDebugLogsGroupName (new String []{GRP });
12851304 }
12861305
12871306 /** */
12881307 @ Test
1289- public void testDumpReaderDebugLogsGroupNameNull () throws Exception {
1290- CheckDumpReaderDebugLogsGroupName (null );
1308+ public void testDumpReaderDebugLogsNullableGroupName () throws Exception {
1309+ checkDumpReaderDebugLogsGroupName (null );
12911310 }
12921311
12931312 /** */
@@ -1335,7 +1354,7 @@ public void testDumpReaderSkipCopiesLogsGroupName() throws Exception {
13351354
13361355 node0 .snapshot ().createDump (dumpName0 , null ).get (getTestTimeout ());
13371356
1338- Thread .sleep (100 );
1357+ U .sleep (100 );
13391358
13401359 node1 .snapshot ().createDump (dumpName1 , null ).get (getTestTimeout ());
13411360
@@ -1400,80 +1419,61 @@ public void testDumpReaderSkipCopiesLogsGroupName() throws Exception {
14001419 }
14011420
14021421 /** */
1403- @ Test
1404- public void testDumpRateLimiter () throws Exception {
1405- try (IgniteEx ign = startGrid (0 )) {
1406- ign .cluster ().state (ClusterState .ACTIVE );
1407-
1408- byte [] val = new byte [(int )U .KB ];
1409- ThreadLocalRandom .current ().nextBytes (val );
1410-
1411- int keysCnt = 10 ;
1412-
1413- for (int i = 0 ; i < keysCnt ; i ++)
1414- ign .getOrCreateCache (DEFAULT_CACHE_NAME ).put (i , val );
1415-
1416- ign .context ().distributedConfiguration ()
1417- .property (SNAPSHOT_TRANSFER_RATE_DMS_KEY )
1418- .propagate (U .KB );
1419-
1420- IgniteFuture <Void > fut = ign .snapshot ().createDump (DMP_NAME , null );
1421-
1422- IgniteSnapshotManager snpMgr = ign .context ().cache ().context ().snapshotMgr ();
1423-
1424- assertTrue (GridTestUtils .waitForCondition (() ->
1425- snpMgr .currentSnapshotTask (CreateDumpFutureTask .class ) != null , 10_000 , 10 ));
1422+ private void checkDumpReaderDebugLogsGroupName (String [] grpNames ) throws Exception {
1423+ String id = "test" ;
14261424
1427- CreateDumpFutureTask task = snpMgr . currentSnapshotTask ( CreateDumpFutureTask . class );
1425+ setLoggerDebugLevel ( );
14281426
1429- List < Long > processedVals = new ArrayList <>( );
1427+ ListeningTestLogger testLog = new ListeningTestLogger ( log );
14301428
1431- assertTrue ( GridTestUtils . waitForCondition (() -> {
1432- processedVals . add ( task . processedSize () );
1429+ LogListener errLsnr = LogListener . matches ( "Error consuming partition" ). andMatches ( "grp=" + GRP ). build ();
1430+ LogListener cnsmLsnr = LogListener . matches ( "Consuming partition" ). andMatches ( "grp=" + GRP ). build ( );
14331431
1434- return fut . isDone ( );
1435- }, getTestTimeout (), 100 ) );
1432+ testLog . registerListener ( errLsnr );
1433+ testLog . registerListener ( cnsmLsnr );
14361434
1437- assertTrue ("Expected distinct values: " + processedVals ,
1438- processedVals .stream ().mapToLong (v -> v ).distinct ().count () >= keysCnt );
1435+ IgniteEx ign = startGrid (getConfiguration (id ).setConsistentId (id ).setGridLogger (testLog ));
14391436
1440- assertTrue ("Expected sorted values: " + processedVals ,
1441- F .isSorted (processedVals .stream ().mapToLong (v -> v ).toArray ()));
1442- }
1443- }
1437+ ign .cluster ().state (ClusterState .ACTIVE );
14441438
1445- /** */
1446- @ Test
1447- public void testConfigOnlySnapshotThrows () throws Exception {
1448- try (IgniteEx ign = startGrid (0 )) {
1449- ign .cluster ().state (ClusterState .ACTIVE );
1439+ IgniteCache <Integer , Integer > cache = ign .createCache (new CacheConfiguration <Integer , Integer >()
1440+ .setName (CACHE_0 )
1441+ .setGroupName (GRP )
1442+ .setBackups (1 )
1443+ .setAffinity (new RendezvousAffinityFunction ().setPartitions (3 ))
1444+ );
14501445
1451- IgniteCache < Integer , Integer > c = ign . createCache ( DEFAULT_CACHE_NAME );
1446+ IntStream . range ( 0 , KEYS_CNT ). forEach ( i -> cache . put ( i , i ) );
14521447
1453- IntStream . range ( 0 , 10 ). forEach ( i -> c . put ( i , i ));
1448+ ign . snapshot (). createDump ( DMP_NAME , null ). get ( getTestTimeout ( ));
14541449
1455- IgniteSnapshotManager snpMgr = ign .context ().cache ().context ().snapshotMgr ();
1450+ TestDumpConsumer cnsmr = new TestDumpConsumer () {
1451+ @ Override public void onPartition (int grp , int part , Iterator <DumpEntry > data ) {
1452+ throw new RuntimeException ("trigger error log" );
1453+ }
1454+ };
14561455
1457- assertThrows (
1456+ assertThrows (null , () -> new DumpReader (
1457+ new DumpReaderConfiguration (
1458+ DMP_NAME ,
14581459 null ,
1459- () -> {
1460- snpMgr .createSnapshot (
1461- DMP_NAME ,
1462- null ,
1463- null ,
1464- false ,
1465- false ,
1466- false ,
1467- false ,
1468- false ,
1469- false ,
1470- true
1471- );
1472- },
1473- IgniteException .class ,
1474- "Config only supported only for dump"
1475- );
1476- }
1460+ ign .configuration (),
1461+ cnsmr ,
1462+ DFLT_THREAD_CNT ,
1463+ DFLT_TIMEOUT ,
1464+ true ,
1465+ true ,
1466+ false ,
1467+ grpNames ,
1468+ null ,
1469+ false ,
1470+ null
1471+ ),
1472+ testLog
1473+ ).run (), RuntimeException .class , "trigger error log" );
1474+
1475+ assertTrue ("Log with group name not found" , errLsnr .check ());
1476+ assertTrue ("Consuming with group name not found" , cnsmLsnr .check ());
14771477 }
14781478
14791479 /** */
0 commit comments