Skip to content
Open
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
4 changes: 2 additions & 2 deletions conf/db/upgrade/V5.5.18__schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ CREATE TABLE IF NOT EXISTS `HostCacheStoreCapacityVO` (
`uuid` VARCHAR(32) NOT NULL,
`totalCapacity` BIGINT NOT NULL DEFAULT 0,
`availableCapacity` BIGINT NOT NULL DEFAULT 0,
`allocated` BIGINT NOT NULL DEFAULT 0,
`dirty` BIGINT NOT NULL DEFAULT 0,
`allocatedCapacity` BIGINT NOT NULL DEFAULT 0,
`dirtyCapacity` BIGINT NOT NULL DEFAULT 0,
PRIMARY KEY (`uuid`),
CONSTRAINT `fkHostCacheStoreCapacityVOHostCacheStoreVO`
FOREIGN KEY (`uuid`) REFERENCES `HostCacheStoreVO` (`uuid`)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ public class HostCacheStoreCapacityInventory implements Serializable {
private String uuid;
private long totalCapacity;
private long availableCapacity;
private long allocated;
private long dirty;
private long allocatedCapacity;
private long dirtyCapacity;

public static HostCacheStoreCapacityInventory valueOf(HostCacheStoreCapacityVO vo) {
if (vo == null) {
Expand All @@ -26,8 +26,8 @@ public static HostCacheStoreCapacityInventory valueOf(HostCacheStoreCapacityVO v
inv.setUuid(vo.getUuid());
inv.setTotalCapacity(vo.getTotalCapacity());
inv.setAvailableCapacity(vo.getAvailableCapacity());
inv.setAllocated(vo.getAllocated());
inv.setDirty(vo.getDirty());
inv.setAllocatedCapacity(vo.getAllocatedCapacity());
inv.setDirtyCapacity(vo.getDirtyCapacity());
return inv;
}

Expand Down Expand Up @@ -67,19 +67,19 @@ public void setAvailableCapacity(long availableCapacity) {
this.availableCapacity = availableCapacity;
}

public long getAllocated() {
return allocated;
public long getAllocatedCapacity() {
return allocatedCapacity;
}

public void setAllocated(long allocated) {
this.allocated = allocated;
public void setAllocatedCapacity(long allocatedCapacity) {
this.allocatedCapacity = allocatedCapacity;
}

public long getDirty() {
return dirty;
public long getDirtyCapacity() {
return dirtyCapacity;
}

public void setDirty(long dirty) {
this.dirty = dirty;
public void setDirtyCapacity(long dirtyCapacity) {
this.dirtyCapacity = dirtyCapacity;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ public class HostCacheStoreCapacityVO {
private long availableCapacity;

@Column
private long allocated;
private long allocatedCapacity;

@Column
private long dirty;
private long dirtyCapacity;

public HostCacheStoreCapacityVO() {
}
Expand Down Expand Up @@ -61,19 +61,19 @@ public void setAvailableCapacity(long availableCapacity) {
this.availableCapacity = availableCapacity;
}

public long getAllocated() {
return allocated;
public long getAllocatedCapacity() {
return allocatedCapacity;
}

public void setAllocated(long allocated) {
this.allocated = allocated;
public void setAllocatedCapacity(long allocatedCapacity) {
this.allocatedCapacity = allocatedCapacity;
}

public long getDirty() {
return dirty;
public long getDirtyCapacity() {
return dirtyCapacity;
}

public void setDirty(long dirty) {
this.dirty = dirty;
public void setDirtyCapacity(long dirtyCapacity) {
this.dirtyCapacity = dirtyCapacity;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ public class HostCacheStoreCapacityVO_ {
public static volatile SingularAttribute<HostCacheStoreCapacityVO, String> uuid;
public static volatile SingularAttribute<HostCacheStoreCapacityVO, Long> totalCapacity;
public static volatile SingularAttribute<HostCacheStoreCapacityVO, Long> availableCapacity;
public static volatile SingularAttribute<HostCacheStoreCapacityVO, Long> allocated;
public static volatile SingularAttribute<HostCacheStoreCapacityVO, Long> dirty;
public static volatile SingularAttribute<HostCacheStoreCapacityVO, Long> allocatedCapacity;
public static volatile SingularAttribute<HostCacheStoreCapacityVO, Long> dirtyCapacity;
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ public class HostCacheStoreInventory implements Serializable {
private long availableCapacity;

@Queryable(mappingClass = HostCacheStoreCapacityInventory.class,
joinColumn = @JoinColumn(name = "uuid", referencedColumnName = "allocated"))
private long allocated;
joinColumn = @JoinColumn(name = "uuid", referencedColumnName = "allocatedCapacity"))
private long allocatedCapacity;

@Queryable(mappingClass = HostCacheStoreCapacityInventory.class,
joinColumn = @JoinColumn(name = "uuid", referencedColumnName = "dirty"))
private long dirty;
joinColumn = @JoinColumn(name = "uuid", referencedColumnName = "dirtyCapacity"))
private long dirtyCapacity;

private HostCacheStoreState state;
private HostCacheStoreStatus status;
Expand All @@ -52,8 +52,8 @@ public static HostCacheStoreInventory valueOf(HostCacheStoreVO vo) {
if (vo.getCapacity() != null) {
inv.setTotalCapacity(vo.getCapacity().getTotalCapacity());
inv.setAvailableCapacity(vo.getCapacity().getAvailableCapacity());
inv.setAllocated(vo.getCapacity().getAllocated());
inv.setDirty(vo.getCapacity().getDirty());
inv.setAllocatedCapacity(vo.getCapacity().getAllocatedCapacity());
inv.setDirtyCapacity(vo.getCapacity().getDirtyCapacity());
}
inv.setState(vo.getState());
inv.setStatus(vo.getStatus());
Expand Down Expand Up @@ -143,20 +143,20 @@ public void setAvailableCapacity(long availableCapacity) {
this.availableCapacity = availableCapacity;
}

public long getAllocated() {
return allocated;
public long getAllocatedCapacity() {
return allocatedCapacity;
}

public void setAllocated(long allocated) {
this.allocated = allocated;
public void setAllocatedCapacity(long allocatedCapacity) {
this.allocatedCapacity = allocatedCapacity;
}

public long getDirty() {
return dirty;
public long getDirtyCapacity() {
return dirtyCapacity;
}

public void setDirty(long dirty) {
this.dirty = dirty;
public void setDirtyCapacity(long dirtyCapacity) {
this.dirtyCapacity = dirtyCapacity;
}

public HostCacheStoreState getState() {
Expand Down Expand Up @@ -207,4 +207,3 @@ public void setLastOpDate(Timestamp lastOpDate) {
this.lastOpDate = lastOpDate;
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,18 @@ doc {
type "long"
since "5.5.6"
}
field {
name "allocatedCapacity"
desc "主机缓存存储已分配的容量,单位为字节"
type "long"
since "5.5.6"
}
field {
name "dirtyCapacity"
desc "主机缓存存储待回收的脏数据容量,单位为字节"
type "long"
since "5.5.6"
}
ref {
name "state"
path "org.zstack.header.volumeCache.HostCacheStoreInventory.state"
Expand Down
15 changes: 8 additions & 7 deletions plugin/kvm/src/main/java/org/zstack/kvm/KVMAgentCommands.java
Original file line number Diff line number Diff line change
Expand Up @@ -5272,19 +5272,20 @@ public static class DetachVolumeCacheCmd extends AgentCommand implements HasThre
public static class PoolRsp extends AgentResponse {
public String poolUuid;
public String mountPoint;
public Long totalCapacity;
public Long availableCapacity;
public Long allocatedCapacity;
public Long dirtyCapacity;
}

public static class PoolHealthRsp extends AgentResponse {
public String poolUuid;
public String mountPoint;
public Boolean healthy;
public String reason;
}
Comment on lines 5272 to 5286
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

缓存池响应模型未完整对齐容量协议(缺 usedPoolHealthRsp 未继承 PoolRsp)。

当前实现会导致容量字段集合不完整,并且健康响应无法复用同一容量载体;这与本次“统一从响应刷新容量”的目标不一致。

建议修改
 public static class PoolRsp extends AgentResponse {
     public String poolUuid;
     public String mountPoint;
     public Long total;
+    public Long used;
     public Long available;
     public Long allocated;
     public Long dirty;
 }

-public static class PoolHealthRsp extends AgentResponse {
+public static class PoolHealthRsp extends PoolRsp {
     public Boolean healthy;
     public String reason;
 }

Also applies to: 5286-5287, 5295-5298

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@plugin/kvm/src/main/java/org/zstack/kvm/KVMAgentCommands.java` around lines
5272 - 5284, The PoolRsp model in KVMAgentCommands is missing the 'used'
capacity field and PoolHealthRsp should extend PoolRsp so health responses reuse
the same capacity carrier; update the PoolRsp class to add a public Long used;
then change PoolHealthRsp to extend PoolRsp (retain its public Boolean healthy
and public String reason fields) so health responses include
poolUuid/mountPoint/total/available/allocated/dirty/used; make the analogous
changes to the other duplicate definitions mentioned (the other
PoolRsp/PoolHealthRsp occurrences).


public static class PoolCapacityRsp extends AgentResponse {
public Long total;
public Long used;
public Long available;
public Long allocated;
public Long dirty;
public static class PoolCapacityRsp extends PoolRsp {
}

public static class CacheRsp extends AgentResponse {
Expand All @@ -5293,7 +5294,7 @@ public static class CacheRsp extends AgentResponse {
public Long actualSize;
}

public static class GCPoolRsp extends AgentResponse {
public static class GCPoolRsp extends PoolRsp {
public List<String> gcFiles;
public Integer gcCount;
}
Expand Down
20 changes: 10 additions & 10 deletions sdk/src/main/java/org/zstack/sdk/HostCacheStoreInventory.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,20 +61,20 @@ public long getAvailableCapacity() {
return this.availableCapacity;
}

public long allocated;
public void setAllocated(long allocated) {
this.allocated = allocated;
public long allocatedCapacity;
public void setAllocatedCapacity(long allocatedCapacity) {
this.allocatedCapacity = allocatedCapacity;
}
public long getAllocated() {
return this.allocated;
public long getAllocatedCapacity() {
return this.allocatedCapacity;
}

public long dirty;
public void setDirty(long dirty) {
this.dirty = dirty;
public long dirtyCapacity;
public void setDirtyCapacity(long dirtyCapacity) {
this.dirtyCapacity = dirtyCapacity;
}
public long getDirty() {
return this.dirty;
public long getDirtyCapacity() {
return this.dirtyCapacity;
}

public HostCacheStoreState state;
Expand Down