Skip to content

Commit

Permalink
HDDS-11463. Fix CheckStyle.
Browse files Browse the repository at this point in the history
  • Loading branch information
fanshilun committed Nov 6, 2024
1 parent 9991e30 commit a83a8f7
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -256,9 +256,9 @@ public static StorageLocationReport getFromProtobuf(StorageReportProto report)
builder.setFailed(report.getFailed());
}

/*if (report.hasFailureDate()) {
builder.setFailureDate(report.getFailureDate());
}*/
if (report.hasFailureTime()) {
builder.setFailureTime(report.getFailureTime());
}

return builder.build();
}
Expand Down Expand Up @@ -292,7 +292,7 @@ public static StorageLocationReport getMetadataFromProtobuf(
}

if (report.hasFailureDate()) {
builder.setFailureDate(report.getFailureDate());
builder.setFailureTime(report.getFailureDate());
}

return builder.build();
Expand Down Expand Up @@ -320,7 +320,7 @@ public static class Builder {
private long freeSpaceToSpare;
private StorageType storageType;
private String storageLocation;
private long failureDate;
private long failureTime;

/**
* Sets the storageId.
Expand Down Expand Up @@ -424,11 +424,11 @@ public Builder setStorageLocation(String storageLocationValue) {
/**
* Sets the lastVolumeFailureDate.
*
* @param failureDate The last failure time of the disk.
* @param failureTime The last failure time of the disk.
* @return StorageLocationReport.Builder
*/
public Builder setFailureDate(long failureDate) {
this.failureDate = failureDate;
public Builder setFailureTime(long failureTime) {
this.failureTime = failureTime;
return this;
}

Expand All @@ -439,7 +439,7 @@ public Builder setFailureDate(long failureDate) {
*/
public StorageLocationReport build() {
return new StorageLocationReport(id, failed, capacity, scmUsed,
remaining, committed, freeSpaceToSpare, storageType, storageLocation, failureDate);
remaining, committed, freeSpaceToSpare, storageType, storageLocation, failureTime);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.apache.hadoop.util.Time;

import java.io.IOException;
import java.time.Instant;

/**
* A factory class for DbVolume.
Expand Down Expand Up @@ -57,7 +58,7 @@ StorageVolume createFailedVolume(String locationString) throws IOException {
DbVolume.Builder volumeBuilder =
new DbVolume.Builder(locationString)
.failedVolume(true)
.failureDate(Time.now());
.failureTime(Instant.now());
return volumeBuilder.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.apache.hadoop.util.Time;

import java.io.IOException;
import java.time.Instant;

/**
* A factory class for HddsVolume.
Expand Down Expand Up @@ -58,7 +59,7 @@ public StorageVolume createFailedVolume(String locationString)
throws IOException {
HddsVolume.Builder volumeBuilder = new HddsVolume.Builder(locationString)
.failedVolume(true)
.failureDate(Time.now());
.failureTime(Instant.now());
return volumeBuilder.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.apache.hadoop.util.Time;

import java.io.IOException;
import java.time.Instant;

/**
* A factory class for MetadataVolume.
Expand Down Expand Up @@ -52,7 +53,7 @@ StorageVolume createFailedVolume(String locationString) throws IOException {
MetadataVolume.Builder volumeBuilder =
new MetadataVolume.Builder(locationString)
.failedVolume(true)
.failureDate(Time.now());
.failureTime(Instant.now());
return volumeBuilder.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ public void removeVolume(String volumeRoot) throws IOException {
LOG.info("Removed Volume : {} from VolumeSet", volumeRoot);
} else if (failedVolumeMap.containsKey(volumeRoot)) {
StorageVolume storageVolume = failedVolumeMap.get(volumeRoot);
storageVolume.resetFailureDate();
storageVolume.resetFailureTime();
failedVolumeMap.remove(volumeRoot);
LOG.info("Removed Volume : {} from failed VolumeSet", volumeRoot);
} else {
Expand Down Expand Up @@ -517,7 +517,7 @@ public StorageLocationReport[] getStorageReport() {
builder.setStorageLocation(volume.getStorageDir()
.getAbsolutePath()).setId(volume.getStorageID()).setFailed(true)
.setCapacity(0).setRemaining(0).setScmUsed(0).setStorageType(
volume.getStorageType()).setFailureDate(volume.getFailureDate());
volume.getStorageType()).setFailureTime(volume.getFailureTime().toEpochMilli());
StorageLocationReport r = builder.build();
reports[counter++] = r;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.time.Instant;
import java.util.LinkedList;
import java.util.Objects;
import java.util.Optional;
Expand Down Expand Up @@ -139,7 +140,7 @@ public enum VolumeState {
private AtomicInteger currentIOFailureCount;
private Queue<Boolean> ioTestSlidingWindow;
private int healthCheckFileSize;
private long failureDate = 0;
private Instant failureTime = Instant.MIN;

protected StorageVolume(Builder<?> b) throws IOException {
if (!b.failedVolume) {
Expand Down Expand Up @@ -383,7 +384,7 @@ public abstract static class Builder<T extends Builder<T>> {
private boolean failedVolume = false;
private String datanodeUuid;
private String clusterID;
private long failureDate;
private Instant failureTime;

public Builder(String volumeRootStr, String storageDirStr) {
this.volumeRootStr = volumeRootStr;
Expand Down Expand Up @@ -430,8 +431,8 @@ public T clusterID(String cid) {
return this.getThis();
}

public T failureDate(long volFailureDate) {
this.failureDate = volFailureDate;
public T failureTime(Instant volFailureTime) {
this.failureTime = volFailureTime;
return this.getThis();
}

Expand All @@ -449,8 +450,8 @@ public StorageType getStorageType() {
return this.storageType;
}

public long getFailureDate() {
return failureDate;
public Instant getFailureTime() {
return failureTime;
}
}

Expand Down Expand Up @@ -521,8 +522,8 @@ public StorageType getStorageType() {
.orElse(StorageType.DEFAULT);
}

public long getFailureDate() {
return failureDate;
public Instant getFailureTime() {
return failureTime;
}

public String getStorageID() {
Expand Down Expand Up @@ -553,12 +554,12 @@ public void setState(VolumeState state) {
this.state = state;
}

public void setFailureDate(long failureDate) {
this.failureDate = failureDate;
public void setFailureTime(Instant failureTime) {
this.failureTime = failureTime;
}

public void resetFailureDate() {
this.failureDate = 0;
public void resetFailureTime() {
this.failureTime = Instant.MIN;
}

public boolean isFailed() {
Expand All @@ -573,8 +574,8 @@ public void failVolume() {
setState(VolumeState.FAILED);
// Ensure it is set only once,
// which is the time when the failure was first detected.
if (failureDate == 0L) {
setFailureDate(Time.now());
if (failureTime == Instant.MIN) {
setFailureTime(Instant.now());
}
volumeInfo.ifPresent(VolumeInfo::shutdownUsageThread);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -406,9 +406,9 @@ public boolean equals(Object obj) {
}

/**
* Retrieve the list of failed disks.
* Get all volume information.
*
* @return list of failed disks.
* @return VolumeInfo List.
*/
public List<VolumeInfoProto> getVolumeInfos() {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1573,6 +1573,7 @@ public GetVolumeInfosResponseProto getVolumeInfos(String displayMode, String uui
break;
}

// Perform memory paging.
MemoryPageUtils<VolumeInfoProto> memoryPageUtils = new MemoryPageUtils<>(pageSize);
volumeInfos.forEach(volumeInfo -> memoryPageUtils.addToMemory(volumeInfo));
int pages = memoryPageUtils.getPages();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,6 @@ public void execute(ScmClient client) throws IOException {
return;
}



System.out.printf("Datanode Volume Failures (%d Volumes)%n%n", volumeInfos.size());
volumeInfos.forEach(this::printInfo);
}
Expand Down

0 comments on commit a83a8f7

Please sign in to comment.