HBASE-19448 Replace StringBuffer with StringBuilder for hbase-server
Signed-off-by: Chia-Ping Tsai <chia7712@gmail.com>
This commit is contained in:
parent
8dc82165f3
commit
c3743be05c
|
@ -621,7 +621,7 @@ public class FavoredNodeAssignmentHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getFavoredNodesAsString(List<ServerName> nodes) {
|
public static String getFavoredNodesAsString(List<ServerName> nodes) {
|
||||||
StringBuffer strBuf = new StringBuffer();
|
StringBuilder strBuf = new StringBuilder();
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (ServerName node : nodes) {
|
for (ServerName node : nodes) {
|
||||||
strBuf.append(node.getHostAndPort());
|
strBuf.append(node.getHostAndPort());
|
||||||
|
|
|
@ -755,7 +755,7 @@ public class BucketCache implements BlockCache, HeapSize {
|
||||||
freeInProgress = true;
|
freeInProgress = true;
|
||||||
long bytesToFreeWithoutExtra = 0;
|
long bytesToFreeWithoutExtra = 0;
|
||||||
// Calculate free byte for each bucketSizeinfo
|
// 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();
|
BucketAllocator.IndexStatistics[] stats = bucketAllocator.getIndexStatistics();
|
||||||
long[] bytesToFreeForBucket = new long[stats.length];
|
long[] bytesToFreeForBucket = new long[stats.length];
|
||||||
for (int i = 0; i < stats.length; i++) {
|
for (int i = 0; i < stats.length; i++) {
|
||||||
|
|
|
@ -49,7 +49,7 @@ public class RpcServerFactory {
|
||||||
RpcScheduler scheduler) throws IOException {
|
RpcScheduler scheduler) throws IOException {
|
||||||
String rpcServerClass = conf.get(CUSTOM_RPC_SERVER_IMPL_CONF_KEY,
|
String rpcServerClass = conf.get(CUSTOM_RPC_SERVER_IMPL_CONF_KEY,
|
||||||
NettyRpcServer.class.getName());
|
NettyRpcServer.class.getName());
|
||||||
StringBuffer servicesList = new StringBuffer();
|
StringBuilder servicesList = new StringBuilder();
|
||||||
for (BlockingServiceAndInterface s: services) {
|
for (BlockingServiceAndInterface s: services) {
|
||||||
ServiceDescriptor sd = s.getBlockingService().getDescriptorForType();
|
ServiceDescriptor sd = s.getBlockingService().getDescriptorForType();
|
||||||
if (sd == null) continue; // Can be null for certain tests like TestTokenAuthentication
|
if (sd == null) continue; // Can be null for certain tests like TestTokenAuthentication
|
||||||
|
|
|
@ -176,7 +176,7 @@ public abstract class AbstractMemStore implements MemStore {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
StringBuffer buf = new StringBuffer();
|
StringBuilder buf = new StringBuilder();
|
||||||
int i = 1;
|
int i = 1;
|
||||||
try {
|
try {
|
||||||
for (Segment segment : getSegments()) {
|
for (Segment segment : getSegments()) {
|
||||||
|
|
|
@ -166,7 +166,7 @@ public class CompactSplit implements CompactionRequester, PropagatingConfigurati
|
||||||
}
|
}
|
||||||
|
|
||||||
public String dumpQueue() {
|
public String dumpQueue() {
|
||||||
StringBuffer queueLists = new StringBuffer();
|
StringBuilder queueLists = new StringBuilder();
|
||||||
queueLists.append("Compaction/Split Queue dump:\n");
|
queueLists.append("Compaction/Split Queue dump:\n");
|
||||||
queueLists.append(" LargeCompation Queue:\n");
|
queueLists.append(" LargeCompation Queue:\n");
|
||||||
BlockingQueue<Runnable> lq = longCompactions.getQueue();
|
BlockingQueue<Runnable> lq = longCompactions.getQueue();
|
||||||
|
|
|
@ -2266,7 +2266,7 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver, Regi
|
||||||
/**
|
/**
|
||||||
* Should the memstore be flushed now
|
* Should the memstore be flushed now
|
||||||
*/
|
*/
|
||||||
boolean shouldFlush(final StringBuffer whyFlush) {
|
boolean shouldFlush(final StringBuilder whyFlush) {
|
||||||
whyFlush.setLength(0);
|
whyFlush.setLength(0);
|
||||||
// This is a rough measure.
|
// This is a rough measure.
|
||||||
if (this.maxFlushedSeqId > 0
|
if (this.maxFlushedSeqId > 0
|
||||||
|
@ -8299,7 +8299,7 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver, Regi
|
||||||
|
|
||||||
//// method for debugging tests
|
//// method for debugging tests
|
||||||
void throwException(String title, String regionName) {
|
void throwException(String title, String regionName) {
|
||||||
StringBuffer buf = new StringBuffer();
|
StringBuilder buf = new StringBuilder();
|
||||||
buf.append(title + ", ");
|
buf.append(title + ", ");
|
||||||
buf.append(getRegionInfo().toString());
|
buf.append(getRegionInfo().toString());
|
||||||
buf.append(getRegionInfo().isMetaRegion() ? " meta region " : " ");
|
buf.append(getRegionInfo().isMetaRegion() ? " meta region " : " ");
|
||||||
|
|
|
@ -1753,7 +1753,7 @@ public class HRegionServer extends HasThread implements
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void chore() {
|
protected void chore() {
|
||||||
final StringBuffer whyFlush = new StringBuffer();
|
final StringBuilder whyFlush = new StringBuilder();
|
||||||
for (HRegion r : this.server.onlineRegions.values()) {
|
for (HRegion r : this.server.onlineRegions.values()) {
|
||||||
if (r == null) continue;
|
if (r == null) continue;
|
||||||
if (r.shouldFlush(whyFlush)) {
|
if (r.shouldFlush(whyFlush)) {
|
||||||
|
|
|
@ -835,7 +835,7 @@ public class ReplicationSourceManager implements ReplicationListener {
|
||||||
* Get a string representation of all the sources' metrics
|
* Get a string representation of all the sources' metrics
|
||||||
*/
|
*/
|
||||||
public String getStats() {
|
public String getStats() {
|
||||||
StringBuffer stats = new StringBuffer();
|
StringBuilder stats = new StringBuilder();
|
||||||
for (ReplicationSourceInterface source : sources) {
|
for (ReplicationSourceInterface source : sources) {
|
||||||
stats.append("Normal source for cluster " + source.getPeerId() + ": ");
|
stats.append("Normal source for cluster " + source.getPeerId() + ": ");
|
||||||
stats.append(source.getStats() + "\n");
|
stats.append(source.getStats() + "\n");
|
||||||
|
|
|
@ -287,7 +287,7 @@ public class TestMasterOperationsForRegionReplicas {
|
||||||
}
|
}
|
||||||
|
|
||||||
private String printRegions(List<RegionInfo> regions) {
|
private String printRegions(List<RegionInfo> regions) {
|
||||||
StringBuffer strBuf = new StringBuffer();
|
StringBuilder strBuf = new StringBuilder();
|
||||||
for (RegionInfo r : regions) {
|
for (RegionInfo r : regions) {
|
||||||
strBuf.append(" ____ " + r.toString());
|
strBuf.append(" ____ " + r.toString());
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,7 @@ public class MobTestUtil {
|
||||||
protected static String generateRandomString(int demoLength) {
|
protected static String generateRandomString(int demoLength) {
|
||||||
String base = "abcdefghijklmnopqrstuvwxyz";
|
String base = "abcdefghijklmnopqrstuvwxyz";
|
||||||
Random random = new Random();
|
Random random = new Random();
|
||||||
StringBuffer sb = new StringBuffer();
|
StringBuilder sb = new StringBuilder();
|
||||||
for (int i = 0; i < demoLength; i++) {
|
for (int i = 0; i < demoLength; i++) {
|
||||||
int number = random.nextInt(base.length());
|
int number = random.nextInt(base.length());
|
||||||
sb.append(base.charAt(number));
|
sb.append(base.charAt(number));
|
||||||
|
|
|
@ -928,7 +928,7 @@ public class TestDefaultMemStore {
|
||||||
p.add(KeyValueTestUtil.create("r", cf, "q", 100, "v"));
|
p.add(KeyValueTestUtil.create("r", cf, "q", 100, "v"));
|
||||||
region.put(p);
|
region.put(p);
|
||||||
edge.setCurrentTimeMillis(1234 + 100);
|
edge.setCurrentTimeMillis(1234 + 100);
|
||||||
StringBuffer sb = new StringBuffer();
|
StringBuilder sb = new StringBuilder();
|
||||||
assertTrue(!region.shouldFlush(sb));
|
assertTrue(!region.shouldFlush(sb));
|
||||||
edge.setCurrentTimeMillis(1234 + 10000);
|
edge.setCurrentTimeMillis(1234 + 10000);
|
||||||
assertTrue(region.shouldFlush(sb) == expected);
|
assertTrue(region.shouldFlush(sb) == expected);
|
||||||
|
@ -966,7 +966,7 @@ public class TestDefaultMemStore {
|
||||||
wFactory.getWAL(hri.getEncodedNameAsBytes(), hri.getTable().getNamespace()));
|
wFactory.getWAL(hri.getEncodedNameAsBytes(), hri.getTable().getNamespace()));
|
||||||
addRegionToMETA(meta, r);
|
addRegionToMETA(meta, r);
|
||||||
edge.setCurrentTimeMillis(1234 + 100);
|
edge.setCurrentTimeMillis(1234 + 100);
|
||||||
StringBuffer sb = new StringBuffer();
|
StringBuilder sb = new StringBuilder();
|
||||||
assertTrue(meta.shouldFlush(sb) == false);
|
assertTrue(meta.shouldFlush(sb) == false);
|
||||||
edge.setCurrentTimeMillis(edge.currentTime() + HRegion.SYSTEM_CACHE_FLUSH_INTERVAL + 1);
|
edge.setCurrentTimeMillis(edge.currentTime() + HRegion.SYSTEM_CACHE_FLUSH_INTERVAL + 1);
|
||||||
assertTrue(meta.shouldFlush(sb) == true);
|
assertTrue(meta.shouldFlush(sb) == true);
|
||||||
|
|
|
@ -85,7 +85,7 @@ public class SecureTestUtil {
|
||||||
// the superuser list or security won't function properly. We expect the
|
// the superuser list or security won't function properly. We expect the
|
||||||
// HBase service account(s) to have superuser privilege.
|
// HBase service account(s) to have superuser privilege.
|
||||||
String currentUser = User.getCurrent().getName();
|
String currentUser = User.getCurrent().getName();
|
||||||
StringBuffer sb = new StringBuffer();
|
StringBuilder sb = new StringBuilder();
|
||||||
sb.append("admin,");
|
sb.append("admin,");
|
||||||
sb.append(currentUser);
|
sb.append(currentUser);
|
||||||
// Assumes we won't ever have a minicluster with more than 5 slaves
|
// Assumes we won't ever have a minicluster with more than 5 slaves
|
||||||
|
|
Loading…
Reference in New Issue