Skip to content

Commit 1f84361

Browse files
committed
print provenance of all options
1 parent b5d5929 commit 1f84361

1 file changed

Lines changed: 17 additions & 11 deletions

File tree

src/main/java/org/apache/hadoop/fs/store/diag/StoreDiag.java

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ private TreeSet<String> sortKeys(final Iterable<?> keySet) {
9292
private void printOptions(Configuration conf, Object[][] options) {
9393
if (options.length > 0) {
9494
heading("Selected and Sanitized Configuration Options");
95-
for (int i = 0; i < options.length; i++) {
96-
printOption(conf, (String) options[i][0], (Boolean) options[i][1]);
95+
for (final Object[] option : options) {
96+
printOption(conf, (String) option[0], (Boolean) option[1]);
9797
}
9898
}
9999
}
@@ -102,27 +102,33 @@ private void printOption(Configuration conf, String key, boolean sensitive) {
102102
if (key.isEmpty()) {
103103
return;
104104
}
105-
String v = conf.get(key);
106-
if (v == null) {
107-
v = "(unset)";
105+
String option = conf.get(key);
106+
String source = "";
107+
if (option == null) {
108+
option = "(unset)";
108109
} else {
109110
if (sensitive) {
110-
int len = v.length();
111+
int len = option.length();
111112
if (len > 2) {
112113
StringBuilder b = new StringBuilder(len);
113-
b.append(v.charAt(0));
114+
b.append(option.charAt(0));
114115
for (int i = 1; i < len - 1; i++) {
115116
b.append('*');
116117
}
117-
b.append(v.charAt(len - 1));
118-
v = b.toString();
118+
b.append(option.charAt(len - 1));
119+
option = b.toString();
119120
} else {
120121
// short values get special treatment
121-
v = "**";
122+
option = "**";
122123
}
123124
}
125+
String[] origins = conf.getPropertySources(key);
126+
if (origins.length !=0) {
127+
source = " [" + StringUtils.join(origins, ",") + "]";
128+
}
129+
124130
}
125-
println("%s = %s", key, v);
131+
println("%s = \"%s\"%s", key, option, source);
126132
}
127133

128134
@Override

0 commit comments

Comments
 (0)