1818package org .apache .ignite .compatibility .persistence ;
1919
2020import java .util .List ;
21- import javax .cache .Cache ;
2221import org .apache .ignite .Ignite ;
2322import org .apache .ignite .IgniteCache ;
24- import org .apache .ignite .IgniteCheckedException ;
25- import org .apache .ignite .cache .CacheEntry ;
2623import org .apache .ignite .cluster .ClusterState ;
2724import org .apache .ignite .compatibility .testframework .junits .IgniteCompatibilityAbstractTest ;
2825import org .apache .ignite .configuration .DataStorageConfiguration ;
2926import org .apache .ignite .configuration .IgniteConfiguration ;
3027import org .apache .ignite .internal .IgniteEx ;
31- import org .apache .ignite .internal .util .typedef .internal .U ;
3228import org .apache .ignite .lang .IgniteInClosure ;
29+ import org .jetbrains .annotations .NotNull ;
3330import org .junit .Test ;
3431
3532/**
@@ -42,6 +39,9 @@ public class SnapshotCompatibilityTest extends IgniteCompatibilityAbstractTest {
4239 /** */
4340 private static final String SNAPSHOT_NAME = "test_snapshot" ;
4441
42+ /** */
43+ public static final String CACHE_NAME = "organizations" ;
44+
4545 /**
4646 *
4747 */
@@ -54,17 +54,15 @@ public void testSnapshotRestore() throws Exception {
5454
5555 cleanPersistenceDir (true );
5656
57- IgniteEx curIdn = startGrid (0 );
57+ IgniteEx curIgn = startGrid (getCurrentIgniteConfiguration ( null ) );
5858
59- curIdn . snapshot ().restoreSnapshot ( SNAPSHOT_NAME , List . of ( "organizations" )). get ( );
59+ curIgn . cluster ().state ( ClusterState . ACTIVE );
6060
61- IgniteCache < String , Integer > cache = curIdn . cache ( "organizations" );
61+ curIgn . snapshot (). restoreSnapshot ( SNAPSHOT_NAME , List . of ( CACHE_NAME )). get ( );
6262
63- for (int i = 0 ; i < 100_000 ; i ++) {
63+ IgniteCache <String , Integer > cache = curIgn .cache (CACHE_NAME );
64+ for (int i = 0 ; i < 10_000 ; i ++)
6465 assertTrue (cache .containsKey ("organization-" + i ));
65- }
66-
67- System .out .println ("Cache read end" );
6866 }
6967 finally {
7068 stopAllGrids ();
@@ -73,6 +71,23 @@ public void testSnapshotRestore() throws Exception {
7371 }
7472 }
7573
74+ /**
75+ *
76+ */
77+ private @ NotNull IgniteConfiguration getCurrentIgniteConfiguration (String consistentId ) throws Exception {
78+ IgniteConfiguration cfg = getConfiguration (getTestIgniteInstanceName (0 ));
79+
80+ DataStorageConfiguration storageCfg = new DataStorageConfiguration ();
81+
82+ storageCfg .getDefaultDataRegionConfiguration ().setPersistenceEnabled (true );
83+
84+ cfg .setDataStorageConfiguration (storageCfg );
85+
86+ cfg .setConsistentId (consistentId );
87+
88+ return cfg ;
89+ }
90+
7691 /**
7792 *
7893 */
@@ -86,8 +101,6 @@ private static class ConfigurationClosure implements IgniteInClosure<IgniteConfi
86101 igniteConfiguration .setDataStorageConfiguration (storageCfg );
87102
88103 igniteConfiguration .setConsistentId (null );
89-
90- System .out .println ("ConfigurationClosure.apply" );
91104 }
92105 }
93106
@@ -99,12 +112,11 @@ private static class PostStartupClosure implements IgniteInClosure<Ignite> {
99112 @ Override public void apply (Ignite ignite ) {
100113 ignite .cluster ().state (ClusterState .ACTIVE );
101114
102- IgniteCache <String , Integer > organizations = ignite .createCache ("organizations" );
103- for (int i = 0 ; i < 100_000 ; i ++)
115+ IgniteCache <String , Integer > organizations = ignite .createCache (CACHE_NAME );
116+ for (int i = 0 ; i < 10_000 ; i ++)
104117 organizations .put ("organization-" + i , i );
105118
106119 ignite .snapshot ().createSnapshot (SNAPSHOT_NAME ).get ();
107- System .out .println ("Snapshot has taken" );
108120 }
109121 }
110122}
0 commit comments