-
Notifications
You must be signed in to change notification settings - Fork 0
<fix>[storage]: ZSTAC-86038 support typed storage resource stats #4548
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 5.5.28
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| package org.zstack.header.storage.addon; | ||
|
|
||
| public abstract class StorageResource { | ||
| protected String installPath; | ||
| protected Long size; | ||
| protected Long actualSize; | ||
| protected String parentUri; | ||
|
|
||
| public String getInstallPath() { | ||
| return installPath; | ||
| } | ||
|
|
||
| public void setInstallPath(String installPath) { | ||
| this.installPath = installPath; | ||
| } | ||
|
|
||
| public Long getSize() { | ||
| return size; | ||
| } | ||
|
|
||
| public void setSize(long size) { | ||
| this.size = size; | ||
| } | ||
|
|
||
| public Long getResourceActualSize() { | ||
| return actualSize; | ||
| } | ||
|
|
||
| public void setActualSize(Long actualSize) { | ||
| this.actualSize = actualSize; | ||
| } | ||
|
|
||
| public void setActualSize(long actualSize) { | ||
| this.actualSize = actualSize; | ||
| } | ||
|
|
||
| public String getParentUri() { | ||
| return parentUri; | ||
| } | ||
|
|
||
| public void setParentUri(String parentUri) { | ||
| this.parentUri = parentUri; | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,22 +1,9 @@ | ||
| package org.zstack.header.storage.snapshot; | ||
|
|
||
| public class VolumeSnapshotStats { | ||
| private String installPath; | ||
| private long actualSize; | ||
|
|
||
| public String getInstallPath() { | ||
| return installPath; | ||
| } | ||
|
|
||
| public void setInstallPath(String installPath) { | ||
| this.installPath = installPath; | ||
| } | ||
| import org.zstack.header.storage.addon.StorageResource; | ||
|
|
||
| public class VolumeSnapshotStats extends StorageResource { | ||
| public long getActualSize() { | ||
| return actualSize; | ||
| } | ||
|
|
||
| public void setActualSize(long actualSize) { | ||
| this.actualSize = actualSize; | ||
| return actualSize == null ? 0L : actualSize; | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -851,15 +851,31 @@ public void flattenVolume(String installPath, ReturnValueCompletion<VolumeStats> | |
| } | ||
|
|
||
| @Override | ||
| public void stats(String installPath, ReturnValueCompletion<VolumeStats> comp) { | ||
| public void stats(String installPath, ReturnValueCompletion<StorageResource> comp) { | ||
| if (installPath.contains("@")) { | ||
| VolumeSnapshotModule snapshot = apiHelper.getVolumeSnapshot(getSnapIdFromPath(installPath)); | ||
| VolumeSnapshotStats stats = new VolumeSnapshotStats(); | ||
| long size = SizeUnit.MEGABYTE.toByte(snapshot.getSpec().getSizeMb()); | ||
| stats.setInstallPath(installPath); | ||
| stats.setSize(size); | ||
| stats.setActualSize(size); | ||
| stats.setParentUri(getParentUri(apiHelper.getVolume(snapshot.getSpec().getBsVolumeId()))); | ||
| comp.success(stats); | ||
| return; | ||
| } | ||
|
|
||
| comp.success(getVolumeStats(installPath)); | ||
| } | ||
|
Comment on lines
+854
to
+868
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
rg -n 'class VolumeSnapshotModule|class VolumeSnapshotSpec' plugin/xinfini/src/main/java/org/zstack/xinfini
rg -n 'getDataSize|getAllocatedSize|DataSize' plugin/xinfini/src/main/java/org/zstack/xinfiniRepository: MatheMatrix/zstack Length of output: 1490 🏁 Script executed: #!/bin/bash
set -euo pipefail
# Inspect the relevant methods and surrounding context
sed -n '840,900p' plugin/xinfini/src/main/java/org/zstack/xinfini/XInfiniStorageController.java
echo '--- getParentUri / buildXInfiniPath / getParentChain ---'
rg -n 'getParentUri\\(|buildXInfiniPath\\(|getParentChain\\(' plugin/xinfini/src/main/java/org/zstack/xinfini -A 12 -B 6
echo '--- VolumeSnapshotModule / VolumeSnapshotSpec ---'
sed -n '1,180p' plugin/xinfini/src/main/java/org/zstack/xinfini/sdk/volume/VolumeSnapshotModule.javaRepository: MatheMatrix/zstack Length of output: 3134 🏁 Script executed: #!/bin/bash
set -euo pipefail
rg -n 'buildXInfiniSnapshotPath|getParentChain|parentUri' plugin/xinfini/src/main/java/org/zstack/xinfini -A 6 -B 6
echo '--- VolumeSnapshotStats definition ---'
sed -n '1,220p' plugin/xinfini/src/main/java/org/zstack/xinfini/sdk/volume/VolumeSnapshotStats.javaRepository: MatheMatrix/zstack Length of output: 5606 🏁 Script executed: #!/bin/bash
set -euo pipefail
# Find every consumer of parentUri and the stats classes involved.
rg -n 'getParentUri\\(|setParentUri\\(|parentUri' plugin/xinfini/src/main/java -A 4 -B 4
echo '--- stats interfaces / models ---'
rg -n 'class .*Stats|interface .*Stats|extends .*Stats|implements .*Stats' plugin/xinfini/src/main/java/org/zstack/xinfini -A 3 -B 3Repository: MatheMatrix/zstack Length of output: 279 快照统计的 🤖 Prompt for AI Agents |
||
|
|
||
| private VolumeStats getVolumeStats(String installPath) { | ||
| VolumeModule vol = apiHelper.getVolume(getVolIdFromPath(installPath)); | ||
| VolumeStats stats = new VolumeStats(); | ||
| stats.setInstallPath(installPath); | ||
| stats.setSize(SizeUnit.MEGABYTE.toByte(vol.getSpec().getSizeMb())); | ||
| stats.setActualSize(vol.getStatus().getAllocatedSizeByte()); | ||
| stats.setFormat(VolumeConstant.VOLUME_FORMAT_RAW); | ||
| stats.setParentUri(getParentUri(vol)); | ||
| comp.success(stats); | ||
| return stats; | ||
| } | ||
|
|
||
| private String getParentUri(VolumeModule vol) { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.