mirror of https://github.com/apache/cassandra
minor code cleanups. patch by Edward Ribeiro; reviewed by jbellis for CASSANDRA-273
git-svn-id: https://svn.apache.org/repos/asf/incubator/cassandra/trunk@791059 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
ef203cf000
commit
0172497ad2
|
|
@ -262,7 +262,7 @@ public class CliClient
|
|||
int portNumber = Integer.parseInt(ast.getChild(1).getText());
|
||||
Tree idList = ast.getChild(0);
|
||||
|
||||
StringBuffer hostName = new StringBuffer();
|
||||
StringBuilder hostName = new StringBuilder();
|
||||
int idCount = idList.getChildCount();
|
||||
for (int idx = 0; idx < idCount; idx++)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -116,7 +116,7 @@ public class DatabaseDescriptor
|
|||
{
|
||||
try
|
||||
{
|
||||
configFileName_ = System.getProperty("storage-config") + System.getProperty("file.separator") + "storage-conf.xml";
|
||||
configFileName_ = System.getProperty("storage-config") + File.separator + "storage-conf.xml";
|
||||
if (logger_.isDebugEnabled())
|
||||
logger_.debug("Loading settings from " + configFileName_);
|
||||
XMLUtils xmlUtils = new XMLUtils(configFileName_);
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ public class CType
|
|||
|
||||
public String toString()
|
||||
{
|
||||
StringBuffer sb = new StringBuffer("<");
|
||||
StringBuilder sb = new StringBuilder("<");
|
||||
for (int idx = types_.size(); idx > 0; idx--)
|
||||
{
|
||||
sb.append(types_.toString());
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@ public class SetColumnMap extends DMLPlan
|
|||
|
||||
public String explainPlan()
|
||||
{
|
||||
StringBuffer sb = new StringBuffer();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
String prefix =
|
||||
String.format("%s Column Family: Batch SET a set of columns: \n" +
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ public class SetSuperColumnMap extends DMLPlan
|
|||
|
||||
public String explainPlan()
|
||||
{
|
||||
StringBuffer sb = new StringBuffer();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
String prefix =
|
||||
String.format("%s Column Family: Batch SET a set of Super Columns: \n" +
|
||||
|
|
|
|||
|
|
@ -157,7 +157,7 @@ public class CalloutManager
|
|||
logger_.warn(LogUtil.throwableToString(ex));
|
||||
}
|
||||
/* save the script to disk */
|
||||
String scriptFile = DatabaseDescriptor.getCalloutLocation() + System.getProperty("file.separator") + callout + extn_;
|
||||
String scriptFile = DatabaseDescriptor.getCalloutLocation() + File.separator + callout + extn_;
|
||||
File file = new File(scriptFile);
|
||||
if ( file.exists() )
|
||||
{
|
||||
|
|
@ -179,7 +179,7 @@ public class CalloutManager
|
|||
{
|
||||
/* remove the script from cache */
|
||||
calloutCache_.remove(callout);
|
||||
String scriptFile = DatabaseDescriptor.getCalloutLocation() + System.getProperty("file.separator") + callout + ".grv";
|
||||
String scriptFile = DatabaseDescriptor.getCalloutLocation() + File.separator + callout + ".grv";
|
||||
File file = new File(scriptFile);
|
||||
file.delete();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1120,7 +1120,7 @@ public final class ColumnFamilyStore implements ColumnFamilyStoreMBean
|
|||
{
|
||||
if (target != null)
|
||||
{
|
||||
rangeFileLocation = rangeFileLocation + System.getProperty("file.separator") + "bootstrap";
|
||||
rangeFileLocation = rangeFileLocation + File.separator + "bootstrap";
|
||||
}
|
||||
FileUtils.createDirectory(rangeFileLocation);
|
||||
String fname = new File(rangeFileLocation, mergedFileName).getAbsolutePath();
|
||||
|
|
|
|||
|
|
@ -161,7 +161,7 @@ public class CommitLog
|
|||
*/
|
||||
private void setNextFileName()
|
||||
{
|
||||
logFile_ = DatabaseDescriptor.getLogFileLocation() + System.getProperty("file.separator") +
|
||||
logFile_ = DatabaseDescriptor.getLogFileLocation() + File.separator +
|
||||
"CommitLog-" + System.currentTimeMillis() + ".log";
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ public class OrderPreservingPartitioner implements IPartitioner
|
|||
// generate random token
|
||||
String chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
|
||||
Random r = new Random();
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
for (int j = 0; j < 16; j++) {
|
||||
buffer.append(chars.charAt(r.nextInt(chars.length())));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -146,16 +146,16 @@ public class Message implements java.io.Serializable
|
|||
|
||||
public String toString()
|
||||
{
|
||||
StringBuffer sbuf = new StringBuffer("");
|
||||
StringBuilder sbuf = new StringBuilder("");
|
||||
String separator = System.getProperty("line.separator");
|
||||
sbuf.append("ID:" + getMessageId());
|
||||
sbuf.append(separator);
|
||||
sbuf.append("FROM:" + getFrom());
|
||||
sbuf.append(separator);
|
||||
sbuf.append("TYPE:" + getMessageType());
|
||||
sbuf.append(separator);
|
||||
sbuf.append("VERB:" + getVerb());
|
||||
sbuf.append(separator);
|
||||
sbuf.append("ID:" + getMessageId())
|
||||
.append(separator)
|
||||
.append("FROM:" + getFrom())
|
||||
.append(separator)
|
||||
.append("TYPE:" + getMessageType())
|
||||
.append(separator)
|
||||
.append("VERB:" + getVerb())
|
||||
.append(separator);
|
||||
return sbuf.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,8 +43,8 @@ public class CassandraServer implements Cassandra.Iface
|
|||
{
|
||||
private static Logger logger = Logger.getLogger(CassandraServer.class);
|
||||
|
||||
private final static List<column_t> EMPTY_COLUMNS = Arrays.asList();
|
||||
private final static List<superColumn_t> EMPTY_SUPERCOLUMNS = Arrays.asList();
|
||||
private final static List<column_t> EMPTY_COLUMNS = Collections.emptyList();
|
||||
private final static List<superColumn_t> EMPTY_SUPERCOLUMNS = Collections.emptyList();
|
||||
|
||||
/*
|
||||
* Handle to the storage service to interact with the other machines in the
|
||||
|
|
@ -406,7 +406,7 @@ public class CassandraServer implements Cassandra.Iface
|
|||
String filename = DatabaseDescriptor.getConfigFileName();
|
||||
try
|
||||
{
|
||||
StringBuffer fileData = new StringBuffer(8192);
|
||||
StringBuilder fileData = new StringBuilder(8192);
|
||||
BufferedInputStream stream = new BufferedInputStream(new FileInputStream(filename));
|
||||
byte[] buf = new byte[1024];
|
||||
int numRead;
|
||||
|
|
|
|||
|
|
@ -18,10 +18,8 @@
|
|||
*/
|
||||
package org.apache.cassandra.service;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.cassandra.config.DatabaseDescriptor;
|
||||
import org.apache.cassandra.db.RangeCommand;
|
||||
import org.apache.cassandra.db.RangeReply;
|
||||
import org.apache.cassandra.db.Table;
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ public class ThreadListBuilder
|
|||
for ( int i = 0; i < size; ++i )
|
||||
{
|
||||
DataOutputBuffer buffer = buffers.get(i);
|
||||
String file = args[1] + System.getProperty("file.separator") + "Bloom-Filter-" + i + ".dat";
|
||||
String file = args[1] + File.separator + "Bloom-Filter-" + i + ".dat";
|
||||
RandomAccessFile raf = new RandomAccessFile(file, "rw");
|
||||
raf.write(buffer.getData(), 0, buffer.getLength());
|
||||
raf.close();
|
||||
|
|
|
|||
|
|
@ -74,12 +74,14 @@ public class FBUtilities
|
|||
{
|
||||
Throwable throwable = new Throwable();
|
||||
StackTraceElement[] ste = throwable.getStackTrace();
|
||||
StringBuffer sbuf = new StringBuffer();
|
||||
StringBuilder sbuf = new StringBuilder();
|
||||
|
||||
for ( int i = ste.length - 1; i > 0; --i )
|
||||
{
|
||||
sbuf.append(ste[i].getClassName() + "." + ste[i].getMethodName());
|
||||
sbuf.append("/");
|
||||
sbuf.append(ste[i].getClassName())
|
||||
.append(".")
|
||||
.append(ste[i].getMethodName())
|
||||
.append("/");
|
||||
}
|
||||
sbuf.deleteCharAt(sbuf.length() - 1);
|
||||
return sbuf.toString();
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ public class GuidGenerator {
|
|||
public static String guid() {
|
||||
byte[] array = guidAsBytes();
|
||||
|
||||
StringBuffer sb = new StringBuffer();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int j = 0; j < array.length; ++j) {
|
||||
int b = array[j] & 0xFF;
|
||||
if (b < 0x10) sb.append('0');
|
||||
|
|
@ -70,7 +70,7 @@ public class GuidGenerator {
|
|||
|
||||
public static String guidToString(byte[] bytes)
|
||||
{
|
||||
StringBuffer sb = new StringBuffer();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int j = 0; j < bytes.length; ++j) {
|
||||
int b = bytes[j] & 0xFF;
|
||||
if (b < 0x10) sb.append('0');
|
||||
|
|
@ -82,15 +82,15 @@ public class GuidGenerator {
|
|||
|
||||
public static byte[] guidAsBytes()
|
||||
{
|
||||
StringBuffer sbValueBeforeMD5 = new StringBuffer();
|
||||
StringBuilder sbValueBeforeMD5 = new StringBuilder();
|
||||
long time = System.currentTimeMillis();
|
||||
long rand = 0;
|
||||
rand = myRand.nextLong();
|
||||
sbValueBeforeMD5.append(s_id);
|
||||
sbValueBeforeMD5.append(":");
|
||||
sbValueBeforeMD5.append(Long.toString(time));
|
||||
sbValueBeforeMD5.append(":");
|
||||
sbValueBeforeMD5.append(Long.toString(rand));
|
||||
sbValueBeforeMD5.append(s_id)
|
||||
.append(":")
|
||||
.append(Long.toString(time))
|
||||
.append(":")
|
||||
.append(Long.toString(rand));
|
||||
|
||||
String valueBeforeMD5 = sbValueBeforeMD5.toString();
|
||||
return md5.digest(valueBeforeMD5.getBytes());
|
||||
|
|
@ -103,16 +103,16 @@ public class GuidGenerator {
|
|||
|
||||
private static String convertToStandardFormat(String valueAfterMD5) {
|
||||
String raw = valueAfterMD5.toUpperCase();
|
||||
StringBuffer sb = new StringBuffer();
|
||||
sb.append(raw.substring(0, 8));
|
||||
sb.append("-");
|
||||
sb.append(raw.substring(8, 12));
|
||||
sb.append("-");
|
||||
sb.append(raw.substring(12, 16));
|
||||
sb.append("-");
|
||||
sb.append(raw.substring(16, 20));
|
||||
sb.append("-");
|
||||
sb.append(raw.substring(20));
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(raw.substring(0, 8))
|
||||
.append("-")
|
||||
.append(raw.substring(8, 12))
|
||||
.append("-")
|
||||
.append(raw.substring(12, 16))
|
||||
.append("-")
|
||||
.append(raw.substring(16, 20))
|
||||
.append("-")
|
||||
.append(raw.substring(20));
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ public class LogUtil
|
|||
{
|
||||
//BasicConfigurator.configure();
|
||||
String file = System.getProperty("storage-config");
|
||||
file += System.getProperty("file.separator") + "log4j.properties";
|
||||
file += File.separator + "log4j.properties";
|
||||
PropertyConfigurator.configure(file);
|
||||
}
|
||||
|
||||
|
|
@ -62,23 +62,31 @@ public class LogUtil
|
|||
|
||||
public static String throwableToString(Throwable e)
|
||||
{
|
||||
StringBuffer sbuf = new StringBuffer("");
|
||||
StringBuilder sbuf = new StringBuilder("");
|
||||
String trace = stackTrace(e);
|
||||
sbuf.append((new StringBuilder()).append("Exception was generated at : ").append(getTimestamp()).append(" on thread ").append(Thread.currentThread().getName()).toString());
|
||||
sbuf.append((new StringBuilder())
|
||||
.append("Exception was generated at : ")
|
||||
.append(getTimestamp())
|
||||
.append(" on thread ")
|
||||
.append(Thread.currentThread().getName())
|
||||
.toString());
|
||||
sbuf.append(System.getProperty("line.separator"));
|
||||
String message = e.getMessage();
|
||||
if(message != null)
|
||||
sbuf.append(message);
|
||||
sbuf.append(System.getProperty("line.separator"));
|
||||
sbuf.append(trace);
|
||||
sbuf.append(System.getProperty("line.separator"))
|
||||
.append(trace);
|
||||
return sbuf.toString();
|
||||
}
|
||||
|
||||
public static String getLogMessage(String message)
|
||||
{
|
||||
StringBuffer sbuf = new StringBuffer((new StringBuilder()).append("Log started at : ").append(getTimestamp()).toString());
|
||||
sbuf.append(System.getProperty("line.separator"));
|
||||
sbuf.append(message);
|
||||
StringBuilder sbuf = new StringBuilder((new StringBuilder())
|
||||
.append("Log started at : ")
|
||||
.append(getTimestamp())
|
||||
.toString());
|
||||
sbuf.append(File.separator)
|
||||
.append(message);
|
||||
return sbuf.toString();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ import java.util.Random;
|
|||
|
||||
public class KeyGenerator {
|
||||
private static String randomKey(Random r) {
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
for (int j = 0; j < 16; j++) {
|
||||
buffer.append((char)r.nextInt());
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue