-
Notifications
You must be signed in to change notification settings - Fork 588
HDDS-9884. Pass DatanodeVersion to the client #6155
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
10 commits
Select commit
Hold shift + click to select a range
fcf6125
HDDS-9884. Pass DatanodeVersion to the client
smengcl 4d0ac8b
Reduce HddsDatanodeService modification.
smengcl c6b0bcc
Clean up
smengcl b5a5f14
`mockStatic` once only for each `Impl` to make Mockito happy.
smengcl f43fc7a
Remove initialVersion from proto.
smengcl 3b024e0
Merge remote-tracking branch 'asf/HDDS-7593' into HDDS-9884
smengcl 7d16cfe
Mock static only when non -1 is set.
smengcl cd70362
Move test to separate class; comment.
smengcl f21b021
Minor refactoring
smengcl 1a26bc5
Add `mockito-inline` to hopefully resolve test failure according to i…
smengcl 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
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
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
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 |
|---|---|---|
|
|
@@ -35,6 +35,7 @@ | |
|
|
||
| import org.apache.commons.lang3.StringUtils; | ||
| import org.apache.hadoop.hdds.DFSConfigKeysLegacy; | ||
| import org.apache.hadoop.hdds.DatanodeVersion; | ||
| import org.apache.hadoop.hdds.HddsConfigKeys; | ||
| import org.apache.hadoop.hdds.annotation.InterfaceAudience; | ||
| import org.apache.hadoop.hdds.client.RatisReplicationConfig; | ||
|
|
@@ -102,6 +103,8 @@ | |
| import static org.apache.ozone.test.GenericTestUtils.PortAllocator.localhostWithFreePort; | ||
|
|
||
| import org.hadoop.ozone.recon.codegen.ReconSqlDbConfig; | ||
| import org.mockito.MockedStatic; | ||
| import org.mockito.Mockito; | ||
| import org.slf4j.Logger; | ||
| import org.slf4j.LoggerFactory; | ||
|
|
||
|
|
@@ -132,12 +135,14 @@ public class MiniOzoneClusterImpl implements MiniOzoneCluster { | |
| private CertificateClient caClient; | ||
| private final Set<AutoCloseable> clients = ConcurrentHashMap.newKeySet(); | ||
| private SecretKeyClient secretKeyClient; | ||
| private static MockedStatic mockDNStatic = Mockito.mockStatic(HddsDatanodeService.class); | ||
|
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. this doc https://www.baeldung.com/mockito-mock-static-methods I think it's fine for this case though because we usually just have one mini cluster. |
||
|
|
||
| /** | ||
| * Creates a new MiniOzoneCluster with Recon. | ||
| * | ||
| * @throws IOException if there is an I/O error | ||
| */ | ||
| @SuppressWarnings("checkstyle:ParameterNumber") | ||
| MiniOzoneClusterImpl(OzoneConfiguration conf, | ||
| SCMConfigurator scmConfigurator, | ||
| OzoneManager ozoneManager, | ||
|
|
@@ -396,6 +401,16 @@ private void waitForHddsDatanodeToStop(DatanodeDetails dn) | |
| }, 1000, waitForClusterToBeReadyTimeout); | ||
| } | ||
|
|
||
| private static void overrideDatanodeVersions(int dnInitialVersion, int dnCurrentVersion) { | ||
| // FUTURE_VERSION (-1) is not a valid version for a datanode, using it as a marker when version is not overridden | ||
| if (dnInitialVersion != DatanodeVersion.FUTURE_VERSION.toProtoValue()) { | ||
| mockDNStatic.when(HddsDatanodeService::getDefaultInitialVersion).thenReturn(dnInitialVersion); | ||
| } | ||
| if (dnCurrentVersion != DatanodeVersion.FUTURE_VERSION.toProtoValue()) { | ||
| mockDNStatic.when(HddsDatanodeService::getDefaultCurrentVersion).thenReturn(dnCurrentVersion); | ||
smengcl marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public void restartHddsDatanode(int i, boolean waitForDatanode) | ||
| throws InterruptedException, TimeoutException { | ||
|
|
@@ -782,10 +797,14 @@ protected List<HddsDatanodeService> createHddsDatanodes( | |
| String[] args = new String[] {}; | ||
| conf.setStrings(ScmConfigKeys.OZONE_SCM_NAMES, scmAddress); | ||
| List<HddsDatanodeService> hddsDatanodes = new ArrayList<>(); | ||
|
|
||
| // Override default datanode initial and current version if necessary | ||
| overrideDatanodeVersions(dnInitialVersion, dnCurrentVersion); | ||
|
|
||
| for (int i = 0; i < numOfDatanodes; i++) { | ||
| OzoneConfiguration dnConf = new OzoneConfiguration(conf); | ||
| configureDatanodePorts(dnConf); | ||
| String datanodeBaseDir = path + "/datanode-" + Integer.toString(i); | ||
| String datanodeBaseDir = path + "/datanode-" + i; | ||
| Path metaDir = Paths.get(datanodeBaseDir, "meta"); | ||
| List<String> dataDirs = new ArrayList<>(); | ||
| List<String> reservedSpaceList = new ArrayList<>(); | ||
|
|
||
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.