-
Notifications
You must be signed in to change notification settings - Fork 1.9k
IGNITE-27716: Add group name to DumpReader logs #12840
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
Open
DEADripER
wants to merge
6
commits into
apache:master
Choose a base branch
from
DEADripER:IGNITE-27716
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+210
−7
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -121,6 +121,7 @@ | |
| import static org.apache.ignite.internal.processors.cache.persistence.snapshot.IgniteSnapshotManager.SNAPSHOT_TRANSFER_RATE_DMS_KEY; | ||
| import static org.apache.ignite.internal.processors.cache.persistence.snapshot.dump.AbstractCacheDumpTest.CACHE_0; | ||
| import static org.apache.ignite.internal.processors.cache.persistence.snapshot.dump.AbstractCacheDumpTest.DMP_NAME; | ||
| import static org.apache.ignite.internal.processors.cache.persistence.snapshot.dump.AbstractCacheDumpTest.GRP; | ||
| import static org.apache.ignite.internal.processors.cache.persistence.snapshot.dump.AbstractCacheDumpTest.KEYS_CNT; | ||
| import static org.apache.ignite.internal.processors.cache.persistence.snapshot.dump.AbstractCacheDumpTest.USER_FACTORY; | ||
| import static org.apache.ignite.internal.processors.cache.persistence.snapshot.dump.AbstractCacheDumpTest.dump; | ||
|
|
@@ -1296,6 +1297,185 @@ public void testConfigOnlySnapshotThrows() throws Exception { | |
| } | ||
| } | ||
|
|
||
| /** */ | ||
| @Test | ||
| public void testDumpReaderDebugLogsGroupName() throws Exception { | ||
| checkDumpReaderDebugLogsGroupName(new String[]{GRP}); | ||
| } | ||
|
|
||
| /** */ | ||
| @Test | ||
| public void testDumpReaderDebugLogsNullableGroupName() throws Exception { | ||
| checkDumpReaderDebugLogsGroupName(null); | ||
| } | ||
|
|
||
| /** */ | ||
| @Test | ||
| public void testDumpReaderSkipCopiesLogsGroupName() throws Exception { | ||
| int parts = 4; | ||
| String dumpName0 = "dump0"; | ||
| String dumpName1 = "dump1"; | ||
|
|
||
| File snapshotPath0 = Files.createTempDirectory("snapshots0").toFile(); | ||
| File snapshotPath1 = Files.createTempDirectory("snapshots1").toFile(); | ||
| File combinedDumpDir = Files.createTempDirectory("combined_dump").toFile(); | ||
|
|
||
| ListeningTestLogger testLog = new ListeningTestLogger(log); | ||
|
|
||
| LogListener skipLsnr = LogListener.matches("Skip copy partition") | ||
| .times(parts) | ||
| .andMatches("grp=" + GRP) | ||
| .build(); | ||
|
|
||
| testLog.registerListener(skipLsnr); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add empty line before. |
||
|
|
||
| try { | ||
| IgniteEx node0 = startGrid(getConfiguration("node0") | ||
| .setConsistentId("node0") | ||
| .setSnapshotPath(snapshotPath0.getAbsolutePath()) | ||
| .setGridLogger(testLog)); | ||
|
|
||
| IgniteEx node1 = startGrid(getConfiguration("node1") | ||
| .setConsistentId("node1") | ||
| .setSnapshotPath(snapshotPath1.getAbsolutePath()) | ||
| .setGridLogger(testLog)); | ||
|
|
||
| node0.cluster().state(ClusterState.ACTIVE); | ||
|
|
||
| CacheConfiguration<Integer, Integer> ccfg = new CacheConfiguration<Integer, Integer>() | ||
| .setName(DEFAULT_CACHE_NAME) | ||
| .setGroupName(GRP) | ||
| .setBackups(1) | ||
| .setAffinity(new RendezvousAffinityFunction().setPartitions(parts)); | ||
|
|
||
| IgniteCache<Integer, Integer> cache = node0.createCache(ccfg); | ||
|
|
||
| IntStream.range(0, KEYS_CNT).forEach(i -> cache.put(i, i)); | ||
|
|
||
| node0.snapshot().createDump(dumpName0, null).get(getTestTimeout()); | ||
|
|
||
| U.sleep(100); | ||
|
|
||
| node1.snapshot().createDump(dumpName1, null).get(getTestTimeout()); | ||
|
|
||
| File dumpDir0 = new File(snapshotPath0, dumpName0); | ||
| File dumpDir1 = new File(snapshotPath1, dumpName1); | ||
|
|
||
| U.copy(dumpDir0, combinedDumpDir, true); | ||
| U.copy(dumpDir1, combinedDumpDir, true); | ||
|
|
||
| DumpConsumer dummyConsumer = new DumpConsumer() { | ||
| @Override public void start() { | ||
| // No-op. | ||
| } | ||
|
|
||
| @Override public void onMappings(Iterator<TypeMapping> mappings) { | ||
| // No-op. | ||
| } | ||
|
|
||
| @Override public void onTypes(Iterator<BinaryType> types) { | ||
| // No-op. | ||
| } | ||
|
|
||
| @Override public void onCacheConfigs(Iterator<StoredCacheData> caches) { | ||
| // No-op. | ||
| } | ||
|
|
||
| @Override public void onPartition(int grpId, int partId, Iterator<DumpEntry> data) { | ||
| // No-op. | ||
| } | ||
|
|
||
| @Override public void stop() { | ||
| // No-op. | ||
| } | ||
| }; | ||
|
|
||
| new DumpReader( | ||
| new DumpReaderConfiguration( | ||
| null, | ||
| combinedDumpDir.getAbsolutePath(), | ||
| null, | ||
| dummyConsumer, | ||
| DFLT_THREAD_CNT, | ||
| DFLT_TIMEOUT, | ||
| false, | ||
| true, | ||
| true, | ||
| new String[]{GRP}, | ||
| null, | ||
| true, | ||
| null | ||
| ), | ||
| testLog | ||
| ).run(); | ||
|
|
||
| assertTrue(skipLsnr.check()); | ||
| } | ||
| finally { | ||
| U.delete(snapshotPath0); | ||
| U.delete(snapshotPath1); | ||
| U.delete(combinedDumpDir); | ||
| } | ||
| } | ||
|
|
||
| /** */ | ||
| private void checkDumpReaderDebugLogsGroupName(String[] grpNames) throws Exception { | ||
| String id = "test"; | ||
|
|
||
| setLoggerDebugLevel(); | ||
|
|
||
| ListeningTestLogger testLog = new ListeningTestLogger(log); | ||
|
|
||
| LogListener errLsnr = LogListener.matches("Error consuming partition").andMatches("grp=" + GRP).build(); | ||
| LogListener cnsmLsnr = LogListener.matches("Consuming partition").andMatches("grp=" + GRP).build(); | ||
|
|
||
| testLog.registerListener(errLsnr); | ||
| testLog.registerListener(cnsmLsnr); | ||
|
|
||
| IgniteEx ign = startGrid(getConfiguration(id).setConsistentId(id).setGridLogger(testLog)); | ||
|
|
||
| ign.cluster().state(ClusterState.ACTIVE); | ||
|
|
||
| IgniteCache<Integer, Integer> cache = ign.createCache(new CacheConfiguration<Integer, Integer>() | ||
| .setName(CACHE_0) | ||
| .setGroupName(GRP) | ||
| .setBackups(1) | ||
| .setAffinity(new RendezvousAffinityFunction().setPartitions(3)) | ||
| ); | ||
|
|
||
| IntStream.range(0, KEYS_CNT).forEach(i -> cache.put(i, i)); | ||
|
|
||
| ign.snapshot().createDump(DMP_NAME, null).get(getTestTimeout()); | ||
|
|
||
| TestDumpConsumer cnsmr = new TestDumpConsumer() { | ||
| @Override public void onPartition(int grp, int part, Iterator<DumpEntry> data) { | ||
| throw new RuntimeException("trigger error log"); | ||
| } | ||
| }; | ||
|
|
||
| assertThrows(null, () -> new DumpReader( | ||
| new DumpReaderConfiguration( | ||
| DMP_NAME, | ||
| null, | ||
| ign.configuration(), | ||
| cnsmr, | ||
| DFLT_THREAD_CNT, | ||
| DFLT_TIMEOUT, | ||
| true, | ||
| true, | ||
| false, | ||
| grpNames, | ||
| null, | ||
| false, | ||
| null | ||
| ), | ||
| testLog | ||
| ).run(), RuntimeException.class, "trigger error log"); | ||
|
|
||
| assertTrue("Log with group name not found", errLsnr.check()); | ||
| assertTrue("Consuming with group name not found", cnsmLsnr.check()); | ||
| } | ||
|
|
||
| /** */ | ||
| public class TestCacheConflictResolutionManager<K, V> extends GridCacheManagerAdapter<K, V> | ||
| implements CacheConflictResolutionManager<K, V> { | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should rename grp -> grpId - both here and in the log messages?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
grp must be used for group name in logs.