Skip to content

Commit ca48b8f

Browse files
author
fuchaohong
committed
update ShellCommandFencer
1 parent be91412 commit ca48b8f

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ha/HAServiceTarget.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ public final Map<String, String> getFencingParameters() {
183183
* expose to fencing implementations/scripts. Fencing methods are free
184184
* to use this map as they see fit -- notably, the shell script
185185
* implementation takes each entry, prepends 'target_', substitutes
186-
* '_' for '.', and adds it to the environment of the script.
186+
* '_' for '.' and '-', and adds it to the environment of the script.
187187
*
188188
* Subclass implementations should be sure to delegate to the superclass
189189
* implementation as well as adding their own keys.

hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ha/ShellCommandFencer.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@
3939
* (cmd.exe on Windows) and may not include any closing parentheses.<p>
4040
*
4141
* The shell command will be run with an environment set up to contain
42-
* all of the current Hadoop configuration variables, with the '_' character
43-
* replacing any '.' characters in the configuration keys.<p>
42+
* all of the current Hadoop configuration variables, with the '_' character
43+
* replacing any '.' or '-' characters in the configuration keys.<p>
4444
*
4545
* If the shell command returns an exit code of 0, the fencing is
4646
* determined to be successful. If it returns any other exit code, the
@@ -202,7 +202,7 @@ private static String tryGetPid(Process p) {
202202

203203
/**
204204
* Set the environment of the subprocess to be the Configuration,
205-
* with '.'s replaced by '_'s.
205+
* with '.'s and '-'s replaced by '_'s.
206206
*/
207207
private void setConfAsEnvVars(Map<String, String> env) {
208208
for (Map.Entry<String, String> pair : getConf()) {
@@ -237,7 +237,7 @@ private void addTargetInfoAsEnvVars(HAServiceTarget target,
237237
for (Map.Entry<String, String> e :
238238
target.getFencingParameters().entrySet()) {
239239
String key = prefix + e.getKey();
240-
key = key.replace('.', '_');
240+
key = key.replaceAll("[.-]", "_");
241241
environment.put(key, e.getValue());
242242
}
243243
}

0 commit comments

Comments
 (0)