|
@@ -419,6 +419,39 @@ public class DFSAdmin extends FsShell {
|
|
return exitCode;
|
|
return exitCode;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Command to ask the namenode to set the balancer bandwidth for all of the
|
|
|
|
+ * datanodes.
|
|
|
|
+ * Usage: java DFSAdmin -setBalancerBandwidth bandwidth
|
|
|
|
+ * @param argv List of of command line parameters.
|
|
|
|
+ * @param idx The index of the command that is being processed.
|
|
|
|
+ * @exception IOException
|
|
|
|
+ */
|
|
|
|
+ public int setBalancerBandwidth(String[] argv, int idx) throws IOException {
|
|
|
|
+ long bandwidth;
|
|
|
|
+ int exitCode = -1;
|
|
|
|
+
|
|
|
|
+ try {
|
|
|
|
+ bandwidth = Long.parseLong(argv[idx]);
|
|
|
|
+ } catch (NumberFormatException nfe) {
|
|
|
|
+ System.err.println("NumberFormatException: " + nfe.getMessage());
|
|
|
|
+ System.err.println("Usage: java DFSAdmin"
|
|
|
|
+ + " [-setBalancerBandwidth <bandwidth in bytes per second>]");
|
|
|
|
+ return exitCode;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (!(fs instanceof DistributedFileSystem)) {
|
|
|
|
+ System.err.println("FileSystem is " + fs.getUri());
|
|
|
|
+ return exitCode;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ DistributedFileSystem dfs = (DistributedFileSystem) fs;
|
|
|
|
+ dfs.setBalancerBandwidth(bandwidth);
|
|
|
|
+ exitCode = 0;
|
|
|
|
+
|
|
|
|
+ return exitCode;
|
|
|
|
+ }
|
|
|
|
+
|
|
private void printHelp(String cmd) {
|
|
private void printHelp(String cmd) {
|
|
String summary = "hadoop dfsadmin is the command to execute DFS administrative commands.\n" +
|
|
String summary = "hadoop dfsadmin is the command to execute DFS administrative commands.\n" +
|
|
"The full syntax is: \n\n" +
|
|
"The full syntax is: \n\n" +
|
|
@@ -432,6 +465,7 @@ public class DFSAdmin extends FsShell {
|
|
"\t[-refreshServiceAcl]\n" +
|
|
"\t[-refreshServiceAcl]\n" +
|
|
"\t[-refreshUserToGroupsMappings]\n" +
|
|
"\t[-refreshUserToGroupsMappings]\n" +
|
|
"\t[refreshSuperUserGroupsConfiguration]\n" +
|
|
"\t[refreshSuperUserGroupsConfiguration]\n" +
|
|
|
|
+ "\t[-setBalancerBandwidth <bandwidth>]\n" +
|
|
"\t[-help [cmd]]\n";
|
|
"\t[-help [cmd]]\n";
|
|
|
|
|
|
String report ="-report: \tReports basic filesystem information and statistics.\n";
|
|
String report ="-report: \tReports basic filesystem information and statistics.\n";
|
|
@@ -486,7 +520,15 @@ public class DFSAdmin extends FsShell {
|
|
|
|
|
|
String refreshSuperUserGroupsConfiguration =
|
|
String refreshSuperUserGroupsConfiguration =
|
|
"-refreshSuperUserGroupsConfiguration: Refresh superuser proxy groups mappings\n";
|
|
"-refreshSuperUserGroupsConfiguration: Refresh superuser proxy groups mappings\n";
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+ String setBalancerBandwidth = "-setBalancerBandwidth <bandwidth>:\n" +
|
|
|
|
+ "\tChanges the network bandwidth used by each datanode during\n" +
|
|
|
|
+ "\tHDFS block balancing.\n\n" +
|
|
|
|
+ "\t\t<bandwidth> is the maximum number of bytes per second\n" +
|
|
|
|
+ "\t\tthat will be used by each datanode. This value overrides\n" +
|
|
|
|
+ "\t\tthe dfs.balance.bandwidthPerSec parameter.\n\n" +
|
|
|
|
+ "\t\t--- NOTE: The new value is not persistent on the DataNode.---\n";
|
|
|
|
+
|
|
String help = "-help [cmd]: \tDisplays help for the given command or all commands if none\n" +
|
|
String help = "-help [cmd]: \tDisplays help for the given command or all commands if none\n" +
|
|
"\t\tis specified.\n";
|
|
"\t\tis specified.\n";
|
|
|
|
|
|
@@ -518,6 +560,8 @@ public class DFSAdmin extends FsShell {
|
|
System.out.println(refreshUserToGroupsMappings);
|
|
System.out.println(refreshUserToGroupsMappings);
|
|
} else if ("refreshSuperUserGroupsConfiguration".equals(cmd)) {
|
|
} else if ("refreshSuperUserGroupsConfiguration".equals(cmd)) {
|
|
System.out.println(refreshSuperUserGroupsConfiguration);
|
|
System.out.println(refreshSuperUserGroupsConfiguration);
|
|
|
|
+ } else if ("setBalancerBandwidth".equals(cmd)) {
|
|
|
|
+ System.out.println(setBalancerBandwidth);
|
|
} else if ("help".equals(cmd)) {
|
|
} else if ("help".equals(cmd)) {
|
|
System.out.println(help);
|
|
System.out.println(help);
|
|
} else {
|
|
} else {
|
|
@@ -536,6 +580,7 @@ public class DFSAdmin extends FsShell {
|
|
System.out.println(refreshServiceAcl);
|
|
System.out.println(refreshServiceAcl);
|
|
System.out.println(refreshUserToGroupsMappings);
|
|
System.out.println(refreshUserToGroupsMappings);
|
|
System.out.println(refreshSuperUserGroupsConfiguration);
|
|
System.out.println(refreshSuperUserGroupsConfiguration);
|
|
|
|
+ System.out.println(setBalancerBandwidth);
|
|
System.out.println(help);
|
|
System.out.println(help);
|
|
System.out.println();
|
|
System.out.println();
|
|
ToolRunner.printGenericCommandUsage(System.out);
|
|
ToolRunner.printGenericCommandUsage(System.out);
|
|
@@ -764,6 +809,9 @@ public class DFSAdmin extends FsShell {
|
|
} else if ("-refreshSuperUserGroupsConfiguration".equals(cmd)) {
|
|
} else if ("-refreshSuperUserGroupsConfiguration".equals(cmd)) {
|
|
System.err.println("Usage: java DFSAdmin"
|
|
System.err.println("Usage: java DFSAdmin"
|
|
+ " [-refreshSuperUserGroupsConfiguration]");
|
|
+ " [-refreshSuperUserGroupsConfiguration]");
|
|
|
|
+ } else if ("-setBalancerBandwidth".equals(cmd)) {
|
|
|
|
+ System.err.println("Usage: java DFSAdmin"
|
|
|
|
+ + " [-setBalancerBandwidth <bandwidth in bytes per second>]");
|
|
} else {
|
|
} else {
|
|
System.err.println("Usage: java DFSAdmin");
|
|
System.err.println("Usage: java DFSAdmin");
|
|
System.err.println(" [-report]");
|
|
System.err.println(" [-report]");
|
|
@@ -780,6 +828,7 @@ public class DFSAdmin extends FsShell {
|
|
System.err.println(" ["+ClearQuotaCommand.USAGE+"]");
|
|
System.err.println(" ["+ClearQuotaCommand.USAGE+"]");
|
|
System.err.println(" ["+SetSpaceQuotaCommand.USAGE+"]");
|
|
System.err.println(" ["+SetSpaceQuotaCommand.USAGE+"]");
|
|
System.err.println(" ["+ClearSpaceQuotaCommand.USAGE+"]");
|
|
System.err.println(" ["+ClearSpaceQuotaCommand.USAGE+"]");
|
|
|
|
+ System.err.println(" [-setBalancerBandwidth <bandwidth in bytes per second>]");
|
|
System.err.println(" [-help [cmd]]");
|
|
System.err.println(" [-help [cmd]]");
|
|
System.err.println();
|
|
System.err.println();
|
|
ToolRunner.printGenericCommandUsage(System.err);
|
|
ToolRunner.printGenericCommandUsage(System.err);
|
|
@@ -851,6 +900,11 @@ public class DFSAdmin extends FsShell {
|
|
printUsage(cmd);
|
|
printUsage(cmd);
|
|
return exitCode;
|
|
return exitCode;
|
|
}
|
|
}
|
|
|
|
+ } else if ("-setBalancerBandwidth".equals(cmd)) {
|
|
|
|
+ if (argv.length != 2) {
|
|
|
|
+ printUsage(cmd);
|
|
|
|
+ return exitCode;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
// initialize DFSAdmin
|
|
// initialize DFSAdmin
|
|
@@ -895,6 +949,8 @@ public class DFSAdmin extends FsShell {
|
|
exitCode = refreshUserToGroupsMappings();
|
|
exitCode = refreshUserToGroupsMappings();
|
|
} else if ("-refreshSuperUserGroupsConfiguration".equals(cmd)) {
|
|
} else if ("-refreshSuperUserGroupsConfiguration".equals(cmd)) {
|
|
exitCode = refreshSuperUserGroupsConfiguration();
|
|
exitCode = refreshSuperUserGroupsConfiguration();
|
|
|
|
+ } else if ("-setBalancerBandwidth".equals(cmd)) {
|
|
|
|
+ exitCode = setBalancerBandwidth(argv, i);
|
|
} else if ("-help".equals(cmd)) {
|
|
} else if ("-help".equals(cmd)) {
|
|
if (i < argv.length) {
|
|
if (i < argv.length) {
|
|
printHelp(argv[i]);
|
|
printHelp(argv[i]);
|