HADOOP-19134. Use StringBuilder instead of StringBuffer. (#6692). Contributed by PJ Fanning
This commit is contained in:
parent
b5f88990b7
commit
59dba6e1bd
@ -169,7 +169,7 @@ protected int init(String[] args) throws IOException {
|
||||
|
||||
@Override
|
||||
public String getCommandUsage() {
|
||||
StringBuffer sbuf = new StringBuffer(USAGE_PREFIX + COMMANDS);
|
||||
StringBuilder sbuf = new StringBuilder(USAGE_PREFIX + COMMANDS);
|
||||
String banner = StringUtils.repeat("=", 66);
|
||||
sbuf.append(banner + "\n");
|
||||
sbuf.append(CreateCommand.USAGE + ":\n\n" + CreateCommand.DESC + "\n");
|
||||
|
@ -163,7 +163,7 @@ protected void parseExecResult(BufferedReader lines) throws IOException {
|
||||
@VisibleForTesting
|
||||
protected void parseOutput() throws IOException {
|
||||
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) {
|
||||
sb.append(": " + output.get(0));
|
||||
}
|
||||
|
@ -1052,7 +1052,7 @@ private static void unTarUsingTar(InputStream inputStream, File untarDir,
|
||||
|
||||
private static void unTarUsingTar(File inFile, File untarDir,
|
||||
boolean gzipped) throws IOException {
|
||||
StringBuffer untarCommand = new StringBuffer();
|
||||
StringBuilder untarCommand = new StringBuilder();
|
||||
// not using canonical path here; this postpones relative path
|
||||
// resolution until bash is executed.
|
||||
final String source = "'" + FileUtil.makeSecureShellPath(inFile) + "'";
|
||||
|
@ -58,7 +58,7 @@ public RejectState getRejectState() {
|
||||
|
||||
@Override
|
||||
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(verifier.getFlavor()).append("rejectState:")
|
||||
.append(rejectState).toString();
|
||||
|
@ -148,7 +148,7 @@ public static Configuration excludeIncompatibleCredentialProviders(
|
||||
if (providerPath == null) {
|
||||
return config;
|
||||
}
|
||||
StringBuffer newProviderPath = new StringBuffer();
|
||||
StringBuilder newProviderPath = new StringBuilder();
|
||||
String[] providers = providerPath.split(",");
|
||||
Path path = null;
|
||||
for (String provider: providers) {
|
||||
|
@ -127,7 +127,7 @@ protected int init(String[] args) throws IOException {
|
||||
|
||||
@Override
|
||||
public String getCommandUsage() {
|
||||
StringBuffer sbuf = new StringBuffer(USAGE_PREFIX + COMMANDS);
|
||||
StringBuilder sbuf = new StringBuilder(USAGE_PREFIX + COMMANDS);
|
||||
String banner = StringUtils.repeat("=", 66);
|
||||
sbuf.append(banner + "\n")
|
||||
.append(CreateCommand.USAGE + ":\n\n" + CreateCommand.DESC + "\n")
|
||||
|
@ -370,7 +370,7 @@ public void check(final String[] hosts, final String[] cns,
|
||||
strictWithSubDomains);
|
||||
}
|
||||
// Build up lists of allowed hosts For logging/debugging purposes.
|
||||
StringBuffer buf = new StringBuffer(32);
|
||||
StringBuilder buf = new StringBuilder(32);
|
||||
buf.append('<');
|
||||
for (int i = 0; i < hosts.length; i++) {
|
||||
String h = hosts[i];
|
||||
@ -408,15 +408,15 @@ public void check(final String[] hosts, final String[] cns,
|
||||
throw new SSLException(msg);
|
||||
}
|
||||
|
||||
// StringBuffer for building the error message.
|
||||
buf = new StringBuffer();
|
||||
// StringBuilder for building the error message.
|
||||
buf = new StringBuilder();
|
||||
|
||||
boolean match = false;
|
||||
out:
|
||||
for (Iterator<String> it = names.iterator(); it.hasNext();) {
|
||||
// Don't trim the CN, though!
|
||||
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(" <")
|
||||
.append(cn)
|
||||
.append('>');
|
||||
|
@ -1014,7 +1014,7 @@ private void runCommand() throws IOException {
|
||||
BufferedReader inReader =
|
||||
new BufferedReader(new InputStreamReader(process.getInputStream(),
|
||||
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
|
||||
// free the error stream buffer
|
||||
@ -1208,7 +1208,7 @@ public static class ShellCommandExecutor extends Shell
|
||||
implements CommandExecutor {
|
||||
|
||||
private String[] command;
|
||||
private StringBuffer output;
|
||||
private StringBuilder output;
|
||||
|
||||
|
||||
public ShellCommandExecutor(String[] execString) {
|
||||
@ -1289,7 +1289,7 @@ public String[] getExecString() {
|
||||
|
||||
@Override
|
||||
protected void parseExecResult(BufferedReader lines) throws IOException {
|
||||
output = new StringBuffer();
|
||||
output = new StringBuilder();
|
||||
char[] buf = new char[512];
|
||||
int nRead;
|
||||
while ( (nRead = lines.read(buf, 0, buf.length)) > 0 ) {
|
||||
|
@ -1334,7 +1334,7 @@ public static String wrap(String str, int wrapLength, String newLineStr,
|
||||
|
||||
int inputLineLength = str.length();
|
||||
int offset = 0;
|
||||
StringBuffer wrappedLine = new StringBuffer(inputLineLength + 32);
|
||||
StringBuilder wrappedLine = new StringBuilder(inputLineLength + 32);
|
||||
|
||||
while(inputLineLength - offset > wrapLength) {
|
||||
if(str.charAt(offset) == 32) {
|
||||
|
@ -580,7 +580,7 @@ public MockQuotaUsage() {
|
||||
public String toString(boolean hOption,
|
||||
boolean tOption, List<StorageType> types) {
|
||||
if (tOption) {
|
||||
StringBuffer result = new StringBuffer();
|
||||
StringBuilder result = new StringBuilder();
|
||||
result.append(hOption ? HUMAN : BYTES);
|
||||
|
||||
for (StorageType type : types) {
|
||||
|
@ -114,7 +114,7 @@ public void testUriErrors() throws Exception {
|
||||
}
|
||||
|
||||
private static char[] generatePassword(int length) {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
Random r = new Random();
|
||||
for (int i = 0; i < length; i++) {
|
||||
sb.append(chars[r.nextInt(chars.length)]);
|
||||
|
@ -480,7 +480,7 @@ public void testBashQuote() {
|
||||
@Test(timeout=120000)
|
||||
public void testDestroyAllShellProcesses() throws Throwable {
|
||||
Assume.assumeFalse(WINDOWS);
|
||||
StringBuffer sleepCommand = new StringBuffer();
|
||||
StringBuilder sleepCommand = new StringBuilder();
|
||||
sleepCommand.append("sleep 200");
|
||||
String[] shellCmd = {"bash", "-c", sleepCommand.toString()};
|
||||
final ShellCommandExecutor shexc1 = new ShellCommandExecutor(shellCmd);
|
||||
|
@ -86,7 +86,7 @@ public void log(Object o) {
|
||||
*/
|
||||
@Test
|
||||
public void testSingleton() throws Throwable {
|
||||
StringBuffer result = new StringBuffer();
|
||||
StringBuilder result = new StringBuilder();
|
||||
String name = "singleton";
|
||||
RemoteIterator<String> it = remoteIteratorFromSingleton(name);
|
||||
assertStringValueContains(it, "SingletonIterator");
|
||||
|
@ -167,7 +167,7 @@ protected String generateLoadBalancingKeyProviderUriString() {
|
||||
if (kmsUrl == null || kmsUrl.size() == 0) {
|
||||
return null;
|
||||
}
|
||||
StringBuffer sb = new StringBuffer();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
for (int i = 0; i < kmsUrl.size(); i++) {
|
||||
sb.append(KMSClientProvider.SCHEME_NAME + "://" +
|
||||
|
@ -195,7 +195,7 @@ private Integer listCorruptFileBlocks(String dir, String baseUrl)
|
||||
final String cookiePrefix = "Cookie:";
|
||||
boolean allDone = false;
|
||||
while (!allDone) {
|
||||
final StringBuffer url = new StringBuffer(baseUrl);
|
||||
final StringBuilder url = new StringBuilder(baseUrl);
|
||||
if (cookie > 0) {
|
||||
url.append("&startblockafter=").append(String.valueOf(cookie));
|
||||
}
|
||||
|
@ -32,7 +32,6 @@
|
||||
import org.apache.hadoop.hdfs.server.namenode.FSEditLogOp;
|
||||
import org.apache.hadoop.hdfs.server.namenode.FSEditLogOpCodes;
|
||||
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.xml.sax.Attributes;
|
||||
import org.xml.sax.InputSource;
|
||||
@ -57,7 +56,7 @@ class OfflineEditsXmlLoader
|
||||
private Stanza stanza;
|
||||
private Stack<Stanza> stanzaStack;
|
||||
private FSEditLogOpCodes opCode;
|
||||
private StringBuffer cbuf;
|
||||
private StringBuilder cbuf;
|
||||
private long nextTxId;
|
||||
private final OpInstanceCache opCache = new OpInstanceCache();
|
||||
|
||||
@ -119,7 +118,7 @@ public void startDocument() {
|
||||
stanza = null;
|
||||
stanzaStack = new Stack<Stanza>();
|
||||
opCode = null;
|
||||
cbuf = new StringBuffer();
|
||||
cbuf = new StringBuilder();
|
||||
nextTxId = -1;
|
||||
}
|
||||
|
||||
@ -182,7 +181,7 @@ public void startElement (String uri, String name,
|
||||
@Override
|
||||
public void endElement (String uri, String name, String qName) {
|
||||
String str = XMLUtils.unmangleXmlString(cbuf.toString(), false).trim();
|
||||
cbuf = new StringBuffer();
|
||||
cbuf = new StringBuilder();
|
||||
switch (state) {
|
||||
case EXPECT_EDITS_TAG:
|
||||
throw new InvalidXmlException("expected <EDITS/>");
|
||||
|
@ -85,7 +85,7 @@ long getId() {
|
||||
}
|
||||
|
||||
String getType() {
|
||||
StringBuffer s = new StringBuffer();
|
||||
StringBuilder s = new StringBuilder();
|
||||
if (type.contains(PBImageCorruptionType.CORRUPT_NODE)) {
|
||||
s.append(PBImageCorruptionType.CORRUPT_NODE);
|
||||
}
|
||||
|
@ -340,7 +340,7 @@ private class MyFile {
|
||||
for (int idx = 0; idx < nLevels; idx++) {
|
||||
levels[idx] = gen.nextInt(10);
|
||||
}
|
||||
StringBuffer sb = new StringBuffer();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int idx = 0; idx < nLevels; idx++) {
|
||||
sb.append(dirNames[levels[idx]]);
|
||||
sb.append("/");
|
||||
|
@ -180,7 +180,7 @@ private Trash getPerUserTrash(UserGroupInformation ugi,
|
||||
FileSystem fileSystem, Configuration config) throws IOException {
|
||||
// generate an unique path per instance
|
||||
UUID trashId = UUID.randomUUID();
|
||||
StringBuffer sb = new StringBuffer()
|
||||
StringBuilder sb = new StringBuilder()
|
||||
.append(ugi.getUserName())
|
||||
.append("-")
|
||||
.append(trashId.toString());
|
||||
|
@ -1833,7 +1833,7 @@ public void testMetaSavePostponedMisreplicatedBlocks() throws IOException {
|
||||
DataInputStream in = new DataInputStream(fstream);
|
||||
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(in));
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
String line;
|
||||
try {
|
||||
while ((line = reader.readLine()) != null) {
|
||||
@ -1861,7 +1861,7 @@ public void testMetaSaveMissingReplicas() throws Exception {
|
||||
FileInputStream fstream = new FileInputStream(file);
|
||||
DataInputStream in = new DataInputStream(fstream);
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(in));
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
String line;
|
||||
try {
|
||||
while ((line = reader.readLine()) != null) {
|
||||
@ -1933,7 +1933,7 @@ public void testMetaSaveInMaintenanceReplicas() throws Exception {
|
||||
FileInputStream fstream = new FileInputStream(file);
|
||||
DataInputStream in = new DataInputStream(fstream);
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(in));
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
String line;
|
||||
try {
|
||||
while ((line = reader.readLine()) != null) {
|
||||
@ -1989,7 +1989,7 @@ public void testMetaSaveDecommissioningReplicas() throws Exception {
|
||||
FileInputStream fstream = new FileInputStream(file);
|
||||
DataInputStream in = new DataInputStream(fstream);
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(in));
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
String line;
|
||||
try {
|
||||
while ((line = reader.readLine()) != null) {
|
||||
|
@ -196,7 +196,7 @@ public void testExcludeDataNodes() throws Exception {
|
||||
//For GETFILECHECKSUM, OPEN and APPEND,
|
||||
//the chosen datanode must be different with exclude nodes.
|
||||
|
||||
StringBuffer sb = new StringBuffer();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < 2; i++) {
|
||||
sb.append(locations[i].getXferAddr());
|
||||
{ // test GETFILECHECKSUM
|
||||
|
@ -83,7 +83,7 @@ public class ConfBlock extends HtmlBlock {
|
||||
__().
|
||||
tbody();
|
||||
for (ConfEntryInfo entry : info.getProperties()) {
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
String[] sources = entry.getSource();
|
||||
//Skip the last entry, because it is always the same HDFS file, and
|
||||
// output them in reverse order so most recent is output first
|
||||
|
@ -2080,7 +2080,7 @@ private void writeOutput(TaskAttempt attempt, Configuration conf)
|
||||
|
||||
private void validateOutput() throws IOException {
|
||||
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(val1).append("\n");
|
||||
expectedOutput.append(val2).append("\n");
|
||||
|
@ -516,7 +516,7 @@ public void verifyTaskAttemptGeneric(TaskAttempt ta, TaskType ttype,
|
||||
String expectDiag = "";
|
||||
List<String> diagnosticsList = ta.getDiagnostics();
|
||||
if (diagnosticsList != null && !diagnostics.isEmpty()) {
|
||||
StringBuffer b = new StringBuffer();
|
||||
StringBuilder b = new StringBuilder();
|
||||
for (String diag : diagnosticsList) {
|
||||
b.append(diag);
|
||||
}
|
||||
|
@ -600,7 +600,7 @@ public void verifyAMJobGenericSecure(Job job, int mapsPending,
|
||||
String diagString = "";
|
||||
List<String> diagList = job.getDiagnostics();
|
||||
if (diagList != null && !diagList.isEmpty()) {
|
||||
StringBuffer b = new StringBuffer();
|
||||
StringBuilder b = new StringBuilder();
|
||||
for (String diag : diagList) {
|
||||
b.append(diag);
|
||||
}
|
||||
|
@ -1027,8 +1027,8 @@ static void setupChildMapredLocalDirs(Task t, JobConf conf) {
|
||||
String taskId = t.getTaskID().toString();
|
||||
boolean isCleanup = t.isTaskCleanupTask();
|
||||
String user = t.getUser();
|
||||
StringBuffer childMapredLocalDir =
|
||||
new StringBuffer(localDirs[0] + Path.SEPARATOR
|
||||
StringBuilder childMapredLocalDir =
|
||||
new StringBuilder(localDirs[0] + Path.SEPARATOR
|
||||
+ getLocalTaskDir(user, jobId, taskId, isCleanup));
|
||||
for (int i = 1; i < localDirs.length; i++) {
|
||||
childMapredLocalDir.append("," + localDirs[i] + Path.SEPARATOR
|
||||
|
@ -145,7 +145,7 @@ public static String getApplicationWebURLOnJHSWithoutScheme(Configuration conf,
|
||||
InetSocketAddress address = NetUtils.createSocketAddr(
|
||||
hsAddress, getDefaultJHSWebappPort(),
|
||||
getDefaultJHSWebappURLWithoutScheme());
|
||||
StringBuffer sb = new StringBuffer();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if (address.getAddress() != null &&
|
||||
(address.getAddress().isAnyLocalAddress() ||
|
||||
address.getAddress().isLoopbackAddress())) {
|
||||
|
@ -102,7 +102,7 @@ public void testNewApis() throws Exception {
|
||||
static String readOutput(Path outDir, Configuration conf)
|
||||
throws IOException {
|
||||
FileSystem fs = outDir.getFileSystem(conf);
|
||||
StringBuffer result = new StringBuffer();
|
||||
StringBuilder result = new StringBuilder();
|
||||
|
||||
Path[] fileList = FileUtil.stat2Paths(fs.listStatus(outDir,
|
||||
new Utils.OutputFileUtils.OutputFilesFilter()));
|
||||
|
@ -470,7 +470,7 @@ public static void addInputPaths(JobConf conf, String commaSeparatedPaths) {
|
||||
*/
|
||||
public static void setInputPaths(JobConf conf, Path... inputPaths) {
|
||||
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++) {
|
||||
str.append(StringUtils.COMMA_STR);
|
||||
path = new Path(conf.getWorkingDirectory(), inputPaths[i]);
|
||||
|
@ -61,7 +61,7 @@ public List<IOException> getProblems() {
|
||||
* @return the concatenated messages from all of the problems.
|
||||
*/
|
||||
public String getMessage() {
|
||||
StringBuffer result = new StringBuffer();
|
||||
StringBuilder result = new StringBuilder();
|
||||
Iterator<IOException> itr = problems.iterator();
|
||||
while(itr.hasNext()) {
|
||||
result.append(itr.next().getMessage());
|
||||
|
@ -70,7 +70,7 @@ private void addToSet(Set<String> set, String[] array) {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for(int i=0; i < getPaths().length; i++) {
|
||||
sb.append(getPath(i).toUri().getPath() + ":0+" + getLength(i));
|
||||
if (i < getPaths().length -1) {
|
||||
|
@ -207,7 +207,7 @@ public synchronized void write(DataOutput out) throws IOException {
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
Iterator<Range> it = ranges.iterator();
|
||||
while(it.hasNext()) {
|
||||
Range range = it.next();
|
||||
|
@ -518,8 +518,8 @@ static String buildCommandLine(List<String> setup, List<String> cmd,
|
||||
throws IOException {
|
||||
|
||||
String stdout = FileUtil.makeShellPath(stdoutFilename);
|
||||
String stderr = FileUtil.makeShellPath(stderrFilename);
|
||||
StringBuffer mergedCmd = new StringBuffer();
|
||||
String stderr = FileUtil.makeShellPath(stderrFilename);
|
||||
StringBuilder mergedCmd = new StringBuilder();
|
||||
|
||||
// Export the pid of taskJvm to env variable JVM_PID.
|
||||
// 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)
|
||||
throws IOException {
|
||||
StringBuffer command = new StringBuffer();
|
||||
StringBuilder command = new StringBuilder();
|
||||
for(String s: cmd) {
|
||||
command.append('\'');
|
||||
if (isExecutable) {
|
||||
|
@ -96,7 +96,7 @@ public class FieldSelectionMapReduce<K, V>
|
||||
LoggerFactory.getLogger("FieldSelectionMapReduce");
|
||||
|
||||
private String specToString() {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("fieldSeparator: ").append(fieldSeparator).append("\n");
|
||||
|
||||
sb.append("mapOutputKeyValueSpec: ").append(mapOutputKeyValueSpec).append(
|
||||
|
@ -476,7 +476,7 @@ public String toString() {
|
||||
} catch (IOException e) {
|
||||
} catch (InterruptedException ie) {
|
||||
}
|
||||
StringBuffer sb = new StringBuffer();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("Job: ").append(status.getJobID()).append("\n");
|
||||
sb.append("Job File: ").append(status.getJobFile()).append("\n");
|
||||
sb.append("Job Tracking URL : ").append(status.getTrackingUrl());
|
||||
|
@ -636,7 +636,7 @@ public synchronized void setUber(boolean isUber) {
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
buffer.append("job-id : " + jobid);
|
||||
buffer.append("uber-mode : " + isUber);
|
||||
buffer.append("map-progress : " + mapProgress);
|
||||
|
@ -188,7 +188,7 @@ protected void setTaskTrackerHttp(String taskTrackerHttp) {
|
||||
|
||||
@Override
|
||||
public String toString(){
|
||||
StringBuffer buf = new StringBuffer();
|
||||
StringBuilder buf = new StringBuilder();
|
||||
buf.append("Task Id : ");
|
||||
buf.append(taskId);
|
||||
buf.append(", Status : ");
|
||||
|
@ -83,7 +83,7 @@ public void addNextValue(Object val) {
|
||||
public String getReport() {
|
||||
long[] counts = new long[items.size()];
|
||||
|
||||
StringBuffer sb = new StringBuffer();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
Iterator<Object> iter = items.values().iterator();
|
||||
int i = 0;
|
||||
while (iter.hasNext()) {
|
||||
@ -133,7 +133,7 @@ public String getReport() {
|
||||
* the histogram
|
||||
*/
|
||||
public String getReportDetails() {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
Iterator<Entry<Object,Object>> iter = items.entrySet().iterator();
|
||||
while (iter.hasNext()) {
|
||||
Entry<Object,Object> en = iter.next();
|
||||
|
@ -121,10 +121,10 @@ private static String selectFields(String[] fields, List<Integer> fieldList,
|
||||
int allFieldsFrom, String separator) {
|
||||
String retv = null;
|
||||
int i = 0;
|
||||
StringBuffer sb = null;
|
||||
StringBuilder sb = null;
|
||||
if (fieldList != null && fieldList.size() > 0) {
|
||||
if (sb == null) {
|
||||
sb = new StringBuffer();
|
||||
sb = new StringBuilder();
|
||||
}
|
||||
for (Integer index : fieldList) {
|
||||
if (index < fields.length) {
|
||||
@ -135,7 +135,7 @@ private static String selectFields(String[] fields, List<Integer> fieldList,
|
||||
}
|
||||
if (allFieldsFrom >= 0) {
|
||||
if (sb == null) {
|
||||
sb = new StringBuffer();
|
||||
sb = new StringBuilder();
|
||||
}
|
||||
for (i = allFieldsFrom; i < fields.length; i++) {
|
||||
sb.append(fields[i]).append(separator);
|
||||
@ -168,7 +168,7 @@ public static int parseOutputKeyValueSpec(String keyValueSpec,
|
||||
public static String specToString(String fieldSeparator, String keyValueSpec,
|
||||
int allValueFieldsFrom, List<Integer> keyFieldList,
|
||||
List<Integer> valueFieldList) {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("fieldSeparator: ").append(fieldSeparator).append("\n");
|
||||
|
||||
sb.append("keyValueSpec: ").append(keyValueSpec).append("\n");
|
||||
|
@ -803,7 +803,7 @@ public boolean accept(Path path) {
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
StringBuffer buf = new StringBuffer();
|
||||
StringBuilder buf = new StringBuilder();
|
||||
buf.append("[");
|
||||
for (PathFilter f: filters) {
|
||||
buf.append(f);
|
||||
|
@ -175,7 +175,7 @@ public void write(DataOutput out) throws IOException {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < paths.length; i++) {
|
||||
if (i == 0 ) {
|
||||
sb.append("Paths:");
|
||||
@ -188,7 +188,7 @@ public String toString() {
|
||||
}
|
||||
if (locations != null) {
|
||||
String locs = "";
|
||||
StringBuffer locsb = new StringBuffer();
|
||||
StringBuilder locsb = new StringBuilder();
|
||||
for (int i = 0; i < locations.length; i++) {
|
||||
locsb.append(locations[i] + ":");
|
||||
}
|
||||
|
@ -569,7 +569,7 @@ public static void setInputPaths(Job job,
|
||||
Path... inputPaths) throws IOException {
|
||||
Configuration conf = job.getConfiguration();
|
||||
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++) {
|
||||
str.append(StringUtils.COMMA_STR);
|
||||
path = inputPaths[i].getFileSystem(conf).makeQualified(inputPaths[i]);
|
||||
|
@ -60,7 +60,7 @@ public List<IOException> getProblems() {
|
||||
* @return the concatenated messages from all of the problems.
|
||||
*/
|
||||
public String getMessage() {
|
||||
StringBuffer result = new StringBuffer();
|
||||
StringBuilder result = new StringBuilder();
|
||||
Iterator<IOException> itr = problems.iterator();
|
||||
while(itr.hasNext()) {
|
||||
result.append(itr.next().getMessage());
|
||||
|
@ -90,7 +90,7 @@ public ControlledJob(Configuration conf) throws IOException {
|
||||
|
||||
@Override
|
||||
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 id:\t").append(this.controlID).append("\n");
|
||||
sb.append("job state:\t").append(this.state).append("\n");
|
||||
|
@ -147,7 +147,7 @@ public void remove() {
|
||||
* <tt>[<child1>,<child2>,...,<childn>]</tt>
|
||||
*/
|
||||
public String toString() {
|
||||
StringBuffer buf = new StringBuffer("[");
|
||||
StringBuilder buf = new StringBuilder("[");
|
||||
for (int i = 0; i < values.length; ++i) {
|
||||
buf.append(has(i) ? values[i].toString() : "");
|
||||
buf.append(",");
|
||||
|
@ -123,7 +123,7 @@ public void write(DataOutput out) throws IOException {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuffer buf = new StringBuffer();
|
||||
StringBuilder buf = new StringBuilder();
|
||||
buf.append("data-size : " + inputDataLength + "\n");
|
||||
buf.append("start-offset : " + startOffset + "\n");
|
||||
buf.append("locations : " + "\n");
|
||||
|
@ -678,7 +678,7 @@ private boolean verifySanity(long compressedLength, long decompressedLength,
|
||||
private URL getMapOutputURL(MapHost host, Collection<TaskAttemptID> maps
|
||||
) throws MalformedURLException {
|
||||
// Get the base url
|
||||
StringBuffer url = new StringBuffer(host.getBaseUrl());
|
||||
StringBuilder url = new StringBuilder(host.getBaseUrl());
|
||||
|
||||
boolean first = true;
|
||||
for (TaskAttemptID mapId : maps) {
|
||||
@ -688,8 +688,10 @@ private URL getMapOutputURL(MapHost host, Collection<TaskAttemptID> maps
|
||||
url.append(mapId);
|
||||
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());
|
||||
}
|
||||
|
||||
|
@ -171,7 +171,7 @@ public void resolve(TaskCompletionEvent event) {
|
||||
}
|
||||
|
||||
static URI getBaseURI(TaskAttemptID reduceId, String url) {
|
||||
StringBuffer baseUrl = new StringBuffer(url);
|
||||
StringBuilder baseUrl = new StringBuilder(url);
|
||||
if (!url.endsWith("/")) {
|
||||
baseUrl.append("/");
|
||||
}
|
||||
|
@ -520,7 +520,7 @@ Cluster createCluster() throws IOException {
|
||||
}
|
||||
|
||||
private String getJobPriorityNames() {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (JobPriority p : JobPriority.values()) {
|
||||
// UNDEFINED_PRIORITY need not to be displayed in usage
|
||||
if (JobPriority.UNDEFINED_PRIORITY == p) {
|
||||
|
@ -175,7 +175,7 @@ public void testRecoveryUpgradeV1V2() throws Exception {
|
||||
private void validateContent(Path dir) throws IOException {
|
||||
File fdir = new File(dir.toUri().getPath());
|
||||
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(val1).append("\n");
|
||||
expectedOutput.append(val2).append("\n");
|
||||
|
@ -227,7 +227,7 @@ private void validateContent(Path dir) throws IOException {
|
||||
private void validateContent(File dir) throws IOException {
|
||||
File expectedFile = new File(dir, partFile);
|
||||
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(val1).append("\n");
|
||||
expectedOutput.append(val2).append("\n");
|
||||
|
@ -109,7 +109,7 @@ public class HsJobBlock extends HtmlBlock {
|
||||
// todo - switch to use JobInfo
|
||||
List<String> diagnostics = j.getDiagnostics();
|
||||
if(diagnostics != null && !diagnostics.isEmpty()) {
|
||||
StringBuffer b = new StringBuffer();
|
||||
StringBuilder b = new StringBuilder();
|
||||
for(String diag: diagnostics) {
|
||||
b.append(addTaskLinks(diag));
|
||||
}
|
||||
|
@ -117,7 +117,7 @@ public JobInfo(Job job) {
|
||||
this.diagnostics = "";
|
||||
List<String> diagnostics = job.getDiagnostics();
|
||||
if (diagnostics != null && !diagnostics.isEmpty()) {
|
||||
StringBuffer b = new StringBuffer();
|
||||
StringBuilder b = new StringBuilder();
|
||||
for (String diag : diagnostics) {
|
||||
b.append(diag);
|
||||
}
|
||||
|
@ -534,7 +534,7 @@ public void verifyTaskAttemptGeneric(TaskAttempt ta, TaskType ttype,
|
||||
String expectDiag = "";
|
||||
List<String> diagnosticsList = ta.getDiagnostics();
|
||||
if (diagnosticsList != null && !diagnostics.isEmpty()) {
|
||||
StringBuffer b = new StringBuffer();
|
||||
StringBuilder b = new StringBuilder();
|
||||
for (String diag : diagnosticsList) {
|
||||
b.append(diag);
|
||||
}
|
||||
|
@ -108,7 +108,7 @@ public static void verifyHsJobGenericSecure(Job job, Boolean uberized,
|
||||
String diagString = "";
|
||||
List<String> diagList = job.getDiagnostics();
|
||||
if (diagList != null && !diagList.isEmpty()) {
|
||||
StringBuffer b = new StringBuffer();
|
||||
StringBuilder b = new StringBuilder();
|
||||
for (String diag : diagList) {
|
||||
b.append(diag);
|
||||
}
|
||||
|
@ -204,7 +204,7 @@ public void map(Text key, Text value,
|
||||
}
|
||||
|
||||
private Text generateSentence(int noWords) {
|
||||
StringBuffer sentence = new StringBuffer();
|
||||
StringBuilder sentence = new StringBuilder();
|
||||
String space = " ";
|
||||
for (int i=0; i < noWords; ++i) {
|
||||
sentence.append(words[random.nextInt(words.length)]);
|
||||
|
@ -73,7 +73,7 @@ public void reduce(Text key,
|
||||
|
||||
// concatenate strings
|
||||
if (field.startsWith(VALUE_TYPE_STRING)) {
|
||||
StringBuffer sSum = new StringBuffer();
|
||||
StringBuilder sSum = new StringBuilder();
|
||||
while (values.hasNext())
|
||||
sSum.append(values.next().toString()).append(";");
|
||||
output.collect(key, new Text(sSum.toString()));
|
||||
|
@ -773,7 +773,7 @@ public void parseLogFile(FileSystem fs,
|
||||
/**
|
||||
* 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 {
|
||||
resBuffer.setLength(0);
|
||||
reader.mark(maxJobDelimiterLineLength);
|
||||
|
@ -132,7 +132,7 @@ public void generateTextFile(FileSystem fs, Path inputFile,
|
||||
*/
|
||||
private static String pad(long number, int length) {
|
||||
String str = String.valueOf(number);
|
||||
StringBuffer value = new StringBuffer();
|
||||
StringBuilder value = new StringBuilder();
|
||||
for (int i = str.length(); i < length; i++) {
|
||||
value.append("0");
|
||||
}
|
||||
|
@ -677,7 +677,7 @@ private static void doSingleBzip2BufferSize(JobConf jConf)
|
||||
}
|
||||
|
||||
private static String unquote(String in) {
|
||||
StringBuffer result = new StringBuffer();
|
||||
StringBuilder result = new StringBuilder();
|
||||
for(int i=0; i < in.length(); ++i) {
|
||||
char ch = in.charAt(i);
|
||||
if (ch == '\\') {
|
||||
|
@ -236,7 +236,7 @@ private ArrayList<String> createFile(Path targetFile, CompressionCodec codec,
|
||||
}
|
||||
Writer writer = new OutputStreamWriter(ostream);
|
||||
try {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < numRecords; i++) {
|
||||
for (int j = 0; j < recordLen; j++) {
|
||||
sb.append(chars[charRand.nextInt(chars.length)]);
|
||||
|
@ -105,7 +105,7 @@ public void testCommitter() throws Exception {
|
||||
|
||||
// validate output
|
||||
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(val1).append("\n");
|
||||
expectedOutput.append(val2).append("\n");
|
||||
|
@ -119,7 +119,7 @@ public boolean canCommit(TaskAttemptID taskid) throws IOException {
|
||||
|
||||
public AMFeedback statusUpdate(TaskAttemptID taskId, TaskStatus taskStatus)
|
||||
throws IOException, InterruptedException {
|
||||
StringBuffer buf = new StringBuffer("Task ");
|
||||
StringBuilder buf = new StringBuilder("Task ");
|
||||
buf.append(taskId);
|
||||
if (taskStatus != null) {
|
||||
buf.append(" making progress to ");
|
||||
|
@ -763,7 +763,7 @@ public void runJob(int items) {
|
||||
SequenceFile.Writer writer = SequenceFile.createWriter(fs, conf, inFile,
|
||||
Text.class, Text.class);
|
||||
|
||||
StringBuffer content = new StringBuffer();
|
||||
StringBuilder content = new StringBuilder();
|
||||
|
||||
for (int i = 0; i < 1000; i++) {
|
||||
content.append(i).append(": This is one more line of content\n");
|
||||
|
@ -80,7 +80,7 @@ static String launchWordCount(URI fileSys, JobConf conf, String input,
|
||||
FileSystem fs = FileSystem.get(fileSys, conf);
|
||||
configureWordCount(fs, conf, input, numMaps, numReduces, inDir, outDir);
|
||||
JobClient.runJob(conf);
|
||||
StringBuffer result = new StringBuffer();
|
||||
StringBuilder result = new StringBuilder();
|
||||
{
|
||||
Path[] parents = FileUtil.stat2Paths(fs.listStatus(outDir.getParent()));
|
||||
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
|
||||
conf.setJarByClass(TestMiniMRClasspath.class);
|
||||
JobClient.runJob(conf);
|
||||
StringBuffer result = new StringBuffer();
|
||||
StringBuilder result = new StringBuilder();
|
||||
Path[] fileList = FileUtil.stat2Paths(fs.listStatus(outDir,
|
||||
new Utils.OutputFileUtils
|
||||
.OutputFilesFilter()));
|
||||
|
@ -106,7 +106,7 @@ public void testFormat() throws Exception {
|
||||
File expectedFile_11 = new File(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++) {
|
||||
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());
|
||||
//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++) {
|
||||
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());
|
||||
//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++) {
|
||||
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());
|
||||
//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++) {
|
||||
expectedOutput.append(""+i).append('\t').append(""+i).append("\n");
|
||||
}
|
||||
|
@ -548,7 +548,7 @@ public void testGzipEmpty() throws IOException {
|
||||
}
|
||||
|
||||
private static String unquote(String in) {
|
||||
StringBuffer result = new StringBuffer();
|
||||
StringBuilder result = new StringBuilder();
|
||||
for(int i=0; i < in.length(); ++i) {
|
||||
char ch = in.charAt(i);
|
||||
if (ch == '\\') {
|
||||
|
@ -91,7 +91,7 @@ public static String ifmt(double d) {
|
||||
}
|
||||
|
||||
public static String formatBytes(long numBytes) {
|
||||
StringBuffer buf = new StringBuffer();
|
||||
StringBuilder buf = new StringBuilder();
|
||||
boolean bDetails = true;
|
||||
double num = numBytes;
|
||||
|
||||
@ -116,7 +116,7 @@ public static String formatBytes(long numBytes) {
|
||||
}
|
||||
|
||||
public static String formatBytes2(long numBytes) {
|
||||
StringBuffer buf = new StringBuffer();
|
||||
StringBuilder buf = new StringBuilder();
|
||||
long u = 0;
|
||||
if (numBytes >= TB) {
|
||||
u = numBytes / TB;
|
||||
@ -145,7 +145,7 @@ public static String formatBytes2(long numBytes) {
|
||||
static final String regexpSpecials = "[]()?*+|.!^-\\~@";
|
||||
|
||||
public static String regexpEscape(String plain) {
|
||||
StringBuffer buf = new StringBuffer();
|
||||
StringBuilder buf = new StringBuilder();
|
||||
char[] ch = plain.toCharArray();
|
||||
int csup = ch.length;
|
||||
for (int c = 0; c < csup; c++) {
|
||||
|
@ -82,7 +82,7 @@ private static String generateRandomWord() {
|
||||
private static String generateRandomLine() {
|
||||
long r = rand.nextLong() % 7;
|
||||
long n = r + 20;
|
||||
StringBuffer sb = new StringBuffer();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < n; i++) {
|
||||
sb.append(generateRandomWord()).append(" ");
|
||||
}
|
||||
|
@ -97,7 +97,7 @@ public static String generateRandomWord() {
|
||||
public static String generateRandomLine() {
|
||||
long r = rand.nextLong() % 7;
|
||||
long n = r + 20;
|
||||
StringBuffer sb = new StringBuffer();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < n; i++) {
|
||||
sb.append(generateRandomWord()).append(" ");
|
||||
}
|
||||
@ -401,7 +401,7 @@ public Counter getCounter(String group, String name) {
|
||||
public static String readOutput(Path outDir, Configuration conf)
|
||||
throws IOException {
|
||||
FileSystem fs = outDir.getFileSystem(conf);
|
||||
StringBuffer result = new StringBuffer();
|
||||
StringBuilder result = new StringBuilder();
|
||||
|
||||
Path[] fileList = FileUtil.stat2Paths(fs.listStatus(outDir,
|
||||
new Utils.OutputFileUtils.OutputFilesFilter()));
|
||||
@ -436,7 +436,7 @@ public static String readTaskLog(TaskLog.LogName filter,
|
||||
org.apache.hadoop.mapred.TaskAttemptID taskId, boolean isCleanup)
|
||||
throws IOException {
|
||||
// string buffer to store task log
|
||||
StringBuffer result = new StringBuffer();
|
||||
StringBuilder result = new StringBuilder();
|
||||
int res;
|
||||
|
||||
// reads the whole tasklog into inputstream
|
||||
|
@ -100,7 +100,7 @@ enum Counters { RECORDS_WRITTEN, BYTES_WRITTEN }
|
||||
|
||||
public static String generateSentenceWithRand(ThreadLocalRandom rand,
|
||||
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++) {
|
||||
sentence.append(" ").append(words[rand.nextInt(words.length)]);
|
||||
}
|
||||
|
@ -262,7 +262,7 @@ private ArrayList<String> createFile(Path targetFile, CompressionCodec codec,
|
||||
}
|
||||
Writer writer = new OutputStreamWriter(ostream);
|
||||
try {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < numRecords; i++) {
|
||||
for (int j = 0; j < recordLen; j++) {
|
||||
sb.append(chars[charRand.nextInt(chars.length)]);
|
||||
|
@ -119,7 +119,7 @@ public void testCommitter() throws Exception {
|
||||
|
||||
// validate output
|
||||
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(val1).append("\n");
|
||||
expectedOutput.append(val2).append("\n");
|
||||
|
@ -106,7 +106,7 @@ public static String getResolvedMRHistoryWebAppURLWithoutScheme(
|
||||
JHAdminConfig.DEFAULT_MR_HISTORY_WEBAPP_ADDRESS,
|
||||
JHAdminConfig.DEFAULT_MR_HISTORY_WEBAPP_PORT); }
|
||||
address = NetUtils.getConnectAddress(address);
|
||||
StringBuffer sb = new StringBuffer();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
InetAddress resolved = address.getAddress();
|
||||
if (resolved == null || resolved.isAnyLocalAddress() ||
|
||||
resolved.isLoopbackAddress()) {
|
||||
|
@ -154,7 +154,7 @@ public void map(Text key, Text value,
|
||||
}
|
||||
|
||||
private Text generateSentence(int noWords) {
|
||||
StringBuffer sentence = new StringBuffer();
|
||||
StringBuilder sentence = new StringBuilder();
|
||||
String space = " ";
|
||||
for (int i=0; i < noWords; ++i) {
|
||||
sentence.append(words[random.nextInt(words.length)]);
|
||||
|
@ -142,7 +142,7 @@ static class Point implements ColumnName {
|
||||
public static String stringifySolution(int width, int height,
|
||||
List<List<ColumnName>> solution) {
|
||||
String[][] picture = new String[height][width];
|
||||
StringBuffer result = new StringBuffer();
|
||||
StringBuilder result = new StringBuilder();
|
||||
// for each piece placement...
|
||||
for(List<ColumnName> row: solution) {
|
||||
// go through to find which piece was placed
|
||||
|
@ -66,7 +66,7 @@ protected static interface ColumnName {
|
||||
*/
|
||||
static String stringifySolution(int size, List<List<ColumnName>> solution) {
|
||||
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
|
||||
// solution.
|
||||
for(List<ColumnName> row: solution) {
|
||||
|
@ -47,7 +47,7 @@ static class Split {
|
||||
this.filename = filename;
|
||||
}
|
||||
public String toString() {
|
||||
StringBuffer result = new StringBuffer();
|
||||
StringBuilder result = new StringBuilder();
|
||||
result.append(filename);
|
||||
result.append(" on ");
|
||||
for(Host host: locations) {
|
||||
@ -64,7 +64,7 @@ static class Host {
|
||||
this.hostname = hostname;
|
||||
}
|
||||
public String toString() {
|
||||
StringBuffer result = new StringBuffer();
|
||||
StringBuilder result = new StringBuilder();
|
||||
result.append(splits.size());
|
||||
result.append(" ");
|
||||
result.append(hostname);
|
||||
|
@ -722,7 +722,7 @@ private void validateContent(Path dir,
|
||||
}
|
||||
Path expectedFile = getPart0000(dir);
|
||||
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(VAL_1).append("\n");
|
||||
expectedOutput.append(VAL_2).append("\n");
|
||||
|
@ -143,7 +143,7 @@ protected void report() {
|
||||
*
|
||||
*/
|
||||
protected String getReport() {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
Iterator iter = this.longCounters.entrySet().iterator();
|
||||
while (iter.hasNext()) {
|
||||
|
@ -614,7 +614,7 @@ private Path translateRenamedPath(Path sourcePath,
|
||||
if (sourcePath.equals(renameItem.getSource())) {
|
||||
return renameItem.getTarget();
|
||||
}
|
||||
StringBuffer sb = new StringBuffer(sourcePath.toString());
|
||||
StringBuilder sb = new StringBuilder(sourcePath.toString());
|
||||
String remain =
|
||||
sb.substring(renameItem.getSource().toString().length() + 1);
|
||||
return new Path(renameItem.getTarget(), remain);
|
||||
|
@ -155,7 +155,7 @@ public static String getRelativePath(Path sourceRootPath, Path childPath) {
|
||||
* @return - String containing first letters of each attribute to preserve
|
||||
*/
|
||||
public static String packAttributes(EnumSet<FileAttribute> attributes) {
|
||||
StringBuffer buffer = new StringBuffer(FileAttribute.values().length);
|
||||
StringBuilder buffer = new StringBuilder(FileAttribute.values().length);
|
||||
int len = 0;
|
||||
for (FileAttribute attribute : attributes) {
|
||||
buffer.append(attribute.name().charAt(0));
|
||||
|
@ -140,7 +140,7 @@ public String getAnonymizedValue(StatePool statePool, Configuration conf) {
|
||||
}
|
||||
|
||||
private void anonymize(StatePool pool) {
|
||||
StringBuffer buf = new StringBuffer();
|
||||
StringBuilder buf = new StringBuilder();
|
||||
NodeNameState state = (NodeNameState) pool.getState(getClass());
|
||||
if (state == null) {
|
||||
state = new NodeNameState();
|
||||
|
@ -254,7 +254,7 @@ void addJobConfToEnvironment(JobConf jobconf, Properties env) {
|
||||
}
|
||||
|
||||
String safeEnvVarName(String var) {
|
||||
StringBuffer safe = new StringBuffer();
|
||||
StringBuilder safe = new StringBuilder();
|
||||
int len = var.length();
|
||||
for (int i = 0; i < len; i++) {
|
||||
char c = var.charAt(i);
|
||||
|
@ -291,7 +291,7 @@ void parseArgv() {
|
||||
LOG.warn("-file option is deprecated, please use generic option" +
|
||||
" -files instead.");
|
||||
|
||||
StringBuffer fileList = new StringBuffer();
|
||||
StringBuilder fileList = new StringBuilder();
|
||||
for (String file : values) {
|
||||
packageFiles_.add(file);
|
||||
try {
|
||||
|
@ -23,9 +23,7 @@
|
||||
import java.util.regex.*;
|
||||
|
||||
import org.apache.hadoop.io.DataOutputBuffer;
|
||||
import org.apache.hadoop.io.Writable;
|
||||
import org.apache.hadoop.io.Text;
|
||||
import org.apache.hadoop.io.WritableComparable;
|
||||
import org.apache.hadoop.fs.FileSystem;
|
||||
import org.apache.hadoop.fs.FSDataInputStream;
|
||||
import org.apache.hadoop.mapred.Reporter;
|
||||
|
@ -128,7 +128,7 @@ protected String[] genArgs() {
|
||||
}
|
||||
|
||||
protected void checkOutput() throws IOException {
|
||||
StringBuffer output = new StringBuffer(256);
|
||||
StringBuilder output = new StringBuilder(256);
|
||||
Path[] fileList = FileUtil.stat2Paths(fileSys.listStatus(
|
||||
new Path(OUTPUT_DIR)));
|
||||
for (int i = 0; i < fileList.length; i++){
|
||||
|
@ -86,7 +86,7 @@ void redirectIfAntJunit() throws IOException
|
||||
}
|
||||
|
||||
public static String collate(List<String> args, String sep) {
|
||||
StringBuffer buf = new StringBuffer();
|
||||
StringBuilder buf = new StringBuilder();
|
||||
Iterator<String> it = args.iterator();
|
||||
while (it.hasNext()) {
|
||||
if (buf.length() > 0) {
|
||||
|
@ -144,7 +144,7 @@ public String toString() {
|
||||
|
||||
public static TimelineEntityGroupId
|
||||
fromString(String timelineEntityGroupIdStr) {
|
||||
StringBuffer buf = new StringBuffer();
|
||||
StringBuilder buf = new StringBuilder();
|
||||
Iterator<String> it = SPLITTER.split(timelineEntityGroupIdStr).iterator();
|
||||
if (!it.next().equals(TIMELINE_ENTITY_GROUPID_STR_PREFIX)) {
|
||||
throw new IllegalArgumentException(
|
||||
|
@ -413,7 +413,7 @@ public boolean equals(Object o) {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if (TargetType.ALLOCATION_TAG == this.targetType) {
|
||||
// following by a comma separated tags
|
||||
sb.append(String.join(",", getTargetValues()));
|
||||
@ -643,7 +643,7 @@ public int hashCode() {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("cardinality").append(",").append(getScope()).append(",");
|
||||
for (String tag : getAllocationTags()) {
|
||||
sb.append(tag).append(",");
|
||||
@ -717,7 +717,7 @@ public <T> T accept(Visitor<T> visitor) {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("and(");
|
||||
Iterator<AbstractConstraint> it = getChildren().iterator();
|
||||
while (it.hasNext()) {
|
||||
@ -759,7 +759,7 @@ public <T> T accept(Visitor<T> visitor) {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("or(");
|
||||
Iterator<AbstractConstraint> it = getChildren().iterator();
|
||||
while (it.hasNext()) {
|
||||
@ -805,7 +805,7 @@ public <T> T accept(Visitor<T> visitor) {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("DelayedOr(");
|
||||
Iterator<TimedPlacementConstraint> it = getChildren().iterator();
|
||||
while (it.hasNext()) {
|
||||
|
@ -1491,7 +1491,7 @@ public void testSaveContainerLogsLocally() throws Exception {
|
||||
private String readContainerContent(Path containerPath,
|
||||
FileSystem fs) throws IOException {
|
||||
assertTrue(fs.exists(containerPath));
|
||||
StringBuffer inputLine = new StringBuffer();
|
||||
StringBuilder inputLine = new StringBuilder();
|
||||
try (BufferedReader reader = new BufferedReader(new InputStreamReader(
|
||||
fs.open(containerPath)))) {
|
||||
String tmp;
|
||||
|
@ -568,7 +568,7 @@ private static ProcessInfo constructProcessInfo(ProcessInfo pinfo,
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuffer pTree = new StringBuffer("[ ");
|
||||
StringBuilder pTree = new StringBuilder("[ ");
|
||||
for (String p : processTree.keySet()) {
|
||||
pTree.append(p);
|
||||
pTree.append(" ");
|
||||
|
@ -130,7 +130,7 @@ protected void initDataTables(List<String> list) {
|
||||
}
|
||||
// for inserting stateSaveInit
|
||||
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,
|
||||
").fnSetFilteringDelay(188);"));
|
||||
String postInit = $(postInitID(DATATABLES, id));
|
||||
@ -146,7 +146,7 @@ protected void initDataTables(List<String> list) {
|
||||
init = defaultInit;
|
||||
}
|
||||
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,
|
||||
").fnSetFilteringDelay(288);"));
|
||||
|
||||
|
@ -401,7 +401,7 @@ void testContainerLogsFileAccess() throws IOException {
|
||||
new BufferedReader(new FileReader(new File(remoteAppLogFile
|
||||
.toUri().getRawPath())));
|
||||
String line;
|
||||
StringBuffer sb = new StringBuffer("");
|
||||
StringBuilder sb = new StringBuilder("");
|
||||
while ((line = in.readLine()) != null) {
|
||||
LOG.info(line);
|
||||
sb.append(line);
|
||||
|
@ -181,7 +181,7 @@ protected void rethrow(SQLException cause, String sql, Object... params)
|
||||
causeMessage = "";
|
||||
}
|
||||
|
||||
StringBuffer msg = new StringBuffer(causeMessage);
|
||||
StringBuilder msg = new StringBuilder(causeMessage);
|
||||
msg.append(" Query: ");
|
||||
msg.append(sql);
|
||||
msg.append(" Parameters: ");
|
||||
|
@ -65,7 +65,7 @@ public void run() {
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuffer sb = new StringBuffer("DockerContainerDeletionTask : ");
|
||||
StringBuilder sb = new StringBuilder("DockerContainerDeletionTask : ");
|
||||
sb.append(" id : ").append(this.getTaskId());
|
||||
sb.append(" containerId : ").append(this.containerId);
|
||||
return sb.toString().trim();
|
||||
|
@ -281,7 +281,7 @@ public IOStreamPair executePrivilegedInteractiveOperation(
|
||||
return null;
|
||||
}
|
||||
|
||||
StringBuffer finalOpArg = new StringBuffer(PrivilegedOperation
|
||||
StringBuilder finalOpArg = new StringBuilder(PrivilegedOperation
|
||||
.CGROUP_ARG_PREFIX);
|
||||
boolean noTasks = true;
|
||||
|
||||
|
@ -104,7 +104,7 @@ public List<PrivilegedOperation> preStart(Container container)
|
||||
//executable.
|
||||
String tasksFile = cGroupsHandler.getPathForCGroupTasks(
|
||||
CGroupsHandler.CGroupController.NET_CLS, containerIdStr);
|
||||
String opArg = new StringBuffer(PrivilegedOperation.CGROUP_ARG_PREFIX)
|
||||
String opArg = new StringBuilder(PrivilegedOperation.CGROUP_ARG_PREFIX)
|
||||
.append(tasksFile).toString();
|
||||
List<PrivilegedOperation> ops = new ArrayList<>();
|
||||
|
||||
|
@ -101,7 +101,7 @@ public List<PrivilegedOperation> bootstrap(Configuration configuration)
|
||||
containerBandwidthMbit = (int) Math.ceil((double) yarnBandwidthMbit /
|
||||
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());
|
||||
|
||||
if (strictMode) {
|
||||
@ -152,7 +152,7 @@ public List<PrivilegedOperation> preStart(Container container)
|
||||
//executable.
|
||||
String tasksFile = cGroupsHandler.getPathForCGroupTasks(
|
||||
CGroupsHandler.CGroupController.NET_CLS, containerIdStr);
|
||||
String opArg = new StringBuffer(PrivilegedOperation.CGROUP_ARG_PREFIX)
|
||||
String opArg = new StringBuilder(PrivilegedOperation.CGROUP_ARG_PREFIX)
|
||||
.append(tasksFile).toString();
|
||||
List<PrivilegedOperation> ops = new ArrayList<>();
|
||||
|
||||
|
@ -225,7 +225,7 @@ private boolean checkIfAlreadyBootstrapped(String state)
|
||||
if (pattern.matcher(state).find()) {
|
||||
LOG.debug("Matched regex: {}", regex);
|
||||
} 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();
|
||||
LOG.warn(logLine);
|
||||
return false;
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user