-
Notifications
You must be signed in to change notification settings - Fork 9.1k
HDDS-1093. Configuration tab in OM/SCM ui is not displaying the correct values #527
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
7 commits
Select commit
Hold shift + click to select a range
95168df
HDDS-1093. Configuration tab in OM/SCM ui is not displaying the corre…
vivekratnavel 305007a
Fix review comments v1
vivekratnavel 2c76ce6
Fix checkstyle warnings
vivekratnavel 8365df4
fix review comments
vivekratnavel 8a82b96
HDDS-1093. Force checks to rerun (empty commit)
vivekratnavel 82cba34
Merge branch 'trunk' into HDDS-1093
vivekratnavel 943fa8b
fix typos
vivekratnavel 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
143 changes: 143 additions & 0 deletions
143
hadoop-hdds/common/src/test/java/org/apache/hadoop/hdds/conf/TestOzoneConfiguration.java
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 |
---|---|---|
@@ -0,0 +1,143 @@ | ||
/** | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* <p> | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* <p> | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.apache.hadoop.hdds.conf; | ||
|
||
import org.apache.hadoop.conf.Configuration; | ||
import org.apache.hadoop.fs.Path; | ||
import org.junit.Rule; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.junit.Assert; | ||
import org.junit.rules.TemporaryFolder; | ||
|
||
import java.io.BufferedWriter; | ||
import java.io.File; | ||
import java.io.FileWriter; | ||
import java.io.IOException; | ||
|
||
/** | ||
* Test class for OzoneConfiguration. | ||
*/ | ||
public class TestOzoneConfiguration { | ||
|
||
private Configuration conf; | ||
|
||
@Rule | ||
public TemporaryFolder tempConfigs = new TemporaryFolder(); | ||
|
||
@Before | ||
public void setUp() throws Exception { | ||
conf = new OzoneConfiguration(); | ||
} | ||
|
||
private void startConfig(BufferedWriter out) throws IOException { | ||
out.write("<?xml version=\"1.0\"?>\n"); | ||
out.write("<configuration>\n"); | ||
} | ||
|
||
private void endConfig(BufferedWriter out) throws IOException { | ||
out.write("</configuration>\n"); | ||
out.flush(); | ||
out.close(); | ||
} | ||
|
||
@Test | ||
public void testGetAllPropertiesByTags() throws Exception { | ||
File coreDefault = tempConfigs.newFile("core-default-test.xml"); | ||
File coreSite = tempConfigs.newFile("core-site-test.xml"); | ||
try (BufferedWriter out = new BufferedWriter(new FileWriter(coreDefault))) { | ||
startConfig(out); | ||
appendProperty(out, "hadoop.tags.system", "YARN,HDFS,NAMENODE"); | ||
appendProperty(out, "hadoop.tags.custom", "MYCUSTOMTAG"); | ||
appendPropertyByTag(out, "dfs.cblock.trace.io", "false", "YARN"); | ||
appendPropertyByTag(out, "dfs.replication", "1", "HDFS"); | ||
appendPropertyByTag(out, "dfs.namenode.logging.level", "INFO", | ||
"NAMENODE"); | ||
appendPropertyByTag(out, "dfs.random.key", "XYZ", "MYCUSTOMTAG"); | ||
endConfig(out); | ||
|
||
Path fileResource = new Path(coreDefault.getAbsolutePath()); | ||
conf.addResource(fileResource); | ||
Assert.assertEquals(conf.getAllPropertiesByTag("MYCUSTOMTAG") | ||
.getProperty("dfs.random.key"), "XYZ"); | ||
} | ||
|
||
try (BufferedWriter out = new BufferedWriter(new FileWriter(coreSite))) { | ||
startConfig(out); | ||
appendProperty(out, "dfs.random.key", "ABC"); | ||
appendProperty(out, "dfs.replication", "3"); | ||
appendProperty(out, "dfs.cblock.trace.io", "true"); | ||
endConfig(out); | ||
|
||
Path fileResource = new Path(coreSite.getAbsolutePath()); | ||
conf.addResource(fileResource); | ||
} | ||
|
||
// Test if values are getting overridden even without tags being present | ||
Assert.assertEquals("3", conf.getAllPropertiesByTag("HDFS") | ||
.getProperty("dfs.replication")); | ||
Assert.assertEquals("ABC", conf.getAllPropertiesByTag("MYCUSTOMTAG") | ||
.getProperty("dfs.random.key")); | ||
Assert.assertEquals("true", conf.getAllPropertiesByTag("YARN") | ||
.getProperty("dfs.cblock.trace.io")); | ||
} | ||
|
||
private void appendProperty(BufferedWriter out, String name, String val) | ||
throws IOException { | ||
this.appendProperty(out, name, val, false); | ||
} | ||
|
||
private void appendProperty(BufferedWriter out, String name, String val, | ||
boolean isFinal) throws IOException { | ||
out.write("<property>"); | ||
out.write("<name>"); | ||
out.write(name); | ||
out.write("</name>"); | ||
out.write("<value>"); | ||
out.write(val); | ||
out.write("</value>"); | ||
if (isFinal) { | ||
out.write("<final>true</final>"); | ||
} | ||
out.write("</property>\n"); | ||
} | ||
|
||
private void appendPropertyByTag(BufferedWriter out, String name, String val, | ||
String tags) throws IOException { | ||
this.appendPropertyByTag(out, name, val, false, tags); | ||
} | ||
|
||
private void appendPropertyByTag(BufferedWriter out, String name, String val, | ||
boolean isFinal, | ||
String tag) throws IOException { | ||
out.write("<property>"); | ||
out.write("<name>"); | ||
out.write(name); | ||
out.write("</name>"); | ||
out.write("<value>"); | ||
out.write(val); | ||
out.write("</value>"); | ||
if (isFinal) { | ||
out.write("<final>true</final>"); | ||
} | ||
out.write("<tag>"); | ||
out.write(tag); | ||
out.write("</tag>"); | ||
out.write("</property>\n"); | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
hadoop-hdds/common/src/test/java/org/apache/hadoop/hdds/conf/package-info.java
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
2E87 * limitations under the License. | ||
*/ | ||
|
||
/** | ||
* This package contains the OzoneConfiguration related tests. | ||
*/ | ||
package org.apache.hadoop.hdds.conf; |
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
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.
Do we need an other (HADOOP) jira to fix it on the hadoop 3.3 line, too?
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.
Yes @elek