HADOOP-19134. Use StringBuilder instead of StringBuffer. (#6692). Contributed by PJ Fanning

This commit is contained in:
PJ Fanning 2024-08-18 16:59:12 +01:00 committed by GitHub
parent b5f88990b7
commit 59dba6e1bd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
122 changed files with 195 additions and 196 deletions

View File

@ -169,7 +169,7 @@ protected int init(String[] args) throws IOException {
@Override @Override
public String getCommandUsage() { public String getCommandUsage() {
StringBuffer sbuf = new StringBuffer(USAGE_PREFIX + COMMANDS); StringBuilder sbuf = new StringBuilder(USAGE_PREFIX + COMMANDS);
String banner = StringUtils.repeat("=", 66); String banner = StringUtils.repeat("=", 66);
sbuf.append(banner + "\n"); sbuf.append(banner + "\n");
sbuf.append(CreateCommand.USAGE + ":\n\n" + CreateCommand.DESC + "\n"); sbuf.append(CreateCommand.USAGE + ":\n\n" + CreateCommand.DESC + "\n");

View File

@ -163,7 +163,7 @@ protected void parseExecResult(BufferedReader lines) throws IOException {
@VisibleForTesting @VisibleForTesting
protected void parseOutput() throws IOException { protected void parseOutput() throws IOException {
if (output.size() < 2) { if (output.size() < 2) {
StringBuffer sb = new StringBuffer("Fewer lines of output than expected"); StringBuilder sb = new StringBuilder("Fewer lines of output than expected");
if (output.size() > 0) { if (output.size() > 0) {
sb.append(": " + output.get(0)); sb.append(": " + output.get(0));
} }

View File

@ -1052,7 +1052,7 @@ private static void unTarUsingTar(InputStream inputStream, File untarDir,
private static void unTarUsingTar(File inFile, File untarDir, private static void unTarUsingTar(File inFile, File untarDir,
boolean gzipped) throws IOException { boolean gzipped) throws IOException {
StringBuffer untarCommand = new StringBuffer(); StringBuilder untarCommand = new StringBuilder();
// not using canonical path here; this postpones relative path // not using canonical path here; this postpones relative path
// resolution until bash is executed. // resolution until bash is executed.
final String source = "'" + FileUtil.makeSecureShellPath(inFile) + "'"; final String source = "'" + FileUtil.makeSecureShellPath(inFile) + "'";

View File

@ -58,7 +58,7 @@ public RejectState getRejectState() {
@Override @Override
public String toString() { public String toString() {
return new StringBuffer().append("xid:").append(xid) return new StringBuilder().append("xid:").append(xid)
.append(",messageType:").append(messageType).append("verifier_flavor:") .append(",messageType:").append(messageType).append("verifier_flavor:")
.append(verifier.getFlavor()).append("rejectState:") .append(verifier.getFlavor()).append("rejectState:")
.append(rejectState).toString(); .append(rejectState).toString();

View File

@ -148,7 +148,7 @@ public static Configuration excludeIncompatibleCredentialProviders(
if (providerPath == null) { if (providerPath == null) {
return config; return config;
} }
StringBuffer newProviderPath = new StringBuffer(); StringBuilder newProviderPath = new StringBuilder();
String[] providers = providerPath.split(","); String[] providers = providerPath.split(",");
Path path = null; Path path = null;
for (String provider: providers) { for (String provider: providers) {

View File

@ -127,7 +127,7 @@ protected int init(String[] args) throws IOException {
@Override @Override
public String getCommandUsage() { public String getCommandUsage() {
StringBuffer sbuf = new StringBuffer(USAGE_PREFIX + COMMANDS); StringBuilder sbuf = new StringBuilder(USAGE_PREFIX + COMMANDS);
String banner = StringUtils.repeat("=", 66); String banner = StringUtils.repeat("=", 66);
sbuf.append(banner + "\n") sbuf.append(banner + "\n")
.append(CreateCommand.USAGE + ":\n\n" + CreateCommand.DESC + "\n") .append(CreateCommand.USAGE + ":\n\n" + CreateCommand.DESC + "\n")

View File

@ -370,7 +370,7 @@ public void check(final String[] hosts, final String[] cns,
strictWithSubDomains); strictWithSubDomains);
} }
// Build up lists of allowed hosts For logging/debugging purposes. // Build up lists of allowed hosts For logging/debugging purposes.
StringBuffer buf = new StringBuffer(32); StringBuilder buf = new StringBuilder(32);
buf.append('<'); buf.append('<');
for (int i = 0; i < hosts.length; i++) { for (int i = 0; i < hosts.length; i++) {
String h = hosts[i]; String h = hosts[i];
@ -408,15 +408,15 @@ public void check(final String[] hosts, final String[] cns,
throw new SSLException(msg); throw new SSLException(msg);
} }
// StringBuffer for building the error message. // StringBuilder for building the error message.
buf = new StringBuffer(); buf = new StringBuilder();
boolean match = false; boolean match = false;
out: out:
for (Iterator<String> it = names.iterator(); it.hasNext();) { for (Iterator<String> it = names.iterator(); it.hasNext();) {
// Don't trim the CN, though! // Don't trim the CN, though!
final String cn = StringUtils.toLowerCase(it.next()); final String cn = StringUtils.toLowerCase(it.next());
// Store CN in StringBuffer in case we need to report an error. // Store CN in StringBuilder in case we need to report an error.
buf.append(" <") buf.append(" <")
.append(cn) .append(cn)
.append('>'); .append('>');

View File

@ -1014,7 +1014,7 @@ private void runCommand() throws IOException {
BufferedReader inReader = BufferedReader inReader =
new BufferedReader(new InputStreamReader(process.getInputStream(), new BufferedReader(new InputStreamReader(process.getInputStream(),
StandardCharsets.UTF_8)); StandardCharsets.UTF_8));
final StringBuffer errMsg = new StringBuffer(); final StringBuilder errMsg = new StringBuilder();
// read error and input streams as this would free up the buffers // read error and input streams as this would free up the buffers
// free the error stream buffer // free the error stream buffer
@ -1208,7 +1208,7 @@ public static class ShellCommandExecutor extends Shell
implements CommandExecutor { implements CommandExecutor {
private String[] command; private String[] command;
private StringBuffer output; private StringBuilder output;
public ShellCommandExecutor(String[] execString) { public ShellCommandExecutor(String[] execString) {
@ -1289,7 +1289,7 @@ public String[] getExecString() {
@Override @Override
protected void parseExecResult(BufferedReader lines) throws IOException { protected void parseExecResult(BufferedReader lines) throws IOException {
output = new StringBuffer(); output = new StringBuilder();
char[] buf = new char[512]; char[] buf = new char[512];
int nRead; int nRead;
while ( (nRead = lines.read(buf, 0, buf.length)) > 0 ) { while ( (nRead = lines.read(buf, 0, buf.length)) > 0 ) {

View File

@ -1334,7 +1334,7 @@ public static String wrap(String str, int wrapLength, String newLineStr,
int inputLineLength = str.length(); int inputLineLength = str.length();
int offset = 0; int offset = 0;
StringBuffer wrappedLine = new StringBuffer(inputLineLength + 32); StringBuilder wrappedLine = new StringBuilder(inputLineLength + 32);
while(inputLineLength - offset > wrapLength) { while(inputLineLength - offset > wrapLength) {
if(str.charAt(offset) == 32) { if(str.charAt(offset) == 32) {

View File

@ -580,7 +580,7 @@ public MockQuotaUsage() {
public String toString(boolean hOption, public String toString(boolean hOption,
boolean tOption, List<StorageType> types) { boolean tOption, List<StorageType> types) {
if (tOption) { if (tOption) {
StringBuffer result = new StringBuffer(); StringBuilder result = new StringBuilder();
result.append(hOption ? HUMAN : BYTES); result.append(hOption ? HUMAN : BYTES);
for (StorageType type : types) { for (StorageType type : types) {

View File

@ -114,7 +114,7 @@ public void testUriErrors() throws Exception {
} }
private static char[] generatePassword(int length) { private static char[] generatePassword(int length) {
StringBuffer sb = new StringBuffer(); StringBuilder sb = new StringBuilder();
Random r = new Random(); Random r = new Random();
for (int i = 0; i < length; i++) { for (int i = 0; i < length; i++) {
sb.append(chars[r.nextInt(chars.length)]); sb.append(chars[r.nextInt(chars.length)]);

View File

@ -480,7 +480,7 @@ public void testBashQuote() {
@Test(timeout=120000) @Test(timeout=120000)
public void testDestroyAllShellProcesses() throws Throwable { public void testDestroyAllShellProcesses() throws Throwable {
Assume.assumeFalse(WINDOWS); Assume.assumeFalse(WINDOWS);
StringBuffer sleepCommand = new StringBuffer(); StringBuilder sleepCommand = new StringBuilder();
sleepCommand.append("sleep 200"); sleepCommand.append("sleep 200");
String[] shellCmd = {"bash", "-c", sleepCommand.toString()}; String[] shellCmd = {"bash", "-c", sleepCommand.toString()};
final ShellCommandExecutor shexc1 = new ShellCommandExecutor(shellCmd); final ShellCommandExecutor shexc1 = new ShellCommandExecutor(shellCmd);

View File

@ -86,7 +86,7 @@ public void log(Object o) {
*/ */
@Test @Test
public void testSingleton() throws Throwable { public void testSingleton() throws Throwable {
StringBuffer result = new StringBuffer(); StringBuilder result = new StringBuilder();
String name = "singleton"; String name = "singleton";
RemoteIterator<String> it = remoteIteratorFromSingleton(name); RemoteIterator<String> it = remoteIteratorFromSingleton(name);
assertStringValueContains(it, "SingletonIterator"); assertStringValueContains(it, "SingletonIterator");

View File

@ -167,7 +167,7 @@ protected String generateLoadBalancingKeyProviderUriString() {
if (kmsUrl == null || kmsUrl.size() == 0) { if (kmsUrl == null || kmsUrl.size() == 0) {
return null; return null;
} }
StringBuffer sb = new StringBuffer(); StringBuilder sb = new StringBuilder();
for (int i = 0; i < kmsUrl.size(); i++) { for (int i = 0; i < kmsUrl.size(); i++) {
sb.append(KMSClientProvider.SCHEME_NAME + "://" + sb.append(KMSClientProvider.SCHEME_NAME + "://" +

View File

@ -195,7 +195,7 @@ private Integer listCorruptFileBlocks(String dir, String baseUrl)
final String cookiePrefix = "Cookie:"; final String cookiePrefix = "Cookie:";
boolean allDone = false; boolean allDone = false;
while (!allDone) { while (!allDone) {
final StringBuffer url = new StringBuffer(baseUrl); final StringBuilder url = new StringBuilder(baseUrl);
if (cookie > 0) { if (cookie > 0) {
url.append("&startblockafter=").append(String.valueOf(cookie)); url.append("&startblockafter=").append(String.valueOf(cookie));
} }

View File

@ -32,7 +32,6 @@
import org.apache.hadoop.hdfs.server.namenode.FSEditLogOp; import org.apache.hadoop.hdfs.server.namenode.FSEditLogOp;
import org.apache.hadoop.hdfs.server.namenode.FSEditLogOpCodes; import org.apache.hadoop.hdfs.server.namenode.FSEditLogOpCodes;
import org.apache.hadoop.hdfs.server.namenode.FSEditLogOp.OpInstanceCache; import org.apache.hadoop.hdfs.server.namenode.FSEditLogOp.OpInstanceCache;
import org.apache.hadoop.hdfs.tools.offlineEditsViewer.OfflineEditsViewer;
import org.apache.hadoop.hdfs.util.XMLUtils.Stanza; import org.apache.hadoop.hdfs.util.XMLUtils.Stanza;
import org.xml.sax.Attributes; import org.xml.sax.Attributes;
import org.xml.sax.InputSource; import org.xml.sax.InputSource;
@ -57,7 +56,7 @@ class OfflineEditsXmlLoader
private Stanza stanza; private Stanza stanza;
private Stack<Stanza> stanzaStack; private Stack<Stanza> stanzaStack;
private FSEditLogOpCodes opCode; private FSEditLogOpCodes opCode;
private StringBuffer cbuf; private StringBuilder cbuf;
private long nextTxId; private long nextTxId;
private final OpInstanceCache opCache = new OpInstanceCache(); private final OpInstanceCache opCache = new OpInstanceCache();
@ -119,7 +118,7 @@ public void startDocument() {
stanza = null; stanza = null;
stanzaStack = new Stack<Stanza>(); stanzaStack = new Stack<Stanza>();
opCode = null; opCode = null;
cbuf = new StringBuffer(); cbuf = new StringBuilder();
nextTxId = -1; nextTxId = -1;
} }
@ -182,7 +181,7 @@ public void startElement (String uri, String name,
@Override @Override
public void endElement (String uri, String name, String qName) { public void endElement (String uri, String name, String qName) {
String str = XMLUtils.unmangleXmlString(cbuf.toString(), false).trim(); String str = XMLUtils.unmangleXmlString(cbuf.toString(), false).trim();
cbuf = new StringBuffer(); cbuf = new StringBuilder();
switch (state) { switch (state) {
case EXPECT_EDITS_TAG: case EXPECT_EDITS_TAG:
throw new InvalidXmlException("expected <EDITS/>"); throw new InvalidXmlException("expected <EDITS/>");

View File

@ -85,7 +85,7 @@ long getId() {
} }
String getType() { String getType() {
StringBuffer s = new StringBuffer(); StringBuilder s = new StringBuilder();
if (type.contains(PBImageCorruptionType.CORRUPT_NODE)) { if (type.contains(PBImageCorruptionType.CORRUPT_NODE)) {
s.append(PBImageCorruptionType.CORRUPT_NODE); s.append(PBImageCorruptionType.CORRUPT_NODE);
} }

View File

@ -340,7 +340,7 @@ private class MyFile {
for (int idx = 0; idx < nLevels; idx++) { for (int idx = 0; idx < nLevels; idx++) {
levels[idx] = gen.nextInt(10); levels[idx] = gen.nextInt(10);
} }
StringBuffer sb = new StringBuffer(); StringBuilder sb = new StringBuilder();
for (int idx = 0; idx < nLevels; idx++) { for (int idx = 0; idx < nLevels; idx++) {
sb.append(dirNames[levels[idx]]); sb.append(dirNames[levels[idx]]);
sb.append("/"); sb.append("/");

View File

@ -180,7 +180,7 @@ private Trash getPerUserTrash(UserGroupInformation ugi,
FileSystem fileSystem, Configuration config) throws IOException { FileSystem fileSystem, Configuration config) throws IOException {
// generate an unique path per instance // generate an unique path per instance
UUID trashId = UUID.randomUUID(); UUID trashId = UUID.randomUUID();
StringBuffer sb = new StringBuffer() StringBuilder sb = new StringBuilder()
.append(ugi.getUserName()) .append(ugi.getUserName())
.append("-") .append("-")
.append(trashId.toString()); .append(trashId.toString());

View File

@ -1833,7 +1833,7 @@ public void testMetaSavePostponedMisreplicatedBlocks() throws IOException {
DataInputStream in = new DataInputStream(fstream); DataInputStream in = new DataInputStream(fstream);
BufferedReader reader = new BufferedReader(new InputStreamReader(in)); BufferedReader reader = new BufferedReader(new InputStreamReader(in));
StringBuffer buffer = new StringBuffer(); StringBuilder buffer = new StringBuilder();
String line; String line;
try { try {
while ((line = reader.readLine()) != null) { while ((line = reader.readLine()) != null) {
@ -1861,7 +1861,7 @@ public void testMetaSaveMissingReplicas() throws Exception {
FileInputStream fstream = new FileInputStream(file); FileInputStream fstream = new FileInputStream(file);
DataInputStream in = new DataInputStream(fstream); DataInputStream in = new DataInputStream(fstream);
BufferedReader reader = new BufferedReader(new InputStreamReader(in)); BufferedReader reader = new BufferedReader(new InputStreamReader(in));
StringBuffer buffer = new StringBuffer(); StringBuilder buffer = new StringBuilder();
String line; String line;
try { try {
while ((line = reader.readLine()) != null) { while ((line = reader.readLine()) != null) {
@ -1933,7 +1933,7 @@ public void testMetaSaveInMaintenanceReplicas() throws Exception {
FileInputStream fstream = new FileInputStream(file); FileInputStream fstream = new FileInputStream(file);
DataInputStream in = new DataInputStream(fstream); DataInputStream in = new DataInputStream(fstream);
BufferedReader reader = new BufferedReader(new InputStreamReader(in)); BufferedReader reader = new BufferedReader(new InputStreamReader(in));
StringBuffer buffer = new StringBuffer(); StringBuilder buffer = new StringBuilder();
String line; String line;
try { try {
while ((line = reader.readLine()) != null) { while ((line = reader.readLine()) != null) {
@ -1989,7 +1989,7 @@ public void testMetaSaveDecommissioningReplicas() throws Exception {
FileInputStream fstream = new FileInputStream(file); FileInputStream fstream = new FileInputStream(file);
DataInputStream in = new DataInputStream(fstream); DataInputStream in = new DataInputStream(fstream);
BufferedReader reader = new BufferedReader(new InputStreamReader(in)); BufferedReader reader = new BufferedReader(new InputStreamReader(in));
StringBuffer buffer = new StringBuffer(); StringBuilder buffer = new StringBuilder();
String line; String line;
try { try {
while ((line = reader.readLine()) != null) { while ((line = reader.readLine()) != null) {

View File

@ -196,7 +196,7 @@ public void testExcludeDataNodes() throws Exception {
//For GETFILECHECKSUM, OPEN and APPEND, //For GETFILECHECKSUM, OPEN and APPEND,
//the chosen datanode must be different with exclude nodes. //the chosen datanode must be different with exclude nodes.
StringBuffer sb = new StringBuffer(); StringBuilder sb = new StringBuilder();
for (int i = 0; i < 2; i++) { for (int i = 0; i < 2; i++) {
sb.append(locations[i].getXferAddr()); sb.append(locations[i].getXferAddr());
{ // test GETFILECHECKSUM { // test GETFILECHECKSUM

View File

@ -83,7 +83,7 @@ public class ConfBlock extends HtmlBlock {
__(). __().
tbody(); tbody();
for (ConfEntryInfo entry : info.getProperties()) { for (ConfEntryInfo entry : info.getProperties()) {
StringBuffer buffer = new StringBuffer(); StringBuilder buffer = new StringBuilder();
String[] sources = entry.getSource(); String[] sources = entry.getSource();
//Skip the last entry, because it is always the same HDFS file, and //Skip the last entry, because it is always the same HDFS file, and
// output them in reverse order so most recent is output first // output them in reverse order so most recent is output first

View File

@ -2080,7 +2080,7 @@ private void writeOutput(TaskAttempt attempt, Configuration conf)
private void validateOutput() throws IOException { private void validateOutput() throws IOException {
File expectedFile = new File(new Path(outputDir, partFile).toString()); File expectedFile = new File(new Path(outputDir, partFile).toString());
StringBuffer expectedOutput = new StringBuffer(); StringBuilder expectedOutput = new StringBuilder();
expectedOutput.append(key1).append('\t').append(val1).append("\n"); expectedOutput.append(key1).append('\t').append(val1).append("\n");
expectedOutput.append(val1).append("\n"); expectedOutput.append(val1).append("\n");
expectedOutput.append(val2).append("\n"); expectedOutput.append(val2).append("\n");

View File

@ -516,7 +516,7 @@ public void verifyTaskAttemptGeneric(TaskAttempt ta, TaskType ttype,
String expectDiag = ""; String expectDiag = "";
List<String> diagnosticsList = ta.getDiagnostics(); List<String> diagnosticsList = ta.getDiagnostics();
if (diagnosticsList != null && !diagnostics.isEmpty()) { if (diagnosticsList != null && !diagnostics.isEmpty()) {
StringBuffer b = new StringBuffer(); StringBuilder b = new StringBuilder();
for (String diag : diagnosticsList) { for (String diag : diagnosticsList) {
b.append(diag); b.append(diag);
} }

View File

@ -600,7 +600,7 @@ public void verifyAMJobGenericSecure(Job job, int mapsPending,
String diagString = ""; String diagString = "";
List<String> diagList = job.getDiagnostics(); List<String> diagList = job.getDiagnostics();
if (diagList != null && !diagList.isEmpty()) { if (diagList != null && !diagList.isEmpty()) {
StringBuffer b = new StringBuffer(); StringBuilder b = new StringBuilder();
for (String diag : diagList) { for (String diag : diagList) {
b.append(diag); b.append(diag);
} }

View File

@ -1027,8 +1027,8 @@ static void setupChildMapredLocalDirs(Task t, JobConf conf) {
String taskId = t.getTaskID().toString(); String taskId = t.getTaskID().toString();
boolean isCleanup = t.isTaskCleanupTask(); boolean isCleanup = t.isTaskCleanupTask();
String user = t.getUser(); String user = t.getUser();
StringBuffer childMapredLocalDir = StringBuilder childMapredLocalDir =
new StringBuffer(localDirs[0] + Path.SEPARATOR new StringBuilder(localDirs[0] + Path.SEPARATOR
+ getLocalTaskDir(user, jobId, taskId, isCleanup)); + getLocalTaskDir(user, jobId, taskId, isCleanup));
for (int i = 1; i < localDirs.length; i++) { for (int i = 1; i < localDirs.length; i++) {
childMapredLocalDir.append("," + localDirs[i] + Path.SEPARATOR childMapredLocalDir.append("," + localDirs[i] + Path.SEPARATOR

View File

@ -145,7 +145,7 @@ public static String getApplicationWebURLOnJHSWithoutScheme(Configuration conf,
InetSocketAddress address = NetUtils.createSocketAddr( InetSocketAddress address = NetUtils.createSocketAddr(
hsAddress, getDefaultJHSWebappPort(), hsAddress, getDefaultJHSWebappPort(),
getDefaultJHSWebappURLWithoutScheme()); getDefaultJHSWebappURLWithoutScheme());
StringBuffer sb = new StringBuffer(); StringBuilder sb = new StringBuilder();
if (address.getAddress() != null && if (address.getAddress() != null &&
(address.getAddress().isAnyLocalAddress() || (address.getAddress().isAnyLocalAddress() ||
address.getAddress().isLoopbackAddress())) { address.getAddress().isLoopbackAddress())) {

View File

@ -102,7 +102,7 @@ public void testNewApis() throws Exception {
static String readOutput(Path outDir, Configuration conf) static String readOutput(Path outDir, Configuration conf)
throws IOException { throws IOException {
FileSystem fs = outDir.getFileSystem(conf); FileSystem fs = outDir.getFileSystem(conf);
StringBuffer result = new StringBuffer(); StringBuilder result = new StringBuilder();
Path[] fileList = FileUtil.stat2Paths(fs.listStatus(outDir, Path[] fileList = FileUtil.stat2Paths(fs.listStatus(outDir,
new Utils.OutputFileUtils.OutputFilesFilter())); new Utils.OutputFileUtils.OutputFilesFilter()));

View File

@ -470,7 +470,7 @@ public static void addInputPaths(JobConf conf, String commaSeparatedPaths) {
*/ */
public static void setInputPaths(JobConf conf, Path... inputPaths) { public static void setInputPaths(JobConf conf, Path... inputPaths) {
Path path = new Path(conf.getWorkingDirectory(), inputPaths[0]); Path path = new Path(conf.getWorkingDirectory(), inputPaths[0]);
StringBuffer str = new StringBuffer(StringUtils.escapeString(path.toString())); StringBuilder str = new StringBuilder(StringUtils.escapeString(path.toString()));
for(int i = 1; i < inputPaths.length;i++) { for(int i = 1; i < inputPaths.length;i++) {
str.append(StringUtils.COMMA_STR); str.append(StringUtils.COMMA_STR);
path = new Path(conf.getWorkingDirectory(), inputPaths[i]); path = new Path(conf.getWorkingDirectory(), inputPaths[i]);

View File

@ -61,7 +61,7 @@ public List<IOException> getProblems() {
* @return the concatenated messages from all of the problems. * @return the concatenated messages from all of the problems.
*/ */
public String getMessage() { public String getMessage() {
StringBuffer result = new StringBuffer(); StringBuilder result = new StringBuilder();
Iterator<IOException> itr = problems.iterator(); Iterator<IOException> itr = problems.iterator();
while(itr.hasNext()) { while(itr.hasNext()) {
result.append(itr.next().getMessage()); result.append(itr.next().getMessage());

View File

@ -70,7 +70,7 @@ private void addToSet(Set<String> set, String[] array) {
@Override @Override
public String toString() { public String toString() {
StringBuffer sb = new StringBuffer(); StringBuilder sb = new StringBuilder();
for(int i=0; i < getPaths().length; i++) { for(int i=0; i < getPaths().length; i++) {
sb.append(getPath(i).toUri().getPath() + ":0+" + getLength(i)); sb.append(getPath(i).toUri().getPath() + ":0+" + getLength(i));
if (i < getPaths().length -1) { if (i < getPaths().length -1) {

View File

@ -207,7 +207,7 @@ public synchronized void write(DataOutput out) throws IOException {
} }
public String toString() { public String toString() {
StringBuffer sb = new StringBuffer(); StringBuilder sb = new StringBuilder();
Iterator<Range> it = ranges.iterator(); Iterator<Range> it = ranges.iterator();
while(it.hasNext()) { while(it.hasNext()) {
Range range = it.next(); Range range = it.next();

View File

@ -518,8 +518,8 @@ static String buildCommandLine(List<String> setup, List<String> cmd,
throws IOException { throws IOException {
String stdout = FileUtil.makeShellPath(stdoutFilename); String stdout = FileUtil.makeShellPath(stdoutFilename);
String stderr = FileUtil.makeShellPath(stderrFilename); String stderr = FileUtil.makeShellPath(stderrFilename);
StringBuffer mergedCmd = new StringBuffer(); StringBuilder mergedCmd = new StringBuilder();
// Export the pid of taskJvm to env variable JVM_PID. // Export the pid of taskJvm to env variable JVM_PID.
// Currently pid is not used on Windows // Currently pid is not used on Windows
@ -606,7 +606,7 @@ static String buildDebugScriptCommandLine(List<String> cmd, String debugout)
*/ */
public static String addCommand(List<String> cmd, boolean isExecutable) public static String addCommand(List<String> cmd, boolean isExecutable)
throws IOException { throws IOException {
StringBuffer command = new StringBuffer(); StringBuilder command = new StringBuilder();
for(String s: cmd) { for(String s: cmd) {
command.append('\''); command.append('\'');
if (isExecutable) { if (isExecutable) {

View File

@ -96,7 +96,7 @@ public class FieldSelectionMapReduce<K, V>
LoggerFactory.getLogger("FieldSelectionMapReduce"); LoggerFactory.getLogger("FieldSelectionMapReduce");
private String specToString() { private String specToString() {
StringBuffer sb = new StringBuffer(); StringBuilder sb = new StringBuilder();
sb.append("fieldSeparator: ").append(fieldSeparator).append("\n"); sb.append("fieldSeparator: ").append(fieldSeparator).append("\n");
sb.append("mapOutputKeyValueSpec: ").append(mapOutputKeyValueSpec).append( sb.append("mapOutputKeyValueSpec: ").append(mapOutputKeyValueSpec).append(

View File

@ -476,7 +476,7 @@ public String toString() {
} catch (IOException e) { } catch (IOException e) {
} catch (InterruptedException ie) { } catch (InterruptedException ie) {
} }
StringBuffer sb = new StringBuffer(); StringBuilder sb = new StringBuilder();
sb.append("Job: ").append(status.getJobID()).append("\n"); sb.append("Job: ").append(status.getJobID()).append("\n");
sb.append("Job File: ").append(status.getJobFile()).append("\n"); sb.append("Job File: ").append(status.getJobFile()).append("\n");
sb.append("Job Tracking URL : ").append(status.getTrackingUrl()); sb.append("Job Tracking URL : ").append(status.getTrackingUrl());

View File

@ -636,7 +636,7 @@ public synchronized void setUber(boolean isUber) {
} }
public String toString() { public String toString() {
StringBuffer buffer = new StringBuffer(); StringBuilder buffer = new StringBuilder();
buffer.append("job-id : " + jobid); buffer.append("job-id : " + jobid);
buffer.append("uber-mode : " + isUber); buffer.append("uber-mode : " + isUber);
buffer.append("map-progress : " + mapProgress); buffer.append("map-progress : " + mapProgress);

View File

@ -188,7 +188,7 @@ protected void setTaskTrackerHttp(String taskTrackerHttp) {
@Override @Override
public String toString(){ public String toString(){
StringBuffer buf = new StringBuffer(); StringBuilder buf = new StringBuilder();
buf.append("Task Id : "); buf.append("Task Id : ");
buf.append(taskId); buf.append(taskId);
buf.append(", Status : "); buf.append(", Status : ");

View File

@ -83,7 +83,7 @@ public void addNextValue(Object val) {
public String getReport() { public String getReport() {
long[] counts = new long[items.size()]; long[] counts = new long[items.size()];
StringBuffer sb = new StringBuffer(); StringBuilder sb = new StringBuilder();
Iterator<Object> iter = items.values().iterator(); Iterator<Object> iter = items.values().iterator();
int i = 0; int i = 0;
while (iter.hasNext()) { while (iter.hasNext()) {
@ -133,7 +133,7 @@ public String getReport() {
* the histogram * the histogram
*/ */
public String getReportDetails() { public String getReportDetails() {
StringBuffer sb = new StringBuffer(); StringBuilder sb = new StringBuilder();
Iterator<Entry<Object,Object>> iter = items.entrySet().iterator(); Iterator<Entry<Object,Object>> iter = items.entrySet().iterator();
while (iter.hasNext()) { while (iter.hasNext()) {
Entry<Object,Object> en = iter.next(); Entry<Object,Object> en = iter.next();

View File

@ -121,10 +121,10 @@ private static String selectFields(String[] fields, List<Integer> fieldList,
int allFieldsFrom, String separator) { int allFieldsFrom, String separator) {
String retv = null; String retv = null;
int i = 0; int i = 0;
StringBuffer sb = null; StringBuilder sb = null;
if (fieldList != null && fieldList.size() > 0) { if (fieldList != null && fieldList.size() > 0) {
if (sb == null) { if (sb == null) {
sb = new StringBuffer(); sb = new StringBuilder();
} }
for (Integer index : fieldList) { for (Integer index : fieldList) {
if (index < fields.length) { if (index < fields.length) {
@ -135,7 +135,7 @@ private static String selectFields(String[] fields, List<Integer> fieldList,
} }
if (allFieldsFrom >= 0) { if (allFieldsFrom >= 0) {
if (sb == null) { if (sb == null) {
sb = new StringBuffer(); sb = new StringBuilder();
} }
for (i = allFieldsFrom; i < fields.length; i++) { for (i = allFieldsFrom; i < fields.length; i++) {
sb.append(fields[i]).append(separator); sb.append(fields[i]).append(separator);
@ -168,7 +168,7 @@ public static int parseOutputKeyValueSpec(String keyValueSpec,
public static String specToString(String fieldSeparator, String keyValueSpec, public static String specToString(String fieldSeparator, String keyValueSpec,
int allValueFieldsFrom, List<Integer> keyFieldList, int allValueFieldsFrom, List<Integer> keyFieldList,
List<Integer> valueFieldList) { List<Integer> valueFieldList) {
StringBuffer sb = new StringBuffer(); StringBuilder sb = new StringBuilder();
sb.append("fieldSeparator: ").append(fieldSeparator).append("\n"); sb.append("fieldSeparator: ").append(fieldSeparator).append("\n");
sb.append("keyValueSpec: ").append(keyValueSpec).append("\n"); sb.append("keyValueSpec: ").append(keyValueSpec).append("\n");

View File

@ -803,7 +803,7 @@ public boolean accept(Path path) {
} }
public String toString() { public String toString() {
StringBuffer buf = new StringBuffer(); StringBuilder buf = new StringBuilder();
buf.append("["); buf.append("[");
for (PathFilter f: filters) { for (PathFilter f: filters) {
buf.append(f); buf.append(f);

View File

@ -175,7 +175,7 @@ public void write(DataOutput out) throws IOException {
@Override @Override
public String toString() { public String toString() {
StringBuffer sb = new StringBuffer(); StringBuilder sb = new StringBuilder();
for (int i = 0; i < paths.length; i++) { for (int i = 0; i < paths.length; i++) {
if (i == 0 ) { if (i == 0 ) {
sb.append("Paths:"); sb.append("Paths:");
@ -188,7 +188,7 @@ public String toString() {
} }
if (locations != null) { if (locations != null) {
String locs = ""; String locs = "";
StringBuffer locsb = new StringBuffer(); StringBuilder locsb = new StringBuilder();
for (int i = 0; i < locations.length; i++) { for (int i = 0; i < locations.length; i++) {
locsb.append(locations[i] + ":"); locsb.append(locations[i] + ":");
} }

View File

@ -569,7 +569,7 @@ public static void setInputPaths(Job job,
Path... inputPaths) throws IOException { Path... inputPaths) throws IOException {
Configuration conf = job.getConfiguration(); Configuration conf = job.getConfiguration();
Path path = inputPaths[0].getFileSystem(conf).makeQualified(inputPaths[0]); Path path = inputPaths[0].getFileSystem(conf).makeQualified(inputPaths[0]);
StringBuffer str = new StringBuffer(StringUtils.escapeString(path.toString())); StringBuilder str = new StringBuilder(StringUtils.escapeString(path.toString()));
for(int i = 1; i < inputPaths.length;i++) { for(int i = 1; i < inputPaths.length;i++) {
str.append(StringUtils.COMMA_STR); str.append(StringUtils.COMMA_STR);
path = inputPaths[i].getFileSystem(conf).makeQualified(inputPaths[i]); path = inputPaths[i].getFileSystem(conf).makeQualified(inputPaths[i]);

View File

@ -60,7 +60,7 @@ public List<IOException> getProblems() {
* @return the concatenated messages from all of the problems. * @return the concatenated messages from all of the problems.
*/ */
public String getMessage() { public String getMessage() {
StringBuffer result = new StringBuffer(); StringBuilder result = new StringBuilder();
Iterator<IOException> itr = problems.iterator(); Iterator<IOException> itr = problems.iterator();
while(itr.hasNext()) { while(itr.hasNext()) {
result.append(itr.next().getMessage()); result.append(itr.next().getMessage());

View File

@ -90,7 +90,7 @@ public ControlledJob(Configuration conf) throws IOException {
@Override @Override
public String toString() { public String toString() {
StringBuffer sb = new StringBuffer(); StringBuilder sb = new StringBuilder();
sb.append("job name:\t").append(this.job.getJobName()).append("\n"); sb.append("job name:\t").append(this.job.getJobName()).append("\n");
sb.append("job id:\t").append(this.controlID).append("\n"); sb.append("job id:\t").append(this.controlID).append("\n");
sb.append("job state:\t").append(this.state).append("\n"); sb.append("job state:\t").append(this.state).append("\n");

View File

@ -147,7 +147,7 @@ public void remove() {
* <tt>[&lt;child1&gt;,&lt;child2&gt;,...,&lt;childn&gt;]</tt> * <tt>[&lt;child1&gt;,&lt;child2&gt;,...,&lt;childn&gt;]</tt>
*/ */
public String toString() { public String toString() {
StringBuffer buf = new StringBuffer("["); StringBuilder buf = new StringBuilder("[");
for (int i = 0; i < values.length; ++i) { for (int i = 0; i < values.length; ++i) {
buf.append(has(i) ? values[i].toString() : ""); buf.append(has(i) ? values[i].toString() : "");
buf.append(","); buf.append(",");

View File

@ -123,7 +123,7 @@ public void write(DataOutput out) throws IOException {
@Override @Override
public String toString() { public String toString() {
StringBuffer buf = new StringBuffer(); StringBuilder buf = new StringBuilder();
buf.append("data-size : " + inputDataLength + "\n"); buf.append("data-size : " + inputDataLength + "\n");
buf.append("start-offset : " + startOffset + "\n"); buf.append("start-offset : " + startOffset + "\n");
buf.append("locations : " + "\n"); buf.append("locations : " + "\n");

View File

@ -678,7 +678,7 @@ private boolean verifySanity(long compressedLength, long decompressedLength,
private URL getMapOutputURL(MapHost host, Collection<TaskAttemptID> maps private URL getMapOutputURL(MapHost host, Collection<TaskAttemptID> maps
) throws MalformedURLException { ) throws MalformedURLException {
// Get the base url // Get the base url
StringBuffer url = new StringBuffer(host.getBaseUrl()); StringBuilder url = new StringBuilder(host.getBaseUrl());
boolean first = true; boolean first = true;
for (TaskAttemptID mapId : maps) { for (TaskAttemptID mapId : maps) {
@ -688,8 +688,10 @@ private URL getMapOutputURL(MapHost host, Collection<TaskAttemptID> maps
url.append(mapId); url.append(mapId);
first = false; first = false;
} }
LOG.debug("MapOutput URL for " + host + " -> " + url.toString()); if (LOG.isDebugEnabled()) {
LOG.debug("MapOutput URL for " + host + " -> " + url.toString());
}
return new URL(url.toString()); return new URL(url.toString());
} }

View File

@ -171,7 +171,7 @@ public void resolve(TaskCompletionEvent event) {
} }
static URI getBaseURI(TaskAttemptID reduceId, String url) { static URI getBaseURI(TaskAttemptID reduceId, String url) {
StringBuffer baseUrl = new StringBuffer(url); StringBuilder baseUrl = new StringBuilder(url);
if (!url.endsWith("/")) { if (!url.endsWith("/")) {
baseUrl.append("/"); baseUrl.append("/");
} }

View File

@ -520,7 +520,7 @@ Cluster createCluster() throws IOException {
} }
private String getJobPriorityNames() { private String getJobPriorityNames() {
StringBuffer sb = new StringBuffer(); StringBuilder sb = new StringBuilder();
for (JobPriority p : JobPriority.values()) { for (JobPriority p : JobPriority.values()) {
// UNDEFINED_PRIORITY need not to be displayed in usage // UNDEFINED_PRIORITY need not to be displayed in usage
if (JobPriority.UNDEFINED_PRIORITY == p) { if (JobPriority.UNDEFINED_PRIORITY == p) {

View File

@ -175,7 +175,7 @@ public void testRecoveryUpgradeV1V2() throws Exception {
private void validateContent(Path dir) throws IOException { private void validateContent(Path dir) throws IOException {
File fdir = new File(dir.toUri().getPath()); File fdir = new File(dir.toUri().getPath());
File expectedFile = new File(fdir, partFile); File expectedFile = new File(fdir, partFile);
StringBuffer expectedOutput = new StringBuffer(); StringBuilder expectedOutput = new StringBuilder();
expectedOutput.append(key1).append('\t').append(val1).append("\n"); expectedOutput.append(key1).append('\t').append(val1).append("\n");
expectedOutput.append(val1).append("\n"); expectedOutput.append(val1).append("\n");
expectedOutput.append(val2).append("\n"); expectedOutput.append(val2).append("\n");

View File

@ -227,7 +227,7 @@ private void validateContent(Path dir) throws IOException {
private void validateContent(File dir) throws IOException { private void validateContent(File dir) throws IOException {
File expectedFile = new File(dir, partFile); File expectedFile = new File(dir, partFile);
assertTrue("Could not find "+expectedFile, expectedFile.exists()); assertTrue("Could not find "+expectedFile, expectedFile.exists());
StringBuffer expectedOutput = new StringBuffer(); StringBuilder expectedOutput = new StringBuilder();
expectedOutput.append(key1).append('\t').append(val1).append("\n"); expectedOutput.append(key1).append('\t').append(val1).append("\n");
expectedOutput.append(val1).append("\n"); expectedOutput.append(val1).append("\n");
expectedOutput.append(val2).append("\n"); expectedOutput.append(val2).append("\n");

View File

@ -109,7 +109,7 @@ public class HsJobBlock extends HtmlBlock {
// todo - switch to use JobInfo // todo - switch to use JobInfo
List<String> diagnostics = j.getDiagnostics(); List<String> diagnostics = j.getDiagnostics();
if(diagnostics != null && !diagnostics.isEmpty()) { if(diagnostics != null && !diagnostics.isEmpty()) {
StringBuffer b = new StringBuffer(); StringBuilder b = new StringBuilder();
for(String diag: diagnostics) { for(String diag: diagnostics) {
b.append(addTaskLinks(diag)); b.append(addTaskLinks(diag));
} }

View File

@ -117,7 +117,7 @@ public JobInfo(Job job) {
this.diagnostics = ""; this.diagnostics = "";
List<String> diagnostics = job.getDiagnostics(); List<String> diagnostics = job.getDiagnostics();
if (diagnostics != null && !diagnostics.isEmpty()) { if (diagnostics != null && !diagnostics.isEmpty()) {
StringBuffer b = new StringBuffer(); StringBuilder b = new StringBuilder();
for (String diag : diagnostics) { for (String diag : diagnostics) {
b.append(diag); b.append(diag);
} }

View File

@ -534,7 +534,7 @@ public void verifyTaskAttemptGeneric(TaskAttempt ta, TaskType ttype,
String expectDiag = ""; String expectDiag = "";
List<String> diagnosticsList = ta.getDiagnostics(); List<String> diagnosticsList = ta.getDiagnostics();
if (diagnosticsList != null && !diagnostics.isEmpty()) { if (diagnosticsList != null && !diagnostics.isEmpty()) {
StringBuffer b = new StringBuffer(); StringBuilder b = new StringBuilder();
for (String diag : diagnosticsList) { for (String diag : diagnosticsList) {
b.append(diag); b.append(diag);
} }

View File

@ -108,7 +108,7 @@ public static void verifyHsJobGenericSecure(Job job, Boolean uberized,
String diagString = ""; String diagString = "";
List<String> diagList = job.getDiagnostics(); List<String> diagList = job.getDiagnostics();
if (diagList != null && !diagList.isEmpty()) { if (diagList != null && !diagList.isEmpty()) {
StringBuffer b = new StringBuffer(); StringBuilder b = new StringBuilder();
for (String diag : diagList) { for (String diag : diagList) {
b.append(diag); b.append(diag);
} }

View File

@ -204,7 +204,7 @@ public void map(Text key, Text value,
} }
private Text generateSentence(int noWords) { private Text generateSentence(int noWords) {
StringBuffer sentence = new StringBuffer(); StringBuilder sentence = new StringBuilder();
String space = " "; String space = " ";
for (int i=0; i < noWords; ++i) { for (int i=0; i < noWords; ++i) {
sentence.append(words[random.nextInt(words.length)]); sentence.append(words[random.nextInt(words.length)]);

View File

@ -73,7 +73,7 @@ public void reduce(Text key,
// concatenate strings // concatenate strings
if (field.startsWith(VALUE_TYPE_STRING)) { if (field.startsWith(VALUE_TYPE_STRING)) {
StringBuffer sSum = new StringBuffer(); StringBuilder sSum = new StringBuilder();
while (values.hasNext()) while (values.hasNext())
sSum.append(values.next().toString()).append(";"); sSum.append(values.next().toString()).append(";");
output.collect(key, new Text(sSum.toString())); output.collect(key, new Text(sSum.toString()));

View File

@ -773,7 +773,7 @@ public void parseLogFile(FileSystem fs,
/** /**
* Read lines until one ends with a " ." or "\" " * Read lines until one ends with a " ." or "\" "
*/ */
private StringBuffer resBuffer = new StringBuffer(); private StringBuilder resBuffer = new StringBuilder();
private String readLine(BufferedReader reader) throws IOException { private String readLine(BufferedReader reader) throws IOException {
resBuffer.setLength(0); resBuffer.setLength(0);
reader.mark(maxJobDelimiterLineLength); reader.mark(maxJobDelimiterLineLength);

View File

@ -132,7 +132,7 @@ public void generateTextFile(FileSystem fs, Path inputFile,
*/ */
private static String pad(long number, int length) { private static String pad(long number, int length) {
String str = String.valueOf(number); String str = String.valueOf(number);
StringBuffer value = new StringBuffer(); StringBuilder value = new StringBuilder();
for (int i = str.length(); i < length; i++) { for (int i = str.length(); i < length; i++) {
value.append("0"); value.append("0");
} }

View File

@ -677,7 +677,7 @@ private static void doSingleBzip2BufferSize(JobConf jConf)
} }
private static String unquote(String in) { private static String unquote(String in) {
StringBuffer result = new StringBuffer(); StringBuilder result = new StringBuilder();
for(int i=0; i < in.length(); ++i) { for(int i=0; i < in.length(); ++i) {
char ch = in.charAt(i); char ch = in.charAt(i);
if (ch == '\\') { if (ch == '\\') {

View File

@ -236,7 +236,7 @@ private ArrayList<String> createFile(Path targetFile, CompressionCodec codec,
} }
Writer writer = new OutputStreamWriter(ostream); Writer writer = new OutputStreamWriter(ostream);
try { try {
StringBuffer sb = new StringBuffer(); StringBuilder sb = new StringBuilder();
for (int i = 0; i < numRecords; i++) { for (int i = 0; i < numRecords; i++) {
for (int j = 0; j < recordLen; j++) { for (int j = 0; j < recordLen; j++) {
sb.append(chars[charRand.nextInt(chars.length)]); sb.append(chars[charRand.nextInt(chars.length)]);

View File

@ -105,7 +105,7 @@ public void testCommitter() throws Exception {
// validate output // validate output
File expectedFile = new File(new Path(outDir, file).toString()); File expectedFile = new File(new Path(outDir, file).toString());
StringBuffer expectedOutput = new StringBuffer(); StringBuilder expectedOutput = new StringBuilder();
expectedOutput.append(key1).append('\t').append(val1).append("\n"); expectedOutput.append(key1).append('\t').append(val1).append("\n");
expectedOutput.append(val1).append("\n"); expectedOutput.append(val1).append("\n");
expectedOutput.append(val2).append("\n"); expectedOutput.append(val2).append("\n");

View File

@ -119,7 +119,7 @@ public boolean canCommit(TaskAttemptID taskid) throws IOException {
public AMFeedback statusUpdate(TaskAttemptID taskId, TaskStatus taskStatus) public AMFeedback statusUpdate(TaskAttemptID taskId, TaskStatus taskStatus)
throws IOException, InterruptedException { throws IOException, InterruptedException {
StringBuffer buf = new StringBuffer("Task "); StringBuilder buf = new StringBuilder("Task ");
buf.append(taskId); buf.append(taskId);
if (taskStatus != null) { if (taskStatus != null) {
buf.append(" making progress to "); buf.append(" making progress to ");

View File

@ -763,7 +763,7 @@ public void runJob(int items) {
SequenceFile.Writer writer = SequenceFile.createWriter(fs, conf, inFile, SequenceFile.Writer writer = SequenceFile.createWriter(fs, conf, inFile,
Text.class, Text.class); Text.class, Text.class);
StringBuffer content = new StringBuffer(); StringBuilder content = new StringBuilder();
for (int i = 0; i < 1000; i++) { for (int i = 0; i < 1000; i++) {
content.append(i).append(": This is one more line of content\n"); content.append(i).append(": This is one more line of content\n");

View File

@ -80,7 +80,7 @@ static String launchWordCount(URI fileSys, JobConf conf, String input,
FileSystem fs = FileSystem.get(fileSys, conf); FileSystem fs = FileSystem.get(fileSys, conf);
configureWordCount(fs, conf, input, numMaps, numReduces, inDir, outDir); configureWordCount(fs, conf, input, numMaps, numReduces, inDir, outDir);
JobClient.runJob(conf); JobClient.runJob(conf);
StringBuffer result = new StringBuffer(); StringBuilder result = new StringBuilder();
{ {
Path[] parents = FileUtil.stat2Paths(fs.listStatus(outDir.getParent())); Path[] parents = FileUtil.stat2Paths(fs.listStatus(outDir.getParent()));
Path[] fileList = FileUtil.stat2Paths(fs.listStatus(outDir, Path[] fileList = FileUtil.stat2Paths(fs.listStatus(outDir,
@ -137,7 +137,7 @@ static String launchExternal(URI uri, JobConf conf, String input,
// set the tests jar file // set the tests jar file
conf.setJarByClass(TestMiniMRClasspath.class); conf.setJarByClass(TestMiniMRClasspath.class);
JobClient.runJob(conf); JobClient.runJob(conf);
StringBuffer result = new StringBuffer(); StringBuilder result = new StringBuilder();
Path[] fileList = FileUtil.stat2Paths(fs.listStatus(outDir, Path[] fileList = FileUtil.stat2Paths(fs.listStatus(outDir,
new Utils.OutputFileUtils new Utils.OutputFileUtils
.OutputFilesFilter())); .OutputFilesFilter()));

View File

@ -106,7 +106,7 @@ public void testFormat() throws Exception {
File expectedFile_11 = new File(new Path(workDir, file_11).toString()); File expectedFile_11 = new File(new Path(workDir, file_11).toString());
//System.out.printf("expectedFile_11: %s\n", new Path(workDir, file_11).toString()); //System.out.printf("expectedFile_11: %s\n", new Path(workDir, file_11).toString());
StringBuffer expectedOutput = new StringBuffer(); StringBuilder expectedOutput = new StringBuilder();
for (int i = 10; i < 20; i++) { for (int i = 10; i < 20; i++) {
expectedOutput.append(""+i).append('\t').append(""+i).append("\n"); expectedOutput.append(""+i).append('\t').append(""+i).append("\n");
} }
@ -118,7 +118,7 @@ public void testFormat() throws Exception {
File expectedFile_12 = new File(new Path(workDir, file_12).toString()); File expectedFile_12 = new File(new Path(workDir, file_12).toString());
//System.out.printf("expectedFile_12: %s\n", new Path(workDir, file_12).toString()); //System.out.printf("expectedFile_12: %s\n", new Path(workDir, file_12).toString());
expectedOutput = new StringBuffer(); expectedOutput = new StringBuilder();
for (int i = 20; i < 30; i++) { for (int i = 20; i < 30; i++) {
expectedOutput.append(""+i).append('\t').append(""+i).append("\n"); expectedOutput.append(""+i).append('\t').append(""+i).append("\n");
} }
@ -130,7 +130,7 @@ public void testFormat() throws Exception {
File expectedFile_13 = new File(new Path(workDir, file_13).toString()); File expectedFile_13 = new File(new Path(workDir, file_13).toString());
//System.out.printf("expectedFile_13: %s\n", new Path(workDir, file_13).toString()); //System.out.printf("expectedFile_13: %s\n", new Path(workDir, file_13).toString());
expectedOutput = new StringBuffer(); expectedOutput = new StringBuilder();
for (int i = 30; i < 40; i++) { for (int i = 30; i < 40; i++) {
expectedOutput.append(""+i).append('\t').append(""+i).append("\n"); expectedOutput.append(""+i).append('\t').append(""+i).append("\n");
} }
@ -142,7 +142,7 @@ public void testFormat() throws Exception {
File expectedFile_2 = new File(new Path(workDir, file_2).toString()); File expectedFile_2 = new File(new Path(workDir, file_2).toString());
//System.out.printf("expectedFile_2: %s\n", new Path(workDir, file_2).toString()); //System.out.printf("expectedFile_2: %s\n", new Path(workDir, file_2).toString());
expectedOutput = new StringBuffer(); expectedOutput = new StringBuilder();
for (int i = 10; i < 40; i++) { for (int i = 10; i < 40; i++) {
expectedOutput.append(""+i).append('\t').append(""+i).append("\n"); expectedOutput.append(""+i).append('\t').append(""+i).append("\n");
} }

View File

@ -548,7 +548,7 @@ public void testGzipEmpty() throws IOException {
} }
private static String unquote(String in) { private static String unquote(String in) {
StringBuffer result = new StringBuffer(); StringBuilder result = new StringBuilder();
for(int i=0; i < in.length(); ++i) { for(int i=0; i < in.length(); ++i) {
char ch = in.charAt(i); char ch = in.charAt(i);
if (ch == '\\') { if (ch == '\\') {

View File

@ -91,7 +91,7 @@ public static String ifmt(double d) {
} }
public static String formatBytes(long numBytes) { public static String formatBytes(long numBytes) {
StringBuffer buf = new StringBuffer(); StringBuilder buf = new StringBuilder();
boolean bDetails = true; boolean bDetails = true;
double num = numBytes; double num = numBytes;
@ -116,7 +116,7 @@ public static String formatBytes(long numBytes) {
} }
public static String formatBytes2(long numBytes) { public static String formatBytes2(long numBytes) {
StringBuffer buf = new StringBuffer(); StringBuilder buf = new StringBuilder();
long u = 0; long u = 0;
if (numBytes >= TB) { if (numBytes >= TB) {
u = numBytes / TB; u = numBytes / TB;
@ -145,7 +145,7 @@ public static String formatBytes2(long numBytes) {
static final String regexpSpecials = "[]()?*+|.!^-\\~@"; static final String regexpSpecials = "[]()?*+|.!^-\\~@";
public static String regexpEscape(String plain) { public static String regexpEscape(String plain) {
StringBuffer buf = new StringBuffer(); StringBuilder buf = new StringBuilder();
char[] ch = plain.toCharArray(); char[] ch = plain.toCharArray();
int csup = ch.length; int csup = ch.length;
for (int c = 0; c < csup; c++) { for (int c = 0; c < csup; c++) {

View File

@ -82,7 +82,7 @@ private static String generateRandomWord() {
private static String generateRandomLine() { private static String generateRandomLine() {
long r = rand.nextLong() % 7; long r = rand.nextLong() % 7;
long n = r + 20; long n = r + 20;
StringBuffer sb = new StringBuffer(); StringBuilder sb = new StringBuilder();
for (int i = 0; i < n; i++) { for (int i = 0; i < n; i++) {
sb.append(generateRandomWord()).append(" "); sb.append(generateRandomWord()).append(" ");
} }

View File

@ -97,7 +97,7 @@ public static String generateRandomWord() {
public static String generateRandomLine() { public static String generateRandomLine() {
long r = rand.nextLong() % 7; long r = rand.nextLong() % 7;
long n = r + 20; long n = r + 20;
StringBuffer sb = new StringBuffer(); StringBuilder sb = new StringBuilder();
for (int i = 0; i < n; i++) { for (int i = 0; i < n; i++) {
sb.append(generateRandomWord()).append(" "); sb.append(generateRandomWord()).append(" ");
} }
@ -401,7 +401,7 @@ public Counter getCounter(String group, String name) {
public static String readOutput(Path outDir, Configuration conf) public static String readOutput(Path outDir, Configuration conf)
throws IOException { throws IOException {
FileSystem fs = outDir.getFileSystem(conf); FileSystem fs = outDir.getFileSystem(conf);
StringBuffer result = new StringBuffer(); StringBuilder result = new StringBuilder();
Path[] fileList = FileUtil.stat2Paths(fs.listStatus(outDir, Path[] fileList = FileUtil.stat2Paths(fs.listStatus(outDir,
new Utils.OutputFileUtils.OutputFilesFilter())); new Utils.OutputFileUtils.OutputFilesFilter()));
@ -436,7 +436,7 @@ public static String readTaskLog(TaskLog.LogName filter,
org.apache.hadoop.mapred.TaskAttemptID taskId, boolean isCleanup) org.apache.hadoop.mapred.TaskAttemptID taskId, boolean isCleanup)
throws IOException { throws IOException {
// string buffer to store task log // string buffer to store task log
StringBuffer result = new StringBuffer(); StringBuilder result = new StringBuilder();
int res; int res;
// reads the whole tasklog into inputstream // reads the whole tasklog into inputstream

View File

@ -100,7 +100,7 @@ enum Counters { RECORDS_WRITTEN, BYTES_WRITTEN }
public static String generateSentenceWithRand(ThreadLocalRandom rand, public static String generateSentenceWithRand(ThreadLocalRandom rand,
int noWords) { int noWords) {
StringBuffer sentence = new StringBuffer(words[rand.nextInt(words.length)]); StringBuilder sentence = new StringBuilder(words[rand.nextInt(words.length)]);
for (int i = 1; i < noWords; i++) { for (int i = 1; i < noWords; i++) {
sentence.append(" ").append(words[rand.nextInt(words.length)]); sentence.append(" ").append(words[rand.nextInt(words.length)]);
} }

View File

@ -262,7 +262,7 @@ private ArrayList<String> createFile(Path targetFile, CompressionCodec codec,
} }
Writer writer = new OutputStreamWriter(ostream); Writer writer = new OutputStreamWriter(ostream);
try { try {
StringBuffer sb = new StringBuffer(); StringBuilder sb = new StringBuilder();
for (int i = 0; i < numRecords; i++) { for (int i = 0; i < numRecords; i++) {
for (int j = 0; j < recordLen; j++) { for (int j = 0; j < recordLen; j++) {
sb.append(chars[charRand.nextInt(chars.length)]); sb.append(chars[charRand.nextInt(chars.length)]);

View File

@ -119,7 +119,7 @@ public void testCommitter() throws Exception {
// validate output // validate output
File expectedFile = new File(new Path(outDir, partFile).toString()); File expectedFile = new File(new Path(outDir, partFile).toString());
StringBuffer expectedOutput = new StringBuffer(); StringBuilder expectedOutput = new StringBuilder();
expectedOutput.append(key1).append('\t').append(val1).append("\n"); expectedOutput.append(key1).append('\t').append(val1).append("\n");
expectedOutput.append(val1).append("\n"); expectedOutput.append(val1).append("\n");
expectedOutput.append(val2).append("\n"); expectedOutput.append(val2).append("\n");

View File

@ -106,7 +106,7 @@ public static String getResolvedMRHistoryWebAppURLWithoutScheme(
JHAdminConfig.DEFAULT_MR_HISTORY_WEBAPP_ADDRESS, JHAdminConfig.DEFAULT_MR_HISTORY_WEBAPP_ADDRESS,
JHAdminConfig.DEFAULT_MR_HISTORY_WEBAPP_PORT); } JHAdminConfig.DEFAULT_MR_HISTORY_WEBAPP_PORT); }
address = NetUtils.getConnectAddress(address); address = NetUtils.getConnectAddress(address);
StringBuffer sb = new StringBuffer(); StringBuilder sb = new StringBuilder();
InetAddress resolved = address.getAddress(); InetAddress resolved = address.getAddress();
if (resolved == null || resolved.isAnyLocalAddress() || if (resolved == null || resolved.isAnyLocalAddress() ||
resolved.isLoopbackAddress()) { resolved.isLoopbackAddress()) {

View File

@ -154,7 +154,7 @@ public void map(Text key, Text value,
} }
private Text generateSentence(int noWords) { private Text generateSentence(int noWords) {
StringBuffer sentence = new StringBuffer(); StringBuilder sentence = new StringBuilder();
String space = " "; String space = " ";
for (int i=0; i < noWords; ++i) { for (int i=0; i < noWords; ++i) {
sentence.append(words[random.nextInt(words.length)]); sentence.append(words[random.nextInt(words.length)]);

View File

@ -142,7 +142,7 @@ static class Point implements ColumnName {
public static String stringifySolution(int width, int height, public static String stringifySolution(int width, int height,
List<List<ColumnName>> solution) { List<List<ColumnName>> solution) {
String[][] picture = new String[height][width]; String[][] picture = new String[height][width];
StringBuffer result = new StringBuffer(); StringBuilder result = new StringBuilder();
// for each piece placement... // for each piece placement...
for(List<ColumnName> row: solution) { for(List<ColumnName> row: solution) {
// go through to find which piece was placed // go through to find which piece was placed

View File

@ -66,7 +66,7 @@ protected static interface ColumnName {
*/ */
static String stringifySolution(int size, List<List<ColumnName>> solution) { static String stringifySolution(int size, List<List<ColumnName>> solution) {
int[][] picture = new int[size][size]; int[][] picture = new int[size][size];
StringBuffer result = new StringBuffer(); StringBuilder result = new StringBuilder();
// go through the rows selected in the model and build a picture of the // go through the rows selected in the model and build a picture of the
// solution. // solution.
for(List<ColumnName> row: solution) { for(List<ColumnName> row: solution) {

View File

@ -47,7 +47,7 @@ static class Split {
this.filename = filename; this.filename = filename;
} }
public String toString() { public String toString() {
StringBuffer result = new StringBuffer(); StringBuilder result = new StringBuilder();
result.append(filename); result.append(filename);
result.append(" on "); result.append(" on ");
for(Host host: locations) { for(Host host: locations) {
@ -64,7 +64,7 @@ static class Host {
this.hostname = hostname; this.hostname = hostname;
} }
public String toString() { public String toString() {
StringBuffer result = new StringBuffer(); StringBuilder result = new StringBuilder();
result.append(splits.size()); result.append(splits.size());
result.append(" "); result.append(" ");
result.append(hostname); result.append(hostname);

View File

@ -722,7 +722,7 @@ private void validateContent(Path dir,
} }
Path expectedFile = getPart0000(dir); Path expectedFile = getPart0000(dir);
log().debug("Validating content in {}", expectedFile); log().debug("Validating content in {}", expectedFile);
StringBuffer expectedOutput = new StringBuffer(); StringBuilder expectedOutput = new StringBuilder();
expectedOutput.append(KEY_1).append('\t').append(VAL_1).append("\n"); expectedOutput.append(KEY_1).append('\t').append(VAL_1).append("\n");
expectedOutput.append(VAL_1).append("\n"); expectedOutput.append(VAL_1).append("\n");
expectedOutput.append(VAL_2).append("\n"); expectedOutput.append(VAL_2).append("\n");

View File

@ -143,7 +143,7 @@ protected void report() {
* *
*/ */
protected String getReport() { protected String getReport() {
StringBuffer sb = new StringBuffer(); StringBuilder sb = new StringBuilder();
Iterator iter = this.longCounters.entrySet().iterator(); Iterator iter = this.longCounters.entrySet().iterator();
while (iter.hasNext()) { while (iter.hasNext()) {

View File

@ -614,7 +614,7 @@ private Path translateRenamedPath(Path sourcePath,
if (sourcePath.equals(renameItem.getSource())) { if (sourcePath.equals(renameItem.getSource())) {
return renameItem.getTarget(); return renameItem.getTarget();
} }
StringBuffer sb = new StringBuffer(sourcePath.toString()); StringBuilder sb = new StringBuilder(sourcePath.toString());
String remain = String remain =
sb.substring(renameItem.getSource().toString().length() + 1); sb.substring(renameItem.getSource().toString().length() + 1);
return new Path(renameItem.getTarget(), remain); return new Path(renameItem.getTarget(), remain);

View File

@ -155,7 +155,7 @@ public static String getRelativePath(Path sourceRootPath, Path childPath) {
* @return - String containing first letters of each attribute to preserve * @return - String containing first letters of each attribute to preserve
*/ */
public static String packAttributes(EnumSet<FileAttribute> attributes) { public static String packAttributes(EnumSet<FileAttribute> attributes) {
StringBuffer buffer = new StringBuffer(FileAttribute.values().length); StringBuilder buffer = new StringBuilder(FileAttribute.values().length);
int len = 0; int len = 0;
for (FileAttribute attribute : attributes) { for (FileAttribute attribute : attributes) {
buffer.append(attribute.name().charAt(0)); buffer.append(attribute.name().charAt(0));

View File

@ -140,7 +140,7 @@ public String getAnonymizedValue(StatePool statePool, Configuration conf) {
} }
private void anonymize(StatePool pool) { private void anonymize(StatePool pool) {
StringBuffer buf = new StringBuffer(); StringBuilder buf = new StringBuilder();
NodeNameState state = (NodeNameState) pool.getState(getClass()); NodeNameState state = (NodeNameState) pool.getState(getClass());
if (state == null) { if (state == null) {
state = new NodeNameState(); state = new NodeNameState();

View File

@ -254,7 +254,7 @@ void addJobConfToEnvironment(JobConf jobconf, Properties env) {
} }
String safeEnvVarName(String var) { String safeEnvVarName(String var) {
StringBuffer safe = new StringBuffer(); StringBuilder safe = new StringBuilder();
int len = var.length(); int len = var.length();
for (int i = 0; i < len; i++) { for (int i = 0; i < len; i++) {
char c = var.charAt(i); char c = var.charAt(i);

View File

@ -291,7 +291,7 @@ void parseArgv() {
LOG.warn("-file option is deprecated, please use generic option" + LOG.warn("-file option is deprecated, please use generic option" +
" -files instead."); " -files instead.");
StringBuffer fileList = new StringBuffer(); StringBuilder fileList = new StringBuilder();
for (String file : values) { for (String file : values) {
packageFiles_.add(file); packageFiles_.add(file);
try { try {

View File

@ -23,9 +23,7 @@
import java.util.regex.*; import java.util.regex.*;
import org.apache.hadoop.io.DataOutputBuffer; import org.apache.hadoop.io.DataOutputBuffer;
import org.apache.hadoop.io.Writable;
import org.apache.hadoop.io.Text; import org.apache.hadoop.io.Text;
import org.apache.hadoop.io.WritableComparable;
import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.FSDataInputStream; import org.apache.hadoop.fs.FSDataInputStream;
import org.apache.hadoop.mapred.Reporter; import org.apache.hadoop.mapred.Reporter;

View File

@ -128,7 +128,7 @@ protected String[] genArgs() {
} }
protected void checkOutput() throws IOException { protected void checkOutput() throws IOException {
StringBuffer output = new StringBuffer(256); StringBuilder output = new StringBuilder(256);
Path[] fileList = FileUtil.stat2Paths(fileSys.listStatus( Path[] fileList = FileUtil.stat2Paths(fileSys.listStatus(
new Path(OUTPUT_DIR))); new Path(OUTPUT_DIR)));
for (int i = 0; i < fileList.length; i++){ for (int i = 0; i < fileList.length; i++){

View File

@ -86,7 +86,7 @@ void redirectIfAntJunit() throws IOException
} }
public static String collate(List<String> args, String sep) { public static String collate(List<String> args, String sep) {
StringBuffer buf = new StringBuffer(); StringBuilder buf = new StringBuilder();
Iterator<String> it = args.iterator(); Iterator<String> it = args.iterator();
while (it.hasNext()) { while (it.hasNext()) {
if (buf.length() > 0) { if (buf.length() > 0) {

View File

@ -144,7 +144,7 @@ public String toString() {
public static TimelineEntityGroupId public static TimelineEntityGroupId
fromString(String timelineEntityGroupIdStr) { fromString(String timelineEntityGroupIdStr) {
StringBuffer buf = new StringBuffer(); StringBuilder buf = new StringBuilder();
Iterator<String> it = SPLITTER.split(timelineEntityGroupIdStr).iterator(); Iterator<String> it = SPLITTER.split(timelineEntityGroupIdStr).iterator();
if (!it.next().equals(TIMELINE_ENTITY_GROUPID_STR_PREFIX)) { if (!it.next().equals(TIMELINE_ENTITY_GROUPID_STR_PREFIX)) {
throw new IllegalArgumentException( throw new IllegalArgumentException(

View File

@ -413,7 +413,7 @@ public boolean equals(Object o) {
@Override @Override
public String toString() { public String toString() {
StringBuffer sb = new StringBuffer(); StringBuilder sb = new StringBuilder();
if (TargetType.ALLOCATION_TAG == this.targetType) { if (TargetType.ALLOCATION_TAG == this.targetType) {
// following by a comma separated tags // following by a comma separated tags
sb.append(String.join(",", getTargetValues())); sb.append(String.join(",", getTargetValues()));
@ -643,7 +643,7 @@ public int hashCode() {
@Override @Override
public String toString() { public String toString() {
StringBuffer sb = new StringBuffer(); StringBuilder sb = new StringBuilder();
sb.append("cardinality").append(",").append(getScope()).append(","); sb.append("cardinality").append(",").append(getScope()).append(",");
for (String tag : getAllocationTags()) { for (String tag : getAllocationTags()) {
sb.append(tag).append(","); sb.append(tag).append(",");
@ -717,7 +717,7 @@ public <T> T accept(Visitor<T> visitor) {
@Override @Override
public String toString() { public String toString() {
StringBuffer sb = new StringBuffer(); StringBuilder sb = new StringBuilder();
sb.append("and("); sb.append("and(");
Iterator<AbstractConstraint> it = getChildren().iterator(); Iterator<AbstractConstraint> it = getChildren().iterator();
while (it.hasNext()) { while (it.hasNext()) {
@ -759,7 +759,7 @@ public <T> T accept(Visitor<T> visitor) {
@Override @Override
public String toString() { public String toString() {
StringBuffer sb = new StringBuffer(); StringBuilder sb = new StringBuilder();
sb.append("or("); sb.append("or(");
Iterator<AbstractConstraint> it = getChildren().iterator(); Iterator<AbstractConstraint> it = getChildren().iterator();
while (it.hasNext()) { while (it.hasNext()) {
@ -805,7 +805,7 @@ public <T> T accept(Visitor<T> visitor) {
@Override @Override
public String toString() { public String toString() {
StringBuffer sb = new StringBuffer(); StringBuilder sb = new StringBuilder();
sb.append("DelayedOr("); sb.append("DelayedOr(");
Iterator<TimedPlacementConstraint> it = getChildren().iterator(); Iterator<TimedPlacementConstraint> it = getChildren().iterator();
while (it.hasNext()) { while (it.hasNext()) {

View File

@ -1491,7 +1491,7 @@ public void testSaveContainerLogsLocally() throws Exception {
private String readContainerContent(Path containerPath, private String readContainerContent(Path containerPath,
FileSystem fs) throws IOException { FileSystem fs) throws IOException {
assertTrue(fs.exists(containerPath)); assertTrue(fs.exists(containerPath));
StringBuffer inputLine = new StringBuffer(); StringBuilder inputLine = new StringBuilder();
try (BufferedReader reader = new BufferedReader(new InputStreamReader( try (BufferedReader reader = new BufferedReader(new InputStreamReader(
fs.open(containerPath)))) { fs.open(containerPath)))) {
String tmp; String tmp;

View File

@ -568,7 +568,7 @@ private static ProcessInfo constructProcessInfo(ProcessInfo pinfo,
*/ */
@Override @Override
public String toString() { public String toString() {
StringBuffer pTree = new StringBuffer("[ "); StringBuilder pTree = new StringBuilder("[ ");
for (String p : processTree.keySet()) { for (String p : processTree.keySet()) {
pTree.append(p); pTree.append(p);
pTree.append(" "); pTree.append(" ");

View File

@ -130,7 +130,7 @@ protected void initDataTables(List<String> list) {
} }
// for inserting stateSaveInit // for inserting stateSaveInit
int pos = init.indexOf('{') + 1; int pos = init.indexOf('{') + 1;
init = new StringBuffer(init).insert(pos, stateSaveInit).toString(); init = new StringBuilder(init).insert(pos, stateSaveInit).toString();
list.add(join(id, "DataTable = $('#", id, "').dataTable(", init, list.add(join(id, "DataTable = $('#", id, "').dataTable(", init,
").fnSetFilteringDelay(188);")); ").fnSetFilteringDelay(188);"));
String postInit = $(postInitID(DATATABLES, id)); String postInit = $(postInitID(DATATABLES, id));
@ -146,7 +146,7 @@ protected void initDataTables(List<String> list) {
init = defaultInit; init = defaultInit;
} }
int pos = init.indexOf('{') + 1; int pos = init.indexOf('{') + 1;
init = new StringBuffer(init).insert(pos, stateSaveInit).toString(); init = new StringBuilder(init).insert(pos, stateSaveInit).toString();
list.add(join(" $('", escapeEcmaScript(selector), "').dataTable(", init, list.add(join(" $('", escapeEcmaScript(selector), "').dataTable(", init,
").fnSetFilteringDelay(288);")); ").fnSetFilteringDelay(288);"));

View File

@ -401,7 +401,7 @@ void testContainerLogsFileAccess() throws IOException {
new BufferedReader(new FileReader(new File(remoteAppLogFile new BufferedReader(new FileReader(new File(remoteAppLogFile
.toUri().getRawPath()))); .toUri().getRawPath())));
String line; String line;
StringBuffer sb = new StringBuffer(""); StringBuilder sb = new StringBuilder("");
while ((line = in.readLine()) != null) { while ((line = in.readLine()) != null) {
LOG.info(line); LOG.info(line);
sb.append(line); sb.append(line);

View File

@ -181,7 +181,7 @@ protected void rethrow(SQLException cause, String sql, Object... params)
causeMessage = ""; causeMessage = "";
} }
StringBuffer msg = new StringBuffer(causeMessage); StringBuilder msg = new StringBuilder(causeMessage);
msg.append(" Query: "); msg.append(" Query: ");
msg.append(sql); msg.append(sql);
msg.append(" Parameters: "); msg.append(" Parameters: ");

View File

@ -65,7 +65,7 @@ public void run() {
*/ */
@Override @Override
public String toString() { public String toString() {
StringBuffer sb = new StringBuffer("DockerContainerDeletionTask : "); StringBuilder sb = new StringBuilder("DockerContainerDeletionTask : ");
sb.append(" id : ").append(this.getTaskId()); sb.append(" id : ").append(this.getTaskId());
sb.append(" containerId : ").append(this.containerId); sb.append(" containerId : ").append(this.containerId);
return sb.toString().trim(); return sb.toString().trim();

View File

@ -281,7 +281,7 @@ public IOStreamPair executePrivilegedInteractiveOperation(
return null; return null;
} }
StringBuffer finalOpArg = new StringBuffer(PrivilegedOperation StringBuilder finalOpArg = new StringBuilder(PrivilegedOperation
.CGROUP_ARG_PREFIX); .CGROUP_ARG_PREFIX);
boolean noTasks = true; boolean noTasks = true;

View File

@ -104,7 +104,7 @@ public List<PrivilegedOperation> preStart(Container container)
//executable. //executable.
String tasksFile = cGroupsHandler.getPathForCGroupTasks( String tasksFile = cGroupsHandler.getPathForCGroupTasks(
CGroupsHandler.CGroupController.NET_CLS, containerIdStr); CGroupsHandler.CGroupController.NET_CLS, containerIdStr);
String opArg = new StringBuffer(PrivilegedOperation.CGROUP_ARG_PREFIX) String opArg = new StringBuilder(PrivilegedOperation.CGROUP_ARG_PREFIX)
.append(tasksFile).toString(); .append(tasksFile).toString();
List<PrivilegedOperation> ops = new ArrayList<>(); List<PrivilegedOperation> ops = new ArrayList<>();

View File

@ -101,7 +101,7 @@ public List<PrivilegedOperation> bootstrap(Configuration configuration)
containerBandwidthMbit = (int) Math.ceil((double) yarnBandwidthMbit / containerBandwidthMbit = (int) Math.ceil((double) yarnBandwidthMbit /
MAX_CONTAINER_COUNT); MAX_CONTAINER_COUNT);
StringBuffer logLine = new StringBuffer("strict mode is set to :") StringBuilder logLine = new StringBuilder("strict mode is set to :")
.append(strictMode).append(System.lineSeparator()); .append(strictMode).append(System.lineSeparator());
if (strictMode) { if (strictMode) {
@ -152,7 +152,7 @@ public List<PrivilegedOperation> preStart(Container container)
//executable. //executable.
String tasksFile = cGroupsHandler.getPathForCGroupTasks( String tasksFile = cGroupsHandler.getPathForCGroupTasks(
CGroupsHandler.CGroupController.NET_CLS, containerIdStr); CGroupsHandler.CGroupController.NET_CLS, containerIdStr);
String opArg = new StringBuffer(PrivilegedOperation.CGROUP_ARG_PREFIX) String opArg = new StringBuilder(PrivilegedOperation.CGROUP_ARG_PREFIX)
.append(tasksFile).toString(); .append(tasksFile).toString();
List<PrivilegedOperation> ops = new ArrayList<>(); List<PrivilegedOperation> ops = new ArrayList<>();

View File

@ -225,7 +225,7 @@ private boolean checkIfAlreadyBootstrapped(String state)
if (pattern.matcher(state).find()) { if (pattern.matcher(state).find()) {
LOG.debug("Matched regex: {}", regex); LOG.debug("Matched regex: {}", regex);
} else { } else {
String logLine = new StringBuffer("Failed to match regex: ") String logLine = new StringBuilder("Failed to match regex: ")
.append(regex).append(" Current state: ").append(state).toString(); .append(regex).append(" Current state: ").append(state).toString();
LOG.warn(logLine); LOG.warn(logLine);
return false; return false;

Some files were not shown because too many files have changed in this diff Show More