HBASE-19448 Replace StringBuffer with StringBuilder for hbase-server

Signed-off-by: Chia-Ping Tsai <chia7712@gmail.com>
This commit is contained in:
BELUGA BEHR 2017-12-07 22:35:13 +08:00 committed by Chia-Ping Tsai
parent f90420b3a5
commit 638433358b
12 changed files with 14 additions and 14 deletions

View File

@ -621,7 +621,7 @@ public class FavoredNodeAssignmentHelper {
}
public static String getFavoredNodesAsString(List<ServerName> nodes) {
StringBuffer strBuf = new StringBuffer();
StringBuilder strBuf = new StringBuilder();
int i = 0;
for (ServerName node : nodes) {
strBuf.append(node.getHostAndPort());

View File

@ -755,7 +755,7 @@ public class BucketCache implements BlockCache, HeapSize {
freeInProgress = true;
long bytesToFreeWithoutExtra = 0;
// Calculate free byte for each bucketSizeinfo
StringBuffer msgBuffer = LOG.isDebugEnabled()? new StringBuffer(): null;
StringBuilder msgBuffer = LOG.isDebugEnabled()? new StringBuilder(): null;
BucketAllocator.IndexStatistics[] stats = bucketAllocator.getIndexStatistics();
long[] bytesToFreeForBucket = new long[stats.length];
for (int i = 0; i < stats.length; i++) {

View File

@ -49,7 +49,7 @@ public class RpcServerFactory {
RpcScheduler scheduler) throws IOException {
String rpcServerClass = conf.get(CUSTOM_RPC_SERVER_IMPL_CONF_KEY,
NettyRpcServer.class.getName());
StringBuffer servicesList = new StringBuffer();
StringBuilder servicesList = new StringBuilder();
for (BlockingServiceAndInterface s: services) {
ServiceDescriptor sd = s.getBlockingService().getDescriptorForType();
if (sd == null) continue; // Can be null for certain tests like TestTokenAuthentication

View File

@ -176,7 +176,7 @@ public abstract class AbstractMemStore implements MemStore {
@Override
public String toString() {
StringBuffer buf = new StringBuffer();
StringBuilder buf = new StringBuilder();
int i = 1;
try {
for (Segment segment : getSegments()) {

View File

@ -166,7 +166,7 @@ public class CompactSplit implements CompactionRequester, PropagatingConfigurati
}
public String dumpQueue() {
StringBuffer queueLists = new StringBuffer();
StringBuilder queueLists = new StringBuilder();
queueLists.append("Compaction/Split Queue dump:\n");
queueLists.append(" LargeCompation Queue:\n");
BlockingQueue<Runnable> lq = longCompactions.getQueue();

View File

@ -2266,7 +2266,7 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver, Regi
/**
* Should the memstore be flushed now
*/
boolean shouldFlush(final StringBuffer whyFlush) {
boolean shouldFlush(final StringBuilder whyFlush) {
whyFlush.setLength(0);
// This is a rough measure.
if (this.maxFlushedSeqId > 0
@ -8299,7 +8299,7 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver, Regi
//// method for debugging tests
void throwException(String title, String regionName) {
StringBuffer buf = new StringBuffer();
StringBuilder buf = new StringBuilder();
buf.append(title + ", ");
buf.append(getRegionInfo().toString());
buf.append(getRegionInfo().isMetaRegion() ? " meta region " : " ");

View File

@ -1753,7 +1753,7 @@ public class HRegionServer extends HasThread implements
@Override
protected void chore() {
final StringBuffer whyFlush = new StringBuffer();
final StringBuilder whyFlush = new StringBuilder();
for (HRegion r : this.server.onlineRegions.values()) {
if (r == null) continue;
if (r.shouldFlush(whyFlush)) {

View File

@ -835,7 +835,7 @@ public class ReplicationSourceManager implements ReplicationListener {
* Get a string representation of all the sources' metrics
*/
public String getStats() {
StringBuffer stats = new StringBuffer();
StringBuilder stats = new StringBuilder();
for (ReplicationSourceInterface source : sources) {
stats.append("Normal source for cluster " + source.getPeerId() + ": ");
stats.append(source.getStats() + "\n");

View File

@ -287,7 +287,7 @@ public class TestMasterOperationsForRegionReplicas {
}
private String printRegions(List<RegionInfo> regions) {
StringBuffer strBuf = new StringBuffer();
StringBuilder strBuf = new StringBuilder();
for (RegionInfo r : regions) {
strBuf.append(" ____ " + r.toString());
}

View File

@ -40,7 +40,7 @@ public class MobTestUtil {
protected static String generateRandomString(int demoLength) {
String base = "abcdefghijklmnopqrstuvwxyz";
Random random = new Random();
StringBuffer sb = new StringBuffer();
StringBuilder sb = new StringBuilder();
for (int i = 0; i < demoLength; i++) {
int number = random.nextInt(base.length());
sb.append(base.charAt(number));

View File

@ -928,7 +928,7 @@ public class TestDefaultMemStore {
p.add(KeyValueTestUtil.create("r", cf, "q", 100, "v"));
region.put(p);
edge.setCurrentTimeMillis(1234 + 100);
StringBuffer sb = new StringBuffer();
StringBuilder sb = new StringBuilder();
assertTrue(!region.shouldFlush(sb));
edge.setCurrentTimeMillis(1234 + 10000);
assertTrue(region.shouldFlush(sb) == expected);
@ -966,7 +966,7 @@ public class TestDefaultMemStore {
wFactory.getWAL(hri.getEncodedNameAsBytes(), hri.getTable().getNamespace()));
addRegionToMETA(meta, r);
edge.setCurrentTimeMillis(1234 + 100);
StringBuffer sb = new StringBuffer();
StringBuilder sb = new StringBuilder();
assertTrue(meta.shouldFlush(sb) == false);
edge.setCurrentTimeMillis(edge.currentTime() + HRegion.SYSTEM_CACHE_FLUSH_INTERVAL + 1);
assertTrue(meta.shouldFlush(sb) == true);

View File

@ -85,7 +85,7 @@ public class SecureTestUtil {
// the superuser list or security won't function properly. We expect the
// HBase service account(s) to have superuser privilege.
String currentUser = User.getCurrent().getName();
StringBuffer sb = new StringBuffer();
StringBuilder sb = new StringBuilder();
sb.append("admin,");
sb.append(currentUser);
// Assumes we won't ever have a minicluster with more than 5 slaves