Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions dev-support/pmd/pmd-ruleset.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
<rule ref="category/java/performance.xml/AddEmptyString"/>
<rule ref="category/java/performance.xml/AppendCharacterWithChar" />
<rule ref="category/java/performance.xml/AvoidFileStream"/>
<rule ref="category/java/performance.xml/ConsecutiveAppendsShouldReuse"/>
<rule ref="category/java/performance.xml/InefficientEmptyStringCheck"/>
<rule ref="category/java/performance.xml/InefficientStringBuffering"/>
<rule ref="category/java/performance.xml/StringInstantiation"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ public String toString() {

public void appendTo(StringBuilder sb) {
containerBlockID.appendTo(sb);
sb.append(" bcsId: ").append(blockCommitSequenceId);
sb.append(" replicaIndex: ").append(replicaIndex);
sb.append(" bcsId: ").append(blockCommitSequenceId)
.append(" replicaIndex: ").append(replicaIndex);
}

@JsonIgnore
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -538,20 +538,19 @@ public int hashCode() {
@Override
public String toString() {
final StringBuilder b =
new StringBuilder(getClass().getSimpleName()).append('{');
b.append(" Id: ").append(id.getId());
b.append(", Nodes: [");
new StringBuilder(getClass().getSimpleName()).append('{')
.append(" Id: ").append(id.getId())
.append(", Nodes: [");
for (DatanodeDetails datanodeDetails : nodeStatus.keySet()) {
b.append(" {").append(datanodeDetails);
b.append(", ReplicaIndex: ").append(this.getReplicaIndex(datanodeDetails)).append("},");
}
b.append(']');
b.append(", ReplicationConfig: ").append(replicationConfig);
b.append(", State:").append(getPipelineState());
b.append(", leaderId:").append(leaderId != null ? leaderId.toString() : "");
b.append(", CreationTimestamp").append(getCreationTimestamp()
.atZone(ZoneId.systemDefault()));
b.append('}');
b.append(" {").append(datanodeDetails)
.append(", ReplicaIndex: ").append(this.getReplicaIndex(datanodeDetails)).append("},");
}
b.append(']')
.append(", ReplicationConfig: ").append(replicationConfig)
.append(", State:").append(getPipelineState())
.append(", leaderId:").append(leaderId != null ? leaderId.toString() : "")
.append(", CreationTimestamp").append(getCreationTimestamp().atZone(ZoneId.systemDefault()))
.append('}');
return b.toString();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,8 +299,8 @@ public String toString() {
public void appendTo(StringBuilder sb) {
sb.append("[blockId=");
blockID.appendTo(sb);
sb.append(", size=").append(size);
sb.append(']');
sb.append(", size=").append(size)
.append(']');
}

public long getBlockGroupLength() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1330,13 +1330,13 @@ public static String smProtoToString(RaftGroupId gid,

if (containerController != null) {
String location = containerController.getContainerLocation(contId);
builder.append(", container path=");
builder.append(location);
builder.append(", container path=")
.append(location);
}
} catch (Exception t) {
LOG.info("smProtoToString failed", t);
builder.append("smProtoToString failed with ");
builder.append(t.getMessage());
builder.append("smProtoToString failed with ")
.append(t.getMessage());
}
return builder.toString();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,13 +157,13 @@ public ReplicationCommandPriority getPriority() {
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(getType());
sb.append(": cmdID: ").append(getId())
sb.append(getType())
.append(": cmdID: ").append(getId())
.append(", encodedToken: \"").append(getEncodedToken()).append('"')
.append(", term: ").append(getTerm())
.append(", deadlineMsSinceEpoch: ").append(getDeadline());
sb.append(", containerId=").append(getContainerID());
sb.append(", replicaIndex=").append(getReplicaIndex());
.append(", deadlineMsSinceEpoch: ").append(getDeadline())
.append(", containerId=").append(getContainerID())
.append(", replicaIndex=").append(getReplicaIndex());
if (targetDatanode != null) {
sb.append(", targetNode=").append(targetDatanode);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,8 @@ private String generateVolumeLocation(String base, int volumeCount) {

StringBuilder sb = new StringBuilder();
for (int i = 0; i < volumeCount; i++) {
sb.append(base).append("/vol").append(i);
sb.append(',');
sb.append(base).append("/vol").append(i)
.append(',');
}
return sb.substring(0, sb.length() - 1);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -480,19 +480,16 @@ protected byte[][] toArrays(ECChunk[] chunks) {
protected void dumpSetting() {
if (allowDump) {
StringBuilder sb = new StringBuilder("Erasure coder test settings:\n");
sb.append(" numDataUnits=").append(numDataUnits);
sb.append(" numParityUnits=").append(numParityUnits);
sb.append(" chunkSize=").append(chunkSize).append('\n');

sb.append(" erasedDataIndexes=").
append(Arrays.toString(erasedDataIndexes));
sb.append(" erasedParityIndexes=").
append(Arrays.toString(erasedParityIndexes));
sb.append(" usingDirectBuffer=").append(usingDirectBuffer);
sb.append(" allowVerboseDump=").append(allowDump);
sb.append('\n');

System.out.println(sb.toString());
sb.append(" numDataUnits=").append(numDataUnits)
.append(" numParityUnits=").append(numParityUnits)
.append(" chunkSize=").append(chunkSize).append('\n')
.append(" erasedDataIndexes=").append(Arrays.toString(erasedDataIndexes))
.append(" erasedParityIndexes=").append(Arrays.toString(erasedParityIndexes))
.append(" usingDirectBuffer=").append(usingDirectBuffer)
.append(" allowVerboseDump=").append(allowDump)
.append('\n');

System.out.println(sb);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -891,20 +891,20 @@ private int getAvailableNodesCount(String scope, List<String> excludedScopes,
public String toString() {
// print max level
StringBuilder tree = new StringBuilder();
tree.append("Level: ");
tree.append(maxLevel);
tree.append('\n');
tree.append("Level: ")
.append(maxLevel)
.append('\n');
netlock.readLock().lock();
try {
// print the number of leaves
int numOfLeaves = clusterTree.getNumOfLeaves();
tree.append("Number of leaves:");
tree.append(numOfLeaves);
tree.append('\n');
tree.append("Number of leaves:")
.append(numOfLeaves)
.append('\n');
// print all nodes
for (int i = 0; i < numOfLeaves; i++) {
tree.append(clusterTree.getLeaf(i).getNetworkFullPath());
tree.append('\n');
tree.append(clusterTree.getLeaf(i).getNetworkFullPath())
.append('\n');
}
} finally {
netlock.readLock().unlock();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ public long getReplicatedSize() {
@Override
public String toString() {
StringBuilder sb = new StringBuilder(64);
sb.append(" localID: ").append(blockID.getContainerBlockID().getLocalID());
sb.append(" containerID: ").append(blockID.getContainerBlockID().getContainerID());
sb.append(" size: ").append(size);
sb.append(" replicatedSize: ").append(replicatedSize);
sb.append(" localID: ").append(blockID.getContainerBlockID().getLocalID())
.append(" containerID: ").append(blockID.getContainerBlockID().getContainerID())
.append(" size: ").append(size)
.append(" replicatedSize: ").append(replicatedSize);
return sb.toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,8 @@ public static String smProtoToString(StateMachineLogEntryProto proto) {
SCMRatisRequestProto.parseFrom(proto.getLogData().asReadOnlyByteBuffer())));
} catch (Throwable ex) {
LOG.error("smProtoToString failed", ex);
builder.append("smProtoToString failed with");
builder.append(ex.getMessage());
builder.append("smProtoToString failed with")
.append(ex.getMessage());
}
return builder.toString();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -497,11 +497,11 @@ public Map<String, List<ContainerID>> getContainersPendingReplication(DatanodeDe

private String replicaDetails(Collection<ContainerReplica> replicas) {
StringBuilder sb = new StringBuilder();
sb.append("Replicas{");
sb.append(replicas.stream()
.map(Object::toString)
.collect(Collectors.joining(",")));
sb.append('}');
sb.append("Replicas{")
.append(replicas.stream()
.map(Object::toString)
.collect(Collectors.joining(",")))
.append('}');
return sb.toString();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -388,8 +388,8 @@ public List<ContainerWithPipeline> getContainerWithPipelineBatch(
try {
ContainerWithPipeline cp = getContainerWithPipelineCommon(containerID);
cpList.add(cp);
strContainerIDs.append(ContainerID.valueOf(containerID).toString());
strContainerIDs.append(',');
strContainerIDs.append(ContainerID.valueOf(containerID).toString())
.append(',');
} catch (IOException ex) {
AUDIT.logReadFailure(buildAuditMessageForFailure(
SCMAction.GET_CONTAINER_WITH_PIPELINE_BATCH,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,12 +280,12 @@ private String constructCommandAuditMap(List<SCMCommandProto> cmds) {
auditMap.append('[');
for (SCMCommandProto cmd : cmds) {
if (cmd.getCommandType().equals(deleteBlocksCommand)) {
auditMap.append("commandType: ").append(cmd.getCommandType());
auditMap.append(" deleteTransactionsCount: ")
.append(cmd.getDeleteBlocksCommandProto().getDeletedBlocksTransactionsCount());
auditMap.append(" cmdID: ").append(cmd.getDeleteBlocksCommandProto().getCmdId());
auditMap.append(" encodedToken: \"").append(cmd.getEncodedToken()).append('"');
auditMap.append(" deadlineMsSinceEpoch: ").append(cmd.getDeadlineMsSinceEpoch());
auditMap.append("commandType: ").append(cmd.getCommandType())
.append(" deleteTransactionsCount: ")
.append(cmd.getDeleteBlocksCommandProto().getDeletedBlocksTransactionsCount())
.append(" cmdID: ").append(cmd.getDeleteBlocksCommandProto().getCmdId())
.append(" encodedToken: \"").append(cmd.getEncodedToken()).append('"')
.append(" deadlineMsSinceEpoch: ").append(cmd.getDeadlineMsSinceEpoch());
} else {
auditMap.append(TextFormat.shortDebugString(cmd));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,9 +286,9 @@ public int getInvocationCount() {
public String toString() {
final StringBuilder sb = new StringBuilder(
"FixedRetryInterval{");
sb.append("interval=").append(intervalMillis);
sb.append(", invocationCount=").append(invocationCount);
sb.append('}');
sb.append("interval=").append(intervalMillis)
.append(", invocationCount=").append(invocationCount)
.append('}');
return sb.toString();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ private static String buildThreadDump() {
Thread.State.WAITING.equals(thread.getState()) ?
"WAITING (on object monitor)" : thread.getState()));
for (StackTraceElement stackTraceElement : e.getValue()) {
dump.append("\n at ");
dump.append(stackTraceElement);
dump.append("\n at ")
.append(stackTraceElement);
}
dump.append('\n');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,21 +100,21 @@ private String generateReport(List<DatanodeDiskBalancerInfoProto> protos) {
String dn = DiskBalancerSubCommandUtil.getDatanodeHostAndIp(p.getNode());

StringBuilder header = new StringBuilder();
header.append("Datanode: ").append(dn).append('\n');
header.append("Aggregate VolumeDataDensity: ").
append(p.getCurrentVolumeDensitySum()).append('\n');
header.append("Datanode: ").append(dn).append('\n')
.append("Aggregate VolumeDataDensity: ").append(p.getCurrentVolumeDensitySum())
.append('\n');

if (p.hasIdealUsage() && p.hasDiskBalancerConf()
&& p.getDiskBalancerConf().hasThreshold()) {
double idealUsage = p.getIdealUsage();
double threshold = p.getDiskBalancerConf().getThreshold();
double lt = idealUsage - threshold / 100.0;
double ut = idealUsage + threshold / 100.0;
header.append("IdealUsage: ").append(String.format("%.8f", idealUsage));
header.append(" | Threshold: ").append(threshold).append('%');
header.append(" | ThresholdRange: (").append(String.format("%.8f", lt));
header.append(", ").append(String.format("%.8f", ut)).append(')').append('\n').append('\n');
header.append("Volume Details:").append('\n');
header.append("IdealUsage: ").append(String.format("%.8f", idealUsage))
.append(" | Threshold: ").append(threshold).append('%')
.append(" | ThresholdRange: (").append(String.format("%.8f", lt))
.append(", ").append(String.format("%.8f", ut)).append(')').append('\n').append('\n')
.append("Volume Details:").append('\n');
}
formatBuilder.append("%s%n");
contentList.add(header.toString());
Expand Down Expand Up @@ -150,21 +150,20 @@ private String generateReport(List<DatanodeDiskBalancerInfoProto> protos) {
}
}

formatBuilder.append("%nNote:%n");
formatBuilder.append(" - Aggregate VolumeDataDensity: Sum of per-volume density" +
" (deviation from ideal); higher means more imbalance.%n");
formatBuilder.append(" - IdealUsage: Target utilization ratio (0-1) when volumes" +
" are evenly balanced.%n");
formatBuilder.append(" - ThresholdRange: Acceptable deviation (percent); volumes within" +
" IdealUsage +/- Threshold are considered balanced.%n");
formatBuilder.append(" - VolumeDensity: Deviation of a particular volume's utilization from IdealUsage.%n");
formatBuilder.append(" - Utilization: Ratio of actual used space to capacity (0-1) for a particular volume.%n");
formatBuilder.append(" - TotalCapacity: Total volume capacity.%n");
formatBuilder.append(" - UsedSpace: Ozone used space.%n");
formatBuilder.append(" - Container Pre-AllocatedSpace: Space reserved for containers not yet written to disk.%n");
formatBuilder.append(" - EffectiveUsedSpace: This is the actual used space of volume which is visible" +
" to the diskBalancer : (ozoneCapacity minus ozoneAvailable) + containerPreAllocatedSpace + " +
"move delta for source volume.%n");
formatBuilder.append("%nNote:%n")
.append(" - Aggregate VolumeDataDensity: Sum of per-volume density (deviation from ideal);")
.append(" higher means more imbalance.%n")
.append(" - IdealUsage: Target utilization ratio (0-1) when volumes are evenly balanced.%n")
.append(" - ThresholdRange: Acceptable deviation (percent); volumes within")
.append(" IdealUsage +/- Threshold are considered balanced.%n")
.append(" - VolumeDensity: Deviation of a particular volume's utilization from IdealUsage.%n")
.append(" - Utilization: Ratio of actual used space to capacity (0-1) for a particular volume.%n")
.append(" - TotalCapacity: Total volume capacity.%n")
.append(" - UsedSpace: Ozone used space.%n")
.append(" - Container Pre-AllocatedSpace: Space reserved for containers not yet written to disk.%n")
.append(" - EffectiveUsedSpace: This is the actual used space of volume which is visible")
.append(" to the diskBalancer : (ozoneCapacity minus ozoneAvailable) + containerPreAllocatedSpace + ")
.append("move delta for source volume.%n");

return String.format(formatBuilder.toString(), contentList.toArray(new String[0]));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,11 @@ private String generateStatus(List<DatanodeDiskBalancerInfoProto> protos) {
contentList.add(estimatedTimeLeft >= 0 ? String.valueOf(estimatedTimeLeft) : "N/A");
}

formatBuilder.append("%nNote:%n");
formatBuilder.append(" - EstBytesToMove is calculated based on the target disk even state" +
" with the configured threshold.%n");
formatBuilder.append(" - EstTimeLeft is calculated based on EstimatedBytesToMove and configured" +
" disk bandwidth.%n");
formatBuilder.append(" - Both EstimatedBytes and EstTimeLeft could be non-zero while no containers" +
" can be moved, especially when the configured threshold or disk capacity is too small.");
formatBuilder.append("%nNote:%n")
.append(" - EstBytesToMove is calculated based on the target disk even state with the configured threshold.%n")
.append(" - EstTimeLeft is calculated based on EstimatedBytesToMove and configured disk bandwidth.%n")
.append(" - Both EstimatedBytes and EstTimeLeft could be non-zero while no containers" +
" can be moved, especially when the configured threshold or disk capacity is too small.");

return String.format(formatBuilder.toString(),
contentList.toArray(new String[0]));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,8 @@ private void printOpenKeysList(ListOpenFilesResult res) {
private String getMessageString(ListOpenFilesResult res, List<OpenKeySession> openFileList) {
StringBuilder sb = new StringBuilder();
sb.append(res.getTotalOpenKeyCount())
.append(" total open files. Showing ");
sb.append(openFileList.size())
.append(" total open files. Showing ")
.append(openFileList.size())
.append(" open files (limit ")
.append(limit)
.append(") under path prefix:\n ")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,8 @@ private static String executeStatement(String dbName, String sql)
int cols = rsm.getColumnCount();
while (rs.next()) {
for (int index = 1; index <= cols; index++) {
result.append(rs.getObject(index));
result.append('\t');
result.append(rs.getObject(index))
.append('\t');
}
result.append('\n');
}
Expand Down
Loading