-
Notifications
You must be signed in to change notification settings - Fork 9.2k
HDFS-16499. [SPS]: Should not start indefinitely while another SPS process is running #4058
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 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 |
|---|---|---|
|
|
@@ -90,6 +90,8 @@ | |
| import org.apache.hadoop.security.ssl.KeyStoreTestUtil; | ||
| import org.apache.hadoop.test.GenericTestUtils; | ||
| import org.apache.hadoop.test.GenericTestUtils.LogCapturer; | ||
| import org.apache.hadoop.test.LambdaTestUtils; | ||
| import org.apache.hadoop.util.ExitUtil; | ||
| import org.junit.After; | ||
| import org.junit.Assert; | ||
| import org.junit.Before; | ||
|
|
@@ -197,9 +199,24 @@ private void createCluster() throws IOException { | |
| writeContent(FILE); | ||
| } | ||
|
|
||
| private void createCluster(boolean createMoverPath) throws IOException { | ||
| getConf().setLong("dfs.block.size", DEFAULT_BLOCK_SIZE); | ||
| setCluster(startCluster(getConf(), allDiskTypes, NUM_OF_DATANODES, | ||
| STORAGES_PER_DATANODE, CAPACITY, createMoverPath)); | ||
| getFS(); | ||
| writeContent(FILE); | ||
| } | ||
|
|
||
| private MiniDFSCluster startCluster(final Configuration conf, | ||
| StorageType[][] storageTypes, int numberOfDatanodes, int storagesPerDn, | ||
| long nodeCapacity) throws IOException { | ||
| return startCluster(conf, storageTypes, numberOfDatanodes, storagesPerDn, | ||
| nodeCapacity, false); | ||
| } | ||
|
|
||
| private MiniDFSCluster startCluster(final Configuration conf, | ||
| StorageType[][] storageTypes, int numberOfDatanodes, int storagesPerDn, | ||
| long nodeCapacity, boolean createMoverPath) throws IOException { | ||
| long[][] capacities = new long[numberOfDatanodes][storagesPerDn]; | ||
| for (int i = 0; i < numberOfDatanodes; i++) { | ||
| for (int j = 0; j < storagesPerDn; j++) { | ||
|
|
@@ -212,7 +229,7 @@ private MiniDFSCluster startCluster(final Configuration conf, | |
| cluster.waitActive(); | ||
|
|
||
| nnc = DFSTestUtil.getNameNodeConnector(getConf(), | ||
| HdfsServerConstants.MOVER_ID_PATH, 1, false); | ||
| HdfsServerConstants.MOVER_ID_PATH, 1, createMoverPath); | ||
|
|
||
| externalSps = new StoragePolicySatisfier(getConf()); | ||
| externalCtxt = new ExternalSPSContext(externalSps, nnc); | ||
|
|
@@ -428,6 +445,30 @@ public void testWhenStoragePolicySetToCOLD() | |
| } | ||
| } | ||
|
|
||
| @Test(timeout = 300000) | ||
| public void testInfiniteStartWhenAnotherSPSRunning() | ||
| throws Exception { | ||
|
|
||
| try { | ||
| // Create cluster and create mover path when get NameNodeConnector. | ||
| createCluster(true); | ||
|
|
||
| // Disable system exit for assert. | ||
| ExitUtil.disableSystemExit(); | ||
|
|
||
| // Get NameNodeConnector one more time to simulate starting other sps process. | ||
| // It should exit immediately when another sps is running. | ||
| LambdaTestUtils.intercept(ExitUtil.ExitException.class, | ||
| "Exit immediately because another ExternalStoragePolicySatisfier is running", | ||
| () -> ExternalStoragePolicySatisfier.getNameNodeConnector(config)); | ||
| } finally { | ||
| // Reset first exit exception to avoid AssertionError in MiniDFSCluster#shutdown. | ||
| // This has no effect on functionality. | ||
|
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. How about doing this reset in finally?
Contributor
Author
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.
Thanks @umamaheswararao for your comments. I fixed it. |
||
| ExitUtil.resetFirstExitException(); | ||
| shutdownCluster(); | ||
| } | ||
| } | ||
|
|
||
| private void doTestWhenStoragePolicySetToCOLD() throws Exception { | ||
| // Change policy to COLD | ||
| dfs.setStoragePolicy(new Path(FILE), COLD); | ||
|
|
||
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.
It's quite some time I looked at this code. Thanks a lot for working on these improvements.
How about using ExitUtil class to terminate. That class has static methods to disable exit. That you can use it from tests.
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.
Thank you @umamaheswararao very much for your review. And your suggestion makes sense to me.
I updated the code. PTAL. Thanks.