Skip to content

Commit 689f74b

Browse files
author
slfan1989
committed
HDFS-16824. add synchronized.
1 parent 13422ba commit 689f74b

1 file changed

Lines changed: 40 additions & 40 deletions

File tree

  • hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools

hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/DFSAdmin.java

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -2068,51 +2068,51 @@ int getReconfigurationStatus(final String nodeType, final String address, final
20682068
errMsg = String.format("Node [%s] reloading configuration: %s.", address,
20692069
e.toString());
20702070
}
2071-
2072-
if (errMsg != null) {
2073-
err.println(errMsg);
2074-
return 1;
2075-
} else {
2076-
out.print(outMsg);
2077-
}
2078-
2079-
if (status != null) {
2080-
if (!status.hasTask()) {
2081-
out.println("no task was found.");
2082-
return 0;
2083-
}
2084-
out.print("started at " + new Date(status.getStartTime()));
2085-
if (!status.stopped()) {
2086-
out.println(" and is still running.");
2087-
return 0;
2071+
synchronized (this) {
2072+
if (errMsg != null) {
2073+
err.println(errMsg);
2074+
return 1;
2075+
} else {
2076+
out.print(outMsg);
20882077
}
20892078

2090-
out.println(" and finished at "
2091-
+ new Date(status.getEndTime()).toString() + ".");
2092-
if (status.getStatus() == null) {
2093-
// Nothing to report.
2094-
return 0;
2095-
}
2096-
for (Map.Entry<PropertyChange, Optional<String>> result : status
2097-
.getStatus().entrySet()) {
2098-
if (!result.getValue().isPresent()) {
2099-
out.printf(
2100-
"SUCCESS: Changed property %s%n\tFrom: \"%s\"%n\tTo: \"%s\"%n",
2101-
result.getKey().prop, result.getKey().oldVal,
2102-
result.getKey().newVal);
2103-
} else {
2104-
final String errorMsg = result.getValue().get();
2105-
out.printf(
2106-
"FAILED: Change property %s%n\tFrom: \"%s\"%n\tTo: \"%s\"%n",
2107-
result.getKey().prop, result.getKey().oldVal,
2108-
result.getKey().newVal);
2109-
out.println("\tError: " + errorMsg + ".");
2079+
if (status != null) {
2080+
if (!status.hasTask()) {
2081+
out.println("no task was found.");
2082+
return 0;
21102083
}
2084+
out.print("started at " + new Date(status.getStartTime()));
2085+
if (!status.stopped()) {
2086+
out.println(" and is still running.");
2087+
return 0;
2088+
}
2089+
2090+
out.println(" and finished at "
2091+
+ new Date(status.getEndTime()).toString() + ".");
2092+
if (status.getStatus() == null) {
2093+
// Nothing to report.
2094+
return 0;
2095+
}
2096+
for (Map.Entry<PropertyChange, Optional<String>> result : status
2097+
.getStatus().entrySet()) {
2098+
if (!result.getValue().isPresent()) {
2099+
out.printf(
2100+
"SUCCESS: Changed property %s%n\tFrom: \"%s\"%n\tTo: \"%s\"%n",
2101+
result.getKey().prop, result.getKey().oldVal,
2102+
result.getKey().newVal);
2103+
} else {
2104+
final String errorMsg = result.getValue().get();
2105+
out.printf(
2106+
"FAILED: Change property %s%n\tFrom: \"%s\"%n\tTo: \"%s\"%n",
2107+
result.getKey().prop, result.getKey().oldVal,
2108+
result.getKey().newVal);
2109+
out.println("\tError: " + errorMsg + ".");
2110+
}
2111+
}
2112+
} else {
2113+
return 1;
21112114
}
2112-
} else {
2113-
return 1;
21142115
}
2115-
21162116
return 0;
21172117
}
21182118

0 commit comments

Comments
 (0)