Skip to content

Commit

Permalink
HDDS-10504. Remove unused VolumeInfo#configuredCapacity (apache#6363)
Browse files Browse the repository at this point in the history
(cherry picked from commit 0763985)
  • Loading branch information
adoroszlai authored and xichen01 committed Jul 18, 2024
1 parent ae38ec3 commit 03c658d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,6 @@ public final class VolumeInfo {
// Space usage calculator
private final VolumeUsage usage;

// Capacity configured. This is useful when we want to
// limit the visible capacity for tests. If negative, then we just
// query from the filesystem.
private long configuredCapacity;

private long reservedInBytes;

/**
Expand All @@ -115,7 +110,6 @@ public static class Builder {
private final String rootDir;
private SpaceUsageCheckFactory usageCheckFactory;
private StorageType storageType;
private long configuredCapacity;

public Builder(String root, ConfigurationSource config) {
this.rootDir = root;
Expand All @@ -127,11 +121,6 @@ public Builder storageType(StorageType st) {
return this;
}

public Builder configuredCapacity(long capacity) {
this.configuredCapacity = capacity;
return this;
}

public Builder usageCheckFactory(SpaceUsageCheckFactory factory) {
this.usageCheckFactory = factory;
return this;
Expand Down Expand Up @@ -206,9 +195,6 @@ private VolumeInfo(Builder b) throws IOException {
this.storageType = (b.storageType != null ?
b.storageType : StorageType.DEFAULT);

this.configuredCapacity = (b.configuredCapacity != 0 ?
b.configuredCapacity : -1);

SpaceUsageCheckFactory usageCheckFactory = b.usageCheckFactory;
if (usageCheckFactory == null) {
usageCheckFactory = SpaceUsageCheckFactory.create(b.conf);
Expand All @@ -222,10 +208,7 @@ private VolumeInfo(Builder b) throws IOException {
}

public long getCapacity() {
if (configuredCapacity < 0) {
return Math.max(usage.getCapacity() - reservedInBytes, 0);
}
return configuredCapacity;
return Math.max(usage.getCapacity() - reservedInBytes, 0);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
* Class that wraps the space df of the Datanode Volumes used by SCM
* containers.
*/
public class VolumeUsage implements SpaceUsageSource {
public class VolumeUsage {

private final CachingSpaceUsageSource source;
private boolean shutdownComplete;
Expand All @@ -47,7 +47,6 @@ public class VolumeUsage implements SpaceUsageSource {
start(); // TODO should start only on demand
}

@Override
public long getCapacity() {
return Math.max(source.getCapacity(), 0);
}
Expand All @@ -60,7 +59,6 @@ public long getCapacity() {
* remainingReserved
* B) avail = fsAvail - Max(reserved - other, 0);
*/
@Override
public long getAvailable() {
return source.getAvailable() - getRemainingReserved();
}
Expand All @@ -70,12 +68,10 @@ public long getAvailable(SpaceUsageSource precomputedVolumeSpace) {
return available - getRemainingReserved(precomputedVolumeSpace);
}

@Override
public long getUsedSpace() {
return source.getUsedSpace();
}

@Override
public SpaceUsageSource snapshot() {
return source.snapshot();
}
Expand Down

0 comments on commit 03c658d

Please sign in to comment.